Thread: Is C the right language for this application?

  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    2

    Is C the right language for this application?

    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
    Last edited by forneydesigns; 11-24-2007 at 10:14 PM. Reason: mispring

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    I would imagine C is probably a very good choice for something like this. I don't know much about the particular hardware you listed, or what would actually fit your requirements (ie. how would I know if the vehicle response is smooth? lol. A lot would probably depend upon the quality of programming.), but I would venture to say, if you can't get the power and precision you want out of C for this project, then your only alternative is assembly.

    If assembly isn't good enough, then your hardware can't do the task. Comparing the two languages, you should hope it's possible in C, since C is, in some respects, a high-level version of assembly. I would imagine it's definitely worth trying C first and seeing where you can get with it.

    If you need to, you could write your own assembly procedures to be called from C code. So all in all, depending on what you have at your disposal, yes, it should be possible to do at least some or all of this in C.

    Someone like Salem would probably have a more direct and better answer.

  3. #3
    Registered User
    Join Date
    Nov 2007
    Posts
    2
    Thanks for the response. Really, what I am asking this program/hardware to do, is monitor 3 variables real-time, and generate responses on the fly.
    You are right; asking how smooth the ride would be is a ridiculous question.
    I have no reference or baseline as to how powerful or fast the hardware or software can be.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. d programming language - a better c++?
    By kypronite in forum Tech Board
    Replies: 12
    Last Post: 02-28-2011, 02:55 AM
  2. The value of learning a new programming language
    By h3ro in forum General Discussions
    Replies: 21
    Last Post: 06-13-2009, 01:48 AM
  3. assembly language...the best tool for game programming?
    By silk.odyssey in forum Game Programming
    Replies: 50
    Last Post: 06-22-2004, 01:11 PM
  4. Language of choice after C++
    By gandalf_bar in forum A Brief History of Cprogramming.com
    Replies: 47
    Last Post: 06-15-2004, 01:20 AM
  5. Enough language discussions.
    By VirtualAce in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 06-13-2004, 09:59 AM