scrap collector implementation

Upload: nany-indresh

Post on 10-Apr-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/8/2019 Scrap Collector Implementation

    1/13

    IMPLEMENTATION SCHEDULE OF SCRAP

    COLLECTOR

    Electronics -- USB-FX2 Interface Board (USB-2.0)

    [click to enlarge: 233kb JPEG]

    This is a USB (universal serial bus) interface boardsupporting USB-2.0 high speed mode (480Mbit/s).

    Features:

    Throughput: Actual continuous transfer rates of

    35Mb/s (mega bytes not bits).

    Flexibility: On-board 8051 microcontroller with

    16kb RAM.

    FIFO IO: 8 or 16 bit wide, additional handshake

    lines, 3.3V logic. Several USB endpoints and buffering

    configurations (up to 512 bytes, quad-buffered);

    bulk, isochronous and interrupt transfer.

    Several additional free digital IO lines.

    Firmware download via USB; optional non-

    volatile 64kb EEPROM.

    USB-powered and externally powered operation.

    Very few discrete components.

    If you would simply like to connect a microcontroller board to a computer

    using USB but don't need massive bandwidth (less than 800kb/s), then you

    may want to have a look at the smaller and cheaperUSB8Bit board.

    [click to enlarge: 153kb PDF]

    The main component is the CY7C68013A USB-2.0

    interface IC ("FX2", actually it's "FX2LP" but don'tmind) fromCypress Semiconductorwith integrated

    8051 microcontroller. Beyond that, really few externalcomponents are required.

    It includes a 5V-to-3.3V low-drop regulator to provide

    the 3.3V logic level. Access to all data, control,handshake and clock pins is granted via dedicated

    connectors and allows direct interfacing to a variety of

    high-speed devices (like AD/DA converters, hard drives,FIFOs, etc.).

    For more information, have a look at the detailed circuit

    description.

    http://www.triplespark.net/elec/periph/USB-FX2/usb-fx2-r2-top.jpghttp://www.triplespark.net/elec/periph/USB8Bit/http://www.triplespark.net/elec/periph/USB-FX2/usb-fx2.pdfhttp://www.cypress.com/http://www.cypress.com/http://www.triplespark.net/elec/periph/USB-FX2/circuit.htmlhttp://www.triplespark.net/elec/periph/USB-FX2/circuit.htmlhttp://www.triplespark.net/elec/periph/USB-FX2/usb-fx2.pdfhttp://www.triplespark.net/elec/periph/USB-FX2/usb-fx2-r2-top.jpghttp://www.triplespark.net/elec/periph/USB-FX2/usb-fx2-r2-top.jpghttp://www.triplespark.net/elec/periph/USB8Bit/http://www.triplespark.net/elec/periph/USB-FX2/usb-fx2.pdfhttp://www.cypress.com/http://www.triplespark.net/elec/periph/USB-FX2/circuit.htmlhttp://www.triplespark.net/elec/periph/USB-FX2/circuit.html
  • 8/8/2019 Scrap Collector Implementation

    2/13

  • 8/8/2019 Scrap Collector Implementation

    3/13

    Step angle

    It is angle through which motor shaft rotates in one step. step angle is

    different for different motor . selection of motor according to stepangle depends on the application , simply if you require small

    increments in rottion choose motor having smaller step angle.

    No of steps require to rotate one complete rotation = 360 deg. / stepangle in deg.

    Steps/second

    The relation between RPM and steps per sec. is given by ,steps or impulses /sec. =(RPM X Steps /revolution ) /60

    Pause between impulses can be shorter or longer and it defines

    revolution rate. This rate cannot be infinite because the motor won'tbe able to "catch up" with all the impulses (documentation on specific

    motor should contain such information). So referring to RPM value in

    datasheet you can calculate steps/sec and from it delay orpause between impulses

    INTERFACING TO 8051.

    To cause the stepper to rotate, we have to send a pulse to each coil in

    turn. The 8051 does not have sufficient drive capability on its outputto drive each coil, so there are a number of ways to drive a stepper,

    Stepper motors are usually controlled by transistor or driver IC like

    ULN2003.

    Driving current for each coil is then needed about 60mA at +5Vsupply. A Darlington transistor array, ULN2003 is used to increase

    driving capacity of the 2051 chip. Four 4.7k resistors help the 2051 toprovide more sourcing current from the +5V supply.

    CODE EXAMPLE

    To move motor in forward direction continuously

    Connection -P1.0 -P1.3 connected to Coils A -D.

  • 8/8/2019 Scrap Collector Implementation

    4/13

    EMBLY LANGUAGE C LANGUAGE (SPJ)

    mov a,#66h ;Load step sequence

    AGAIN

    mov p2,a ;issue sequence to motorr a ;rotate step sequence right clockwise=Next sequence

    call DELAY ;~ 20 msec.

    jmp AGAIN ;Repete again

    void main ()

    {

    TMOD = 0x20 ;

    TCON = 0x40 ;TH1 = 0xf9 ;

    TL1 = 0xf9 ;

    PCON = 0x80 ;

    SCON = 0x50 ;

    while (1) /*continues loop */

    {

    printf("a"); /* transmit a along with CR & LF.

    }

    Basic Circuit for 8051

    8051 PIN OUT

    Power - Vcc, Vss

    Reset - RST

    Crystal - XTAL[1,2]External device interfacing

    EA, ALE, PSEN, WR, RD

    I/O Port P0[7;0], P1[7:0], P2[7:0], P3

    P3 is shared with control lines

    Serial I/O RxD, TxD, external interrupts INT0, INT1

    Counter control T0, T1P0 and P2 are multiplexed with Address and Data bus

  • 8/8/2019 Scrap Collector Implementation

    5/13

  • 8/8/2019 Scrap Collector Implementation

    6/13

    EA/VP Pin

    The EA on pin 31 is tied high to make the 8051 executes program fromInternal ROM

    Reset Circuit

    RESET is an active High input When RESET is set to High, 8051 goes

    back to the power on state.The 8051 is reset by holding the RST high for at least two machine

    cycles and then returning it low.

    Power-On Reset

    - Initially charging of capacitor makes RST High- When capacitor charges fully it blocks DC.

    Manual reset

    -closing the switch momentarily will make RST High.

  • 8/8/2019 Scrap Collector Implementation

    7/13

    After a reset, the program counter is loaded with 0000H but thecontent of on-chip RAM is

    not affected.

    Oscillator Circuit

    The 8051 uses the crystalfor precisely that: to

    synchronize its operation.Effectively, the 8051

    operates using what are

    called "machine cycles." Asingle machine cycle is the minimum amount of time in which a single

    8051 instruction can be executed. although many instructions takemultiple cycles.

    8051 has an on-chip oscillator. It needs an external crystal thats

    decides the operating frequency of the 8051.

    This can be achieved in two ways,,

    The crystal is connected to pins 18 and 19 with stabilizing capacitors.

    12 MHz(11.059MHz) crystal is often used and the capacitance rangesfrom 20pF to 40pF.

    The oscillator can also be a TTL clock source connected with a NOT

    gate asshown

    How fast 8051 works ?

    A cycle is, in reality, 12 pulses of the crystal. That is to say, if aninstruction takes one machine cycle to execute, it will take 12 pulses of

    the crystal to execute. Since we know the crystal is pulsing

    11,059,000 times per second and that one machine cycle is 12 pulses,we can calculate how many instruction cycles the 8051 can execute

    per second:

    11,059,000 / 12 = 921,583

    Why is such an oddball crystal frequency?

  • 8/8/2019 Scrap Collector Implementation

    8/13

    11.0592 MHz crystals are often used because it can be divided to giveyou exact clock rates for most of the common baud rates for the

    UART, especially for the higher speeds (9600, 19200). Despite the"oddball" value, these crystals are readily available and commonly

    used.

    Power Supply

    C1-1000 mf ,C2-100 mf

    The 78L05 is a 5V regulator. The input voltage ranges from 7V to 35V

    and the output voltage is about 5V.

    Using Ports for I/O Operation

    8051 is TTL logic device. TTL logic has two levels: Logic "High" (1) andlogic "Low" (0). The voltage and current involved for the two levels are

    as follows:

    Level Voltage Current

    High Above 2.4V Virtually no current flow

    Low Below 0.9V1.6mA Sinking current from TTL input toground

    (Depends on logic family)

    1.Configuring for output

    P0 is open drain. Has to be pulled high by external 10K resistors.

  • 8/8/2019 Scrap Collector Implementation

    9/13

    Not needed if P0 is used for address lines

    Writing to a port pin loads data into a port latch that drives a FET

    connected to the port pin.

    P0: Note that the pull-up is absent on Port 0 except when functioningas the external address/data bus. When a "0" is written to a bit in port0, the pin is pulled low. But when a "1" is written to it, it is in high

    impedance (disconnected) state. So when using port 0 for output, anexternal pull-up resistor is needed, depending on the input

    characteristics of the device driven by the port pin

    P1, P2, P3 have internal pull-ups: When a "0" is written to a bit inthese port , the pin is pulled low ( FET-ON) ,also when 1 is written to

    a bit in these port pin becomes high (FET-OFF) thus using portP1,P2,P3 is simple.

    2. Configuring for input

    At power-on all are output ports by defaultTo configure any port for input, write all 1s (0xFF) to the port

    Latch bit=1, FET=OFF, Read Pin asserted by read instruction

    You can used a port for output any time. But for input, the FET mustbe off. Otherwise, you will be reading your own latch rather than the

    signal coming from the outside. Therefore, a "1" should be written to

    the pin if you want to use it as input, especially when you have used itfor output before. If you don't do this input high voltage will getgrounded through FET so you will read pin as low and not as high. An

    external device cannot easily drive it high

    so, you should not tide a port high directly without any resistor.Otherwise, the FET would burn.

    Be Careful :

    Some port pins serve multiple functions. Be careful writing to such

    ports. For example, P3.0 is the UART RXD (serial input), and P3.1 isthe UART TXD (serial output). If you set P3.0 to a '0', an externalbuffer (such as an RS232 level translator) cannot drive it high.

    Therefore you have prevented receiving any serial input.

    If an external interrupt such as EX1 on P3.3 is enabled, and set to belevel sensitive, and you clear this pin's output latch to a zero, guess

  • 8/8/2019 Scrap Collector Implementation

    10/13

    what? You've just caused a perpetual interrupt 1. The pin's inputbuffer will read the output of it's latch as always low. Your controller

    will spend all of its time in the interrupt handler code and will appearto have crashed, since it will have very little time for other tasks. In

    fact, it will get to execute a single instruction before re-entering the

    interrupt handler, so the rest of your program will execute very, veryslowly.

    MACHINE CONTROL:

    Three IR sensors are placed in the front of the machine. So the inputs can be considered

    as a three bit word with the following possibilities of output

    0 0 0(00h) the machine must continue moving straight.

    0 0 1 (01h) the machine has encountered an obstacle in the left and hence has to move

    right.

    1 0 0(04h) the machine has encountered an obstacle in the right and hence has to move

    left.

    0 1 1(03h) the machine must move left twice and continue moving forward.

    1 1 0(03h) the machine must move right twice and continue moving forward.

    0 1 0(02h) the machine must use its arm.

    1 1 1(07h) the machine must move back and turn left or right

  • 8/8/2019 Scrap Collector Implementation

    11/13

    PROGRAM CODING FOR 8051:

    mov b,#00;

    mov a,#00;initial:mov a,p1;cmp a,#00;

    jnz l1;

    jmp drive;l1: cmp a,#01;

    jnz l2;

    jmp back;jmp right;

    l2:cmp a,#04;

    jnz l3;jmp back;

    jmp left;

    l3:cmp a,#03;

    jnz l4;

    jmp back;jmp left;

  • 8/8/2019 Scrap Collector Implementation

    12/13

    jmp left;

    l4:cmp a,#06;jnz l5;

    jmp back;

    jmp right;jmp right;

    l5:cmp a,#02;jnz l6;

    jmp arm;

    l6:cmp a,#07;jnz l7;

    jmp back;

    jmp right;

    l7:jmp initialhlt

    drive:

    mov ro,a;

    mov a,#ffh ;Load step sequence

    mov p2,a ;issue sequence to motor

    rr a ;rotate step sequence right clockwise=Next sequence

    acall DELAY ;~ 20 msec.mov a,ro;

    ret;

    back:

    mov ro,a;

    mov a,#66h ;Load step sequence

    mov p2,a ;issue sequence to motor

    rr a ;rotate step sequence right clockwise=Next sequence

    acall DELAY ;~ 20 msec.mov a,ro;

    setb p3.1;

    ret;

    right:

    mov ro,a;mov a,#66h ;Load step sequence

    mov p2,a ;issue sequence to motor

    rr a ;rotate step sequence right clockwise=Next sequence

  • 8/8/2019 Scrap Collector Implementation

    13/13

    acall DELAY ;~ 20 msec.

    mov a,ro;

    setb p3.2;

    ret;

    left:

    mov ro,a;

    mov a,#66h ;Load step sequence

    mov p2,a ;issue sequence to motor

    rr a ;rotate step sequence right clockwise=Next sequence

    acall DELAY ;~ 20 msec.mov a,ro;

    setb p3.3;

    ret;

    arm:mov ro,a;

    mov a,#ffh ;Load step sequence

    mov r1,#50repeat:mov p2,a ;issue sequence to motor

    rr a ;rotate step sequence right clockwise=Next sequence

    acall DELAY ;~ 20 msec.dec r1;

    jnz repeat;

    mov a,ro;

    ret;

    PROJECT ESTIMATION:

    OBJECTS-COST:

    8051 microcontroller

    Uln2038

    Lm7235

    Battery

    Stepper motor

    Usb 8051 driver

    Body plate

    Bread board

    Connecting wires