Está en la página 1de 163

King Saud University

C ll
College
off Engineering
E i
i
Electrical Engineering Department
EE 435

Speed Control of DC Motors


P
Prepared
db
by

Ameen Rashed Abdulqadeer


Supervised by

Dr: Ali M. Eltamaly



) ( Buck Converter

microcontroller Pulse
Buck converter

PWM

220/
220
/24

B kC
Buck
Converter
t Ci
Circuit
it (Step
(St Down
D
DC-DC Converter)
C
t )




PWM Switch
Ton
d
duty
ratio
i
VO ton
=D
=
Vd TS
Vd -Vo
A

toff

-Vo
ton
Ts

vL

PWM

Pulse

Microcontroller
PIC16F
PIC16
F877
877A
A


33


40


input output

+5 v
input output

Port B

)
(

Port A

input output

Port E

input output

)(+5 v
input output

Port D
Crystal 4MHz

input output

Port C

Port C

input output

input output

Port D

Port D

input output

Mic ocont olle


Microcontroller



Port A
Port B
Port C
Port D
Port E
Port B

portB.0
portB.
0 , portB.1
portB.1 , portB.2
portB.2 , portB.3
portB.3 , portB.4
portB.4 , portB.5
portB.5 , portB.6
portB.6 , portB.7
portB.7
portB.0
portB
portB.0











portB. ) IR (
portB.3
LED 3

Microcontroller
13 14
) (Crystal 4MHz

Microcontroller
Proteus 7 Professional

Proton IDE


ISIS 7

Proteus 7 Professional


....

-2

-1


Pic16f877a

-1

-2

-1 10K

-3 3W

-2
:

-4

-1

-2 )
(

-3

-2

-3

-1

-1

-2


) (LED

PortC.
P
PortC.0
tC 0








)(

-1
-2 LED

ACTIVE




PortC.0

PortC.0

Proton
C


hex F9

16F877A

Crystal 4MHz
XTAL 4


output Port(Port
(
))Name

c output PortC
c ) c (
output portc.0
portc.
portc 0
portc.
portc 0
portc.0
c
)input Port(Port Name
c input PortC
input portc.
portc.1
portc. 1
portc.1
1
: +5 V
sensor 5 V

portc.0



+5 V



Output portB.4
portB.4
portB.4
portB.
p
4 =1
+5 v

PortB.1
PortB.
1 =0

DelayMS
hold

) (ms ) (

)) (1000 ms


DelayMS 1000


portc.0
portc.
0

portc.
portc 0
portc.0


D i = 16
Device
16F
F877
877A
A
XTAL 4
Output PortC.
PortC.0
0
Portc.0 =1
Portc.0
DelayMS 10000
Portc.0=0
Portc.0
DelayMS 5000



ProtC.
ProtC.0
0
+5 v

loop

De ice = 16
Device
16F
F877
877A
A
XTAL 4
Output
p PortC.
PortC.0
0
Main:
Portc.0 =1
Portc
Portc.0
DelayMS 10000
Portc.0=0
Portc.0
DelayMS 5000
Goto main

Device = 16F
16F877
877A
A
XTAL 4
Output PortC.
PortC.0
0
Main:
Portc.0
Portc.
0 =1
DelayMS 10000
Portc.0
Portc.
0=0
DelayMS 5000
Goto main

loop


C
C
D
D:\Micro


F9

4MHz


HEX
open

OK


LCD

LCD
LCD 16xx2 with back light
16
6
16

6 4

LCD DATASHEET


PortD


+5 V

H - Bridge Diode


PortD

) (1
) (2 +5 V
(

)






) (3


) PortD. 21 (
PortD.2
) (4 2
) (5
22 (
) PortD.
PortD.3
) (6 3

) (7
) (8
) (9


(10
))10

) PortD. 27 (
PortD.4
) (11 4
)11
) PortD. 28 (
PortD.5
) (12 5
)12
29 (
) PortD.
PortD.6
) (13 6
)13

) PortD. 30 (
PortD.7
) (14 7
)14
) (15 +5 V
)15
) (16
)16


PortD

Declare LCD_TYPE 0
D l
Declare
LCD
LCD_DTPIN
DTPIN PORTD.4
PORTD 4
Declare LCD_ENPIN PORTD.3
Declare LCD
LCD_INTERFACE
INTERFACE 4
Declare LCD_RSPIN PORTD.2

LCD


16x2

DC
LCD

-1

-2
5 V



15 16




)
(

P i t Enter
Print
E t your sentence
t






" Print At 1,1," Enter your sentence

16




Welcome


C F9

) (HEX
4MHz

-2
Welcome



-1



F9


Print At 1,9, "Welcome

Print At 2,9, "Welcome"


Welcome

P i t At 1,15,
Print
1 15 "Welcome"
"W l
"

Print At 2,10, "Welcome"

Print At 1,1, "Welcome 123"

Print At 1,1, "Welcome

112233"

IR Sensor & Remote Control



IR Sensor
S


ProtB.
ProtB.7
7

PWM

IR Sensor

IR Sensor
signal
] [0 1
]1

