Saturday, November 7, 2009

8051 to Stepper Motor Interfacing


BASICS OF 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.


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 LM293D.

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.



Coil AA’
Coil BB’
Coil CC’
Coil DD’
Step
1
0
0
0
1
0
1
0
0
2
0
0
1
0
3
0
0
0
1
4


Programming


        MOV B,#data \\Number of Rotation
        MOV A,#11
L:     MOV P2,A
        RR A
        DEC B
        JNZ L





Thursday, October 8, 2009

LCD Interfacing with MicroController

LCD Backgorund

Frequently, an 8051 program must interact with the outside world using input and output devices that communicate directly with a human being. One of the most common devices attached to an 8051 is an LCD display. Some of the most common LCDs connected to the 8051 are 16x2 and 20x2 displays. This means 16 characters per line by 2 lines and 20 characters per line by 2 lines, respectively.
Fortunately, a very popular standard exists which allows us to communicate with the vast majority of LCDs regardless of their manufacturer. The standard is referred to as HD44780U, which refers to the controller chip which receives data from an external source (in this case, the 8051) and communicates directly with the LCD.
The 44780 standard requires 3 control lines as well as either 4 or 8 I/O lines for the data bus. The user may select whether the LCD is to operate with a 4-bit data bus or an 8-bit data bus. If a 4-bit data bus is used the LCD will require a total of 7 data lines (3 control lines plus the 4 lines for the data bus). If an 8-bit data bus is used the LCD will require a total of 11 data lines (3 control lines plus the 8 lines for the data bus).


The three control lines are referred to as EN, RS, and RW.

The EN line is called "Enable." This control line is used to tell the LCD that you are sending it data. To send data to the LCD, your program should make sure this line is low (0) and then set the other two control lines and/or put data on the data bus. When the other lines are completely ready, bring EN high (1) and wait for the minimum amount of time required by the LCD datasheet (this varies from LCD to LCD), and end by bringing it low (0) again.

The RS line is the "Register Select" line. When RS is low (0), the data is to be treated as a ommand or special instruction (such as clear screen, position cursor, etc.). When RS is high (1), the data being sent is text data which sould be displayed on the screen. For example, to display the letter "T" on the screen you would set RS high.

The RW line is the "Read/Write" control line. When RW is low (0), the information on the data bus is being written to the LCD. When RW is high (1), the program is effectively querying (or reading) the LCD. Only one instruction ("Get LCD status") is a read command. All others are write commands--so RW will almost always be low.

HANDLING THE EN CONTROL LINE

As we mentioned above, the EN line is used to tell the LCD that you are ready for it to execute an instruction that you've prepared on the data bus and on the other control lines. Note that the EN line must be raised/lowered before/after each instruction sent to the LCD regardless of whether that instruction is read or write, text or instruction. In short, you must always manipulate EN when communicating with the LCD. EN is the LCD's way of knowing that you are talking to it. If you don't raise/lower EN, the LCD doesn't know you're talking to it on the other lines.

Thus, before we interact in any way with the LCD we will always bring the EN line low with the
following instruction:
CLR EN
And once we've finished setting up our instruction with the other control lines and data bus lines,
we'll always bring this line high:
SETB EN
The instruction is executed by the LCD at the moment the EN line is brought low with a final
CLR EN instruction.

INITIALIZING THE LCD

Before you may really use the LCD, you must initialize and configure it. This is accomplished by
sending a number of initialization instructions to the LCD.

The first instruction we send must tell the LCD whether we'll be communicating with it with an 8-bit or 4-bit data bus. We also select a 5x8 dot character font. These two options are selected by sending the command 38h to the LCD as a command. As you will recall from the last section, we mentioned that the RS line must be low if we are sending a command to the LCD.

Programming Tip: The LCD command 38h is really the sum of a number of option bits. The instruction itself is the instruction 20h ("Function set"). However, to this we add the values 10h to indicate an 8-bit data bus plus 08h to indicate that the display is a two-line display.

We've now sent the first byte of the initialization sequence. The second byte of the initialization
sequence is the instruction 0Eh.

Programming Tip: The command 0Eh is really the instruction 08h plus 04h to turn the LCD on. To that an additional 02h is added in order to turn the cursor on.

The last byte we need to send is used to configure additional operational parameters of the LCD.
We must send the value 06h.

Programming Tip: The command 06h is really the instruction 04h plus 02h to configure the
LCD such that every time we send it a character, the cursor position automatically moves to the
right.

CLEARING THE DISPLAY

An LCD command exists to accomplish this function. Not suprisingly, it is the command 01h.

Programming Tip: Executing the "Clear Screen" instruction on the LCD also positions the
cursor in the upper left-hand corner as we would expect.

http://rapidshare.de/files/48540357/LCD_8051.pdf.html

Tuesday, September 22, 2009

Mobile controlled Robot

This is the complete detail you can have to create your own Global Robo that can be driven by sending DTMF tones from your mobile phone!!!!!!! "" Yes!! your mobile phone""

All you need to do is to have a DTMF tone decoder IC and some capacitors and resisors to complete the circuitry along with two mobile phones and a headphone for inputting the DTMF tones into the circuitry and you are done.

The complete list of bill of materials is provided below along with the circuitry with a little explanation of how the complete circuit works.




Bill of Materials:
MT8870 dtmf decoder ic
100k resitor 2pc.
300k resistor 1pc.
3.57945Mhz crystal oscillator
0.1 uf capacitor 2pc.
4 LED
connecting wires....





Working: while the input from the mobile using a headphone is connected b/w the 0.1uf capacitor and the ground, DTMF tones can be transferred to the decoder ic(8870) and once the ic is powered up the o/p can be seen by connecting LED's at Q!, Q2, Q3 and Q4 o/p of the decoder ic.
The output on the Q1 to Q4 pins of the decoder IC has been shown in the image.

the o/p of the decoder ic then can be connected to a motor driver ic like(L298 or L293D) to drive some motors or relays as a switch to operate some devices remotely as the Mobile phone connected can be called from anywhere in the world and by pressing the keys the DTMF tones can be transmitted to the receiving end mobile and hence any device connected can be operated globally.

As soon i get a camera i will Upload the image of my circuit and the robo i made and operated using my mobile phone.