DC Motor Speed Control using PWM
This project gives a speed control of DC motor through PWM method. The Dc motor is derived by the L298 driver IC.
You can also control the direction of the motor.
There are three buttons to control the motor. Also a bar graph Led display indicate the speed of the motor.
An proteus simulation file is also available at the download so that you can check the code on your PC.
Project from this Link
Circuit Diagram
Bascom Code
$regfile = "m16def.dat"
$crystal = 1000000
'============================================================================
Config Timer1 = Pwm , Pwm = 8 , Compare A Pwm = Clear Down , Prescale = 1024
Config Portb = Input
Config Portc = Output
Config Porta = Output
'============================================================================
Dim A As Word , B As Bit
'============================================================================
Declare Sub Progress(num As Word)
'============================================================================
A = 100
Pwm1a = A
Portc.0 = 1
Portc.1 = 0
B = 0
'============================================================================
Do
'////////////////////////////////////////////////////////////////////////////
If Pinb.0 = 1 Then
A = A + 10
If A >= 250 Then A = 250
Pwm1a = A
Waitms 250
End If
'////////////////////////////////////////////////////////////////////////////
If Pinb.1 = 1 Then
A = A - 10
If A <= 10 Then A = 10
Pwm1a = A
Waitms 250
End If
'////////////////////////////////////////////////////////////////////////////
If Pinb.2 = 1 Then
If B = 0 Then
B = 1
Portc.0 = 0
Portc.1 = 1
Elseif B = 1 Then
B = 0
Portc.0 = 1
Portc.1 = 0
End If
Waitms 250
End If
'////////////////////////////////////////////////////////////////////////////
Call Progress(a)
'////////////////////////////////////////////////////////////////////////////
Loop
'============================================================================
End
'/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Sub Progress(num As Word)
If Num < 25 Then
Portc.7 = 1
Portc.6 = 0
Porta = 0
End If
If Num < 50 And Num >= 25 Then
Portc.6 = 1
Portc.7 = 1
Porta = 0
End If
If Num < 75 And Num >= 50 Then
Portc.6 = 1
Portc.7 = 1
Porta = &B00000001
End If
If Num < 100 And Num >= 75 Then
Portc.6 = 1
Portc.7 = 1
Porta = &B00000011
End If
If Num < 125 And Num >= 100 Then
Portc.6 = 1
Portc.7 = 1
Porta = &B00000111
End If
If Num < 150 And Num >= 125 Then
Portc.6 = 1
Portc.7 = 1
Porta = &B00001111
End If
If Num < 175 And Num >= 150 Then
Portc.6 = 1
Portc.7 = 1
Porta = &B00011111
End If
If Num < 200 And Num >= 175 Then
Portc.6 = 1
Portc.7 = 1
Porta = &B00111111
End If
If Num < 225 And Num >= 200 Then
Portc.6 = 1
Portc.7 = 1
Porta = &B01111111
End If
If Num < 255 And Num >= 225 Then
Portc.6 = 1
Portc.7 = 1
Porta = &B11111111
End If
End Sub

11.10.2009 at 7:18 PM
sir i have a doubt that
->what is that device in 2nd photo of 20 pin and getting input form (P1-P10) from atmega .
11.22.2009 at 6:27 PM
sir, thanks a lot!
your site is providing quite usefull informations,this is really a saviour for a amateur pratisioner
12.17.2009 at 12:09 AM
i've 2 motors connected to the 2 wheels of my robot.i need one wheel to run at 40 rpm and another at 60 rpm.how do i achieve this using a microcontroller
1.05.2010 at 4:31 PM
i need the assembly code.
1.10.2010 at 4:44 PM
Good! but need codevision avr code
1.13.2010 at 2:04 AM
chegooneh soraat va jahate motor dc ra ba control az rahe dur ba estefade az pwm control konim???
pleas HELP ME.
thanks.
1.22.2010 at 6:17 AM
How to calculate to produces PWM with 10 rpm..?
2.27.2010 at 1:20 PM
sir i need programming
for controlling speed of dc motor through uc also program to stop &start it thank u
3.29.2010 at 9:32 PM
hello i have done the project on implementing pwm on dc motor the project is working properly but i want the material to make the study report of my project ..............so plz help sir
3.29.2010 at 9:32 PM
hello i have done the project on implementing pwm on dc motor the project is working properly but i want the material to make the study report of my project ..............so plz help sir
4.02.2010 at 5:55 PM
hey ajay. even i gotta make a project on "speed control of dc motor using pwm". can u plz help me. i just want to know if the above circuit works and can u gimme ur email id for further queries??? help...
4.02.2010 at 5:55 PM
hey ajay. even i gotta make a project on "speed control of dc motor using pwm". can u plz help me. i just want to know if the above circuit works and can u gimme ur email id for further queries??? help...
5.30.2010 at 1:17 PM
Sir, i need the c code for this programming. And can it be done by ATMEGA 32? please reply
9.27.2010 at 12:57 PM
hi
many thanks for this project .
i need to controlthe speed via a pc using C++ GUI and view its trace on the PC monitor
11.22.2010 at 11:25 AM
hi sir
i am having 2 pmdc motors for my robotic application i am using atmega16 uc ,i want to control the directions like if i press 1st button it will move forward direction 2nd backward,3rd left motor should run backward ,4th right motor should run backward fot the movement of right direction. i want the code please help me sir
11.22.2010 at 11:26 AM
sir that code should be in c langauge
11.26.2010 at 2:33 PM
hi,
thanks for this great tutorial,
can i have this code in some what C language, it will be easy for me to understand in that case,
thanks,
waiting for reply..
12.30.2010 at 9:18 PM
what is the total time(frequency) of PWM?
can i use uln2003 to drive 5V dc motor?
1.09.2011 at 9:03 PM
tankyou
2.02.2011 at 3:31 PM
hi sir i need, code in c to interface key which does one function when press once does any other when pressed twice.
2.02.2011 at 3:31 PM
hi sir i need, code in c to interface key which does one function when press once does any other when pressed twice.
2.02.2011 at 8:10 PM
sir, i hv a doubt.we r controlling the brightness of LED by PWM. can we control the brightness of AC,220V BULB ? how to control it?pls giv me tips for it.
2.26.2011 at 9:23 PM
sir my nme is mahesh stdying in vasavi college so this project can used for car sir
3.14.2011 at 2:02 PM
sir can i get the c code for this....
4.08.2011 at 2:25 PM
Hi
Thanks a lot for this
Iranians humen love you
4.20.2011 at 7:07 PM
sir i need programming
for controlling speed of dc motor through uc also program to stop &start it thank u
5.04.2011 at 4:50 PM
www.avrprojects.info/.../DC-moto-speed-c
5.17.2011 at 10:46 AM
pls mail me the full report for the same...
6.21.2011 at 2:38 PM
hi sir pls put the name of tranziztor or other elemans that use for it
thanks