You are on page 1of 19

DC MOTOR CONTROL SYSTEM

And research about automated speed control of DC induction motor

Arachchi T.M.L. 090024H EE3202 Individual Project

Abstract
Objective of this project is to design a controlling circuit to control speed, direction of a DC motor using a microcontroller. Additionally find out ways of speed and direction control of three phase induction motor and to find the present situation of those controllers in the market. Three phase induction motors and DC motors are widely used in industries. So study about those is important nowadays.

Introduction
Control of movement of DC motors plays a vital role in industrial automation. Manufacturing plants in industries like chemical, medical, plastic and textile all require motion control. And it may be a flat belt application, flow-control application or mixing of substances. Different types of motors - AC, DC, servo or stepper - are used depending upon the application. Of these, DC motors are widely used because controlling a DC motor is somewhat easier than other kinds of motors. The motion of a DC motor is controlled using a DC drive. DC drive changes the speed and direction of motion of the motor. Some of the DC drives are just a rectifier with a series resistor that converts standard AC supply into DC and gives it to the motor through a switch and a series resistor to change the speed and direction of rotation of the motor. But many of the DC drives have an inbuilt microcontroller that provides programmable facilities, message display on LCD, precise control and also protection for motors. Using the DC drive you can program the motion of the motor, i.e., how it should rotate. D.C motor is considered a SISO (Single Input and Single Output) system having torque/speed characteristics compatible with most mechanical loads. This makes a D.C motor controllable over a wide range of speeds by proper adjustment of the terminal voltage. Now days, Induction motors, Brushless D.C motors and Synchronous motors have gained widespread use in electric traction system. Even then, there is a persistent effort towards making them behave like dc motors through innovative design and control techniques. Hence dc motors are always a good option for advanced control algorithm because the theory of dc motor speed control is extendable to other types of motors as well.

About the circuit of controller unit

The above picture shows the circuit diagram for the controller unit. At the heart of the DC motor controller is microcontroller AT89C51. Port pins P0.0 through P0.7 of the microcontroller are interfaced with data pins D0 through D7 of the LCD module, respectively. Port pins P3.0, P3.1 and P3.2 control the LCD operation through enable (E), register-select (RS) and read/write (R/W) pins, respectively. Contrast of the LCD is set by preset VR1. Port pins P1.0 to P1.7 are connected to switches S1 to S8 for performing the various operations. Power-on reset signal for the microcontroller is generated by the combination of capacitor C1 and resistor R1. Switch S9 provides manual reset to the microcontroller. A 12MHz crystal provides the basic clock frequency to the microcontroller. Capacitors C2 and C3 provide stability to the oscillator. EA pin (pin 31) of the microcontroller is connected to 5V to enable internal access. Port pins 2.0 through P2.3 of the microcontroller are used for LED indication of run, stop, clockwise and anti-clockwise rotation. Port pins P2.4 through P2.6 are connected to the inputs of inverters N3, N2 and N1 of 74LS04 (IC2). The output of inverter N3 is used to trigger pin 2 of NE555 timer. Timer NE555 is configured as a monostable and its time period is decided by preset VR2 and capacitor C4. When pin 2 of NE555 goes low, output pin 3 becomes high for the predetermined period. The output of NE555 is connected to pole P of relay RL1. Normally-open (N/O) contacts of relay RL1 are connected to N/O1 and N/C2 contacts of relay RL2. N/C1 and N/O2 contacts of RL2 are connected to ground.

The outputs of inverters N2 and N1 drive relays RL1 and RL2 with the help of transistors T1 and T2, respectively. D1 and D2 act as free-wheeling diodes. Poles P1 and P2 of RL2 are connected to IN1 and IN2 pins of motor driver L293D. OUT1 and OUT2 of L293D drive motor M.

The 230V AC mains are stepped down by transformer X1 to deliver the secondary output of 9V, 500 mA. The transformer output is rectified by a full-wave bridge rectifier comprising diodes D3 through D6, filtered by capacitor C6 and then regulated by ICs 7805 (IC5) and 7806 (IC6). Capacitors C7 and C8 bypass the ripples present in the regulated 5V and 6V power supplies. LED5 acts as a power-on indicator and resistor R10 limits the current through LED5.

