Hello Readers:
I have started this blog to show you Embedded C programming for 8051 family microcontroller using KEIL compiler. The KISS philosophy is used to write this tutorial. What is KISS? Keep It Simple, Stupid!
5.2 Dc Motor
Now we see how to write program for DC motors.The DC motor interface application is usually found in moving robotic vehicle systems. This program shows how to rotate two DC motors [useful in vehicle controlling] with 25% duty cycle. In DC motor 25% duty cycle means, ON time is 25% and OFF time is 75%.
Code explanation: Motor is switched ON for 25 Milliseconds and OFF for 75 Milliseconds delay continuously.
After typing the code, press F7 or click Project->Build Target for building the source code. If there are no typical errors file will build successively and shows zero errors and zero warnings.
Now enter into debug mode by pressing Ctrl+F5 or click Debug->Start/Stop Debug Session menu. Our program is toggling Port 2’s motor pins continuously. So we want to watch the Port 2 pins while running this program for toggling values. To get Port 2 tab click Peripherals->I/O Ports->Port 2 text.
Run the program by pressing F5 or clicking Debug->Run. You can see the toggling values on Port 2 tab continuously in binary form. If you generate HEX file of this program, burn it into your target chip’s memory using suitable uploader and connecting two DC motors to Port 2 you can watch DC motor rotation continuously. To stop running the program press red ‘x’ mark icon or click Debug->Stop.
...till next post bye-bye & take care.
No comments:
Post a Comment