Chuong 7 thiet ke giao tiep

Download Chuong 7 thiet ke giao tiep

Post on 18-Jul-2015

1.945 views

Category:

Documents

0 download

Embed Size (px)

TRANSCRIPT

  • Ni dung: Chng 1: Gii thiu v Vi x l Chng 2: Gii thiu v cu trc ca H Vi iu

    khin 8051 Chng 3: Kho st tp lnh v lp trnh Vi iu

    khin 8051 Chng 4: Hot ng ca b nh thi Chng 5: Hot ng ngt Chng 6: Hot ng truyn thng ni tip Chng 7: Thit k giao tip v ng dng

    Ni dung chng 7: Giao tip vi LED n. Giao tip vi LED 7 on. Giao tip vi ma trn LED (quang bo). Giao tip vi LCD. Giao tip vi ng c in 1 chiu v ng c bc. Giao tip vi bn phm. Giao tip vi ADC (Analog to Digital Converter) v cc

    cm bin.

    Giao tip vi my tnh.

    7.1. Giao tip vi LED nDng in qua 89x51 ti a 10mA nn phi mc nitip vo in tr gim dng hoc dng mch khuchi.

    Tnh R1=?m

    LED

    IVVccR =1

    Vcc = 5V, VLED = 2V, Im = 10mA

    R1 = 300 Chn R1 = 330

    7.1. Giao tip vi LED n

    Dng mch khuch i

  • Giao tip VK vi 8 LED nVCC

    R410330

    R41330

    R42330

    R43330

    R44330

    R45330

    R46330

    R47330

    R310k

    C333p

    C4

    33p

    C5

    33p

    X1CRYSTAL

    R2100

    XTAL218

    XTAL119

    ALE30EA31

    PSEN29

    RST9

    P0.0/AD0 39P0.1/AD1 38P0.2/AD2 37P0.3/AD3 36P0.4/AD4 35P0.5/AD5 34P0.6/AD6 33P0.7/AD7 32

    P1.01P1.12P1.23P1.34P1.45P1.56P1.67P1.78

    P3.0/RXD 10P3.1/TXD 11P3.2/INT0 12P3.3/INT1 13

    P3.4/T0 14

    P3.7/RD 17P3.6/WR 16P3.5/T1 15

    P2.7/A15 28

    P2.0/A8 21P2.1/A9 22

    P2.2/A10 23P2.3/A11 24P2.4/A12 25P2.5/A13 26P2.6/A14 27

    U2

    AT89C51

    7.2. Giao tip vi LED 7 onLED 7 on bao gm 7 on (thanh), mi a tngng vi 7 LED n.

    LED 7 on c 2 loi: Anode (dng) chung. Catode (m) chung.

    7.2.1. Loi Anode chung

    Bng m hinth cc s.

    7.2.2. Loi Catode chung

    Bng m hinth cc s.

  • Bng m (s HEX) LED 7 on loi Anode chung

    Bng m qut th loiLED Anode chung.

    M qut iu khin cc Transistor

    Bng m qut hin th loiLED Anode chung.

    7.3. Giao tip vi ma trn LED

  • 7.3. Giao tip vi ma trn LEDMa trn LED bao gm nhiu LED n cng nmtrong mt v, chia thnh nhiu hng v nhiu ct.

    Ma trn LED 7x5

    Ghp ni vi ma trn LED

    iu khin ma trn LEDVic iu khin sng ti mt im c thc hinbng cch cp ngun vo Anode (dng) v Catode(m).

    V d: sng s 0, ta thc hin qut lin tc cchng v ct nh sau:

    Ln 1: Hng = 01000001; Ct = 00000001Ln 2: Hng = 00111110; Ct = 00000010Ln 3: Hng = 00111110; Ct = 00000100Ln 4: Hng = 00111110; Ct = 00001000Ln 5: Hng = 01000001; Ct = 00010000

    R310k

    C333p

    C4

    33p

    C5

    33p

    X1C R YS TA L

    R2100

    X TA L218

    X TA L119

    A LE30EA31

    P SEN29

    R S T9

    P 0 .0 /AD0 39P 0 .1 /AD1 38P 0 .2 /AD2 37P 0 .3 /AD3 36P 0 .4 /AD4 35P 0 .5 /AD5 34P 0 .6 /AD6 33P 0 .7 /AD7 32

    P 1.01P 1.12P 1.23P 1.34P 1.45P 1.56P 1.67P 1.78

    P 3 .0 /RXD 10P 3.1 /TXD 11P 3.2 /IN T0 12P 3.3 /IN T1 13

    P 3 .4 /T0 14

    P 3 .7 /RD 17P 3 .6/W R 16

    P 3 .5 /T1 15

    P 2.7 /A15 28

    P 2 .0 /A8 21P 2 .1 /A9 22

    P 2.2 /A10 23P 2.3 /A11 24P 2.4 /A12 25P 2.5 /A13 26P 2.6 /A14 27

    U2

    A T89C 51

    Q 12N 2222A

    R11k

    Q 22N 2222A

    R41k

    Q 32N 2222A

    R51k

    Q 42N 2222A

    R61k

    Q 52N 2222A

    R710k

    1 2 3 4 5 6 7 8

    1

    6

    1

    5

    1

    4

    1

    3

    1

    2

    1

    1

    1

    0

    9

    R22

    Ghp ni vi ma trn LED

  • 7.4. Giao tip vi LCD (Liquid Crystal Display) S chn ca LCD

    S chn ca LCD

    LCD c 14 chn, c chia lm 3 nhm: Nhm 1 (cp ngun): Vcc, Vss, Vee Nhm 2 (d liu vo ra): D0...D7 Nhm 3 (iu khin d liu vo ra): RS, R/W, E

    Chn K hiu Chc nng1 Vss Ngun m ( 0V )2 Vcc Ngun dng ( 5V )3 Vee iu chnh sng ca LCD

    4 RS Chn thanh ghi: - RS = 0: thanh ghi lnh- RS = 1: Thanh ghi d liu

    5 R/W R/W = 1 c d liu. R/W = 0 ghi d liu. 6 E Cho php thng tin hin th trn LCD7 DB0

    Cc bit d liu. Dng gi thng tin ln LCDhoc c ni dung cc thanh ghi trong LCD.

    8 DB19 DB2

    10 DB311 DB412 DB513 DB614 DB7

  • M lnh (HEX) Lnh n thanh ghi ca LCD1 Xa mn hnh hin th

    2 Tr v u dng

    4 Dch con tr sang tri

    6 Dch con tr sang phi

    5 Dch hin th sang tri

    7 Dch hin th sang phi

    8 Tt con tr, tt hin th

    Bng m lnh ca LCDM lnh (HEX) Lnh n thanh ghi ca LCD

    A Bt con tr, tt hin th

    C Tt con tr, bt hin th

    E Nhp nhy con tr, Bt hin th

    F Tt con tr, nhp nhy con tr

    10 Dch con tr sang tri

    14 Dch con tr sang phi

    18 Dch ton b hin th sang tri1C Dch ton b hin th sang phi80 a con tr v u dng th nhtC0 a con tr v u dng th hai38 Hai dng hin th ma trn 5x7

    R310k

    C333p

    C4

    33p

    C5

    33p

    X1C R YS TA L

    R2100

    X TA L218

    X TA L119

    A LE30EA31

    P SEN29

    R S T9

    P 0.0 /AD0 39P 0.1 /AD1 38P 0.2 /AD2 37P 0.3 /AD3 36P 0.4 /AD4 35P 0.5 /AD5 34P 0.6 /AD6 33P 0.7 /AD7 32

    P 1.01P 1.12P 1.23P 1.34P 1.45P 1.56P 1.67P 1.78

    P 3.0 /RXD 10P 3.1 /TXD 11P 3.2 /IN T0 12P 3.3 /IN T1 13

    P 3.4 /T0 14

    P 3 .7 /RD 17P 3.6/W R 16

    P 3.5 /T1 15

    P 2 .7 /A15 28

    P 2.0 /A8 21P 2.1 /A9 22

    P 2 .2 /A10 23P 2 .3 /A11 24P 2 .4 /A12 25P 2 .5 /A13 26P 2 .6 /A14 27

    U2

    A T89C 51

    D

    7

    1

    4

    D

    6

    1

    3

    D

    5

    1

    2

    D

    4

    1

    1

    D

    3

    1

    0

    D

    2

    9

    D

    1

    8

    D

    0

    7

    E

    6

    R

    W

    5

    R

    S

    4

    V

    S

    S

    1

    V

    D

    D

    2

    V

    E

    E

    3

    LC D1LM 032L

    R1

    5k

    Ghp ni vi LCD 7.5. Giao tip vi ng c in DC

    +5V

    R310k

    C310p

    C4

    33p

    C5

    33p

    X1CRYSTAL

    R2100

    XTAL218

    XTAL119

    ALE30EA31

    PSEN29

    RST9

    P0.0/AD0 39P0.1/AD1 38P0.2/AD2 37P0.3/AD3 36P0.4/AD4 35P0.5/AD5 34P0.6/AD6 33P0.7/AD7 32

    P1.01P1.12P1.23P1.34P1.45P1.56P1.67P1.78

    P3.0/RXD 10P3.1/TXD 11P3.2/INT0 12P3.3/INT1 13

    P3.4/T0 14

    P3.7/RD 17P3.6/WR 16P3.5/T1 15

    P2.7/A15 28

    P2.0/A8 21P2.1/A9 22

    P2.2/A10 23P2.3/A11 24P2.4/A12 25P2.5/A13 26P2.6/A14 27

    U2

    AT89C51

    -460

    +12V

    RL2OMI-SH-205

    R11k

    Q22N4403

    +5V

  • ng c bc (Stepper Motor)

    7.6. Giao tip vi ng c bc (Stepper Motor)

    ng c bc n cc 4 pha 4 u dy

    7.6.1. Cc loi ng c bc (Stepper Motor)

    ng c bc lng cc 2 pha 6 u dy

    7.6.1. Cc loi ng c bc (Stepper Motor)

    ng c bc n cc 4 pha 8 u dy

    7.6.1. Cc loi ng c bc (Stepper Motor)

  • 7.6.2. iu khin ng c bc (Full step) 7.6.2. iu khin ng c bc (Full step)

    Chui xung 4 bc iu khin ng c

    Mi bc c mt cun dy ln lt c kch hot

    7.6.2. iu khin ng c bc (Full step) 7.6.2. iu khin ng c bc (Full step)

    Chui xung 4 bc iu khin ng c

    mt bc c 2 cun dy ln lt c kch hot

  • 7.6.2. iu khin ng c bc (Half step) 7.6.2. iu khin ng c bc (Half step)

    7.6.2. iu khin ng c bc (Half step)

    Chui xung 8 bc iu khin ng c

    7.6.3. Ghp ni vi ng c bc

    R310k

    C333p

    C4

    33p

    C5

    33p

    X1CRYSTAL

    R2100

    XTAL218

    XTAL119

    ALE30EA31

    PSEN29

    RST9

    P0.0/AD0 39P0.1/AD1 38P0.2/AD2 37P0.3/AD3 36P0.4/AD4 35P0.5/AD5 34P0.6/AD6 33P0.7/AD7 32

    P1.01P1.12P1.23P1.34P1.45P1.56P1.67P1.78

    P3.0/RXD 10P3.1/TXD 11P3.2/INT0 12P3.3/INT1 13

    P3.4/T0 14

    P3.7/RD 17P3.6/WR 16P3.5/T1 15

    P2.7/A15 28

    P2.0/A8 21P2.1/A9 22

    P2.2/A10 23P2.3/A11 24P2.4/A12 25P2.5/A13 26P2.6/A14 27

    U2

    AT89C51

    1B12B23B34B45B56B67B78B8

    1C 182C 173C 164C 155C 146C 137C 128C 11

    COM 10U1

    ULN2803

    +5V

    1

    ? ?

    1

  • 7.7. Ghp ni vi ADC (Analog to Digital Converter)

    Cm bin (Sensor) chuyn cc i lng vt l dngtng t: nhit , p sut, lu lng, thnh tnhiu in (dng in hoc in p tng t).

    ADC (Analog to Digital Converter B chuyn itng t - s) chuyn cc tn hiu in (tng t)thnh tn hiu s a vo Vi iu khin x l.

    7.7.1. B chuyn i ADC

    7.7.1. B chuyn i ADC

    7.7.1. B chuyn i ADC 7.7.2. B chuyn i ADC 0804

  • 7.7.3. Ghp ni vi ADC 0804

    +5V

    R310k

    C310p

    C4

    33p

    C5

    33p

    X1CRYSTAL

    R2100

    XTAL218

    XTAL119

    ALE30EA31

    PSEN29

    RST9

    P0.0/AD0 39P0.1/AD1 38P0.2/AD2 37P0.3/AD3 36P0.4/AD4 35P0.5/AD5 34P0.6/AD6 33P0.7/AD7 32

    P1.01P1.12P1.23P1.34P1.45P1.56P1.67P1.78

    P3.0/RXD 10P3.1/TXD 11P3.2/INT0 12P3.3/INT1 13

    P3.4/T0 14

    P3.7/RD 17P3.6/WR 16P3.5/T1 15

    P2.7/A15 28

    P2.0/A8 21P2.1/A9 22

    P2.2/A10 23P2.3/A11 24P2.4/A12 25P2.5/A13 26P2.6/A14 27

    U2

    AT89C51

    VIN+ 6VIN- 7

    VREF/2 9

    CLK IN 4

    A GND 8

    RD 2WR 3

    INTR 5

    CS 1

    D GND 10

    DB7(MSB)11DB612DB513DB414DB315DB216DB117DB0(LSB)18

    CLK R 19

    VCC20U1

    ADC0804

    50%

    RV11k

    R110k

    C1100p

    +5V

    00000001

    0 1 10

    7.7.4. B chuyn i ADC 0809

    7.8. Giao tip vi my tnh 7.8.1. Cng giao tip RS 232

  • * 0 # D

    7 8 9

    4

    C

    5 6 B

    1 2 3 A

    +5V

    PA0

    PA1

    PA2

    PA3

    PA4

    PA5

    PA6

    PA7

    Col 0 1 2 3 Row

    0

    1

    2

    3

    10K

    FE

    7.9. Giao tip vi bn phm

    * 0 # D

    7 8 9

    4

    C

    5 6 B

    1 2 3 A

    +5V

    PA0

    PA1

    PA2

    PA3

    PA4

    PA5

    PA6

    PA7

    Col 0 1 2 3 Row

    0

    1

    2

    3

    10K

    FE

    7.9. Giao tip vi bn phm

    Key 0 1 2 3 4 5 6 7 8 9 A B C D *E #FCode D7 EE DE BE ED DD BD EB DB BB 7E 7D 7B 77 E7 B7