Operation of the circuit


The eight pushbutton switches are connected for eight different functions as shown in the table. When S1 is pressed, the microcontroller sends low logic to port pin P2.5. The high output of inverter N2 drives transistor T1 into saturation and relay RL1 energizes. So the output of NE555 is fed to inputs IN1 and IN2 of L293D through both the contacts of relay RL2. Now at the same time, after RL1 energises, the microcontroller starts generating PWM signal on port pin P2.4, which is fed to trigger pin 2 of NE555 through inverter N3. The base frequency of the generated PWM signal is 500 Hz, which means the time period is 2 ms (2000s). The output pulse width varies from 500 s to 1500 s. The R-C time constant of the monostable multivibrator is kept slightly less than 500 s to generate exactly the same inverted PWM as is generated by the microcontroller. When switch S2 is pressed, port-pin P2.5 goes high and RL1 de-energises to stop the motor. When switch S3 is pressed, relay RL2 energises. Pin IN1 of motor driver L293D receives the PWM signal and pin IN2 connects to ground. As a result, the motor rotates in one direction (say, clockwise). When switch S4 is pressed again, relay RL2 de-energises. Pin IN2 of motor driver L293D receives the PWM signal and pin IN1 connects to ground. The motor now rotates in opposite direction (anticlockwise). When switch S3 is pressed, different modes are selected in cyclic manner as given below: 1. Continuous mode. The motor rotates continuously with the set speed in either direction 2. Reversible mode. The motor reverses automatically after the set time 3. Jogging mode. The motor rotates for the set time in either direction and then stops for a few seconds and again rotates for the set time. It is also called pulse rotation Switches S5 and S6 are used to set the speed of the motor, either in increasing order or decreasing order, in continuous mode only. Switches S7 and S8 are used to set the time either in increasing order or decreasing order.

About programming and software


The program is written in C language and compiled using Keil Vision3 compiler. It is well commented and easy to understand. The program has three major sections: initialisation and key press, display and motor control. Initialisation and key press. It consists of the main function that initializes timers, ports, LCD module and LED indication and then waits for key press. When any key is pressed, the program calls that particular function. In the main function, first the ports are initialised as input/output, then the LCD is initialised and cleared. At power-on reset or manual reset, message DC motor controller is displayed on the LCD and LED1 through LED4 turn off. When start switch S1 is pressed, message Motor Start is displayed for a second, and then the mode and current speed are displayed. Run LED and clockwise-direction LED are on. Now the program waits for key press. When any key is pressed, the program jumps to one of the functions (start, direction, mode, etc). Display. It uses the following functions: 1. writecmd function sends command byte to the LCD. It takes one argument byte and sends it to P0. 2. writedata function sends data byte to be displayed on the LCD. It also takes one argument byte and sends it to P0. 3. writestr function writes the whole string (message) on the LCD. It takes pointer as an argument that points address of the first character of the string, then through the pointer it sends all the characters one by one to P0. 4. busy function checks the status of the busy flag of the LCD. If the flag is set, the LCD is not ready and the program remains within the loop. When he flag is reset, the LCD is ready and the program comes out of the loop. Motor control. It uses the following functions: 1. start function starts motor rotation in one of the modes (continuous, reversible or jogging). The mode is selected by mode-selection flag m. As explained earlier, in continuous mode the motor keeps rotating with the set speed. In reversible mode, the motor changes direction

