Embedded System Manual

Embed Size (px)

Citation preview

  • 7/24/2019 Embedded System Manual

    1/74

    List of Experiments

    EXPERIMENT #1

    Introduction to C programming in 8051...................................................2

    EXPERIMENT #2

    Introduction to Keil & Proteus software...................................................5

    EXPERIMENT #3

    Test Benc for 8!"51 or 8!C51 microcontroller...............................1!

    EXPERIMENT #4

    "ow up and down counter on #$% s using 8!"51microcontroller....................................................................................................28

    EXPERIMENT #5

    Identification of alid and In'alid BC% codes...................................(2

    EXPERIMENT #6

    )larm s*stem using 8!"51 wit te elp of a single +it +ased

    alarm s*stem.EXPERIMENT #7

    Interfacing of #%, and Termistor wit 8!"51.................................(!

    EXPERIMENT #8

    -our a* Traffic #igt "*stem using 8!"51......................................./

    EXPERIMENT #9

    Interfacing of 8!"51 wit %C otor.......................................................50

    EXPERIMENT #1

    Interfacing of 8!"51 wit "tepper otor..............................................55

    EXPERIMENT #11

    Interfacing te 8!"51 microcontroller wit )%C080/ cip.........1

    ........................................................................................................ (

  • 7/24/2019 Embedded System Manual

    2/74

    1

  • 7/24/2019 Embedded System Manual

    3/74

    $3P$,I$4T 4 1

    Intro!"tion to $ pro%r&mmin% in 851

    '()eti*e+

    To get familiar wit te +asic C programming in 8051 famil* microcontroller

    T,eoreti&- .&/%ro"n!+

    Bot C language and assem+l* language is used for programming in 8051 +ut ere wewill tal6 a+out C onl*. e +riefl* discuss ere a+out ma7or reasons for using C datat*pes of C 8051 e9tension t*pes time dela* I: programming in C and #ogicoperations in 8051 C.

    0&t& Tpes+

    -ollowing data t*pes are used in C language. Teir ranges are also gi'en in tis ta+le1;1.

    T&(-e 11

    851 extension tpes+

    (it+

    Te s+it 6e*word is a widel* used 8051 C data t*pe designed specificall* to accesssingle +it addressa+le registers. It allows access to te single +it of te "-, register.

    2

  • 7/24/2019 Embedded System Manual

    4/74

    .it &n! R+

    Te +it data t*pe allows access to single +its of a +it addressa+le memor* spaces 20;2-

  • 7/24/2019 Embedded System Manual

    5/74

    %ata FF num+er of +its to +e sifted left

    :!*&nt&%es of $ -&n%"&%e o*er &ssem(- -&n%"&%e+

    nli6e assem+l* C as ad'antage of processor;independence and is not

    specific to an* particular microprocessor: microcontroller or an* s*stem. Tis

    ma6es it con'enient for a user to de'elop programs tat can run on most of te

    s*stems.

    )s C com+ines functionalit* of assem+l* language and features of ig le'el

    languages C is treated as a middle;le'el computer language or ig le'el

    assem+l* language

    It is fairl* efficient

    It supports access to I: and pro'ides ease of management of large em+eddedpro7ects.

    Re*ie ;"estions+

    1

  • 7/24/2019 Embedded System Manual

    6/74

    $3P$,I$4T 4 2

    Intro!"tion to >ei- ? Prote"s soft&re

    '()eti*e+

    Introduction to Keil software.

  • 7/24/2019 Embedded System Manual

    7/74

    (. "elect 4ew Nision Pro7ect from te Pro7ect enu.

    /. 4ame te pro7ect Toggle .5. Clic6 on te "a'e Button.

  • 7/24/2019 Embedded System Manual

    8/74

    . Te de'ice window will +e displa*ed.

    . "elect te part *ou will +e using to test wit. -or now we will use te )tmel"emiconductor part 8!"51 or 8!C51.

    8. %ou+le Clic6 on te )tmel "emiconductor.

    !. "croll down and select te )T8!"51Part.

    10. Clic6 K.

  • 7/24/2019 Embedded System Manual

    9/74

    $re&tin% o"re i-e+

    1. Clic6 -ile enu and select 4ew.

    2. ) new window will open up in te Keil I%$.

    8

  • 7/24/2019 Embedded System Manual

    10/74

    (. Cop* te e9ample to te ,igt into te new window. Tis file will toggle Ports 1and 2 continuousl* wit a dela*.

    Oinclude Freg51.H

    'oid "%ela*unsigned int'oid main 'oidQ

    wile1 ::anoter wa* to do it fore'er

    Q

    P1R0955

    P2R0955

    "%ela*250

    P1R09))

    P2R09))

    "%ela*250

    S

    S

    'oid "%ela*unsigned int itimeQ

    unsigned int i 7foriR0iFitimeifor7R07F1257

    S

    /. Clic6 on -ile menu and select "a'e )sU

    !

  • 7/24/2019 Embedded System Manual

    11/74

    5. 4ame te file Toggle.c

    . Clic6 te "a'e Button

    . Cange file t*pe to )sm "ource -ile V.c.

    8. "elect toggle.c

    !. Clic6 )dd +utton

    10. Clic6 Close +utton.

    10

  • 7/24/2019 Embedded System Manual

    12/74

    11.$9pand te "ource roup 1 in te Tree menu to ensure tat te file was added tote pro7ect.

    $re&tin% @EX for t,e P&rt+

    1. Clic6 on Target 1 in Tree menu

    2. Clic6 on Pro7ect enu and select ptions for Target 1

    11

  • 7/24/2019 Embedded System Manual

    13/74

    (. "elect Target Ta+

    /. Cange 3tal

  • 7/24/2019 Embedded System Manual

    14/74

    . Clic6 K Button.

    8. Clic6 on Pro7ect enu and select ,e+uild all Target -iles.

    !. In te Build indow it sould report 0 $rrors s 0 arnings .

    10. Wou are now read* to Program *our Part.

    1(

  • 7/24/2019 Embedded System Manual

    15/74

    Testin% Pro%r&m in 0e("%%er+

    1. Clic6 on %e+ug enu and "elect "tart:"top %e+ug "ession.

    2. If *ou use a free 'ersion of Keil te dialog appears. Clic6 K

    (. Te Keil %e+ugger sould +e now ,unning.

    /. Clic6 on Periperals. "elect I: Ports "elect Port 1. ,epeat for Port 2.

    1/

  • 7/24/2019 Embedded System Manual

    16/74

    ) new window sould will pop up. Tis represents te Ports and Pins.

    5. 4ow press -5 to run te de+ugging.

    15

  • 7/24/2019 Embedded System Manual

    17/74

    . To e9it out Clic6 on %e+ug enu and "elect "tart:"top %e+ug "ession or

    press icon.

    Prote"s oft&re+

    Proteus PCB design com+ines te I"I" scematic capture and ),$" PCB la*outprograms to pro'ide a powerful integrated and eas* to use suite of tools forprofessional PCB %esign. )ll Proteus PCB design products include an integrated

    sape +ased autorouter and a +asic "PIC$ simulation capa+ilit* as standard. oread'anced routing modes are included in Proteus PCB %esign #e'el 2 and igerwilst simulation capa+ilities can +e enanced +* purcasing te )d'anced"imulation option and:or micro;controller simulation capa+ilities.

    Proteus is a single integrated application wit I"I" ),$" and (% iewer modulesappearing as ta++ed modules. Te program ena+les canges on te scematic to +ereflected across PCB B and %esign $9plorer in real time. Proteus stores tedesign %"4 la*out #WT and common data+ase in a single pro7ect file P%"P,X.

    Proteus is perfect tool for engineers to test teir microcontroller designs +eforeconstructing a p*sical protot*pe in real time. Tis program allows users to interactwit te design using on;screen indicators and:or #$% and #C% displa*s and ifattaced to te PC switces and +uttons.

    Lo&!in% & Miroontro--er it, & ,ex fi-e in prote"s+

    "tep1= Place *our components from te li+rar* and ma6e scematic.

    1

  • 7/24/2019 Embedded System Manual

    18/74

    "tep2= Place cursor on microcontroller 8!"51 and dou+le clic6 it. ) window will

    open on program file option clic6 on folder icon and add director* of *our e9 file

    KeilYC51Y$9amplesY

  • 7/24/2019 Embedded System Manual

    19/74

    Re*ie A"estions+

    1 ei- ompi-er=

    2 ei-=

    3 @o e -in/ @ex fi-e on Prote"s s,em&ti=

    4 ei- ompi-er=

    5 ei- ompi-er is "se! for re&tin% @ex fi-es for miroontro--ers=

    18

  • 7/24/2019 Embedded System Manual

    20/74

    $3P$,I$4T 4 (

    Test .en, for 8951 or 89$51 miroontro--er

    '()eti*e+

    %escription of test +enc

    $omponents+

    8!"51 or 8!C51 microcontroller

    8 #$% s

    BuLLer

    ,ela*

    ,esistors ((0Z 116Z 1106Z8 & 8.26Z1

    Capacitors 10u-1 & (0p-2

    12

  • 7/24/2019 Embedded System Manual

    21/74

    te registers to +e lost. It will set program counter to all 0 s. In order for te ,$"$Tinput to +e effecti'e it must a'e a minimum duration of 2 macine c*cles. In oterwords te ig pulse must +e ig for a minimum of 2 macine c*cles +efore it isallowed to go low. -igure 2 a and + sow two wa*s of connecting te ,"T pin to

    power;on reset circuitr*. -igure 2 + uses a momentar* switc for reset circuitr*.U1

    3921

    P0.0/AD0 P2.0/A838 22P0.1/AD1 P2.1/A937 23P0.2/AD2 P2.2/A1036 24P0.3/AD3 P2.3/A1135 25P0.4/AD4 P2.4/A1234 26P0.5/AD5 P2.5/A1333 27P0.6/AD6 P2.6/A1432 28P0.7/AD7 P2.7/A15

    1 10P1.0/T2 P3.0/RXD2 11P1.1/T2EX P3.1/TXD3 12P1.2/ECI P3.2/ INT04 13P1.3/CEX0 P3.3/INT15 14P1.4/CEX1 P3.4/T06 15P1.5/CEX2 P3.5/T17 16P1.6/CEX3 P3.6/WR8 17P1.7/CEX4 P3.7/RD

    19 30X1 ALE

    18

    29

    X2 PSEN10uF 31

    EA

    5V 30pF 12M! 9 RST GND

    40

    VCC

    8.2" 30pF 20

    80C51

    0

    0

    &

    30pF

    0 12M!

    30pF

    10uF

    5V

    8.2"

    0

    SW PUS$UTT%N0

  • 7/24/2019 Embedded System Manual

    22/74

    U1

    3921

    P0.0/AD0 P2.0/A838 22P0.1/AD1 P2.1/A937 23P0.2/AD2 P2.2/A1036 24P0.3/AD3 P2.3/A1135 25P0.4/AD4 P2.4/A1234 26P0.5/AD5 P2.5/A1333 27P0.6/AD6 P2.6/A1432 28P0.7/AD7 P2.7/A15

    1 10

    P1 .0 /T2 P3.0 /RXD2 11P1.1/T2EX P3.1/TXD3 12P1.2/ECI P3.2/INT04 13P1.3/CEX0 P3.3/INT15 14P1.4/CEX1 P3.4/T06 15P1.5/CEX2 P3.5/T17 16P1.6/CEX3 P3.6/WR8 17P1.7/CEX4 P3.7/RD

    19 30X1 ALE

    18 29X2 PSEN

    31EA9RST

    40GND

    VCC

    80C51 20

    (

    i%"re 2+ Poer'n REET $ir"it

    E:+

    ;$) ?e9ternal access is an input pin and must +e connected to cc or 4%. Te

    8051 famil* mem+ers all come wit on;cip , to store programs. "o ;$) pin isconnected to cc. Te 80(1 and 80(2 famil* mem+ers do not a'e on;cip , so

    20

  • 7/24/2019 Embedded System Manual

    23/74

    code is stored on an e9ternal , and is fetced +* 80(1:(2. "o ;$) pin must +econnected to 4% to indicate tat te code is stored e9ternall*.

    PEN+

    ;P"$4 ?program store ena+le is an output pin. Tis pin is connected to te $ pin

    of te, in 80(1 +ased s*stems.

    :LE+

    )#$ ?address latc ena+le@ is an output pin and is acti'e ig in 80(1 +aseds*stems.

    Ports 1 2 &n! 3+

    Te four 8;+it I: ports P0 P1 P2 and P( eac uses 8 pins. )ll te ports upon ,$"$Tare configured as output read* to +e used as input ports.

    P+

    Port 0 is also designated as )%0;)% allowing it to +e used for +ot address anddata. en connecting an8051:(1 to an e9ternal memor*

    5V

    port 0 pro'ides +ot address and 330 330 330 330 330 330 330 330 U1data. Te 8051 multiple9es

    39 21

    address and data troug port 0 0 P0.0/AD0 P2.0/A838 22P0.1/AD1 P2.1/A937 23to sa'e pins. )#$ indicates if P0

    P0.2/AD2 P2.2/A1036 24

    P0.3/AD3 P2.3/A1135 25P0.4/AD4 P2.4/A12

    as address or data. 34 26P0.5/AD5 P2.5/A1333 27P0.6/AD6 P2.6/A1432

    28

    en )#$R0 it pro'idesP0.7/AD7 P2.7/A15

    1 10P1.0/T2 P3.0/RXD2 11

    data %0;%. P1.1/T2EX P3.1/TXD

    3 12P1.2/ECI P3.2/INT04 13P1.3/CEX0 P3.3/INT1

    en )#$R1 it as 5 14P1.4/CEX1 P3.4/T06 15P1.5/CEX2 P3.5/T1

    address )0;).7 16

    P1.6/CEX3 P3.6/WR8 17P1.7/CEX4 P3.7/RD

    19 30

    It can +e used for input or output X1 ALE

    18 29X2 PSENi%"re 3 31

    eac pin must +e connected EA9RST

    GNDe9ternall* to a 10K om pull;up 40 VCC

    resistor. Tis is due to te fact 80C5120

    tat P0 is an open drain unli6eP1 P2 and P(. Tis is sown in figure (.

    P1 &n! P2+

    Bot P1 and P2 are used as simple I: pins.

    P3+

    Port ( can +e used as input or output. Port ( as te additional function of pro'idingsome e9tremel* important signals. Te* are listed in figure /.

    21

  • 7/24/2019 Embedded System Manual

    24/74

    i%"re 4

    8 LE0s p&ne-+

    -or 'isual representation of data from microcontroller we use 8 #$%s panel on tetest +enc. Tese are connected from te microcontroller in ?sin6 in@ configuration.Te anodes of #$%s are pro'ided 5 %C suppl* troug ((0Z resistors and tecatodes are connected to te microcontroller ports troug female eader.

    V5

    0

    10uF

    5V

    8.2"

    0

    0

    5V

    0

    10" 10" 10" 10" 10" 10" 10" 10"

    U1

    39P0.0/AD0 P2.0/A8

    2138 22

    P0.1/AD1 P2.1/A937 23P0.2/AD2 P2.2/A1036 24P0.3/AD3 P2.3/A11

    35 25P0.4/AD4 P2.4/A12

    34 26P0.5/AD5 P2.5/A13

    33 27P0.6/AD6 P2.6/A14

    32 28P0.7/AD7 P2.7/A15

    330 1P1.0/T2 P3.0/RXD

    10330 2 11

    P1.1/T2EX P3.1/TXD330 3 12P1.2/ECI P3.2/INT0330 4 13P1.3/CEX0 P3.3/ INT1330 5 14P1.4/CEX1 P3.4/T0

    330 6 15P1.5/CEX2 P3.5/T1

    330 7 16P1.6/CEX3 P3.6/WR

    330 8 17P1.7/CEX4 P3.7/RD

    19X1 ALE

    3018 29

    X2 PSEN

    31EA

    30pF 9RST

    12M!

    GND40

    VCC

    30pF

    2080C51

    5V

    0

    i%"re 5

    22

  • 7/24/2019 Embedded System Manual

    25/74

    :IB e*en e%ment 0isp-&+

    ;"egment %ispla* consists of se'en indi'idual coloured #$% s

    called te segments witin one single displa* pac6age. Inorder to produce te re[uired num+ers or

  • 7/24/2019 Embedded System Manual

    26/74

    inducing rapid mo'ements in te diapragm of te +uLLer. In electronic +uLLers tese'i+rations are made +* an oscillator circuit wic dri'es a pieLo to produce te sound.BuLLers ma* +e )C operated or %C operated. In our test +enc we are using %C

    +uLLer. It as a +uilt;in dri'er circuit and re[uires onl* a %C 'oltage to dri'e it.or6ing wit a 2/ %C suppl* 'oltage tis tin* unit can suppl* sound le'els of o'er

    !5 dB at a (0 cm distance. Te unit will operate well wit 5 TT# 'oltages drawingonl* around 2 m). It will terefore ma6e an e9cellent +ell or warning alarm fordigital s*stems.

    5V

    0

    10" 10" 10" 10" 10" 10" 10" 10"U1

    5V

    0

    $U&&ER

    10uF 30pF

    5V

    8.2" 30pF

    0

    0

  • 7/24/2019 Embedded System Manual

    27/74

    3921

    P0.0/AD0

    P2.0/A838 22

    P0.1/AD1 P2.1/A937 23P0.2/AD2 P2.2/A1036 24P0.3/AD3 P2.3/A1135 25P0.4/AD4 P2.4/A1234 26P0.5/AD5 P2.5/A1333 27P0.6/AD6 P2.6/A14

    32 28P0.7/AD7 P2.7/A151

    10P1.0/T2

    P3.0/RXD2

    11

    P1.1/T2EX P3.1/TXD3 12

    P1.2/ECI P3.2/INT04 13

    P1.3/CEX0 P3.3/INT15 14

    P1.4/CEX1 P3.4/T06 15

    7 16P1.6/CEX3 P3.6/WR

    3308 P1.7/CEX4 P3.7/RD 17

    19 X1 ALE 30

    18

    29

    X2 PSEN31

    9 EA

    12M! RST

    GN

    D

    40 VCC

    80C51 20

    5V

    0

    i%"re 7

    ICB Re-&+

    ) rela* is an electricall* operated switc tat uses anelectromagnet to mo'e te switc from off to on

    position instead of a person mo'ing a switc. It is anelectromagnetic de'ice wic is used to isolate twocircuits electricall* and connect tem magneticall*.Te* are often used to interface an electronic circuitwor6ing at a low 'oltage to an electrical circuitwic wor6s at 'er* ig 'oltage.

    i%"re 8

    2/

  • 7/24/2019 Embedded System Manual

    28/74

    $onstr"tion &n! suall* it doesn]tmatter if te rela* ta6es 1ms or 100ms to turn off.

    255V 0

  • 7/24/2019 Embedded System Manual

    29/74

    39P0.0/AD0 P2.0/A8

    2138 22

    P0.1/AD1 P2.1/A937 23P0.2/AD2 P2.2/A1036 24P0.3/AD3 P2.3/A1135 25 1"P0.4/AD4 P2.4/A1234 26P0.5/AD5 P2.5/A13

    33 27P0.6/AD6 P2.6/A1432 28P0.7/AD7 P2.7/A15

    1P1.0/T2 P3.0/RXD

    10

    2 11 '1P1.1/T2EX P3.1/TXD3 12 2N1069P1.2/ECI P3.2/INT04 13P1.3/CEX0 P3.3/INT15 14P1.4/CEX1 P3.4/T06 15P1.5/CEX2 P3.5/T17 16P1.6/CEX3 P3.6/WR 08 17P1.7/CEX4 P3.7/RD

    19X1 ALE

    3018 29

    X2 PSEN

    10uF 31EA30pF 9RST5V 12M!

    GND

    40VCC

    8.2" 30pF

    20

    0 80C51

    0

    5V

    0

    i%"re 9

    Re*ie ;"estions+

    1

  • 7/24/2019 Embedded System Manual

    30/74

    5V

    0

  • 7/24/2019 Embedded System Manual

    31/74

    2

  • 7/24/2019 Embedded System Manual

    32/74

    $3P$,I$4T 4. /

    ,o "p &n! !on o"nter on LE0s "sin% 8951miroontro--erB

    '()eti*e+

    e are sowing up and down counter on led s wic are solded on test +enc.

    $omponents+

    8!"51 microcontroller

    8 #$% s

    8 resistors ((0Z

    Connecting wires

    Power suppl* 5

    T,eoreti&- .&/%ro"n!+

    In digital logic and computing a counter is a de'ice wic stores and sometimesdispla*s te num+er of times a particular e'ent or process as occurred often inrelationsip to a cloc6 signal. In practice tere are two t*pes of counters=

    >p counters wic increase increment in 'alue

    %own counters wic decrease decrement in 'alue

    In electronics counters can +e implemented [uite easil* using register;t*pe circuits

    suc as te flip;flop and a wide 'ariet* of classifications e9ist=

    )s*ncronous ripple counter ^ canging state +its are used as cloc6s to

    su+se[uent state flip;flops.

    "*ncronous counter ^ all state +its cange under control of a single cloc6.

    >p:down counter ^ counts +ot up and down under command of a control input.

    $ac is useful for different applications. >suall* counter circuits are digital in nature

    and count in natural +inar*. ccasionall* tere are ad'antages to using a counting

    se[uence oter tan te natural +inar* se[uence suc as te +inar* coded decimal

    counter a linear feed+ac6 sift register counter or a ra*;code counter. Counters are

    useful for digital cloc6s and timers and in o'en timers C, cloc6s etc.

    Proe!"re+

    rite up and down counter code in Keil software. Create its e9 file.

    Burn te program on microcontroller wit te elp of +urner.

    a6e test +enc wit #$% s resistors capacitors and 8!"51.

    )fter +urning program insert microcontroller in its +ase in test +enc.

    Connect pins of port1 to #$% s troug 7umper wires.

    Pro'ide power suppl* from trainer to test +enc.

  • 7/24/2019 Embedded System Manual

    33/74

    28

  • 7/24/2019 Embedded System Manual

    34/74

    Wou will see com+ination of +inar* num+ers +eing displa*ed on #$% s fromdown to up 0000 to 1001 and ten up to down 1001 to 0000.

    $$o!e+

    OincludeFreg51.H'oid main'oidQ

    unsigned int9 forQ

    P1R0900

    for9R09F/00009

    P1R0901

    for9R09F/00009

    P1R0902

    for9R09F/00009P1R090(

    for9R09F/00009

    P1R090/

    for9R09F/00009

    P1R0905

    for9R09F/00009

    P1R090

    for9R09F/00009

    P1R090for9R09F/00009

    P1R0908for9R09F/00009

    P1R090!

    for9R09F/00009

    P1R0908

    for9R09F/00009

    P1R090

    for9R09F/00009

    P1R090

    for9R09F/00009

    P1R0905

    for9R09F/00009P1R090/

    for9R09F/00009

    P1R090(

    for9R09F/00009

    P1R0902

    for9R09F/00009

    P1R0901

    for9R09F/00009

    P1R0900

    for9R09F/00009

    S

    2!

  • 7/24/2019 Embedded System Manual

    35/74

    S

    ,em&ti+

    Res"-ts+

    Te counter is displa*ing on #$% s num+ers from 0000 to 10010 to ! inascending and ten descending order according to te code de'eloped. e can use itin man* applications.

    Re*ie ;"estions+

    1 In ,i, onfi%"r&tion LE0s &re onnete! to form o"nter=

    (0

  • 7/24/2019 Embedded System Manual

    36/74

    2 LE0s i-- %-o ,en t,e reei*e from miroontro--er -o%i 1 or -o%i =

    3 @o &n "p o"nters (e m&!e=

    4

  • 7/24/2019 Embedded System Manual

    37/74

    $3P$,I$4T 4 5

    I!entifi&tion of C&-i! &n! In*&-i! .$0 o!es

    '()eti*e+

    Identif* te 'alid BC% and in'alid BC% codes +* using a microcontroller 8!51.

    $omponents+

    i. 8!"51 icrocontroller.

    ii. /#"/ %ecoder.

    iii. "e'en "egment %ispla* common anode.

    i'. Power "uppl* 5.

    T,eoreti&- .&/%ro"n!+

    Te codes mostl* used toda* are in +inar* +ut te* are in special form called BC%.But depending upon te no of inputs some BC% codes generate 'alid num+er +utoter displa* in'alid no at a displa*ing unit li6e se'en segment.

  • 7/24/2019 Embedded System Manual

    38/74

    i%"re 1

    ain difference in use of a+o'e displa*s is tat segment is common catode groundat 1 pin or segment is common anode 5 at 1 pin. Te pin configuration can +e seen

    in te dataseet of segment displa*.

    7447 0eo!er+

    It is te common concept tat e'er*ting in realit* needs some support and tatsupport run tat ting in realit*. Te ting wic interfaces a unit wit realit* or

    practicall* wit real wor6 is called dri'er. "imilarl* se'en segment displa*s alsore[uire a dri'er for its operation in realit* or real world. Te dri'er used for te se'ensegment is // an IC t*pe sape. Tis dri'er also called a decoder wic con'ertste BC% in tat manner so tat on appl*ing te 'alid BC% te 'alid num+er at se'ensegment displa* is displa*ed. // is a dri'er as well as decoder for dri'ing se'ensegment displa* of common anode configuration and //8 is decoder and dri'er for

    common catode t*pe se'en segment displa*.

    Proe!"re+

    i. ade te circuit according to scematic sown in figure.

    ii. 4ow write te C;code for in'alid BC% codes tat correspond to +inar*num+ers from 1010 to 1111.

    iii. Compile te program in Keil and +urn it into 8!"51 using +urner.

    i'. Insert te programmed microcontroller into its +ase on test +enc.

    '. Cec6 connections +etween "e'en segment displa* and decoder and +etweendecoder and microcontroller.

    'i. Pro'ide power suppl* to test +enc troug trainer.

    'ii. +ser'e and record te random figures tat are formed on "e'en segmentdispla* for eac in'alid BC% code.

    ,em&ti

    ((

  • 7/24/2019 Embedded System Manual

    39/74

    i%"re 2

    $$o!e for *&-i! .$0 o!es+

    OincludeFreg51.Hoid mainQ

    unsigned car LforLR0LFR/0000LQ

    P1R0900 :: P1 is set as port for sending te data.

    forLR0LFR/0000LP1R0901

    forLR0LFR/0000L

    P1R0902

    forLR0LFR/0000L

    P1R090(

    forLR0LFR/0000L

    P1R090/

    forLR0LFR/0000L

    P1R0905

    forLR0LFR/0000L

    P1R090forLR0LFR/0000L

    P1R090

    forLR0LFR/0000L

    P1R0908

    forLR0LFR/0000L

    P1R090!

    forLR0LFR/0000L

    S

    S

    $$o!e for In*&-i! .$0 o!es+

    (/

  • 7/24/2019 Embedded System Manual

    40/74

    OincludeFreg51.Hoid mainQ

    unsigned car LforLR0LFR/0000L

    QP1R090) :: P1 is set as port for sending te data.forLR0LFR/0000LP1R090B

    forLR0LFR/0000L

    P1R090C

    forLR0LFR/0000L

    P1R090%

    forLR0LFR/0000L

    P1R090$

    forLR0LFR/0000L

    P1R090-forLR0LFR/0000L

    S

    S

    Re*ie ;"estions+

    1

  • 7/24/2019 Embedded System Manual

    41/74

    $3P$,I$4T 4

    :-&rm sstem "sin% 8951 it, t,e ,e-p of & sin%-e (it (&se!&-&rm sstemB

    '()eti*e+

    %esign of alarm s*stem using 8!C51 wit te elp of single +it +ased alarm s*stem.

    $omponents+

    Test +enc of 8!"51

    2 ,esistors ((0Z

    BuLLer

    #$%

    T,eoreti&- .&/%ro"n!+

    )n alarm s*stem is needed to pre'ent an* +ad condition or situation wic we don twant to face. en alarm de'ice is installed ten we can a'oid unsuita+lecircumstances as we can use a fire alarm antiteft alarm de'ice etc. "o we need analarm s*stem wic can +e implemented for antiteft purpose. )n alarm de'ice ors*stem gi'es an audi+le 'isual or an* oter form of signal during a pro+lem or an*una'oida+le circumstances. Te* are often connected wit a +uLLer or siren. Te*a'e a capa+ilit* of causing a figt or fligt response in umans. In tis condition a

    person will panic and eiter flee te percei'ed danger or attempt to eliminate it. Tis+uLLer ma6es sound wen te force is applied to te force sensiti'e resistor. Tis actsas an alarm s*stem and it is connected troug te ,- module so it can +e called aswireless alarm s*stem. en some force is applied to te force sensiti'e resistor tesignal is transmitted to te recei'er and te +uLLer ma6es sound wic ser'es as analarm. Te alarm +lows for 2 sec and ten it is off.

    Proe!"re+

    rite a code for te single +it +ased alarm s*stem using 8!"51 in 6eilsoftware.

    Burn te program on 8!"51 using +urner.

    Insert te programmed 8!"51 into its +ase on test +enc..

    Connect te +uLLer and resistor to port P2A1.

    Connect te led and resistor to P2A2

    Ta6e te port P2A0 as a input.

    en te input is connected to low logic led will +e 4 gi'ing te indicationof correct alarm.

    en te input is connected to ig logic +uLLer will +e 4 gi'ing teindication of wrong alarm.

    $$o!e+

    OincludeFreg51.H

    s+it inputRP2A0s+it +uLLerRP2A1

    (

  • 7/24/2019 Embedded System Manual

    42/74

    s+it ledRP2A2'oid mainQ

    wile1

    Q

    ifinputRR0Q

    ledR0

    +uLLerR1

    S

    else ifinputRR1

    Q

    +uLLerR0

    ledR1

    S

    S

    S

    ,em&ti+

    5V

    10" 10" 10" 10" 10"

    5V

    0

    $U&&ER 330

    10uF30pF

    5V 12M!

    8.2" 30pF

    0

    0

    0

    i%"

    re 1

    (

  • 7/24/2019 Embedded System Manual

    43/74

    0

  • 7/24/2019 Embedded System Manual

    44/74

    U121

    P0. 0/AD0 P2.0/A8 22P0. 1/AD1 P2.1/A9 23P0. 2/AD2 P2.2/A10 24P0. 3/AD3 P2.3/A11 25P0. 4/AD4 P2.4/A12 26P0. 5/AD5 P2.5/A13 27P0. 6/AD6 P2.6/A14 28

    P0. 7/AD7 P2.7/A1510

    P1. 0/T2 P3.0/RXD 11P1. 1/T2EX P3.1/TXD 12P1. 2/ECI P3.2/ INT0 13P1. 3/CEX0 P3.3/INT1 14P1. 4/CEX1 P3.4/T0 15P1. 5/CEX2 P3.5/T1 16P1. 6/CEX3 P3.6/WR 17

    P1. 7/CEX4 P3.7/RD 30

    X1 ALE29

    X2 PSEN

    EARST

    GND

    VCC

    80C5120

  • 7/24/2019 Embedded System Manual

    45/74

    Res"-t+

    "etting te 'alue at 0 led will +e 4 indicating correct code .ile setting 'alue at

    1 +uLLer will +e 4 indicating wrong code.

    Re*ie ;"estions+

    1B

  • 7/24/2019 Embedded System Manual

    46/74

    $3P$,I$4T 4

    Interf&in% of L0R &n! T,ermistor it, 8951

    $omponents+

    #%,

    Termistor

    aria+le resistors 2

    ((0Z resistor 1

    #$%s 2

    10u- capacitor

    %C 'oltmeter

    Torc

  • 7/24/2019 Embedded System Manual

    47/74

    ligt dependent resistors are semiconductors wen used as a poto;resistor te* areused onl* as a resisti'e element and tere are no P4 7unctions. )ccordingl* te de'iceis purel* passi'e.

    Tere are two t*pes of potoconductor and ence potoresistor=

    1 Intrinsi p,otoresistor+

    Tis t*pe of potoresistor uses a potoconducti'e material tat in'ol'es e9citation ofcarge carriers from te 'alence +ands to te conduction +and.

    2 Extrinsi p,otoresistor+

    Tis t*pe of potoresistor uses a potoconducti'e material tat in'ol'es e9citation of

    carge carriers +etween an impurit* and te 'alence +and or conduction +and. It

    re[uires sallow impurit* dopants tat are not ionised in te presence of ligt.

    $9trinisc potoresistors or potocells are generall* designed for long wa'elengt

    radiation ; often infra;red +ut to a'oid termal generation te* need to +e operated atlow temperature

    .&si p,otoresistor str"t"re

    )ltoug tere are man* wa*s in wic ligt dependent resistors or poto resistors

    can +e manufactured tere are naturall* a few more common metods tat are seen.

    $ssentiall* te potoresisitor or potocell consists of a resisti'e material sensiti'e to

    ligt tat is e9posed to ligt. Te poto resisti'e element comprises section of te

    material wit contacts at eiter end.

    ) t*pical structure for a ligt dependent or poto resistor uses an acti'esemiconductor la*er tat is deposited on an insulating su+strate. Te semiconductor is

    normall* ligtl* doped to ena+le it to a'e te re[uired le'el of conducti'it*. Contacts

    are ten placed eiter side of te e9posed area. itin te +asic poto resistor or

    potocell structure te resistance of te material itself is a 6e* issue. To ensure te

    resistance canges resulting from te ligt dominate contact resistance is minimiLed.

    To acie'e tis te area around te contacts is normall* ea'il* doped to reduce te

    resistance in tis region. In man* instances te area +etween te contacts is in te

    form of a Lig Lag or inter digital pattern. Tis ma9imiLes te e9posed area and +*

    6eeping te distance +etween te contacts small it reduces te spurious resistance

    le'els and enances te gain.

    P,otoresistor or p,otoe-- it, inter!i%it&- ont&t p&ttern

    /0

  • 7/24/2019 Embedded System Manual

    48/74

    It is also possi+le to use a pol*cr*stalline semiconductor tat is deposited onto asu+strate suc as ceramic. Tis ma6es for a 'er* low cost ligt dependent resistor.

    P,otoresistor &pp-i&tions

    Te potoresistor or ligt dependent resistor is attracti'e in man* electronic circuit

    designs +ecause of its low cost simple structure and rugged features. ile it ma* not

    a'e some of te features of te poto;diode and poto;transistor it is ideal for man*

    applications. )s a result te poto;resistor is widel* used in circuits suc as

    potograpic meters flame or smo6e detectors +urglar alarms card readers controls

    for street ligting and man* oters.

    T,ermistor

    ) resistor made of semiconductors a'ing resistance tat 'aries rapidl* andpredicta+l* wit temperature is called termistor. Te termistor is a resistor woseresistance strongl* depends on temperature sowing a nonlinear ;I caracteristic.

    "pecific to tis temperature dependence compared wit tat of fi9ed linear resistorsis te fact tat for a temperature 'ariation wit one degree te 'alue of te termistorsresistance canges +* tens of percent. In oter words it is possi+le tat witin anarrow temperature range te termistor would al'e or dou+le its resistance 'alue.

    T,ermistor ssm(o-

    %ecrease or increase in resistance is closel* correlated wit te t*pe of te termistorwic can +e=

    a 4egati'e temperature coefficient 4TC

    + Positi'e temperature coefficient PTC.

    Termistors s*m+ols are sown in -igure.

    /1

  • 7/24/2019 Embedded System Manual

    49/74

    Dr&p, of NT$ &n! PT$

    Prinip-e of

  • 7/24/2019 Embedded System Manual

    50/74

    Proe!"re

    Tere are te following steps in'ol'ing in tis e9periment.

    L0R

    a6e connections of #%, wit 8!"51 test +enc as sown in te figure.

    Place a ((0Z resistor in series wit #%, and connect an #$% in parallel.

    Connect a %C 'oltmeter in parallel to te #$% for measuring 'oltages for te4 state and -- state of #$%.

    +tain re[uired le'els of ligt for wic #$% glows and for wic it sta*s

    -- +* inserting a 'aria+le resistor in series wit te #%,. Increasing te

    resistance will reduce te intensit* le'el of ligt for wic #$% glows.

    easure te 'oltages +* %C 'oltmeter witout trowing ligt on #%,. Te

    'oltage sould lie +etween 0 to 0.8 for tis condition and #$% sould

    remain --.

    easure te 'oltages +* %C 'oltmeter again +* trowing re[uired intensit* of

    ligt on #%,. Te 'oltage sould lie +etween 2 to 5 for tis condition and

    #$% sould glow.

    ,ecord te 'oltages against te two intensit* le'els of ligt in ta+le.

    inute ligt less tan /0 )t ligt effect 2000 lu9

    lu9

    0.(52.22

    $9periment can +e repeated for different ligt intensities +* canging 'alue of'aria+le resistor.

    /(

  • 7/24/2019 Embedded System Manual

    51/74

    i%"re 1

    T,ermistor

    a6e connections of termistor wit 8!"51 test +enc as sown in te figure.

    Place a ((0Z resistor in series wit parallel com+ination of 10u- capacitor

    and termistor. )lso connect an #$% and %C 'oltmeter in parallel for

    measuring 'oltages for te 4 state and -- state of #$%.

    +tain re[uired le'els of eat:temperature for wic #$% glows and for

    wic it sta*s -- +* inserting a 'aria+le resistor in series wit te #%,

    instead of ((0 Z resistor. Increasing te resistance will reduce te intensit*

    le'el of eat for wic #$% glows.

    easure te 'oltages +* %C 'oltmeter at room temperature witout eating.

    Te 'oltage sould lie +etween 0 to 0.8 for tis condition and #$% sould

    remain --.

    easure te 'oltages +* %C 'oltmeter again +* eating to +oiling point. Te'oltage sould lie +etween 2 to 5 for tis condition and #$% sould glow.

    ,ecord te 'oltages against te two temperature le'els in ta+le.

    ,oom Temperature 25 C )t eating effect 100 C

    0.(12.1!

    //

  • 7/24/2019 Embedded System Manual

    52/74

    i%"re 2

    $$o!e

    "ame code is used for #%, and termistor wen tese are connected to an* pin of I:port.Oinclude Freg51.H

    s+it a+itRP1A0 ::input reference from #%, or termistor

    s+it loc61RP1A5 ::input to te application to turn on or off

    'oid main'oid

    Q

    wile1

    Q

    ifa+itRR1

    loc61R0 ::means use te +it at te ground side of application

    elseloc61R1

    S

    S

    Re*ie ;"estions

    1

  • 7/24/2019 Embedded System Manual

    53/74

    JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ

    JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ

    3

  • 7/24/2019 Embedded System Manual

    54/74

    $9periment 4o 8

    o"r

  • 7/24/2019 Embedded System Manual

    55/74

    $ir"it 0i&%r&m+

    $$o!e+

    Oinclude Freg51.H'oid main'oidQ

    unsigned int9 forQ

    P0R09/P2R09!2P(R092/

    for9R09F55(59

    for9R09F55(59

    P0R0952P2R09!2P(R092/for9R09F55(59

    for9R09F55(59

    P0R098!P2R09!/P(R092/

    for9R09F55(59

    for9R09F55(59

    P0R090!P2R09!!P(R092/

    for9R09F55(59

    for9R09F55(59P0R098!P2R09!/P(R092/

    for9R09F55(59

    for9R09F55(59P0R09/!P2R0922P(R0925

    /8

  • 7/24/2019 Embedded System Manual

    56/74

    for9R09F55(59

    for9R09F55(59

    P0R09/!P2R09/2P(R092

    for9R09F55(59

    for9R09F55(59

    P0R09/!P2R0922P(R0925for9R09F55(59

    for9R09F55(59

    P0R09/!P2R09!2P(R09/8

    for9R09F55(59

    for9R09F55(59

    P0R09/!P2R09!2P(R09!0

    for9R09F55(59

    for9R09F55(59

    P0R09/!P2R09!2P(R09/8

    for9R09F55(59

    for9R09F55(59P0R0952P2R09!2P(R092/

    for9R09F55(59

    for9R09F55(59

    S

    S

    Re*ie ;"estions+

    1.

  • 7/24/2019 Embedded System Manual

    57/74

    Experiment No 9

    Interf&in% of 8951 it, 0$ Motor

    '()eti*e+

    Te o+7ecti'e of tis e9periment is to interface %C motor wit 8!"51 microcontrollerand control te speed of %C motor.

    EA"ipment ReA"ire!+

    )T8!"51 icrocontroller

    pto;isolator I#%/

    %arlington Transistor TIP120

    %iode 14/00/

    ,esistors ((0Z 106Z 1006Z

    Capacitor 0.1>f

    "imple %C otor

    Components for 8!"51 test +enc circuitr*

    T,eoreti&- .&/%ro"n!+

    IB 0$ Motor+

    Te %C otor is te most commonl* used actuator for producing continuousmo'ement and wose speed of rotation can easil* +e controlled ma6ing tem idealfor use in applications were speed control ser'o t*pe control and:or positioning is

    re[uired. ) %C motor consists of two parts a ?"tator@ wic is te stationar* part anda ?,otor@ wic is te rotating part. Te result is tat tere are +asicall* tree t*pes of%C otor a'aila+le.

    .r"s,e! Motor+

    Tis t*pe of motor produces a magnetic field in a wound rotor te part tat rotates+* passing an electrical current troug a commutator and car+on +rus assem+l*ence te term ?Brused@. Te stators te stationar* part magnetic field is produced

    +* using eiter a wound stator field winding or +* permanent magnets. enerall*+rused %C motors are ceap small and easil* controlled.

    .r"s,-ess Motor+

    Tis t*pe of motor produce a magnetic field in te rotor +* using permanent magnetsattaced to it and commutation is acie'ed electronicall*. Te* are generall* smaller

    +ut more e9pensi'e tan con'entional +rused t*pe %C motors +ecause te* use

    ?

  • 7/24/2019 Embedded System Manual

    58/74

    :IB 0$ Motor it,in% &n! $ontro-+

    Te ma9imum current tat can +e sourced or sun6 from an 8051 microcontroller is 15m) at 5'. But a %C otor need currents 'er* muc more tan tat and it need'oltages ' 12' 2/' etc. depending upon te t*pe of motor used. )noter pro+lem is

    tat te +ac6 emf produced +* te motor ma* affect te proper functioning of temicrocontroller. %ue to tese reasons we can t connect a %C otor directl* to amicrocontroller.

    To o'ercome tese pro+lems

  • 7/24/2019 Embedded System Manual

    59/74

    i%"re 1

    0is&!*&nt&%e of t,is ontro- met,o!+

    ile controlling te speed of a %C motor wit a single transistor as man*ad'antages it also as one main disad'antage te direction of rotation is alwa*s tesame it s a ?>nidirectional@ circuit. In man* applications we need to operate temotor in +ot directions forward and +ac6. To control te direction of a %C motor te

    polarit* of te %C power applied to te motor s connections must +e re'ersedallowing its saft to rotate in te opposite direction.

    Proe!"re+

    1. $[uip icrocontroller 8!"51 wit te e9ternal cloc6 and reset circuitr*.

    2. Connect pin1 of ptoisolator I#%/ to 5 troug ((0Z resistor and its pin 2to P2A0 of icrocontroller.

    (. Connect pin / of ptoisolator I#%/ to +ase of %arlington transistor TIP120wile its pin 5 is connected to 12.

    /. Connect freeweeling diode 14/00/ 0.1u- capacitor and %C motor inparallel wit one terminal connected to 12 and te oter terminal connected

    to Collector terminal of TIP120.5. Program te microcontroller turn on power supplies and o+ser'e results.

    52

    ,em&ti+

  • 7/24/2019 Embedded System Manual

    60/74

    10" 10" 10" 10" 10" 10" 10" 10"

    30pF

    5V 10uF

    30pF12M!

    8.2"

    0 0

    $ $o!e+

    OincludeFreg51.H

    OincludeFstdio.H

    'oid dela*int

    'oid main

    Q

    doQ

    P2 R 0901dela*100P2 R 0900dela*100

    S

    wile1

    S

    'oid dela*int 6

    Q

    int i7foriR0iF6iQ

    for7R07F1007

    QS

    S

    S

    5V

    12V

    2

    0

    0 0.1uF

    U1 330 1N40041

    39 P0.0/AD0 P2.0/A8 21

    38

    P0.1/AD1 P2.1/A9 22 '1

    37 P0.2/AD2 P2.2/A10 23 10"36 P0.3/AD3 P2.3/A11 2435 P0.4/AD4 P2.4/A12 2534 P0.5/AD5 P2.5/A13 2633 P0.6/AD6 P2.6/A14 27 TIP122

    32 P0.7/AD7 P2.7/A15

    28 12V

    1P1.0/T2 P3.0/RXD

    10 IS%1

    2 11 %PT% IS%LAT%R 100"P1.1/T2EX P3.1/TXD

    3 12P1.2/ECI P3.2/INT04

    P1.3/CEX0 P3.3/INT1 13

    5 14P1.4/CEX1 P3.4/T06 15P1.5/CEX2 P3.5/T17 16

    8 P1.6/CEX3 P3.6/WR 17P1.7/CEX4 P3.7/RD 0

    19 30X1 ALE

    18 29X2 PSEN

    31EA9RST

    40 GND

    VCC

    80C51 20

    5V

    0

    i%"re 2+ Interf&in% 0$ motor it, 89$51

    5(

    M1M%T%R DC

  • 7/24/2019 Embedded System Manual

    61/74

    Res"-t+

    Te motor stepping se[uence was o+ser'ed as follows=

    P2.0:I4 otor "tatus

    0 o'es C#CKI"$1 "tops

    Re*ie ;"estions+

    1

  • 7/24/2019 Embedded System Manual

    62/74

    Experiment # 1

    Interf&in% of 8951 it, tepper Motor

    '()eti*e+

    Te o+7ecti'e of tis e9periment is to interface stepper motor wit 8!"51microcontroller and to control te speed of te motor.

    EA"ipment ReA"ire!+

    )T8!"51 icrocontroller

    otor %ri'er >#4200( IC

    >nipolar "tepper otor

    ,esistors /.6Z

    Components for 8!"51 test +enc circuitr*

    T,eoreti&- .&/%ro"n!+

    IB tepper Motor+

    ) stepper motor is a widel* used de'ice tat translates electrical pulses intomecanical mo'ement. In applications suc as dis6 dri'es dot matri9 printers andro+otics te stepper motor is used for position control. "tepper motors commonl*a'e a permanent magnet rotor also called te saft surrounded +* a stator.Tereare also steppers called 'aria+le reluctance stepper motors tat do not a'e a Protor. Te most common stepper motors a'e four stator windings tat are paired wit

    a center;tapped common. Tis t*pe of stepper motor is commonl* referred to as afour;pase unipolar stepper motor. Te center tap allows a cange of current directionin eac of two coils wen a winding is grounded tere+* resulting in a polarit*cange of te stator.

    ) "tepper otor is +asicall* +rusless s*ncronous %C otor. Te total rotation ofte motor is di'ided into steps. Te angle of a single step is 6nown as te stepperangle of te motor.

    :IB To p,&se tepper Motors+

    Tere are two +asic winding arrangements for te electromagnetic coils in a twopase stepper motor= +ipolar and unipolar.

    .ipo-&r stepper motor+

    Te +ipolar stepper motor usuall* as four wires coming out of it. >nli6e unipolarsteppers +ipolar steppers a'e no common center connection. Te* a'e twoindependent sets of coils instead. Te* can +e distinguised from unipolar steppers +*measuring te resistance +etween te wires. ne sould find two pairs of wires wite[ual resistance. If *ou 'e got te leads of *our meter connected to two wires tat arenot connected i.e. not attaced to te same coil *ou sould see infinite resistance orno continuit*.Bipolar stepper motors a'e no center tap and a'ing e[ual coilresistances.

    55

  • 7/24/2019 Embedded System Manual

    63/74

    i%"re 1+ Bipolar stepper motor coils

    Knipo-&r stepper motor+

    ) unipolar stepper motor as one winding wit center tap per pase. "ince in tisarrangement a magnetic pole can +e re'ersed witout switcing te direction ofcurrent te commutation circuit can +e made 'er* simple e.g. a single transistor foreac winding. T*picall* gi'en a pase te center tap of eac winding is madecommon= gi'ing tree leads per pase and si9 leads for a t*pical two pase motor.ften tese two pase commons are internall* 7oined so te motor as onl* fi'eleads. indings of tis motor can +e identified +* toucing te terminal wirestogeter in P motors. If te terminals of a coil are connected te saft +ecomesarder to turn. ne wa* to distinguis te center tap common wire from a coil;endwire is +* measuring te resistance. ,esistance +etween common wire and coil;endwire is alwa*s alf of wat it is +etween coil;end and coil;end wires. %ue to te easeof operation unipolar stepper motor is commonl* used. e are using it in tise9periment too.

    i%"re 2+ >nipolar stepper motor coils

    .IB 0ri*in% Knipo-&r tepper it, 89$51+

    >nipolar stepper motors can +e used in 'arious modes. Tree of most common are tea'e %ri'e -ull %ri'e and

  • 7/24/2019 Embedded System Manual

    64/74

    "-- 0ri*e+

    In tis mode two electromagnets are energiLed at a time so te tor[ue generated will+e larger wen compared to a'e %ri'e. Tis dri'e is commonl* used tan oters.Power consumption will +e iger tan oter modes.

    "-- 0ri*e teppin% eA"ene

    tep : . $ 0

    1 1 1 0 0

    2 0 1 1 0

    ( 0 0 1 1

    / 1 0 0 1

    @&-f 0ri*e+

    In tis mode alternati'el* one and two electromagnets are energiLed so it is acom+ination of a'e and -ull dri'es. Tis mode is commonl* used to increase te

    angular resolution of te motor +ut te tor[ue will +e less a+out 0 at its alf stepposition. e can see tat te angular resolution dou+les wen using #4200() as a 2.;6Z series +ase resistor for eac %arlington pair for operationdirectl* wit TT# or 5; C" de'ices. In te motor dri'ing circuit >#4200(reduces +ac6 $-.

    Proe!"re+

    1. $[uip icrocontroller 8!"51 wit te e9ternal cloc6 and reset circuitr*.

    2. Connect input pins 1 to / of >#4200( dri'er IC P2A0 to P2A( respecti'el* andalso to 5 suppl* troug /.6Z resistors.

    5

  • 7/24/2019 Embedded System Manual

    65/74

    (. "ort center tap common wire of +ot windings of unipolar stepper motorand connect to 5 suppl*.

    /. Connect remaining two ends of eac winding one +* one to collectors of poto%arlington pairs in >#4200() i.e. pins 1( to 1 of >#4200(.

    5. Program te microcontroller turn on power supplies and o+ser'e results.

    ,em&ti+

    5V5V

    10" 10" 10" 10" 10" 10" 10" 10"

    30pF

    5V 10uF

    30pF12M!

    8.2"

    0 0

    0

    4.7" 4.7"

    0 4.7"

    4.7"M1

    U1 U4 M%T%R STEPPERULN2003A

    39P0.0/AD0 P2.0/A8

    21 11$ 1C

    16

    38 22 2 15P0.1/AD1 P2.1/A9 2$ 2C37 23 3 14P0.2/AD2 P2.2/A10 3$ 3C

    36 24 4 13P0.3/AD3 P2.3/A11 4$ 4C35 25 5 12

    34 P0.4/AD4 P2.4/A12 26 6 5$ 5C 11P0.5/AD5 P2.5/A13 6$ 6C33 27 7 10P0.6/AD6 P2.6/A14 7$ 7C

    32 28P0.7/AD7P2.7/A15

    9C%MGND

    1 P1.0/T2 P3.0/RXD 102 P1.1/T2EX P3.1/TXD 11

    83 12

    P1.2/ECI P3.2/INT04 135 P1.3/CEX0 P3.3/INT1 14

    6 P1.4/CEX1 P3.4/T0 15 5VP1.5/CEX2 P3.5/T1

    7 16P1.6/CEX3 P3.6/WR

    8 P1.7/CEX4 P3.7/RD

    17

    19

    30

    X1 ALE18 29

    31X2 PSEN 0

    EA9RST

    40G

    ND

    VCC

    80C51 20

    5V

    0

    i%"re 3+ Knipo-&r stepper motor interf&in% it, 89$51 "sin% !ri*er KLN23

    $ $o!e+

    OincludeFreg51.HOincludeFstdio.H

    'oid dela*int

    'oid main

    Q

    do

    Q

    P2 R 090( ::0011dela*1000

    P2 R 090 ::0110dela*1000P2 R 090C ::1100

    58

  • 7/24/2019 Embedded System Manual

    66/74

    dela*1000

    P2 R 090! ::1001dela*1000

    S

    wile1

    S

    'oid dela*int 6

    Q

    int i7foriR0iF6iQ

    for7R07F1007

    QS

    S

    S

    Res"-t+

    Te motor stepping se[uence was o+ser'ed as follows=

    Res"-tin% eA"enetep : . $ 0

    1 0 0 1 1

    2 0 1 1 0

    ( 1 1 0 0

    / 1 0 0 1

    Re*ie ;"estions+

    1

  • 7/24/2019 Embedded System Manual

    67/74

    JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ

    5

  • 7/24/2019 Embedded System Manual

    68/74

    Experiment # 11

    Interf&in% t,e 8951 miroontro--er it, :0$84 ,ip

    '()eti*e+

    Te o+7ecti'e of tis e9periment is to interface )%C080/ cip wit 8!"C51microcontroller and to displa* te result on #C%.

    EA"ipment ReA"ire!+

    )T8!"51 icrocontroller

    )%C080/ IC

    1V2 #C% %ispla*

    Potentiometer 106Z

    Capacitor 150p-

    Components for 8!"51 test +enc circuitr*

    T,eoreti&- .&/%ro"n!+

    In em+edded s*stem it is essential tat microcontrollers ta6e analog input. "ensorsand transducers used in industr* are analog in nature. It is needed to con'ert teanalog output from te sensors to digital so tat te corresponding signal can +e

    processed +* te controller. Tese are generall* used in control operation andinstrumentation in industries. )%Cs are used e'er*were wen we a'e to processstore or transmit an analog signal in digital form.

    )%Cs are used in T tuner cards and for digital data processing in microcontrollers inte form of on cip 8 +it 10 +it )%Cs. Commercial )%Cs are also used as integratedcircuits. Con'ertors wit a resolution of 8 to 2/ +its are used and its sample fre[uenc*is in order of some K

  • 7/24/2019 Embedded System Manual

    69/74

    digital con'ertor i.e. it can ta6e onl* one analog signal. )n )%C as n +it resolution+inar* form were n can +e 810121 or e'en 2/ +its. )%C 080/ as 8 +itresolution. Te iger resolution )%C gi'es smaller step siLe. "tep siLe is smallestcange tat can +e measured +* an )%C. -or an )%C wit resolution of 8 +its testep siLe is 1!.5(m 5:255.

    Te time ta6en +* te )%C to con'ert analog data into digital form is dependent onte fre[uenc* of cloc6 source. )%C080/ can +e gi'en cloc6 from e9ternal source. Italso as an internal cloc6.

  • 7/24/2019 Embedded System Manual

    70/74

    clearing its screen setting te cursor position controlling displa* etc. Te dataregister stores te data to +e displa*ed on te #C%. Te data is te )"CII 'alue of tecaracter to +e displa*ed on te #C%.

  • 7/24/2019 Embedded System Manual

    71/74

    LCD DB7DB6DB5DB4DB3DB2DB1DB0

    ER/WRS

    VEEVCCVSS

    1413121110987

    654

    321

    10" 10" 10" 10" 10"10" 10" 10"

    5V 5V

    0 U1

    39P0.0/AD0 P2.0/A8

    2138 22

    0 P0.1/AD1 P2.1/A937 23P0.2/AD2 P2.2/A1036 24P0.3/AD3 P2.3/A1135 25P0.4/AD4 P2.4/A1210" 34 26P0.5/AD5 P2.5/A13P%T 33 27P0.6/AD6 P2.6/A14U6 32 28P0.7/AD7 P2.7/A15

    6(IN D$0

    18 1P1.0/T2 P3.0/RXD

    107 17 2 11

    )IN D$1 P1.1/T2EX P3.1/TXD10" 16 3 12D$2 P1.2/ECI P3.2/INT09 15 4 13

    0 VREF/2 D$3 P1.3/CEX0 P3.3/INT114 5 14D$4 P1.4/CEX1 P3.4/T04 13 6 15

    CL*IN D$5 P1.5/CEX2 P3.5/T119 12 7 16CL*R D$6 P1.6/CEX3 P3.6/WR150pF 11 8 17

    D$7 P1.7/CEX4 P3.7/RD2RD3 5 19 30WR INTR X1 ALE1 18 29

    CS AGN

    D

    X2 PSEN

    GND20

    VCC/VREF31

    EA9

    0 RST

    10

    GND

    ADC08048

    30pF 40VCC5V 10uF

    5V

    20

    30pF12M! 80C51

    8.2"5V

    0

    0 0 0

    i%"re+ :0$84 interf&in% it, 8951 to !isp-& res"-ts on L$0

    $ $o!e+

    OincludeFreg51.H s+itrs R P2A0 s+it rw RP2A1 s+it en R P2A2

    s+it rd R P2A( s+it wrR P2A/ s+it intr RP2A5 'oid initJlcd

    'oid lcdJcommunsigned car 'alue1 'oidlcdJdataunsigned car 'alue2 'oid

    lcdJmsgunsigned car Vc 'oiddela*unsigned int ms

    'oid adcJinit 'oidadcJread'oid Con'erterunsigned car '/

    unsigned car asciiJlutb R 012(/58!)BC%$- 'oidmainQ

    P0 R 0900

    P1 R 09--

    P2 R 0900

    /

  • 7/24/2019 Embedded System Manual

    72/74

    initJlcdadcJinitlcdJcomm0980lcdJmsg)%CRwile1

    QadcJread

    S

    S

    'oid adcJinit

    Q

    wr R 1rd R 1

    intr R 1 S 'oid adcJread

    Q

    unsigned car' wr R 0

    wr R 1wileintr RR 1rd R 0

    ' R P1Con'erter'intr R 0

    S

    'oid Con'erterunsigned car '/

    Q

    ::;;;Con'erter to analog input 'oltagefloat gunsigned int dt

    g R '/ V5:255 d R g R g ; d

    t R V 100 lcdJcomm0985

    lcdJdatadD09(0

    lcdJdata].]

    lcdJdatat:1010D09(0

    lcdJdatat10D09(0

    lcdJdata]]lcdJcomm09C0

    lcdJmsg%R

    lcdJdata'/:10010D09(0lcdJdata'/:1010D09(0lcdJdata'/10D09(0lcdJcomm09ClcdJmsg

  • 7/24/2019 Embedded System Manual

    73/74

    'oid initJlcd

    Q

    lcdJcomm09(8

    dela*10

    lcdJcomm090$

    dela*10lcdJcomm0901

    dela*10

    lcdJcomm090

    dela*10

    lcdJcomm0980

    dela*10

    S

    'oid lcdJcommunsigned car 'alue1

    Q

    P0 R 'alue1rs R 0rw R 0en R 1dela*1en R 0

    S

    'oid lcdJdataunsigned car 'alue2

    Q

    P0 R 'alue2

    rs R 1

    rw R 0

    en R 1dela*1 ::;;;;1ms dela*

    en R 0

    S

    'oid lcdJmsgunsigned car Vc

    Q

    wileVc ER 0

    Q

    lcdJdataVcc

    S

    S

    'oid dela*unsigned int ms

    Q

    unsigned int i7foriR0iFRmsifor7R07FR1207

    S

    Res"-ts+

    Te following result appeared on #C%in accordance wit te analog data gi'en to

    )%C080/ = %R051

  • 7/24/2019 Embedded System Manual

    74/74

    Re*ie ;"estions+

    1