Home | IR Remotes | RF Remotes | Industrial Automation | Embedded Systems | Robotics | Project Kits | FAQs | Download

DC Motor control

Software program for remote control DC drive

using C++
DC motor control
using VC++
Stepper motor
control using VC++
Industrial DC Motor
Control panel
industrial stepper

Entire program can be well explained by explaining all the functions used in this program.
Start function is a continuous function that will rotate motor in either direction with set speed. Actually it
generates PWM to vary the speed of motor. It will set the direction of motor and then generate PWM on either
P3.6 or P3.7
Intra function is an interrupt enabled function that will receive data byte available on P1. Whenever interrupt
arrives it will be automatically called and after some delay it will get the byte available on P1

motor control panel
remote control for AC
Traffic control
Wireless DC Motor
Wireless Stepper
motor controller
remote controlled DC

chngdir will change the direction of motor every time. It increments a count every time and checks even or odd.
If its even sets CW direction and vice versa
incspeed increase speed by one step. Actually it increases pulse width time by 1 ms. Total time is 10 ms and we
are varying the width of pulse from 1ms to 9ms. So speed of motor varies in 8 step. That is indicated on 8 LED
bar graph. Dec speed is similar to this but it will decreases pulse width by 1 ms
Shift up function is similar to rotate the content of port P2 left, once. It sends one more zero every time on P2
pins from P2.7 to P2.0 so bar graph is raised once. shiftdown function does the reverse thing. It will send one
more 1 on P2 pins from P2.0 to P2.7. So bargraph is reduced by once.
Delay function is a variable delay that varies the delay from 1 ms to the count you load into the function. T0
generates basic delay of 1ms and then this basic delay in a loop is repeated for number of times (like 2,3,4....) to
generate delay of 2ms, 3ms, 4 ms and likewise
Kodaly is fix delay and it is just used to settle down the data byte available on P1 from ST3049.
Here is complete program in C language written and compiled in KEIL (IDE)
unsigned char a;
bdata unsigned char byte=0x0F, databyt=0x00;
unsigned int d1=5,d2=5,c=0,f=0;
sbit b0 = byte^0;
sbit b1 = byte^1;
sbit b2 = byte^2;
sbit b3 = byte^3;
sbit b4 = byte^4;
sbit b5 = byte^5;
sbit b6 = byte^6;

} void shiftdown() { b7=b6. sbit led3=P3^4. b1=b2. b3=b4.x++) for(y=0. TL0 = 0x17. b5=b6. b6=b5. } void delay(int d) { int k.x<25. sbit op2=P3^7. TH0 = 0xFC. b1=b0.y. b0=1. for(k=0. for(x=0. sbit led4=P3^5. sbit led2=P3^1. TF0 = 0.k++) { while(TF0==0). b2=b3. TL0 = 0x17. } TR0 = 0. b7=0.sbit b7 = byte^7. TR0 = 1. b2=b1. b6=b7.k<d. } void incspeed() { if(d1<9) . b4=b3. b4=b5. sbit led1=P3^0.y<1000. } void shiftup() { b0=b1. TH0 = 0xFC. b3=b2.y++). void keydely() { int x. b5=b4. sbit op1=P3^6.

led4=1. op2=0. if((c%2)==1) { led3=0. P2=byte. delay(d2). d2--. d1--. } } void decspeed() { if(d2<9) { d2++. } } void chngdir() { c++. shiftdown(). led1=1. while(databyt==0x00) { op1=1. delay(d1). shiftup().{ d1++. op2=0. delay(d1). delay(d2). } } else { op1=0. } else { led3=1. led4=0. if((c%2)==0) { op2=0. } } void start() { led2=0. P2=byte. } } } void intr() interrupt 0 { . while(databyt==0x00) { op2=1.

break. break. start(). databyt=0x00. start(). case 0xD7: decspeed(). start(). check: switch(databyt) { case 0xD2: tmp++. } All the projects are designed and developed by sight owner and they are thoroughly tested by him. TMOD = 0x01. led1=0. led3=1. back: while(databyt==0x00). led2=1. databyt=P1. } else { f=0. All rights reserved. P3=0x04. break. . databyt=0x00. led2=1. } if(f==0)goto back. } void main() { int tmp=0. if((tmp%2)==1) { f=1. case 0xD6: incspeed(). else goto check. case 0xD3: chngdir(). ©Copyrights Ashutosh Bhatt 2010. op2=0. IE=0x81. databyt=0x00. databyt=0x00. start(). databyt=0x00. op1=0. } break. P2=byte.{ keydely().