PWM: motor speed control

speed of motor depends on voltage. using this property we can vary the speed of dc motor. although voltage is fixed but variation can  be possible by giving duty cycle pulse i.e wider the on period of pulse,higher the speed we'll get. we can provide different duty cycle pulses using software.

                                                         

consider a waveform  such as voltage switching between 0v and 5v. then a 'suitable device' connected to its output will see the average voltage and think it is being fed 2.5v - exactly half of 5v. So by varying the width of the positive pulse - we can vary the 'average' voltage.

Proteus design

 

a varying frequency is fed by adjusting the width of wave connected to output device(motor) connected with pin P1.0 and P1.1. switch 1 and switch 2 connected with pin number P2.0 and P2.1 for increasing and decreasing the width of wave respectively.

CODE

initially we can assign any value in between 0 to 100 to a variable 'speed'. each time switch1 is plunged as the condition satisfies speed is incremented by factor of one until speed would  achieve value of 100 i.e full rated speed(100% duty cycle). similar you can decrease the speed of motor .

complete code

#include<reg51.h>
sbit m1=P1^0;
sbit m2=P1^1;
sbit inc=P2^0;
sbit dec=P2^1; 
void delay(unsigned int);
int speed=20;
void main()
{
inc=0;
dec=0;
while(1)
{
if(inc==1)
{
speed=(speed<100)?speed+1:100;
}
if(dec==1)
{
speed=(speed>0)?speed-1:0;
}
m1=1;
m2=0;
delay(speed);
m1=0;
m2=0;
delay(100-speed);
}
}

void delay(unsigned int x)
{
unsigned int i,j;
for(i=0;i<x;i++)
for(j=0;j<1273;j++);
}

VIDEO

Category: 

tags: 

Share

Who's new

  • ravirajpatil871...
  • shubhambajoria
  • yassir
  • demiholyman890954
  • scottgillum51169040

Get Notified

 

Share

We are Social

Syndicate

Subscribe to Syndicate