Sunteți pe pagina 1din 13

IMPLEMENTATION SCHEDULE OF SCRAP

COLLECTOR
Electronics -- USB-FX2 Interface Board (USB-2.0)
This is a USB (universal serial bus) interface board
supporting 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.
[click to enlarge: 233kb JPEG] • 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 cheaper USB8Bit board.

The main component is the CY7C68013A USB-2.0


interface IC ("FX2", actually it's "FX2LP" but don't
mind) from Cypress Semiconductor with integrated
8051 microcontroller. Beyond that, really few external
components 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
[click to enlarge: 153kb PDF]
high-speed devices (like AD/DA converters, hard drives,
FIFOs, etc.).
For more information, have a look at the detailed circuit
description.
Stepper Motor:
Of all motors, step motor is the easiest to control. It's handling
simplicity is really hard to deny - all there
is to do is to bring the sequence of
rectangle impulses to one input of step
controller and direction information to
another input. Direction information is
very simple and comes down to "left" for
logical one on that pin and "right" for
logical zero. Motor control is also very
simple - every impulse makes the motor
operating for one step and if there is no
impulse the motor won't start. Pause
between impulses can be shorter or longer and it defines revolution
rate. This rate cannot be infinite because the motor won't be able to
"catch up" with all the impulses (documentation on specific motor
should contain such information). The picture below represents the
scheme for connecting the step motor to microcontroller and
appropriate program code follows.

The key to driving a stepper is realizing how the motor is constructed.


A diagram shows the representation of a 4 coil motor, so named
because 4 coils are used to cause the revolution of the drive shaft.
Each coil must be energized in the correct order for the motor to spin.

The key to driving a stepper is realizing how the motor is constructed.


A diagram shows the representation of a 4 coil motor, so named
because 4 coils are used to cause the revolution of the drive shaft.
Each coil must be energized in the correct order for the motor to spin.

In Figure 3.3, as in Figure 3.1, boxes are used to represent switches; a


control unit, not shown, is responsible for providing the control signals
to open and close the switches at the appropriate times in order to
spin the motors. The control unit is commonly a computer or
programmable interface controller, with software directly generating
the outputs needed to control the switches.

As with drive circuitry for variable reluctance motors, we must deal


with the inductive kick produced when each of these switches is turned
off. Again, we may shunt the inductive kick using diodes, but now, 4
diodes are required
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 step
angle 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. / step


angle 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't
be 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 or
pause 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 output
to 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 +5V
supply. A Darlington transistor array, ULN2003 is used to increase
driving capacity of the 2051 chip. Four 4.7k resistors help the 2051 to
provide 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.


ASSEMBLY LANGUAGE C LANGUAGE (SPJ)

mov a,#66h ;Load step sequence void main ()


{
AGAIN TMOD = 0x20 ;
mov p2,a ;issue sequence to motor TCON = 0x40 ;
rr a ;rotate step sequence right clockwise=Next sequence TH1 = 0xf9 ;
acall DELAY ;~ 20 msec. TL1 = 0xf9 ;
sjmp AGAIN ;Repete again 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, T1

P0 and P2 are multiplexed with Address and Data bus


EA/VP Pin
The EA on pin 31 is tied high to make the 8051 executes program from
Internal 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.


After a reset, the program counter is loaded with 0000H but the
content of on-chip RAM is
not affected.

Oscillator Circuit

The 8051 uses the crystal


for precisely that: to
synchronize it’s operation.
Effectively, the 8051
operates using what are
called "machine cycles." A
single machine cycle is the minimum amount of time in which a single
8051 instruction can be executed. although many instructions take
multiple 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 ranges
from 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 an


instruction 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?


11.0592 MHz crystals are often used because it can be divided to give
you 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) and
logic "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

1.6mA Sinking current from TTL input to


Low Below 0.9V ground
(Depends on logic family)

1.Configuring for output

P0 is open drain.
– Has to be pulled high by external 10K resistors.
– 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 functioning
as the external address/data bus. When a "0" is written to a bit in port
0, 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, an
external 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 in


these 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 port
P1,P2,P3 is simple.

2. Configuring for input

At power-on all are output ports by default


To configure any port for input, write all 1’s (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 must
be 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 it
for output before. If you don't do this input high voltage will get
grounded 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 is
the UART TXD (serial output). If you set P3.0 to a '0', an external
buffer (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 be


level sensitive, and you clear this pin's output latch to a zero, guess
what? You've just caused a perpetual interrupt 1. The pin's input
buffer 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 appear
to 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, very
slowly.

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
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;
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 initial
hlt

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
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,#50
repeat: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 

S-ar putea să vă placă și