automatically after the set time. In jogging mode, the motor rotates for the set time, stops for a few seconds and then rotates. 2. stop function stops rotating the motor and displays the message on the LCD module. This is indicated by glowing of the stop LED. 3. direction function increments the counter by 1 every time and checks whether the count is even or odd. If the count is even, it selects clock-wise direction, and if the count is odd, it selects anticlockwise direction. This is also indicated on direction CLK and ACLK LEDs. 4. mode function changes modes in cyclic manner. It increases modeselection flag m every time. If m=0 it selects continuous mode, if m=1 it selects reversible mode and if m=2 it selects jogging mode. If m=3 it is reset to 0 again and selects continuous mode and likewise. 5. incspeed function increases the width of the pulse by 100 s. The generated PWM is of 500 Hz. That means total time is 2 ms=2000 s. The width of the pulse is varied from 500 s to 1500 s in steps of 100 s. To display the speed, the variable is first converted into speed factor 1 to 9 and then into ASCII. 6. decspeed function is the same as incspeed but here the width of the pulse is decreased by 100 s. 7. inctime function increases the reversible time of the motor by one second. It increases the variable in multiples of 20. To display it on the LCD module, it is first divided by 20 and then converted into ASCII. 8. dectime function is the same as inctime but it decreases reversible time by one second. Delay. It uses the following functions: 1. keydly function generates a fix delay of around 50 ms for key debouncing. 2. delay function generates a variable delay by timer 0. The basic delay is of 100 s. It is rotated in loop from five to 15 times to generate minimum 500s and maximum 1500s delay. 3. time function again generates a variable delay by timer 1. The basic delay is of 50 ms. It is rotated in multiples of 20 from 20 to 180 to generate minimum 1- second and maximum 9second delay.

C code is in the appendix

For programming the AT89C51 microcontroller programming circuits are not available in the market. So I had to build a programmer as well. Following circuit diagram shows the arrangement of the programmer

Conclusion
Why AT89C51? The AT89C51 is a low-power, high-performance CMOS 8-bit microcomputer with4Kbytes of Flash programmable and erasable read only memory (PEROM). The device is manufactured using Atmels high-density nonvolatile memory technology and is compatible with the industrystandard MCS-51 instruction set and pin out. The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional nonvolatile memory programmer. By combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel AT89C51 is a powerful microcomputer, which provides a highly-flexible and cost-effective solution to many embedded control applications. TheAT89C51 provides the following standard features: 4Kbytes of Flash, 128 bytes of RAM,32 I/O lines, two 16-bit timer/counters, a five vector two-level interrupt architecture, a full duplex serial port, on-chip oscillator and clock circuitry. In addition, the AT89C51 is designed with static logic for operation down to zero frequency and supports two software selectable power saving modes. The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial port and interrupt system to continue functioning. The Power-down Mode saves the RAM contents but freezes the oscillator disabling all other chip functions until the next hardware reset.

Next Goal..
My next aim is to build a controller circuit to control the motion of separately excited DC motor. There are some more advantages of this project as it is going to inter communicate with the personnel computer. Many industrial applications require rotating drives and dc source. The versatile control characteristics of DC motor and DC Drives have contributed a lot to industrial application .This driver are normally capable of speed control and often require an equipment to attain a versatile and smooth speed control and make the motor to operate on a desired specific speed torque characteristic. Its speed can be varied by varying the applied voltage to armature or by varying the field current. The speed control below the base can be obtained by armature control method whereas the variation of above the base can be obtained by field current method or field weakening. The conventional method of controlling the speed of a separately excited motor is being used extensively in the industrial application. The motor can be started at constant torque and no additional starting equipment is required this method has some disadvantages; they are (1.) High initial cost (2.) Low efficiency (3.) The requirement of large space as the system is bulky (4.) Requirement of frequent maintenance. However these disadvantage can be over overcame by the Thyristor controller .The normal ac supply is rectified and supplied to a load. The average voltage applied to a load can be varied continuously by varying the firing angle of the Thyristor. When the convertor has Thyristor in all its places the regeneration is also possible. Therefore the drives employing phase controlled rectifiers are compact, flexible and simple and have fast response. More over many industrial use convectional autotransformer and individual metering circuits to control and monitor the motor operation. With the existing systems can able to control the speed alone

without regulation. But for good process of operation we require both speed and regulation without any moving parts. At the same time the new design should be coupled with the latest art of technology, which is smaller in size and must be efficient to use for all global standards. A specially designed microchip PIC16F877A can be adopted to solve the mentioned electrical problems, which has its unique features like built-in ADC, RAM, EPROM, USART and much more. Block Diagram of System

