0% found this document useful (0 votes)
1 views31 pages

Module5 - Interfacing Only

The document discusses the interfacing of stepper motors, DACs, ADCs, and LCDs with microcontrollers, specifically the 8051. It explains the construction, operation, and programming of stepper motors, as well as the principles of DAC and ADC conversion processes. Additionally, it covers the use of LCDs for displaying information and the commands needed for their operation.

Uploaded by

sreeni 1005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views31 pages

Module5 - Interfacing Only

The document discusses the interfacing of stepper motors, DACs, ADCs, and LCDs with microcontrollers, specifically the 8051. It explains the construction, operation, and programming of stepper motors, as well as the principles of DAC and ADC conversion processes. Additionally, it covers the use of LCDs for displaying information and the commands needed for their operation.

Uploaded by

sreeni 1005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 31

Stepper Motor Interfacing:

Stepper motor is a widely used device that translates electrical pulses into mechanical movement.
Stepper motor is used in applications such as; disk drives, dot matrix printer, robotics etc,. The
construction of the motor is as shown in figure below.

Figure: Structure of stepper motor


It has a permanent magnet rotor called the shaft which is surrounded by a stator. Commonly used
stepper motors have four stator windings that are paired with a center – tapped common. Such motors
are called as four-phase or unipolar stepper motor. The stator is a magnet over which the electric
coil is wound. One end of the coil are connected commonly either to ground or +5V. The other
end is provided with a fixed sequence such that the motor rotates in a particular direction. Stepper
motor shaft moves in a fixed repeatable increment, which allows one to move it to a precise
position. Direction of the rotation is dictated by the stator poles. Stator poles are determined by the
current sent through the wire coils.

Step angle: Step angle is defined as the minimum degree of rotation with a single step.
No of steps per revolution = 360° / step angle Steps per second = (rpm x steps per revolution) / 60
Example: step angle = 2° No of steps per revolution = 180

Switching Sequence of Motor: As discussed earlier the coils need to be energized for the
rotation. This can be done by sending a bits sequence to one end of the coil while the other end is
commonly connected. The bit sequence sent can make either one phase ON or two phase ON for a
full step sequence or it can be a combination of one and two phase ON for half step sequence.
Both are tabulated below.
Full Step: Two Phase ON
Half Step (8 – sequence): The sequence is tabulated as below:

Figure: 8051 interface to stepper motor

The following example 1 to example 6 shown below will elaborate on the discussion done above:
Example 1: Write an ALP to rotate the stepper motor clockwise / anticlockwise continuously with full
step sequence.
Program:
MOV A, #66H
BACK: MOV P1, A
RR A
ACALL DELAY
SJMP BACK
DELAY: MOV R1, #100
UP1: MOV R2, #50
UP: DJNZ R2, UP
DJNZ R1, UP1
RET

Note: motor to rotate in anticlockwise use instruction RL A instead of RR A


Programming Stepper Motor with 8051 C
The following examples 5 and 6 will show the programming of stepper motor using 8051 C.
Digital-to-Analog (DAC) converter:
The DAC is a device widely used to convert digital pulses to analog signals. In this section we
will discuss the basics of interfacing a DAC to 8051. The two method of creating a DAC is binary
weighted and R/2R ladder. The Binary Weighted DAC, which contains one resistor or current
source for each bit of the DAC connected to a summing point. These precise voltages or currents
sum to the correct output value. This is one of the fastest conversion methods but suffers from poor
accuracy because of the high precision required for each individual voltage or current. Such high-
precision resistors and current-sources are expensive, so this type of converter is usually limited to 8-
bit resolution or less.

The R-2R ladder DAC, which is a binary weighted DAC that uses a repeating cascaded structure
of resistor values R and 2R. This improves the precision due to the relative ease of producing equal
valued matched resistors (or current sources). However, wide converters perform slowly due to
increasingly large RC-constants for each added R-2R link.
The first criterion for judging a DAC is its resolution, which is a function of the number of binary
inputs. The common ones are 8, 10, and 12 bits. The number of data bit inputs decides the
resolution of the DAC since the number of analog output levels is equal to 2n, where n is the
number of data bit inputs. DAC0808: The digital inputs are converter to current Iout, and by
connecting a resistor to the Iout pin, we can convert the result to voltage. The total current Iout is a
function of the binary numbers at the D0-D7 inputs of the DAC0808 and the reference current Iref ,
and is as follows:

