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
7.24.2010 at 6:34 PM
thanks, for every things,specialy include the source site.
thank you sir