Appendix
C code for AT89C51 /********************************** *Name - Arachchi T.M.L. *Index no. - 090024H *DC motor control system **********************************/ #include<reg51.h> #include<string.h> sbit rs = P3^1; // rs pin of LCD sbit en = P3^0; // en pin of LCD sbit rw = P3^2; // rw pin of LCD sbit b = P0^7; // busy flag sbit led1=P2^0; // run indicator sbit led2=P2^1; // stop indicator sbit led3=P2^2; // clockwise direction indicator sbit led4=P2^3; // anticlockwise direction indicator sbit PWM=P2^4; // PWM output sbit RL1=P2^5; // relay 1 pin sbit RL2=P2^6; // relay 2 pin unsigned int x=10; //ontime unsigned int y=10; //offtime unsigned int m=0; // mode unsigned int d=0; // direction unsigned int t=100; // time unsigned int r=0; // run flag

void start(void); // function initilization void mode(void); void direction(void); void incspeed(void); void decspeed(void); void inctime(void); void dectime(void); void time(unsigned int); void delay(unsigned int); void keydly(void); void busy(void); void writecmd(unsigned char a) // send command to LCD

{ busy(); // check busy flag rs = 0; // select command register rw = 0; // write enable P0 = a; // send byte to LCD en = 1; // apply strobe pulse en = 0; } void writedata(unsigned char b) // send data to LCD { busy(); // check busy flag rs = 1; // select data register rw = 0; // write enable P0 = b; // write enable en = 1; // send byte to LCD en = 0; // apply strobe pulse } void busy() // check busy flag of LCD { en = 0; // disable display P0 = 0xFF; // P0 as input rs = 0; // select command register rw = 1; // read enable while(b==1) // if busy bit is 1 { en=0; // remain withine loop en=1; } en=0; } void writestr(unsigned char *s) // send string message to LCD { unsigned char l,i; l = strlen(s); // get length of string for(i=0;i<l;i++) { writedata(*s); // till the length of string s++; // send characters oneby one } } void start() // start rotating motor { if(m==0)// for m=0 start continuous mode

{ RL1=0; // switch on RL1 r=1; // set run flag P1=0xFF; // send all 1s to P1 while(P1==0xFF) // till no key is pressed { led1=1; // indication on run LED PWM=1; // send high logic to PWM pin delay(x); // on time delay PWM=0; // now send low logic to PWM delay(y); // off time delay } } else if(m==1) // for m=1 start reversible mode { r=1; // set run flag P1=0xFF; // send all 1s to P1 while(P1==0xFF) // till no key is pressed { led1=1; // run LED=1 led3=1; led4=0; PWM=1; // send high on PWM pin RL2=1; // select one direction RL1=0; // switch on RL1 time(t); // wait for desired time RL1=1; // switch off RL1 led1=0; // run LED=0; time(20); // wait for 1 sec led1=1; // again run LED=1 led3=0; led4=1; RL2=0; // select other direction RL1=0; // switch on RL1 time(t); // wait for desire time RL1=1; // switch off RL1 led1=0; // run LED=0 time(20); // wait for 1 sec } PWM=0; } else if(m==2) // for m=2 start jogging mode { r=1; // reset run flag P1=0xFF; // send all 1s to P1 while(P1==0xFF) // till no key is pressed {

led1=1; PWM=1; // send high on PWM pin RL1=0; // switch on RL1 time(t); // wait for 1 sec RL1=1; // switch off RL1 PWM=0; // send low on PWM pin led1=0; time(20); } } } void direction() // alter the direction { keydly(); // key debounce delay d++; // increment count if((d%2)==0) // check for even or odd { led3=1; // indicate on LEDs led4=0; RL2=1; // switch ON / OFF RL2 } else { led3=0; led4=1; RL2=0; } } void mode() // change mode of rotation { keydly(); // key debounce delay writecmd(0x80); // display message on first line first column m++; // increment count if(m==3) m=0; // if it is 3 reset it if(m==0) { writestr("mode:continuou"); // otherwise display mode time(15); } else if(m==1) { writestr("mode:reversible "); time(15); } else if(m==2) { writestr("mode:jogging ");

time(15); } } void decspeed() // increase speed { int z; keydly(); //key debounce writecmd(0xC0); //select second line on LCD if(y<14) //if not max pulse width { x--; y++; //increase it convert it in to z=y-5+0x30; //1 to 10 scale and ASCII writestr("speed: "); // diaplay speed on LCD writedata(z); writestr(" "); } else if(y==14) writestr("min speed: 9 "); //if max speed display message } void incspeed() //increase speed { int w; keydly(); writecmd(0xC0); // key debounce if(y>6) //if not minimum width { x++; y-- ; // decrease it w=y-5+0x30; // do same as above writestr("speed: "); writedata(w); writestr(" "); } else if(y==6) writestr("max speed: 1 "); //if min speed display message } void inctime() //increase time { int p; keydly(); //key debounce delay writecmd(0xC0); if(t<180) //if not max time {

