|
~: DC Motor Controller :~
Abstract: - DC Motors are widely used for motion control in manufacturing industries. Motion of DC motor is controlled using DC Drive. DC drive changes the speed and direction of a motor. Many of the DC drives provides programmable facilities means to program the motion of motor. So here I am giving one such example where one can completely program the motion of motor. Using this controller one can
- Change the direction of motor
- Change the speed of motor
- Change the running mode of motor in continuous, reversible or jogging
- Change the forward and reverse running time of motor
Some of the features of this controller are
- Programmable due to 89C51 controller
- Push button control
- Message display on LCD panel
- LED indications
- Can control DC motors from 12 V to up to 100V (up to 5 Amp)
- Uses PWM (500 Hz) to change the speed of motor
- Uses Darlington H-bridge for switching action
I have tested this controller with motor having following specifications
- Motor type - DC series
- Max operating voltage - 12 VDC
- Max operating current - 2 Amp
- Max RPM - 3000 @ 12 V
_____________________________________________
Complete circuit is combination of two sections
- Control section
- Driver section
Control section includes 89C51 micro controller that actually controls the motion of motor depending upon given user commands. It receives user command through push buttons, generates all controlling signals, displays messages on LCD and give indications on LEDs
Driver section actually drives the DC motor. It provides sufficient voltage and current to run the DC motor in desire manner. It just receives signals from control section and rotates the motor
Control section: -

Connections: - As shown in above figure major components of the circuit are 89C51, LCD panel and hex inverter IC 7404. 8 push buttons are connected with P1. Data pins of LCD (D0-D7) are connected with P0. Control pins E, RS & RW are connected with P3.0, P3.1 and P3.2 respectively. Four LEDs are connected with P2.0 - P2.3 as shown. Other port P2 pins P2.4 - P2.6 are connected to the inputs of inverter IC 7404. The outputs of this chip are connected with driver section. One switch (RST) and capacitor C3 is connected in between Vcc and RST pin (pin no. 9) of 89C51 that will serve as power on reset circuit. EA pin (pin no 31) is connected with Vcc to enable internal excess. The circuit is energized by regulated 5 V supply.
Driver section: -

Connection: -Major components of this section are IC555, NPN Darlington pair TIP122 and PNP Darlington pair TIP127. This section will receive signals from control section A, B & C as shown. Signals B & C are used to switch ON / OFF relay RL1 and RL2 respectively through transistors Q1 & Q2. Signal A is connected to trigger input of IC 555 which is connected in monostable mode. Its output is connected with 2 inputs of Darlington H-bridge circuit through RL1 and RL2 connections. H-bridge circuit is made using 2 NPN and 2 PNP Darlington pairs. Collectors of TIP122 are shorted and tied to Vcc. The collector of TIP127 are shorted and tied to ground. A 220E resistor is connected with the base of each Darlington pair. As shown in figure bases of TIP122 and TIP127 of same side are shorted to take one common input. The DC motor is connected with output of h-bridge as shown.
Operation: - 8 push buttons connected are for eight different functions
|
Switch |
Function |
|
SW1 |
To start motor |
|
SW2 |
To stop the motor |
|
SW3 |
Change the direction |
|
SW4 |
Change the mode |
|
SW5 |
Increase speed |
|
SW6 |
Decrease speed |
|
SW7 |
Increase time |
|
SW8 |
Decrease time |
When SW1 is pressed micro controller will send low logic on P2.5 so signal B will be high (due to inheritor) that will switch on RL1. So output of IC555 is fed to Darlington pairs Q5 & Q6 through RL2 terminals 1 & 2. Darlington pairs Q3 & Q4 will be off due to their bases are connected to ground through 4 - 5 terminals of RL2. Now at the same time after switching RL1 micro controller will start generating PWM on P2.4 that is fed to trigger i/p of IC555 through inverter. The base frequency of generated PWM is 500 Hz that means time period is 2 ms = 2000 micro sec. The output pulse width vary from 500 micro sec to 1500 micro sec. The RC time constant of monostable mltivibrator is kept slightly less then 500 micro sec to generate exact inverted PWM that is generated by 89C51. PWM is fed to Q5 & Q6 that will start driving motor
On pressing SW2, P2.5 will be high so signal B is low and RL1 is switched off. So motor will be stopped
On pressing SW3 will switch ON / OFF RL2 alternatively. Means first time pressing SW3 will switch ON the RL2 and pressing it second time RL2 is OFF. When RL2 is off bases of Q3 & Q4 are connected to ground and bases of Q5 & Q6 is receiving PWM. That means the direction of current is Vcc-Q5-motor-Q4-Gnd and motor runs in one direction. Now when RL2 is switched on Q2 & Q3 will receive PWM and bases of Q5 & Q6 are connected to ground. Now the direction of the current will change to VCC-Q2-motor-Q6-Gnd and that will change motor direction.
SW4 will change rotating mode in cyclic manner, means pressing it once will set mode 1, pressing it twice will set mode 2, thrice will set mode 3 and again pressing it fourth time will set mode 1 and this continuous. The three modes are
- Continuous mode: - Rotates motor continuously with set speed in either direction
- Reversible mode: - Motor reverses automatically after set time. Also called see-saw rotation
- Jogging: - Motor rotates till SW1 is pressed in either direction. Also called pulse rotation (this mode is used to see in which direction the motor will start running actually or when motor is connected with load whether it can take it or not)
SW5 & SW6 are for continuous mode only. They will increase / decrease the set speed by increasing / decreasing output pulse width.
SW7 & SW8 are for reversible mode only. They will increase / decrease the time for which motor will automatically reverse.
Below figure shows the panel arrangement for DC motor controller that includes all the controls, display and indications

