Académique Documents
Professionnel Documents
Culture Documents
requirements. The DC motor is an attractive piece of equipment in many industrial applications requiring variable speed and load characteristics due to its ease of controllability. Microcontrollers provide a suitable means of meeting these needs. Certainty, part of the recent activity on microcontrollers can be ascribed to their newness and challenge. In this paper, implementation of the MC68HC11E9 microcontroller for speed control of DC motor fed by a DC chopper has been investigated. The chopper is driven by a high frequency PWM signal. Controlling the PWM duty cycle is equivalent to controlling the motor terminal voltage, which in turn adjusts directly the motor speed. Experimental results have been obtained that show the employment of microcontroller for speed control and over current protection of a DC motor.
DC Motors
DC motor: has only a pair of + and leads. Connecting to a DC voltage source, DC motors move in one direction. By reversing the voltage polarity, they will move in the opposite direction.
P1.0 =0
P1.1 =1
P1.2 =1
Figure 11.8 H-Bridge Motor Configuration Figure 11.9 H-Bridge Motor Clockwise Configuration
P1.3=0
H-Bridge control can be created using relays, transistors, or a single IC solution. When using relays and transistors, make sure that invalid configuration do not occur.
Figure 11.12
dee pS r ot o M
DC Motors
Only One Winding Two Connections: + and Reversing Polarity Reverses Motor Move Continuously Cannot Determine Position
Characteristics:
RPM
No Load: Maximum RPM With No Load on Shaft
Given in Data Sheets
Voltage Range
Speed Increases With Voltage on a Given Motor
Current Draw
Data Sheet Rating Is With Nominal Voltage and No Load Increases With Load
Bi-Directional Control
Can Change Polarity With a Little Work H-Bridge Is Simplest Method
Uses Switches (Relays Will do)
Controlling Speed
Speed Depends On
Load Voltage Current
#include<REG51xD2.H> sbit inr=P32; //speed increment switch sbit dcr=P33; //speed decrement switch main() {unsigned char i=080; //i has initial speed value=half speed = 80 H P3=0ff; //configure P3 to accept switches while(1) {if (!inr) //if increment is pressed {while (!inr); //wait till key is released if (i>10) //if speed is more than minimum i=i-10; //increase the DC motor speed, by decreasing the count } //end of if if (!dcr) //if decrement is pressed {while (!dcr); //wait till key is released if (i<0xf0) //decrease the DC motor speed, by increasing the count } //end of if P0=i; //output the value to port P0 for speed control
Hex keypad
#include<reg51xd2.h> #include<intrins.h> #include"lcd.h" unsigned char rows,columns,result; unsigned char temp = 0; void delay() //delay subroutine {unsigned int i; for(i=0;i<=20000;i++);} //display subroutine to convert hex to ASCII and display on LCD void Display() {if(result>0x09) {result += 0x37; //if value is greater than 9, add 37H WriteChar(result);} else {result += 0x30; //if value is between 0 to 9, add 30H WriteChar(result);} } //end of display subroutine
void KeyScan() //Keypad subroutine {again:columns = 0x0e; //make P1.0 low rows = 0x04; //4 rows to check result = 0x0; //Key value starts at 0 next: P1 = columns; //output columns CY = 1; //make CY = 1 for next rotation columns <<= 1; //rotate columns left temp = P0; //store in temp temp = (temp & 0x0f); if(temp != 0x0f); //if key pressed {rot: temp>> = 1; if(!CY) {ClrLcd(); //key found return;} else {result += 1; //next column; key value is incremented goto rot;} }
else {result += 0x04; //for next row; 4 is added to key value rows - -; //decrement number of rows if(rows = = 0) goto again; //start from beginning else {goto next; } }} void main() {P0 = 0xff; //make as input port P1 = 0x00; InitLcd(); //initialize LCD WriteString("KEY PRESSED=") while(1) {KeyScan(); //call keypad subroutine WriteString("KEY PRESSED=") Display(); //display the value }}
#include<reg51xd2.H> void delay(unsigned int); main() {unsigned char Flr[9] = {0xff,0x00,0x03,0xff,0x06,0xff,0xff,0xff,0x09}; unsigned char ReqFlr,CurFlr = 0x01,i,j; P0 = 0x00; P0 = 0xf0; while(1) {P1 = 0x0f; ReqFlr = P1|0xf0; while(ReqFlr == 0xff) ReqFlr = P1|0xf0; //Read Request Floor from P1 ReqFlr = ~ ReqFlr; if(CurFlr == ReqFlr) //If request floor is equal to current floor {P0 = Flr[CurFlr]; //Clear Floor Indicator P0 = P0|0xf0; //Enable again continue; //Go up to read again }
else if (CurFlr > ReqFlr) //If current floor is > request floor { i = Flr[CurFlr] - Flr[ReqFlr]; //Get the no of floors to travel j = Flr[CurFlr]; for(; i>0; i- -) //Move the indicator down {P0 = 0x0f0 | j; j- -; delay(25000); }} else //If Current floor is < request floor {i = Flr[ReqFlr] - Flr[CurFlr]; //Get the no of floors to travel j = Flr[CurFlr]; for(; i>0; i- -) //Move the indicator Up {P0=0f0 | j; j++; delay(25000); }}
CurFlr = ReqFlr; //Update current floor P0 = Flr[CurFlr]; //Clear the request indicator P0 = P0|0xf0; } //end of while } //end of main void delay(unsigned int x) {for(; x>0; x- -);}
What is PWM
commonly used technique for controlling power to inertial electrical devices, made practical by modern electronic power switches. The average value of voltage (and current) fed to the load is controlled by turning the switch between supply and load on and off at a fast pace. The longer the switch is on compared to the off periods, the higher the power supplied to the load is.
What is PWM
The PWM switching frequency has to be much faster than what would affect the load, which is to say the device that uses the power. Typically switchings have to be done several times a minute in an electric stove, 120 Hz in a lamp dimmer, from few kilohertz (kHz) to tens of kHz for a motor drive and well into the tens or hundreds of kHz in audio amplifiers and computer power supplies.
What is PWM
The main advantage of PWM is that power loss in the switching devices is very low. When a switch is off there is practically no current, and when it is on, there is almost no voltage drop across the switch. Power loss, being the product of voltage and current, is thus in both cases close to zero. PWM also works well with digital controls, which, because of their on/off nature, can easily set the needed duty cycle.