Top Banner

of 23

Interfacing 8051

Jun 04, 2018

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • 8/13/2019 Interfacing 8051

    1/23

    INTERFACING 8051

    UNIT-8 INTERFACING 8051

    STEPPER MOTOR INTERFACING:

    Interfacing the Stepper motor to the 8051 is done to controlof angle and direction

    of rotation

    A stepper motor is a !idel" #sed de$ice that translates electrical p#lses intomechanical mo$ement

    Applications

    As disc dri$es In dot matri% printers

    In ro&otics for position control

    Tp!s o" st!pp!r #otor

    'ermanent magnet

    (aria&le Rel#ctance

    'ermanent magnet Stepper motor consists of t!o parts

    1 Rotor )shaft*+a permanent magnet

    , Stator -s#rro#nds the rotor as sho!n in fig )a*

    Fig )a*

    (eenaS. /IT /"sore 1

  • 8/13/2019 Interfacing 8051

    2/23

    INTERFACING 8051

    The most common steppers ha$e fo#r stator !indings that are paired !ith a

    center+tapped common as sho!n in fig)&* This t"pe of stepper motor is

    commonl" reffered to as a fo#r+phase or #nipolar stepper motor The center+tapallo!s a change of c#rrent direction in each of t!o coils !hen a !inding is

    gro#nded res#lting in a polarit" change of the stator

    Fig )&*

    The stepper motor shaft mo$es in a fi%ed repeata&le increment !hich allo!s one

    to mo$e it to a precise position

    The stator poles are determined &" the c#rrent sent thro#gh the !ire coils

    As the direction of the c#rrent is changed the polarit" is also changed ca#sing the

    re$erse motion of the rotor

    The stepper motor disc#ssed here has a total of leads2 3 leads representing the

    fo#r stator !indings and , commons for the center+tapped leads

    As the se4#ence of po!er is applied to each stator !indingthe rotor !ill rotate

    There are se$eral !idel" #sed se4#ences !here each has a different degree of

    precision

    (eenaS. /IT /"sore ,

  • 8/13/2019 Interfacing 8051

    3/23

    INTERFACING 8051

    Ta&le &elo! sho!s a ,+phase ) , !indings are energied at a time*3+step stepping

    se4#ence

    6e can start !ith an" of the se4#ences in the a&o$e ta&le once !e start !e m#st contin#e

    in the proper order

    For e%ample if !e start !ith st!p$%0110& !e m#st contin#e in the se4#ence of steps31,731,etc

    Step angle is the minim#m degree of rotation associated !ith a single step

    Step per re$ol#tion is the total n#m&er of steps needed to rotate one complete

    rotation or 70 degrees) eg 180steps, degrees970*

    (ario#s motors ha$e different step angles

    Ta&le &elo! sho!s some step angles for $ario#s motors

    Step angle Step per re$ol#tion:, 500

    18 ,00

    ,0 180

    ,5 133

    50 :,

    :5 38

    15 ,3

    St!ps p!r s!con' an' rp# r!lation

    0

    re$ol#tion;stepsrpmondsec;steps

    =

    (eenaS. /IT /"sore 7

  • 8/13/2019 Interfacing 8051

    4/23

    INTERFACING 8051

    T(! "o)r st!p s!*)!nc! an' n)#+!r o" t!!t( on rotor:

    After completing e$er" "o)r st!ps the rotor mo$es onl" on! toot( pitc(

    In a stepper motor !ith ,00 steps per re$ol#tion the rotor has 50 teeth since

    3509,00 steps are needed to complete one re$ol#tion

    The smaller the step angle the more teeth the rotor passes

    E,a#pl!:

    Gi$e the n#m&er of times the 3+step se4#ence m#st &e applied to a stepper motor to ma

  • 8/13/2019 Interfacing 8051

    5/23

    INTERFACING 8051

    Unipolar !rs)s +ipolar st!pp!r #otor int!r"ac!:

    There are three common t"pes of stepper motor interfacing2 #ni$ersal #nipolar

    and &ipolar The" can &e identified &" the n#m&er of connections to the motor

    A #ni$ersal stepper motor has 8 connections #nipolar stepper motor has connections And &ipolar stepper motor has 3 connectionsas sho!n in fig &elo!

    The #ni$ersal stepper motor can &e config#red for all three modes !hile the

    #nipolar can &e either #nipolar or &ipolar and the &ipolar cannot &e config#red for#ni$ersal nor #nipolar mode

    Int!r "acin2 )nipolar st!pp!r #otor to 8051:

    Controllin2 st!pp!r #otor ia optoisolator

    (eenaS. /IT /"sore 5

  • 8/13/2019 Interfacing 8051

    6/23

    INTERFACING 8051

    A&o$e fig#re sho!s an interface to a #ni$ersal stepper motor #sing optoisolator!hich are !idel" #sed to isolate the stepper motor=s &ac< E/F $oltage ie to

    protect from damaging the digital;microcontroller s"stem

    The fo#r leads of the stator !inding are controlled &" fo#r &its of the 8051

    port)p10+p17*

    Since the 8051 lac?N,007 to energise the stator

    Instead of >?N,007 !e can also #se transistor as dri$ersas sho!n in fig#re

    &elo!

    (eenaS. /IT /"sore

  • 8/13/2019 Interfacing 8051

    7/23

    INTERFACING 8051

    If the transistors are #sed as dri$ers !e m#st also #se diodes to ta?N,007 has aninternal diode to ta

  • 8/13/2019 Interfacing 8051

    8/23

    INTERFACING 8051

    Fig)a*

    Fig#re &elo! sho!s the s!itch config#ration for t#rning the motor in onedirection

    6hen s!itches 1 and 3 are closed the c#rrent is allo!ed to pass thro#gh the

    motor cloc

    6hen s!itches , and 7 are closed the c#rrent is allo!ed to pass thro#gh the

    motor co#ntercloc

    Fig#re &elo! sho!s the in$alid config#ration C#rrent flo!s directl" to gro#nd

    creating a short circ#it

    (eenaS. /IT /"sore 8

  • 8/13/2019 Interfacing 8051

    9/23

    INTERFACING 8051

    The same effect )in$alid state*occ#rs !hen s!itches 1 and 7 are closed ors!itches ,and 3 closed

    P)ls! 7i't( #o')lation%P4M&

    The speed of the motor depends on three factors2

    1* load ,* $oltage and 7*c#rrent

    For a gi$en fi%ed load !e can maintain a stead" speed &" #sing a method called

    p#lse !idth mod#lation)'6/*

    " changing )mod#lating* the !idth of the p#lse applied to the @C motor !e can

    increase or decrease the amo#nt of po!er pro$ided to the motor ther&" increasing

    or decreasing the motor speedie !ider the p#lse higher the speed

    Fig#re &elo! sho!s the '6/ comparisions

    3C #otor control 7it( optoisolator:

    Fig#res &elo! sho!s the connections to a simple @Cmotor #sing a &ipolar and a

    /SFET transistor

    The 8051 is protected from E/I created &" motor &r#shes &" #sing an optoisolator and a

    separate po!er s#ppl"

    (eenaS. /IT /"sore D

  • 8/13/2019 Interfacing 8051

    10/23

    INTERFACING 8051

    Separate po!er s#pplies to the motor and logic !ill red#ce the posi&ilit" of damage to the

    control circ#itr" And also allo!s the #se of high+$oltage motors

    The deco#pling capacitor across the motor helps to red#ce the E/I created &" the motor

    The ener diode is #sed to red#ce gate $oltage &elo! the rated ma%im#m$al#e

    1*!rite a program to monitor the stat#s of the s!itch and perform the follo!ing )a* if S691 the @C motor mo$es co#ntercloc

    )&* if S690 the @C motor mo$es cloc

    Sol#tion2

    rg 0000h/AIN2 C?R '10

    C?R '11 C?R '1,

    SET',:

    /NITIR2 SET '10

    N ',: C?C.6ISE

    C?R '11

    SET '1,

    S/' /NITR

    C?C.6ISE2 SET '11 C?R '1,

    S/' /NITR

    EN@

    (eenaS. /IT /"sore 10

  • 8/13/2019 Interfacing 8051

    11/23

    INTERFACING 8051

    ,*!rite a program to monitor the stat#s of the s!itch and perform the follo!ing

    )a* if p,:91 the @C motor mo$es !ith ,5 d#t" c"cle p#lse )&* if p,:90 the @C motor mo$es !ith 50 d#t" c"cle p#lse

    Sol#tion2 rg 0000h/ain2

    C?R '10

    SET ',:

    /NITR2

    N ',: FIFT'ERCENT Hif p,:91 follo! the ne%t instr#ction if p,:90 go to la&el fift"percent

    SET '10

    /( R5,5

    ACA?? @E?A C?R '10

    /( R5:5 ACA?? @E?A

    S/' /NITR

    FIFT'ERCENT2

    SET '10

    /( R550

    ACA?? @E?A C?R '10

    /( R550

    ACA?? @E?A

    S/' /NITR

    @E?A2

    /( R, FF

    ?12 /( R7 FF ?,2 @NJ R7 ?,

    @NJ R, ?1

    RET EN@

    3AC INTERFACE

    @igital to analog con$erters)@AC* is a de$ice !idel" #sed to con$ert digital p#lses toanalog signals

    The first criterion for K#dging a @ACis its resol#tion !hich is a f#nction of then#m&er of &inar" inp#ts

    R!sol)tion2 This is the n#m&er of possi&le o#tp#t le$els the @AC is designed to

    reprod#ce This is #s#all" stated as the n#m&er of&itsit #ses !hich is the &aset!o logarithmof the n#m&er of le$els For instance a 1 &it @AC is designed to

    reprod#ce , ),1* le$els !hile an 8 &it @AC is designed for ,5 ), 8* le$els

    (eenaS. /IT /"sore 11

    http://en.wikipedia.org/wiki/Bithttp://en.wikipedia.org/wiki/Logarithmhttp://en.wikipedia.org/wiki/Bithttp://en.wikipedia.org/wiki/Logarithm
  • 8/13/2019 Interfacing 8051

    12/23

    INTERFACING 8051

    An 8+&it @AC s#ch as @AC 0808 pro$ides ,5 discrete $oltages )or c#rrent*

    le$els of o#tp#t similarl" 1,+&it @AC pro$ides 30D discrete $oltage le$els

    The digital inp#t are con$erted to c)rr!ntIo#t L &" connecting a r!sistor to the

    Io#t pin !e con$ert the res#lt to olta2!

    i! Io)tR9o)t

    The total c#rrent pro$ided &" the Io#t pin is a f#nction of the &inar" n#m&er atthe @o+@:

    *)IrefIo#t,5

    1@

    1,8

    1@

    3

    ,@

    7,

    7@

    1

    3@

    8

    5@

    3

    @

    ,

    :@+++++++=

    The Iref c#rrent is generall" set to ,mA

    calc#late (o#t for the follo!ing &inar" inp#t

    1*10011001&,* 11001000& ass#me resistance95.ohms

    Sol#tion2

    1*

    1D1m,*)m,Io#t,5

    157

    ,5

    1

    1,8

    0

    3

    0

    7,

    1

    1

    1

    8

    0

    3

    0

    ,

    1==+++++++=

    $D:55

  • 8/13/2019 Interfacing 8051

    13/23

    INTERFACING 8051

    Inp#t $al#es for @AC for $ario#s angles is calc#lated and sho!n as in ta&le &elo! for

    step angle 70 degree

    Angle sin 9o)t5%5sin &

    3AC inp)t al)!s

    %1;81;8 sin &

    '!ci#al

    Inp#t $al#es in(!,

    0 0 5 1,8 80

    70 5 :5 1D, C0

    0 8 D77 ,78 EE

    D0 10 10 ,55 FF

    1,0 8 D77 ,78 EE

    150 5 :5 1D, C0

    180 0 5 1,8 80

    ,10 +5 ,5 3 30

    ,30 +8 : 1: 11

    ,:0 +10 0 0 0

    700 +8 : 1: 11

    770 +5 ,5 3 3070 0 5 1,8 80

    C 'rogram to generate a sine !a$e of step angle70 degree

    incl#dereg51hO

    Sfr dacdata9'1H(oid main) *

    P

    >nsigned char !a$e$al#eQ1,9P1,81D,,78,55,781D,1,831:01:3H

    >nsigned char %H

    6hile)1*P

    For )%90H %1,H %MM*

    @acdata 9 !a$e$al#eQ%H

    C 'rogram to generate a triangle !a$e

    (eenaS. /IT /"sore 17

    3AC inp)t al)!s 1;81;8 sin

  • 8/13/2019 Interfacing 8051

    14/23

    INTERFACING 8051

    incl#dereg51hO

    (oid main) *

    >nsigned char co#ntH

    P

    6hile)1*

    P For )co#nt90H co#nt90%ffH co#ntMM*

    '09co#ntH

    P

    For)co#nt90%ffH co#ntO0Hco#nt++* '09co#ntH

    C 'rogram to generate s4#are !a$e incl#dereg51hO

    (oid main) *>nsigned char co#ntH

    P

    6hile)1*

    P

    '090%00H For)%90H %1,50H %MM*

    P

    '090%ffH

    For)%90H %1,50H %MM*

    8051 conn!ction to 3AC8082

    (eenaS. /IT /"sore 13

  • 8/13/2019 Interfacing 8051

    15/23

    INTERFACING 8051

    Fig#re sho!s the generation of c#rrent reference setting Iref9,mA L&" #sing the

    standard 5$ po!er s#ppl" L 1< or 15< ohm resistors

    Con$ert this c#rrent to $oltage and monitor the o#tp#t on scope

    Ideall" !e connect the o#tp#t pin Io#t to a resistor

    #t this resistor affect the o#tp#t $oltage For this reason Iref c#rrent o#tp#t is isolat!'&" connecting it to an op+amp s#ch

    as :31 !ith Rf95

  • 8/13/2019 Interfacing 8051

    16/23

    INTERFACING 8051

    >E?6OAR3 INTERFACING:

    .e"&oard L?C@s are the most !idel" #sed inp#t;o#tp#t de$ices of the 8051

    .e"&oards are organied in a matri% of ro!s and col#mns

    The 8051 C'> accesses &oth ro!s and col#mns thro#gh , 8+&it ports an 88

    matri% of

  • 8/13/2019 Interfacing 8051

    17/23

    INTERFACING 8051

    6hen a

  • 8/13/2019 Interfacing 8051

    18/23

    INTERFACING 8051

    EUA/'?E2

    From Fig identif" the ro! and col#mn of the pressed

  • 8/13/2019 Interfacing 8051

    19/23

    INTERFACING 8051

    Fig &2Flo!chart for detection and identification of

  • 8/13/2019 Interfacing 8051

    20/23

    INTERFACING 8051

    .C3 INTERFACING:

    In recent "ears the ?C@ is finding !idespread #se replacing ?E@s )se$en segment* d#eto the follo!ing reasons2

    1 The declining prices of ?C@s

    , The a&ilit" to displa" n#m&ers characters and graphics7 Ease of programming for characters and graphics

    The ?C@ descri&ed in this chapter has 13 pins The f#nction of each pin is gi$en in ta&le&elo!

    (eenaS. /IT /"sore ,0

  • 8/13/2019 Interfacing 8051

    21/23

    INTERFACING 8051

    9CCB 9SS 9EE: %pin 1B;$&

    (CC (SS pro$ide M5( and gro#nd respecti$el"

    (EE is #sed for controlling lcd contrast

    RS- R!2ist!r s!l!ct %pin D&:

    If RS0Bthe instr#ction command code register is selected !hich

    Allo!s the #ser to send a command s#ch as clear displa" c#rser at home etc

    ta&le 1 &elo! lists the instr#ction command codes

    If RS1B the data register is selected !hich Allo!s the #ser to send data to &e

    displa"ed on the ?C@

    To displa" letters and n#m&ers !e send ASCII codes for the letters A+J a+

    and n#m&ers 0+D to 8+&it data pins )@0+@:* !hile ma

  • 8/13/2019 Interfacing 8051

    22/23

    INTERFACING 8051

    fig d sho!s ?C@ timing to !rite)B+? for E pin*

    Ta+l! 1 : .C3 co##an' co'!s2

    (eenaS. /IT /"sore ,,

  • 8/13/2019 Interfacing 8051

    23/23

    INTERFACING 8051