Usually reference current is 2mA. Ideally we connect the output pin to a resistor, convert this current
to voltage, and monitor the output on the scope. But this can cause inaccuracy; hence an opamp is
used to convert the output current to voltage. The 8051 connection to DAC0808 is as shown in
the figure below.
Figure: 8051 connection to DAC0808
The following examples 9, 10 and 11 will show the generation of waveforms using DAC0808.
Analog-to-digital converter (ADC) interfacing:
ADCs (analog-to-digital converters) are among the most widely used devices for data acquisition.
A physical quantity, like temperature, pressure, humidity, and velocity, etc., is converted to
electrical (voltage, current) signals using a device called a transducer, or sensor We need an
analog-to-digital converter to translate the analog signals to digital numbers, so microcontroller can
read them. ADC804 chip: ADC804 IC is an analog-to-digital converter. It works with +5 volts and
has a resolution of 8 bits. Conversion time is another major factor in judging an ADC. Conversion
time is defined as the time it takes the ADC to convert the analog input to a digital (binary) number.
In ADC804 conversion time varies depending on the clocking signals applied to CLK R and CLK
IN pins, but it cannot be faster than 110μs.

Pin Description of ADC804:


CLK IN and CLK R: CLK IN is an input pin connected to an external clock source. To use the
internal clock generator (also called self-clocking), CLK IN and CLK R pins are connected to a
capacitor and a resistor and the clock frequency is determined by:
Typical values are R = 10K ohms and C =150pF. We get f = 606 kHz and the conversion time is
110μs.
Vref/2 : It is used for the reference voltage. If this pin is open (not connected), the analog input voltage
is in the range of 0 to 5 volts (the same as the Vcc pin). If the analog input range needs to be 0 to
4 volts, Vref/2 is connected to 2 volts. Step size is the smallest change can be discerned by an
ADC
D0-D7: The digital data output pins. These are tri-state buffered. The converted data is accessed only
when CS =0 and RD is forced low. To calculate the output voltage, use the following formula

Dout = digital data output (in decimal),


Vin = analog voltage, and
step size (resolution) is the smallest change

Analog ground and digital ground: Analog ground is connected to the ground of the analog Vin
and digital ground is connected to the ground of the Vcc pin. To isolate the analog Vin signal from
transient voltages caused by digital switching of the output D0 – D7. This contributes to the
accuracy of the digital data output.

Vin(+) & Vin(-): Differential analog inputs where Vin = Vin (+) – Vin (-). Vin (-) is connected to
ground and Vin (+) is used as the analog input to be converted.

RD: Is “output enable” a high-to-low RD pulse is used to get the 8-bit converted data out of ADC804.

INTR: It is “end of conversion” When the conversion is finished, it goes low to signal the CPU
that the converted data is ready to be picked up.

WR: It is “start conversion” When WR makes a low-to-high transition, ADC804 starts converting the
analog input value of Vin to an 8- bit digital number.
CS: It is an active low input used to activate ADC804.

The following steps must be followed for data conversion by the ADC804 chip:
1. Make CS= 0 and send a L-to-H pulse to pin WR to start conversion.
2. Monitor the INTR pin, if high keep polling but if low, conversion is complete, go to next step.
3. Make CS= 0 and send a H-to-L pulse to pin RD to get the data

out The following figure shows the read and write timing for

ADC804.
The following figures shows the self-clocking with the RC component for frequency and the external
frequency connected to XTAL2 of 8051.
ADC0808/0809 chip: ADC808 has 8 analog inputs. It allows us to monitor up to 8 different
transducers using only single chip. The chip has 8-bit data output just like the ADC804. The 8 analog
input channels are multiplexed and selected according to the values given to the three address pins, A,
B, and C. that is; if CBA=000, CH0 is selected; CBA=011, CH3 is selected and so on. The pin details
of ADC0808 are as shown in the figure below. (Explanation can be done as is with ADC0804).

Steps to Program ADC0808/0809


1. Select an analog channel by providing bits to A, B, and C addresses.
2. Activate the ALE pin. It needs an L-to-H pulse to latch in the address.
3. Activate SC (start conversion) by an H-to-L pulse to initiate conversion.
4. Monitor EOC (end of conversion) to see whether conversion is finished.
5. Activate OE (output enable) to read data out of the ADC chip. An H-to-L pulse to the OE pin
will bring digital data out of the chip.
LCD Interfacing:
LCD is finding widespread use replacing LEDs for the following reasons: The declining prices of LCD
The ability to display numbers, characters, and graphics Incorporation of a refreshing controller
into the LCD, thereby relieving the CPU of the task of refreshing the LCD Ease of programming
for characters and graphics.
Command codes
LCD timing diagram for reading and writing is as shown in the below figures.

Sending Data/ Commands to LCDs with Time Delay: To send any of the commands to the LCD,
make pin RS=0. For data, make RS=1. Then send a high-to-low pulse to the E pin to enable the
internal latch of the LCD.
****************************************************************************************

You might also like