robot_line(project 1).pdf

Embed Size (px)

Citation preview

  • 5/26/2018 robot_line(project 1).pdf

    1/26

  • 5/26/2018 robot_line(project 1).pdf

    2/26

    ................................................................................................................

    .........................................................................................11.1 ...................................................................................................................................................................1.2....................................................................1.3

    ..............................................................................1.3.1................................................................................IR1.3.2................................................................................IR1.3.3..................................................................................1.3.4

    .....................................................................................1.41.4.1 ..........................................................................

    .....................................................1.4.1.1...............................................................1.4.1.2

    1.4.2Timer-555..............................................................................

    ............................................................................1.4.3..................................................................................IR1.4.4....................................................................................1.4.5....................................................................................1.4.6.............................................................................1.4.7

    ............................................................................................2..........................................................................................2.1

    ......................................3 .........................................................................)................................................................................(4

    .........................................................................................................................

  • 5/26/2018 robot_line(project 1).pdf

    3/26

    1

    1.1,,-

    ,..,

    :.)(.-)(..)(.

    .,;.

    .,-.)(,

    :..

  • 5/26/2018 robot_line(project 1).pdf

    4/26

    1.2

    1.1:

    1.3 .

  • 5/26/2018 robot_line(project 1).pdf

    5/26

    1.3.1 ,)1.1(1114ORB

    .((IR.

    IR1.3.2)1.2(IR.))IR

    ..

    .

    1.3.3. .

    .

    1.1 1114ORB

    1.2 IR

  • 5/26/2018 robot_line(project 1).pdf

    6/26

    1.4.

    1.4.1.

    .'

    1.4.1.1:,

    ..1..2..3..4..56

    ..:.7

    ))CPU

    ,.-.2.1

    ))RAM.))CPU.))I/O/

    2.1: /

  • 5/26/2018 robot_line(project 1).pdf

    7/26

    PICmicrocontroller16F876- .MICROCHIP

    :4 F87616

    28 .25Mhz

    )ABS ( ///

  • 5/26/2018 robot_line(project 1).pdf

    8/26

    9.1.2 5 .

    :5 16F84

    6Bit A .

    . 8Bit B . 8Bit C PWM .

    .I2C 6

  • 5/26/2018 robot_line(project 1).pdf

    9/26

    2.5 .

    2.5

    .VSS5vVDD

    : ..)(

    .4MHzOSC2 16OSC1 15

    .

    RESET ""1.""0MCLR'4

    RC.

    .

    Flash.MikroCCcompilerC.

    ..HexC

  • 5/26/2018 robot_line(project 1).pdf

    10/26

    :1.4.1.2

    H-BRIDGE",H-Bridge.,

    - .,

    .293L.,.

    .))Enable.4DC.V36A1

    :

    L293

  • 5/26/2018 robot_line(project 1).pdf

    11/26

    :

    ENABLE DIRA DIRB Function

    H H L Turn Right

    H L H Turn Left

    H L/H H/L Fast Stop

    L Either Either Slow Stop

    :

    L293.L2933.5v

    .L2934.5vL293.PWM

    P.W.MPulse Width Modulation

    PWM,.

    .PWM

    On;-T.-T.offTOff;-OnT

  • 5/26/2018 robot_line(project 1).pdf

    12/26

    .,TonT":PWM

    off

    on

    T

    T

    Vavg =Vin

    "+Vduty cycle.duty cycle

    PWM/*************************************************************/

    void speed(char index)

    {

    char i,j;

    EN=ON;

    EN1=ON;

    for(i=0;i

  • 5/26/2018 robot_line(project 1).pdf

    13/26

    AL293.B4B

    PORTAL293

    ..

    Vin

    Motor1

    l293-out1 L293-out2

  • 5/26/2018 robot_line(project 1).pdf

    14/26

    ."12V .-80V (

    ,)..

    L293PORTA=0x05 ; //Forward

    MB1MA1A4/EN1A1 / DIRB1A0 / DIRA1

    0PWMPWM10

    0v5vL293.PWMVin =9v

  • 5/26/2018 robot_line(project 1).pdf

    15/26

    ) .)IR-,

    .,,1

    -,,

    :1

    .,,,

    ,(,(..

    ).')'1,)')'0:

    1.4.2

    1

    2.

    ."

    .

    IR

  • 5/26/2018 robot_line(project 1).pdf

    16/26

    R110k

    R2220

    1

    26

    5

    5v

    5

    6

    7

    8

    4

    U3:BLM258

    5v

    RV210k

    5v

    6 .

    .

    .

    6" ."0

    " ."16

    .LM258

  • 5/26/2018 robot_line(project 1).pdf

    17/26

    .1B0B

    L293

    /**************************************************************/

    void read_sensor()

    {

    char sensor;

    while(1)

    {

    rd_ir();

    if(!stp) break;

    sensor=PORTB&0x03;

    speed(55);

    switch( sensor )

    {

    case 0x00: PORTA=0x0A ; break; //Back

    case 0x01: PORTA=0x04 ; break; // Left

    case 0x02: PORTA=0x01 ; break; //Right

    case 0x03: PORTA=0x05 ; break; //Forward}

    }

    }

    /**************************************************************/

  • 5/26/2018 robot_line(project 1).pdf

    18/26

    IR1.4.3

    ."""". -.,

    "" --LED.,

    ,.,.

    :

    ,.,

    .100000-700nm,""900-700nm

    .""100000-900nm

    ""..

    LED,-LED..

  • 5/26/2018 robot_line(project 1).pdf

    19/26

    IR LED940nm.5V

    IR LED

    .tfms 5400 Infrared ReceiverIR

    .,IR

  • 5/26/2018 robot_line(project 1).pdf

    20/26

    Infrared Receiver

    R310k

    5v

    VI 1

    VO3

    GND

    2

    TFMS5400

    IR Receiver

    RB2

    R2330

    C40.01u

    .40k Hz55540k HzIR

    .

    .B2RBIR40k HzIR""1

    .""0

  • 5/26/2018 robot_line(project 1).pdf

    21/26

    .40k HzIRInfrared Receiver. 555 555

    40k Hz.

    R4

    DC7

    Q3

    GND

    1

    VCC

    8

    TR2

    TH6

    CV5

    U4

    555

    R2150

    R11k

    D1IR

    R3330

    C40.01u

    RV1

    10k

    BAT9V

    C10.01u

    1*)2211(

    44.1

    CRRVRf

    ++

    =

    40k HzR1+RV1 = 3.3K

    RV1 40k Hz 555.3

    5559v.IR3.5553

  • 5/26/2018 robot_line(project 1).pdf

    22/26

    .

    IR.1.""1""1

    ""0IRIR

    2. /**********************************************************/

    3. void rd_ir()

    4. {

    5. char ir_sens;

    6.

    7. while((IR&&!stp)) ;

    8. //delay_ms(20);

    9. if(!IR) stp=~stp;

    10. while(!IR);

    11. }

    12.

    /*************************************************/

    WHILE""17 .

  • 5/26/2018 robot_line(project 1).pdf

    23/26

    .2""1.""0

    3. /*******************************************************/

    4. void read_sensor()

    5. {

    6. char sensor;

    7.

    8. while(1)

    9. {

    10. rd_ir();

    11. if(!stp) break;

    12. sensor=PORTB&0x03;

    13. speed(55);

    14. switch( sensor )

    15. {

    16. case 0x00: PORTA=0x0A ; break; //Back

    17. case 0x01: PORTA=0x04 ; break; // Left

    18. case 0x02: PORTA=0x01 ; break; //Right19. case 0x03: PORTA=0x05 ; break; //Forward

    20. }

    21. }

    22. }

    23.

    24. /***************************************************/

    ()rd_ir-IR()read_sensor-L293PWMIR

    .

  • 5/26/2018 robot_line(project 1).pdf

    24/26

    IR=1

    SR=1

    SL=1 SL=1

    " """

    SRSL

    IR=1

    SR=1

    SL=1 SL=1

    " """

    SRSL

    IR=1

    SR=1

    SL=1 SL=1

    " """

    SRSL

  • 5/26/2018 robot_line(project 1).pdf

    25/26

    #define IR PORTB.F2

    #define EN PORTA.F4

    #define EN1 PORTB.F4

    #define ON 1

    #define OFF 0

    char stp;

    /**************************************************/

    void rd_ir()

    {

    char ir_sens;

    while((IR&&!stp)) ;

    //delay_ms(20);

    if(!IR) stp=~stp;

    while(!IR);}

    /*******************************************************/

    void speed(char index)

    {

    char i,j;

    EN=ON;

    EN1=ON;

    for(i=0;i

  • 5/26/2018 robot_line(project 1).pdf

    26/26

    void init_pic()

    {

    INTCON = 0; // disable all interrupts

    TRISA=0x00;

    TRISB=0x0F;

    }

    /*****************************************************/

    void main()

    {

    init_pic();

    stp=0;

    while(1)

    {

    PORTA=0x00;

    rd_ir();

    read_sensor();}

    }