Top Banner

of 12

Robotcup Guide Book

Apr 07, 2018

Download

Documents

Aby Se
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/4/2019 Robotcup Guide Book

    1/12

    8051 Basic Connection

    fig1: 8051 basic connection

    Push Button (tact switch) with LED indicator

    fig2: push button (tact switch) with LED indicator

    When button is LED Logic State

    Pushed Light On 0

    Not Pushed Light Off 1

  • 8/4/2019 Robotcup Guide Book

    2/12

    +5V DC Voltage Supply

    fig3: voltage regulator connection

    Component Description

    1N4001 This rectifier diodes function is to protect voltage regulator 7805 from

    being damaged by reverse polarity battery input. Its forward bias voltage

    is around 1.1V thus the effective voltage supply to 7805 is +10.9V (12V

    1.1V = 10.9V)C1, C4 They smooth the voltage level.

    C2, C3 They are used to suppress high frequency noise. The impedance of

    capacitor is Xc = 1/j2fc, where f is frequency and c is capacitance.The higher the frequency, the lower the impedance. Effectively, high

    frequency noise is being filtered.

    7805 Normal 7805 can supply 1.0A current. For proper operation, the inputvoltage should at least +9V.

    Relay configuration of H-Bridge

    *bat = batteryfig4: H-bridge connection

  • 8/4/2019 Robotcup Guide Book

    3/12

    Component Description

    74HC04 It is a Hex Inverter to act as a

    buffer between microcontroller and

    the ULN2803.It inverts the input logic at the

    output side.

    Input Output

    nA nY

    L (Logic 0) H (Logic 1)

    H (Logic 1) L (Logic 0)

    *H = HIGH voltage levelL = LOW voltage level

    ULN2803 This is Darlington Transistor

    Arrays used to drive high current

    load such as dc motor.

    C1 It is used for high frequency noise filtering.R1, R2 To limit the current flows through the LED. A normal LED (3mm)

    requires 10mA to emit light.V = IR thus R = V / I = 12V / 10mA = 1.2K

    H-Bridge It mainly consists of 2 12V relay, namely RLY1 and RLY2.

    P0.0 D1 P0.1 D2 Motor state

    L On L On Stop

    L On H Off CCW

    H Off L On CW

    H Off H Off Stop

    *H = HIGH voltage levelL = LOW voltage level

    CW = Clockwise direction (assume that current flow from M1 to M2

    is CW)CCW = Counter Clockwise direction (assume that current flow from

    M2 to M1 is CCW)

  • 8/4/2019 Robotcup Guide Book

    4/12

    Extra Note on H-Bridge

    fig5: Comparison of pin layout of real relay component and the schematic symbol

    fig6: Basic H-Bridge.

  • 8/4/2019 Robotcup Guide Book

    5/12

    H-Bridge Working Principle

    fig7: Clock-Wise (CW) direction

    NO = Normally Open

    NC = Normally CloseCOM = Common

    Coil1 = one side of coil named as coil1Coil2 = another side of coil named as coil2

    Clock-Wise (CW) direction

    1. When P0.1 is cleared (LOW state), 74HC04 will invert it and output to 2Y as

    HIGH state. This High state will be inverted again by ULN2803 to LOWstate at pin 17.

    2. Since there is a voltage difference between Coil1 and Coil2 (relay on your right

    hand side), current will flows through the coil and generate magnetic field to pullthe internal switch from NC to NO.

    3. Now a voltage difference appears between M1 and M2. Thus current flows from

    +12V terminal -> M1 -> M2 -> GND. (assume that current flow from M1 to M2is CW)

  • 8/4/2019 Robotcup Guide Book

    6/12

    fig8: Counter Clock-Wise (CCW) direction

    Counter Clock-Wise (CCW) direction

    4. When P0.0 is cleared (LOW state), 74HC04 will invert it and output to 1Y as

    HIGH state. This High state will be inverted again by ULN2803 to LOWstate at pin 18.

    5. Since there is a voltage difference between Coil1 and Coil2 (relay on your right

    hand side), current will flows through the coil and generate magnetic field to pull

    the internal switch from NC to NO.6. Now a voltage difference appears between M1 and M2. Thus current flows from

    +12V terminal -> M2 -> M1 -> GND. (assume that current flow from M2 to M1

    is CCW)

  • 8/4/2019 Robotcup Guide Book

    7/12

    Programming

    Below are the simple assembly codes that can perform triggering the relay by pressing abutton.;Simple button pressing and trigger on relays assembly code.

    ORG 0000

    MAIN: SETB P2.0 ;clear P2.0, and wait for another button pressSETB P2.1 ;clear P2.1, and wait for another button press

    OK1: JNB P1.0, RELAY1 ;wait for P1.0 button press, and jump to Relay1JNB P1.1, RELAY2 ;wait for P1.0 button press, and jump to Relay1JMP MAIN

    RELAY1: CLR P2.0 ;trigger on relay at P2.0JMP OK1 ;jump back button press inspection loop

    RELAY2: CLR P2.1 ;trigger on relay at P2.1JMP OK1 ;jump back button press inspection loop

    END

    Description of the code:Button1 = Pin 1.0 of the micro-controller

    Button2= Pin 1.1 of the micro-controllerRelay1= Pin 2.0 require to connect to a transistor to trigger on the first relay.

    Relay2= Pin 2.1 require to connect to a transistor to trigger on the second relay.

    Operation of the code:

    The operation of this code is simple.

    When you press the button1 (that require to grounding the P1.0), relay1 will turn on (with

    pin2.0 set to low that will turn on a PNP transistor for trigger on a relay).When yourelease pressing button1, P2.0 will set to high, and relay1 will turn off.

    The same response will show with respective pin configuration when youpressing/release button2.

    Step by step of using Fet89c5x.

    Step1

  • 8/4/2019 Robotcup Guide Book

    8/12

    - Write your code in Fet89c5x.

    Step2

    -go to -> file, -> save as; to save your code that you had wrote to a specific location.

  • 8/4/2019 Robotcup Guide Book

    9/12

    Step3

    - Compile your code by pressing the build icon .- A .hex file will generate after compile the code.

    - There will be a massage box to show how many errors in your code.

    Step by step of using 8052Simulator.

  • 8/4/2019 Robotcup Guide Book

    10/12

    Step1

    - Open 8052SIM.exe (this program not requires to install).

    - Go to View, and then select I/O ports and SFR window.- I/O ports window is for you to observe the I/O ports response; SFR window is for you

    to observe Special Function Registers value while program running.

    Step2

    -open the .hex file from respective location that you had save your code.

  • 8/4/2019 Robotcup Guide Book

    11/12

    Step3

    - Run your program (by pressing the icon ) and observe the Ports window

    response.

    - Un-tick (set low) the P1.0 box at the Ports window. You will see P2.0 box also

    follow un-tick. Tick (set high) the P1.0 box, P2.0 will follow to tick back.

    - The same response will show when you tick/ un-tick P1.1 box.

  • 8/4/2019 Robotcup Guide Book

    12/12

    Following are the sample code for simple LED blinking.;simple led blinking

    ORG 0000HMOV P1, 0FFHMOV P2, 0FFH

    START: JNB P1.0 , LEDBLINK JMP START

    STOP: CLR P2.0JMP START

    LEDBLINK: CLR P2.0CALL DELAY_1SECCLR P2.0JNB P1.1, STOPJMP LEDBLINK

    ;The subroutine below causes a delay of 1 second;(crystal frequency = 12 MHz)

    DELAY_1SEC:MOV R0, #4 ;1 machine cycle

    REPEAT: MOV R1, #250 ;1 machine cycleAGAIN: MOV R2, #250 ;1 machine cycleHERE: NOP ;1 machine cycle

    NOP ;1 machine cycleDJNZ R2, HERE ;2 machine cycleDJNZ R1, AGAIN ;2 machine cycleDJNZ R0, REPEAT ;2 machine cycle

    RET ;2 machine cycle

    END

    (For the LED blinking code, you might not be able to observe the response of I/O ports

    by using 8952Simulator program because of 8952Simulator cant simulate the real timedelay, and you might wait for long time to count a second delay.)