I am setting out to program a PIC16F877A board to take three inputs, and create two outputs. The board has to be programmed in C. Before I learn how to program in C, please let me know if it can be done. No how, just if.
I am building a tilting car, similar to the BMW Clever. The main body of the vehicle tilts when turning at high speeds to keep the body of the vehicle aligned with the G-force that the passenger feels. To do this, I will be taking inputs from a Lateral Accelerometer (mounted to the body of the vehicle), a radial accelerometer (on the steering column) to measure steering rate, and a velocity input with precise vehicle speed.
The two output signal will drive two opposing hydraulic actuators that tilt the vehicle. These actuators are push-only, and only one actuator will receive the "push" signal at any one time. Of course, the switching between these actuator signals could happen many times per second.
When the Lateral Accelerometer senses a side force (i.e. in a turn), I want to tell the actuators to correct this condition by tilting the body of the vehicle until the Lateral Accelerometer senses no sidewards forces. This should be a continuous sensing-acting protocol.
To make a smooth transition into this lean, the Steering mounted sensor (radial accelerometer) sends a signal to help the program anticipate, or proactively anticipate the turn by tilting the vehicle before the Lat Accel senses the turn. This needs to be done in reference to the final signal, the velocity sensor. Otherwise, the vehicle could get silly and roll down the highway (sideways, not on it's wheels).
The Card I want to use is the PIC16F877A board. The inputs from all sensors will be 0 to 5 Volts TTL. 2.5 Volts is the normal, non-accelerating state. Velocity will be from 0 to 5 volts. For the output, I will require a step signal (2 ea), and a direction signal, to interface with my servo drives. The step signal will be pulse output, up to 25Khz. The servo drives are open loop, that is, once they have the signal of step and direction, they will take care of the business end.
I would like to think that the program could take all 3 variables into account, equate logical responses, and generate signals to move my servos. The Servos will take care of the rest.
I only have a background in CNC programming and motion control, I have not yet begun to dabble in C programming. Therefore, I would like the opportunity to ask an expert:
Can this be done with C programming on the prototyping board I have selected? Can I reasonably expect to create a smooth response from the vehicle? Is this prototyping board powerful enough to do the job?
I am asking this now to save myself the trouble of investing hundreds of hours to learn C programming.
Thank you for taking the time to read this, I look forward to reading your replies.
Rob