C Programming for Microcontrollers

This is a discussion on C Programming for Microcontrollers within the C Programming forums, part of the General Programming Boards category; Hi, Is there anybody out there who can help me? I'm tryin to program a microcontroller to read signals from ...

  1. #1
    CB4
    CB4 is offline
    Registered User
    Join Date
    Mar 2005
    Posts
    2

    C Programming for Microcontrollers

    Hi, Is there anybody out there who can help me? I'm tryin to program a microcontroller to read signals from attached sensors and to control 2 stepper-motors. I want to use this to control a robot car which automatically detects obstacles on the driveway using sensors. Depending on the feedbacks from the sensors, the microcontroller should react by either stoppin or change the direction of movement for the stepper-motors.

    This is really new to me, but i want to learn. I'll appreciate any form of help. Thanks in advance

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Scour the app notes on the site of your target micro.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    Registered User computerfreaks's Avatar
    Join Date
    Jan 2005
    Posts
    30
    Not knowing what you already know... some basic theory behind what you want to do:

    You will have sensors which connect to the microcontroller, when as obstacle is hit, then the curent sensor sends a HIGH logic 1 input to he microcontroller input for that sensor. To do this, the sensor simply needs to close a switch allowing high logic voltage (usually 5v) to go to the input. The same will apply if the sensor is an IR sensor, or ultrasonic.... get a logic 1 to the input.

    You would then have a program running on the controller which checks the status of the input pin, when it is high it branches off and performs a function.... for example, set output logic high for stepper motor. So the left sensor could control the right motor (to stop it or reduce its speed) and vica versa.

    The stepper motor if being controlled by the microcontroller will need to be pulsed to work. However note that the pulses from a microcontroller will not be powerfull enougth to run the motor... so use transitors to drive a higher power (the transistor base being controlled by the mirocontroller, allowing a high collecter emitter current). Alternatively you could use a stepper motor control chip which will do all the pulsing work for you.


    As Dave said, check your microprocessor documentation for the exact setup relevant to your controller. There are many examples on the net of simple control circuits for your application.
    Last edited by computerfreaks; 03-04-2005 at 12:07 PM.

  4. #4
    CB4
    CB4 is offline
    Registered User
    Join Date
    Mar 2005
    Posts
    2

    Thumbs up C for Microcontrollers

    Hi computerfreaks, Dave,

    Thanks alot for your guide. This has narrowed my search. In fact, i'm using 2 ULN2003 to which my stepper-motors are connected. These are attached to a MB95F108HS microcontroller.For the sensors, i got LTH209-1 (IR Sensor).

    Please, don't hesitate to give me more links to this if u happen to lay hands on. My request wasn't detail, but your reply gave me the impression you understood exactly what i wanted to say.

    Greetings

  5. #5
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Quote Originally Posted by CB4
    These are attached to a MB95F108HS microcontroller.

    Please, don't hesitate to give me more links to this if u happen to lay hands on.
    Have you found this already?
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21