IR sensor

IR Sensor

Starting ) (240 us

< ))(90 us

] [1

][0

IR Sensor
IR Sensor




+5 v

0 v
0 v
+5 v

Voltmeter





IR Sensor

IR sensor

IR Sensor


Symbol
Symbol ir
ir_sensor=PORTB.
ir_sensor=PORTB.7
sensor PORTB 7

PortB.7 ir_sensor


PWM

IR Sensor









Dim variable name As variable type
Variable type may be one of these :
Byte word bit dword float

Dim st As Word

Variable type
BIT: Variable type that may hold a value of 0 or 1.
BYTE: Variable type that may hold a value of 0 to 255.
255.
WORD: Variable type that may hold a value of 0 to 65535.
65535.
DWORD:
O
Variable
bl type that
h may hold
h ld a value
l off -2147483648
2
83 8 to
+2147483647.
2147483647.
FLOAT: Variable type that may theoretically hold a value of -1e37 to
+1e38.
38. However, with floating point calculations, smaller values
offer more accurate results
results.


: BIT 0 1
: BYTE 0 255
: WORD 0 65535
: DWORD -2147483648 +2147483647
: FLOAT -1e37 +1e38

IF Statement

IF condition then
Code
End IF

IF ProtB.
ProtB.7
7 =1 then
PortC.0
PortC.
0=1
PortC.1
PortC.
1=0
End IF

IF PortB.
PortB.7
7 =1 then PortC.0
PortC.0 =1

Nested if
if x=
x=10
10 then
High led1
led1
elseif x=20
x=20 then
high led
led2
2
ELSE
high led3
led3
ENDIF

For loop
For variable name =startcount To endcount STEP stepval
code bodyy
Next
Overview :
For loop is used to execute a code for predefined amount of times
Ex :
For I =0
=0 to 10 step 1
portb =I
Next
For i=
i=100
100 to 0 step -2
portb=I
Next
Next

IR Sensor
IR Sensor


PortB.7
PortB.7 ir_sensor
ir_word


st
Starting 240 us

flg

main:

goto main



main

sony_in






goSub goto
flg=0

main sony_in



flg
fl


sony_in

flg
200 ms

main

sony_in
flg=1
g


PortB.7
ir_sensor +5v 0 V


IF ir_sensor=1 Then GoTO no_sig
+5 V
PortB.7

no_sig
PortB.7


PulsIN ][0 1
PortB.7
Starting
st
) (240 us

) (240 us

) (270 us no_sig
) (200 us no_sig

Starting

Starting ] [1 ][1

] [0 12










:




shift




] [1

For Loop
0 11 12

PulsIn
P lsIn





id
)) ((90 us 1
ir_word
ir_word

return sony_in
main


flg=0 main

print ir_word
1 32

2 4128
3 2080
4 1676
5 1056
5152



6



7 3104
8 7200
9 544
0 4640

ir_word

Dec
D


Hex



32
ir_word
ir word =32


100 85









1 2 0



120


K


ikey

ikey=0

] k[0
ikey
] k[1 ikey


] k[0

ikey
] k[1 ]k[2

K[0]=1
] [
K[1]=2
K[2]=4

ikey

5344



comp



main






124
rpm

IR Sensor PWM


100 %100
) (100

PWM
PWM Ton
duty ratio


VO ton
= =D
Vd TS
100 ms Ton
t_on
_ = (rpm/100
(rpm/
*)( p /100
))*100
100
Toff
= t_off
=100
)100 - (t_on
Toff=0

Ton =100

100


50 Ton=50 Toff=50

PortC.
PortC.1
PWM 1

Speed_flag

PWM


PortC.1



rpm
speed_flag

t_on
t_off
rat_speed 100

100

rat speed =100


rat_speed
100

Speed_flag=0
main


speed flag=1
speed_flag=1
) (+5 v t_on
t off
t_off


) (0 v

PWM
))((ms


comp



rat_speed
d
speed_flag=0

100



main

100

)

( Speed is
t_on t_off
speed_flag=1
)

ir_word
ir word





= speed_flag
speed_flag=0
0

)
(



4N32

PWM
+18 V



PortC. 1
PortC.1
1
2


+18 v +5 v


+18 v

Switch +18 v

4N32



4N32

Datasheet
h


+5 v 0 v
t_on t_off

PortC.1

t_on

t_off

speed_flag =0

PortC.1=1
Po tC 1 1




G
PWM

220/
220
/24

B kC
Buck
Converter
t Ci
Circuit
it (Step
(St Down
D
DC-DC Converter)
C
t )


12 mH
continuous region
Electrical Switch mosfet
IRFPC50
IRFPC
50



24 v



duty ratio

Switch

24 v
dutyy ratio

S
G

220//24
220

Buck Converter Circuit


G

220//24
220

Isolating
so at g C
Circuit
cu t

Microcontroller Circuit

Programmer


Programmer


USB

MicroPro

Programmer

DC Supply +12 v


RS USB

RS to USB



MicroPro

RS to Usb
port 4

Load

)(XT


Fuses
F

Program

(



)

Device=16F877A
XTAL=4
Declare LCD_DTPIN PORTD.4
Declare LCD_ENPIN PORTD.3
Declare LCD
LCD_INTERFACE
INTERFACE 4
Declare LCD_RSPIN PORTD.2
Input PORTB.7
Output PORTC.1
Symbol ir_sensor =PORTB.7
Dim i As Byte
Dim ir_word As Word
Dim st As Word
Dim k[4] As Byte
Di flg
Dim
fl As
A Byte
B
Dim ikey As Byte
Dim rpm As Word
Dim speed_flag As Byte
Dim t_on As Float
Dim t_off As Float
Di rat_speed
Dim
t
d As
A Word
W d

rat_speed = 100
speed_flag =0
k[0]=0
k[1]=0
k[2] 0
k[2]=0
k[3]=0
Cursor 1,1
PORTC.1=1
main:
If speed_flag =1 Then
PORTC.1=0
PORTC.1
0
DelayMS t_on
PORTC.1=1
DelayMS t_off
PORTC 1 0
PORTC.1=0
Else
PORTC.1=1
End If

If ir_sensor=0 Then speed_flag =0


GoSub sony_in
If flg=0 Then GoTo main
DelayMS 200

If ir_word
ir word = 32 Then
speed_flag =0
k[ikey]="1"
Print "1"
Inc ikey
EndIf
If ir_word = 4128 Then
speed
p
_flag
g =0
k[ikey]="2"
Print "2"
Inc ikey
EndIf
If ir_word = 2080 Then
speed_flag =0
k[ikey]="3"
[ y]
Print "3"
Inc ikey
EndIf

If ir_word = 6176 Then


speed_flag =0
k[ikey]="4"
Print "4"
Inc ikey
EndIf
If ir_word = 1056 Then
speed_flag =0
k[ikey]="5"
Print "5"
Inc ikey
EndIf
If ir_word = 5152 Then
speed_flag =0
k[ikey]="6"
Print "6"
Inc ikey
EndIf
If ir_word = 3104 Then
speed_flag =0
k[ikey]="7"
Print "7"
Inc ikey
k
EndIf

If ir_word = 7200 Then


speed_flag =0
k[ikey]="8"
Print "8"
Inc ikey
EndIf
If ir_word = 544 Then
speed_flag =0
k[ikey]="9"
Print "9"
Inc ikey
EndIf
If ir_word = 4640 Then
speed_flag =0
k[ikey]="0"
Print "0"
Inc ikey
EndIf
Iff ir_word=5344
d
Then
h
GoTo comp
GoTo main
comp:
rpm=Val (k,Dec)

If rpm > rat_speed Then


speed_flag=0
Print At 1,1,"max speed 100 "
DelayMS 1000
Print At 1,1,"

"

ikey=0
Cursor 1,1
11
k[0]=""
k[1]=""
k[2]=""
k[3]=""
GoTo main
EndIf
Print At 2,1,"Speed is : ",Dec rpm ," "
t_on = (rpm/100)*100
t_off=100-(t_on)
speed flag=1
speed_flag=1

Print At 1,1,"
ikey=0
Cursor 1,1
k[0]=""
k[1] ""
k[1]=""
k[2]=""
k[3]
k[3]=""

ir_word=0
GoTo main

"

sony_in:
flg=1
g
If ir_sensor=1 Then GoTo no_sig
st= PulsIn ir_sensor,0
If st < 200 Then GoTo no_sig
If st > 270 Then GoTo no_sig
no sig
For i=0 To 11
id= PulsIn ir_sensor ,0
If ID>=90 Then
ir_word.0=1
Else
ir word 0 0
ir_word.0=0
EndIf
ir_word=ir_word<<1
Next i
Return
no_sig:
flg=0
Return


PIC16F877A

Crystal 4MHz

LCD 2x16 with back light

Socket


Transformers 220/12 , 220/24 (need 2 pieces)
Transformers,

Inductor 12 mH

Switch Heat Sinks

4N32 Optocoupler


Capacitor 470 uF 45 V (need 6 pieces)

H Bridge (need 3 pieces)

Regulators:
g
7805,, 7818

IRFPC50 mosfet
f t (S
(Switch)
it h)

Diode

Sony Remote Control

IR Sensor with ground

DC motor 12V

Board


Programmer For PIC16F877A (USB)

RS232 TO USB Converter

Adapter 12v For programmer

programmer
23
18
23918961 :

www ram com eg
www.ram.com.eg

) (





HugE@windowslive.com
HugE@windowslive com
:

También podría gustarte