dc motor remote control

Upload: linocmr

Post on 03-Jun-2018

225 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/12/2019 DC Motor Remote Control

    1/163

    King Saud UniversityKing Saud University

    Co ege o EngineeringCo ege o EngineeringElectrical Engineering DepartmentElectrical Engineering DepartmentEEEE 435435

    Speed Control of DC MotorsSpeed Control of DC Motorsrepare yrepare y

    Supervised bySupervised by

    Dr: Ali M. EltamalyDr: Ali M. Eltamaly

  • 8/12/2019 DC Motor Remote Control

    2/163

    ( Buck Converter )( Buck Converter )

    Buck converterBuck converter

  • 8/12/2019 DC Motor Remote Control

    3/163

    _+

    PWM

    220220//2424

    uc onverter rcu t tep own DC-DC onverter

  • 8/12/2019 DC Motor Remote Control

    4/163

    SwitchSwitchPWMPWM

    TTononuty rat outy rat o

    vL

    S

    on

    d

    O

    TVD =

    =

    Vd

    A

    -Vo

    -Vo

    B

    on off

    Ts

  • 8/12/2019 DC Motor Remote Control

    5/163

    PWMPWMPulsePulse

  • 8/12/2019 DC Motor Remote Control

    6/163

    MicrocontrollerMicrocontroller

    PICPIC1616FF877877AA

    outputoutputinputinput

  • 8/12/2019 DC Motor Remote Control

    7/163

    +5 v

    Port BPort A

    outputinputoutputinput

    Port Einputoutput ( )

    Port D outputinput ((+5 v

    Crystal 4MHz

    Port CPort C outputinputoutputinput

    Port DPort D outputinputoutputinput

  • 8/12/2019 DC Motor Remote Control

    8/163

    r r rr r r Port APort A

    Port BPort B

    Port DPort D

    Port EPort E

    Port BPort B portB.portB.00 , portB., portB.11 , portB., portB.22 , portB., portB.33 , portB., portB.44 , portB., portB.55 , portB., portB.66 , portB., portB.77

    ..))((IRIRportB.portB.33LEDLED

  • 8/12/2019 DC Motor Remote Control

    9/163

  • 8/12/2019 DC Motor Remote Control

    10/163

    MicrocontrollerMicrocontroller

    14141313((Crystal(Crystal 44MHz)MHz

  • 8/12/2019 DC Motor Remote Control

    11/163

    MicrocontrollerMicrocontroller

    ProteusProteus 77 ProfessionalProfessional Proton IDEProton IDE

  • 8/12/2019 DC Motor Remote Control

    12/163

    ProteusProteus 77 ProfessionalProfessionalISISISIS 77

  • 8/12/2019 DC Motor Remote Control

    13/163

    ....

  • 8/12/2019 DC Motor Remote Control

    14/163

    -1

    -2

  • 8/12/2019 DC Motor Remote Control

    15/163

  • 8/12/2019 DC Motor Remote Control

    16/163

    -1

    -2

  • 8/12/2019 DC Motor Remote Control

    17/163

    -

    --2 3W-3

    :

  • 8/12/2019 DC Motor Remote Control

    18/163

    -

    (-2)

    -3

  • 8/12/2019 DC Motor Remote Control

    19/163

  • 8/12/2019 DC Motor Remote Control

    20/163

    -2 -3

    -1

  • 8/12/2019 DC Motor Remote Control

    21/163

    1-

    -2

  • 8/12/2019 DC Motor Remote Control

    22/163

    ((LED)(LED

    or .or .

    ))((

  • 8/12/2019 DC Motor Remote Control

    23/163

    - LED-2

  • 8/12/2019 DC Motor Remote Control

    24/163

    ACTIVE

  • 8/12/2019 DC Motor Remote Control

    25/163

    PortC.0

    PortC.0

  • 8/12/2019 DC Motor Remote Control

    26/163

  • 8/12/2019 DC Motor Remote Control

    27/163

  • 8/12/2019 DC Motor Remote Control

    28/163

    ProtonProton CC

  • 8/12/2019 DC Motor Remote Control

    29/163

  • 8/12/2019 DC Motor Remote Control

    30/163

    16F877A

    Crystal 4MHz

  • 8/12/2019 DC Motor Remote Control

    31/163

    (output Port(Port Name)output Port(Port Nameoutput PortCoutput PortCcc

    ))cc((cc ....(input Port(Port Name)input Port(Port Name

    input portc.input portc.11portc.portc.11++55 VV::

    55 VVsensorsensor

  • 8/12/2019 DC Motor Remote Control

    32/163

    portc.0

  • 8/12/2019 DC Motor Remote Control

    33/163

    ++

    Output portB.Output portB.44ortB.ortB.44 ==11

    ++55 vv

    PortB.PortB.11 ==00

  • 8/12/2019 DC Motor Remote Control

    34/163

    DelayMSDelayMS

    holdhold ))((((ms)(ms msms

  • 8/12/2019 DC Motor Remote Control

    35/163

    portc.portc.00 ..

  • 8/12/2019 DC Motor Remote Control

    36/163

    ev ce =ev ce =

    XTALXTAL 44

    Output PortC.Output PortC.00

    Portc.Portc.00 ==11

    DelayMSDelayMS 1000010000

    Portc.Portc.00==00

    DelayMSDelayMS 50005000

    ProtC.ProtC.00

    ++55 vv looploop

  • 8/12/2019 DC Motor Remote Control

    37/163

    Device =Device = 1616FF877877AAXTALXTAL 44

    ev ce =ev ce =XTALXTAL 44

    Out ut PortC.Out ut PortC.00Output PortC.Output PortC.00

    Main:Main:Main:Main:

    Portc.Portc.00 ==11or c.or c. ==

    DelayMSDelayMS 1000010000

    Portc.Portc.00==00

    DelayMSDelayMS 1000010000

    DelayMSDelayMS 50005000

    Goto mainGoto main

    Portc.Portc.00==00

    DelayMSDelayMS 50005000

    Goto mainGoto main

    looploop

  • 8/12/2019 DC Motor Remote Control

    38/163

  • 8/12/2019 DC Motor Remote Control

    39/163

    C

    DD:\Micro

  • 8/12/2019 DC Motor Remote Control

    40/163

    F9

  • 8/12/2019 DC Motor Remote Control

    41/163

  • 8/12/2019 DC Motor Remote Control

    42/163

    4MHz

  • 8/12/2019 DC Motor Remote Control

    43/163

    HEXopen

  • 8/12/2019 DC Motor Remote Control

    44/163

    OK

  • 8/12/2019 DC Motor Remote Control

    45/163

  • 8/12/2019 DC Motor Remote Control

    46/163

  • 8/12/2019 DC Motor Remote Control

    47/163

    LCDLCD

  • 8/12/2019 DC Motor Remote Control

    48/163

    LCDLCD

    1616xx22 with back lightwith back lightLCDLCD

    4466

  • 8/12/2019 DC Motor Remote Control

    49/163

    LCD DATASHEETLCD DATASHEET

  • 8/12/2019 DC Motor Remote Control

    50/163

    PortDPortD

  • 8/12/2019 DC Motor Remote Control

    51/163

    H - Bridge Diode

    PortD

  • 8/12/2019 DC Motor Remote Control

    52/163

    ((((11++55 VV((((22 ))2121((PortD.PortD.22((((44((((55 ))2222((PortD.PortD.33((((66 ((((77((((88((((99 ))2727((PortD.PortD.44((((1111))2828((PortD.PortD.55((((1212))2929((PortD.PortD.66((((1313 ))3030((PortD.PortD.77((((1414++55 VV((((1515((((1616

  • 8/12/2019 DC Motor Remote Control

    53/163

    Declare LCD_TYPE 0

    ec are _ .

    Declare LCD_ENPIN PORTD.3

    PortD _

    Declare LCD_RSPIN PORTD.2

  • 8/12/2019 DC Motor Remote Control

    54/163

    LCD

  • 8/12/2019 DC Motor Remote Control

    55/163

    DCLCD

  • 8/12/2019 DC Motor Remote Control

    56/163

  • 8/12/2019 DC Motor Remote Control

    57/163

  • 8/12/2019 DC Motor Remote Control

    58/163

    16161515

    (( ))

  • 8/12/2019 DC Motor Remote Control

    59/163

  • 8/12/2019 DC Motor Remote Control

    60/163

  • 8/12/2019 DC Motor Remote Control

    61/163

  • 8/12/2019 DC Motor Remote Control

    62/163

    r nt nter your sentence

    Print At 1,1," Enter your sentence "

  • 8/12/2019 DC Motor Remote Control

    63/163

  • 8/12/2019 DC Motor Remote Control

    64/163

    F9C

  • 8/12/2019 DC Motor Remote Control

    65/163

    ((HEX

    4MHz

  • 8/12/2019 DC Motor Remote Control

    66/163

    -2 Welcome

    -1

  • 8/12/2019 DC Motor Remote Control

    67/163

    F9

  • 8/12/2019 DC Motor Remote Control

    68/163

  • 8/12/2019 DC Motor Remote Control

    69/163

    Print At 1,9, "Welcome

    " " , ,

    r nt t , , e come

    Print At 2,10, "Welcome"

    Print At 1,1, "Welcome 123"

    Print At 1,1, "Welcome 112233"

  • 8/12/2019 DC Motor Remote Control

    70/163

    IR Sensor & Remote ControlIR Sensor & Remote Control

    ensorensor ProtB.ProtB.77

  • 8/12/2019 DC Motor Remote Control

    71/163

    PWM

    IR Sensor

  • 8/12/2019 DC Motor Remote Control

    72/163

    IR SensorIR Sensor

    signalsignal

  • 8/12/2019 DC Motor Remote Control

    73/163

    IR SensorIR Sensor

    StartingStarting((240240 us)us)

  • 8/12/2019 DC Motor Remote Control

    74/163

    IR SensorIR Sensor

    IR SensorIR Sensor ++ vv00 vv 00 vv

    ++55 vv

  • 8/12/2019 DC Motor Remote Control

    75/163

    IR SensorIR Sensor

    IR sensorIR sensor

  • 8/12/2019 DC Motor Remote Control

    76/163

    IR SensorIR Sensor

    Symbol

    _ = ._ = .

    ir_sensorPortB.7

  • 8/12/2019 DC Motor Remote Control

    77/163

    IR SensorIR Sensor

    Dim variable name As variable typeDim variable name As variable type

    Variable type may be one of these :Variable type may be one of these :

    ByteByte wordword bitbitdworddword floatfloat

  • 8/12/2019 DC Motor Remote Control

    78/163

    Variable typeVariable type

    BIT: Variable type that may hold a value ofBIT: Variable type that may hold a value of 00 oror 11..

    BYTE: Variable type that may hold a value ofBYTE: Variable type that may hold a value of 00 toto 255255..

    WORD: Variable type that may hold a value ofWORD: Variable type that may hold a value of 00 toto 6553565535..

    DWORD: Varia e type t at may o a va ue oDWORD: Varia e type t at may o a va ue o --21474836482147483648 toto++21474836472147483647..

    FLOAT: Variable type that may theoretically hold a value ofFLOAT: Variable type that may theoretically hold a value of --11ee3737 toto++11ee3838. However, with floating point calculations, smaller values. However, with floating point calculations, smaller values

    . .

  • 8/12/2019 DC Motor Remote Control

    79/163

    BITBIT::0011

    BYTEBYTE::00255255WORDWORD::006553565535

    DWORDDWORD::--21474836482147483648++21474836472147483647FLOATFLOAT::--11ee3737++11ee3838

  • 8/12/2019 DC Motor Remote Control

    80/163

    IF StatementIF Statement

    CodeCode

    End IFEnd IF

    IF ProtB.IF ProtB.77 ==11 thenthen

    PortC.PortC.00 == 11

    PortC.PortC.11 == 00

    IF PortB.IF PortB.77 ==11 then PortC.then PortC.00 ==11

  • 8/12/2019 DC Motor Remote Control

    81/163

    Nested ifNested if

    if x=if x=1010 thenthen

    High ledHigh led11

    ==

    high ledhigh led22

    high ledhigh led33

    ENDIFENDIF

  • 8/12/2019 DC Motor Remote Control

    82/163

    For loopFor loopFor variable name =startcount To endcount STEP stepvalFor variable name =startcount To endcount STEP stepval

    code bodycode bodyNextNext

    Overview :Overview :

    For loop is used to execute a code for predefined amount of timesFor loop is used to execute a code for predefined amount of times

    For I =For I =00 toto 1010 stepstep 11portb =Iportb =I

    For i=For i=100100 toto 00 stepstep --22

    portb=Iportb=INextNext

  • 8/12/2019 DC Motor Remote Control

    83/163

    IR SensorIR Sensor

    IR SensorIR Sensor

  • 8/12/2019 DC Motor Remote Control

    84/163

    PortB.7

    ir_sensorPortB.7ir_word

    Starting 240 us

  • 8/12/2019 DC Motor Remote Control

    85/163

    :main

  • 8/12/2019 DC Motor Remote Control

    86/163

    main sony_in

    gotogoSub

    mainsony_in

    g sony_in

  • 8/12/2019 DC Motor Remote Control

    87/163

    flg200 ms

  • 8/12/2019 DC Motor Remote Control

    88/163

    sony_infl 1=

  • 8/12/2019 DC Motor Remote Control

    89/163

    PortB.7ir_sensor 0 V+5v

    IF ir_sensor=1 Then GoTO no_sig

    +5 VPortB.7 no_sig

    PortB.7

  • 8/12/2019 DC Motor Remote Control

    90/163

    PulsIN[0 1]

    PortB.7 Starting

    st

  • 8/12/2019 DC Motor Remote Control

    91/163

    ((240 us no_sig((270 us no_sig((200 us

  • 8/12/2019 DC Motor Remote Control

    92/163

  • 8/12/2019 DC Motor Remote Control

    93/163

    [[[[11[[[[11StartingStarting[[[[00 1212

    ::

  • 8/12/2019 DC Motor Remote Control

    94/163

    12110

    u s nid

    1((90 us ir_word

    ir_word

  • 8/12/2019 DC Motor Remote Control

    95/163

  • 8/12/2019 DC Motor Remote Control

    96/163

    sony_inreturn main

  • 8/12/2019 DC Motor Remote Control

    97/163

    mainflg=0

  • 8/12/2019 DC Motor Remote Control

    98/163

    ir_wordir_wordprintprint 4128412822208020803316761676441056105655 51525152663104310477 544544994640464000

  • 8/12/2019 DC Motor Remote Control

    99/163

    ir_word

    Hexec

  • 8/12/2019 DC Motor Remote Control

    100/163

    32 = _

  • 8/12/2019 DC Motor Remote Control

    101/163

    8585100100

    11 22 00 120120

  • 8/12/2019 DC Motor Remote Control

    102/163

    ikey

  • 8/12/2019 DC Motor Remote Control

    103/163

    ikey=0

    [k[0ikey

    ikey[k[1 ikey

    [k[0 ikey

    [k[2[k[1

    K[0]=1

    K 1 =2

    K[2]=4

  • 8/12/2019 DC Motor Remote Control

    104/163

    5344

  • 8/12/2019 DC Motor Remote Control

    105/163

    main

    124 rpm

  • 8/12/2019 DC Motor Remote Control

    106/163

    IR SensorIR Sensor PWMPWM

    100100%%100100))100100((

    PWMPWM

  • 8/12/2019 DC Motor Remote Control

    107/163

    PWMPWM TTononPWMPWM dut ratiodut ratio

    onO

    T

    t

    V

    VD ==

    TonTon100100 msmst_on = r mt_on = r m 100100 **100100

    TToffofft_off =t_off =100100 -- (t_on)(t_on)

    onon ==offoff== TToffoff==5050TTonon==50505050

  • 8/12/2019 DC Motor Remote Control

    108/163

    PortC.PortC.11PWMPWM

    Speed_flagSpeed_flag

  • 8/12/2019 DC Motor Remote Control

    109/163

    PWM

    PortC.1

  • 8/12/2019 DC Motor Remote Control

    110/163

    speed_flag t_on

    t_offrat_speed100

    100

    =

  • 8/12/2019 DC Motor Remote Control

    111/163

    = _Speed_flag=0 main

  • 8/12/2019 DC Motor Remote Control

    112/163

    _t_on((+5 v

    _PWMms

  • 8/12/2019 DC Motor Remote Control

    113/163

    comp

    rat_spee speed_flag=0

    100

    main

  • 8/12/2019 DC Motor Remote Control

    114/163

    100 ) Speed is)

    t_offt_onspeed_flag=1

    ( _

  • 8/12/2019 DC Motor Remote Control

    115/163

    speed_flag=speed_flag=00

  • 8/12/2019 DC Motor Remote Control

    116/163

    )(

  • 8/12/2019 DC Motor Remote Control

    117/163

  • 8/12/2019 DC Motor Remote Control

    118/163

    44NN3232

    PWM

    +18 V

  • 8/12/2019 DC Motor Remote Control

    119/163

  • 8/12/2019 DC Motor Remote Control

    120/163

    11PortC.PortC.11

    SwitchSwitch ++1818 vv

    44NN3232 Datas eetDatas eet44NN

  • 8/12/2019 DC Motor Remote Control

    121/163

    Datas eetDatas eet44NN 00 vv++55 vv

    t_offt_offt_ont_on

    PortC 1

  • 8/12/2019 DC Motor Remote Control

    122/163

    PortC.1

    t_ont_off

    speed_flag =0 or . =

  • 8/12/2019 DC Motor Remote Control

    123/163

    _+

    SD

  • 8/12/2019 DC Motor Remote Control

    124/163

    G

    PWM

    220220//2424

    uc onverter rcu t tep own DC-DC onverter

  • 8/12/2019 DC Motor Remote Control

    125/163

    1212 mHmH Electrical SwitchElectrical Switchmosfetmosfet 2424 vv

    duty ratioduty ratio

    SwitchSwitch

  • 8/12/2019 DC Motor Remote Control

    126/163

    2424 vvdut ratiodut ratio

    G D

  • 8/12/2019 DC Motor Remote Control

    127/163

    D S

    G

    220220//2424

  • 8/12/2019 DC Motor Remote Control

    128/163

    D S

    G

    Buck Converter Circuit

    220220//2424

  • 8/12/2019 DC Motor Remote Control

    129/163

    Isolatin Circuit

    Microcontroller Circuit

    ProgrammerProgrammer

  • 8/12/2019 DC Motor Remote Control

    130/163

    ProgrammerProgrammer MicroProMicroPro

    ProgrammerProgrammer

  • 8/12/2019 DC Motor Remote Control

    131/163

    USBRS

    RS to USBRS to USB

  • 8/12/2019 DC Motor Remote Control

    132/163

  • 8/12/2019 DC Motor Remote Control

    133/163

    MicroProMicroPro

  • 8/12/2019 DC Motor Remote Control

    134/163

  • 8/12/2019 DC Motor Remote Control

    135/163

    RS to Usb

  • 8/12/2019 DC Motor Remote Control

    136/163

  • 8/12/2019 DC Motor Remote Control

    137/163

    Load

  • 8/12/2019 DC Motor Remote Control

    138/163

    ((XT

    uses

    Program

  • 8/12/2019 DC Motor Remote Control

    139/163

  • 8/12/2019 DC Motor Remote Control

    140/163

    Device=16F877AXTAL=4

    Declare LCD_DTPIN PORTD.4

    Declare LCD_ENPIN PORTD.3_

    Declare LCD_RSPIN PORTD.2

  • 8/12/2019 DC Motor Remote Control

    141/163

    Input PORTB.7Output PORTC.1

    Symbol ir_sensor =PORTB.7

    Dim ir_wordAs WordDim stAs Word

    Dim k[4]As Bytem g s yte

    Dim ikeyAs Byte

    Dim speed_flagAs ByteDim t_onAs FloatDim t_offAs Float

    m rat_spee s or

    rat_speed = 100speed_flag =0

    k[0]=0k[1]=0

    =k[3]=0

  • 8/12/2019 DC Motor Remote Control

    142/163

    Cursor 1 1

    PORTC.1=1

    main:

    If speed_flag =1 Then

    PORTC.1=0DelayMS t_onPORTC.1=1DelayMS t_off

    . =

    ElsePORTC.1=1

    End If

    If ir_sensor=0 Then speed_flag =0

    GoSub sony_in

    If flg=0 Then GoTo mainDela MS 200

  • 8/12/2019 DC Motor Remote Control

    143/163

    Ifir word = 32 Then_

    speed_flag =0k[ikey]="1"Print "1"Inc ikeEndIf

    If ir_word = 4128 Thens eed fla =0_k[ikey]="2"Print "2"Inc ikeyEndIf

    If ir_word = 2080 Thenspeed_flag =0kike ="3"Print "3"Inc ikeyEndIf

    If ir_word = 6176 Thenspeed_flag =0k[ikey]="4"

    Print "4"Inc ikeyEndIf

    If ir_word = 1056 Then

  • 8/12/2019 DC Motor Remote Control

    144/163

    speed_flag =0k[ikey]="5"Print "5"Inc ikeyEndIf

    If ir_word = 5152 Thenspeed_flag =0

    k[ikey]="6"Print "6"Inc ikeyEndIf

    If ir_word = 3104 Then

    speed_flag =0k[ikey]="7"Print "7"Inc i eyEndIf

    If ir_word = 7200 Thenspeed_flag =0k[ikey]="8"Print "8"Inc ikey

    EndIf

    If ir_word = 544 Thenspeed_flag =0k[ikey]="9"P i t "9"

  • 8/12/2019 DC Motor Remote Control

    145/163

    Print "9"Inc ikey

    EndIf

    If ir_word = 4640 Thenspeed_flag =0k[ikey]="0"

    Print "0"Inc ikeyEndIf

    I ir_wor =5344 T en GoTo comp

    GoTo main

    comp:

    rpm=Val (k,Dec)

    If rpm > rat_speed Thenspeed_flag=0

    Print At 1,1,"max speed 100 "

    DelayMS 1000

    Print At 1,1," "

    ikey=0

  • 8/12/2019 DC Motor Remote Control

    146/163

    ikey 0 ,

    k[0]=""k[1]=""k[2]=""k[3]=""

    GoTo main

    EndIf

    Print At 2,1,"Speed is : ",Dec rpm ," "

    t_on = (rpm/100)*100t_off=100-(t_on)

    _

    Print At 1,1," "

    ikey=0Cursor 1,1k[0]=""

  • 8/12/2019 DC Motor Remote Control

    147/163

    =k[2]=""=""

    ir_word=0

    sony_in:fl =1If ir_sensor=1 Then GoTo no_sigst= PulsIn ir_sensor,0

    If st < 200 Then GoTo no_sigs en o o no_s g

    For i=0 To 11id= PulsIn ir_sensor ,0

    If ID> 90 Then

  • 8/12/2019 DC Motor Remote Control

    148/163

    If ID>=90 Then

    ir_word.0=1

    Else_ . =

    EndIf

    ir_word=ir_word

  • 8/12/2019 DC Motor Remote Control

    149/163

    PIC16F877A

    Crystal 4MHz

    LCD 2x16 with back light

  • 8/12/2019 DC Motor Remote Control

    150/163

    , ,

    Inductor 12 mH

    Heat SinksSwitch

    4N32 O tocou ler

    Capacitor 470 uF 45 V (need 6 pieces)

  • 8/12/2019 DC Motor Remote Control

    151/163

    H Bridge (need 3 pieces)

    Re ulators: 7805 7818

    mos e w c

    Diode

  • 8/12/2019 DC Motor Remote Control

    152/163

  • 8/12/2019 DC Motor Remote Control

    153/163

    Programmer For PIC16F877A (USB)

    RS232 TO USB Converter

    Ada ter 12v For ro rammer

    programmerprogrammer

  • 8/12/2019 DC Motor Remote Control

    154/163

    2323 ::2391896123918961

    . . .. . .

    (( ))

  • 8/12/2019 DC Motor Remote Control

    155/163

  • 8/12/2019 DC Motor Remote Control

    156/163

  • 8/12/2019 DC Motor Remote Control

    157/163

  • 8/12/2019 DC Motor Remote Control

    158/163

  • 8/12/2019 DC Motor Remote Control

    159/163

  • 8/12/2019 DC Motor Remote Control

    160/163

  • 8/12/2019 DC Motor Remote Control

    161/163

  • 8/12/2019 DC Motor Remote Control

    162/163

  • 8/12/2019 DC Motor Remote Control

    163/163

    ..

    ::