Software: -
The program is written in Keil C cross compiler. Complete program is well understood by dividing it in to three major sections
- Initialization and key press section
- Display section
- DC motor control section
First section is in main function that initializes timers, ports, LCD, indication on LEDs etc and then wait for key press. When any key is pressed program will call the particular function. In main function first ports are initialized as input or output then LCD is initialized and cleared. The message "DC Motor controller" is displayed for 2 and a half second and then it displays mode and current speed. Stop LED and clockwise direction LED is on. Now program waits for any key press. When any key is pressed it is detected and program will jump to one of the function like start, direction, mode etc.
In display section there are four functions
- writecmd function sends command byte to LCD. It takes one argument byte and sends it to P0
- writedata function sends data byte to be displayed on LCD. It also takes one argument byte and sends it to P0
- writestr function writes whole string (message) on LCD. It takes pointer as an argument that points address of first character of string. then through pointer it sends all the character one by one to P0
- busy function checks the status of busy flag of LCD. If flag is set that means LCD is not ready so and programs remains within loop. when flag is reset that means LCD is ready and program comes out of loop
Given all other functions falls under DC motor control sections
- start function starts rotating motor in one of the mode continuous, reversible or jogging. The mode is selected by mode selection flag 'm'. As explained earlier in continuous mode motor keeps rotating with set speed. In reversible mode motor alters direction automatically after set time. And in jogging motor rotates till start key is pressed
- stop function stops rotating motor and displays message
- direction function increases one counter every time and checks for even or odd. If its even then selects forward direction and if odd then selects reverse direction. This is also indicated on direction LEDs
- mode function changes modes in cyclic manner. It increases mode selection flag m every time. If m=0 selects continuous mode if m=1 selects reversible and if m=2 selects jogging. If m=3 it is reset to 0 again and selects continuous mode and like wise
- incspeed function actually increases the width of pulse by 100 micro sec. The generated PWM is of 500 Hz. That means total time is 2 ms = 2000 micro sec. Width of pulse is varied from 500 micro sec to 1500 micro sec in step of 100 micro sec. To display the speed first the variable is converted in to speed factor 1 to 10 and then converted into ASCII
- decspeed function is same as inc speed but here width of pulse is decreased by 100 micro sec.
- inctime function increases reversible time of motor by one sec. It increases variable in multiple of 20. To display it on LDC first it is divided by 20 and then converted in to ASCII.
- dectime function is same as inctime but it will decreases reversible time by 1 sec
Rest three functions are for generating delay
- keydly function is fix delay that is approx 50 ms delay used for key debouncing
- delay function is variable delay generated by timer 0. The basic delay is of 100 micro sec. this basic delay is rotated in loop from 5 to 15 times to generate min 500 micro sec and max 1500 micro sec delay
- time function is again variable delay generated by timer 1. The basic delay is of 50 ms. It is rotated in multiples of 20 form 20 to 180 to generate min 1 sec and max 9 sec delay
click here for complete code with comments
|