t+=20; //increase it by 1 sec p=t/20; p=p+0x30; //convert it in to ASCII writestr("time: "); //display it writedata(p); writestr("sec"); } else if(t==180) writestr("max time: 9 sec"); // if max time display message } void dectime() //ecrease time { int q; keydly(); //key debounce delay writecmd(0xC0); if(t>20) //if not min time { t-=20; //decrease it q=t/20; q=q+0x30; //do same as above writestr("time: "); writedata(q); writestr("sec"); } else if(t==20) writestr("min time: 1 sec");// if min time display message } void keydly() //key debounce delay { int a,b; for(a=0;a<50;a++) for(b=0;b<1000;b++); } void time(unsigned int c) // change time in seconds { int k; TL1 = 0xAF; // use timer 1 TH1 = 0x3C; // to generate 50 ms delay TR1 = 1; //start timer for(k=0;k<=c;k++) //rotate loop in multiples of 20 { while(TF1==0); //wait till timer overflow TF1 = 0; //reset the flag TL1 = 0xAF; // reload it

TH1 = 0x3C; } TR1 = 0; //stop timer } void delay(unsigned int c1) // change time in micro seconds { int a; TH0=0x9B; //select timer 0 TL0=0x9B; //to generate 100 micro second delay TR0=1; //start timer for(a=0;a<c1;a++) //rotate loop between 5 to 15 { while(TF0==0); //wait until timer overflow TF0=0; //reset the flag } TR0=0; //stop timer } void main() { TMOD=0x12; // timer1 in 16 bit,timer 0 in 8 bit auto reload mode P2=0xE0; //LEDs off, relays OFF P0=0x00; //P0, P3 output ports P3=0x00; writecmd(0x3C); //initilize LCD writecmd(0x0E); writecmd(0x01); writecmd(0x84); //display message writestr("DC Motor"); // DC motor controller in writecmd(0xC3); //center of LCD writestr("Controller"); agin:P1=0xFF; //P1 as input port while(P1==0xFF); //wait until any key press loop:switch(P1) { case 0xFE: // for first key keydly(); // key debounce writecmd(0x01); writestr("motor start"); time(50); // wait for 2.5 sec writecmd(0x80); writestr("mode:continuous");// display current mode and speed writecmd(0xC0); writestr("speed: 5 "); led1=1; //Run LED ON led2=0; //stop LED OFF led3=1; //clockwise direction ON

led4=0; //anticlockwise direction OFF start(); //sart rotating motor break; case 0xFD:// for second key keydly();// key debounce r=0;// run flag reset writecmd(0x01); writestr("motor stop");// display message led1=0; //Run OFF led2=1; //stop LED ON led3=0; //clockwise direction OFF led4=0; //anticlockwise direction OFF PWM=0; //low logic to PWM pin RL1=1; //relay1 off break; case 0xFB:// for third key mode(); //select mode if(r==1) start(); //jump to start if run flag is set break; case 0xF7:// for fourth key direction(); //change direction if(r==1) start(); // jump to start if run flag is set break; case 0xEF:// for fifth key incspeed(); //increase speed if(r==1) start(); // jump to start if run flag is set break; case 0xDF:// for sixth key decspeed(); //decrease speed if(r==1) start(); // jump to start if run flag is set break; case 0xBF:// for seventh key inctime();// increase time if(r==1) start(); // jump to start if run flag is set break; case 0x7F:// for eigth key dectime();// decrease time if(r==1) start(); // jump to start if run flag is set break; } if(r==1) goto loop; //if run flag is set jump of key detect else goto agin; //if not jump to again }

You might also like