J C C Jeewandara (719225784) Eex4336 Tma #2
J C C Jeewandara (719225784) Eex4336 Tma #2
J C C Jeewandara (719225784) Eex4336 Tma #2
TMA – 02
EEX4436
MICROPROCESSORS AND INTERFACING
DC Motor
DC motors are known as Direct Current motors which have two wire of power and ground. DC
motor runs until the power is removed that we have supply. DC motors run in high revolution per
minute. By controlling pulse width modulation DC motor can manage the power on off option.
Servo motor
A servo motor (or servo motor) is a simple electric motor controlled by servo mechanics. If the
motor is a DC motor connected to a servomechanism, such as a controlled device, it is usually
called a DC servo motor. If a controlled AC motor is used, it is called an AC servo motor. It
consists of a motor coupled to a sensor for position feedback. The main reason for using a servo
motor is that it provides angular precision, only rotates as far as we want and then stops and
waits for the next one. A servo motor is different from a normal electric motor in that it starts
rotating as soon as we turn on the power and continues to rotate until we turn off the power. We
cannot control the rotation progress of an electric motor but we can control the rotation speed
and turn it on and off.
Stepper motor
Stepper motors are DC motors that move in discrete steps. They have multiple windings
organized into groups called "phases". By firing each phase sequentially, the motor rotates step
by step. Stepper motors come in many different sizes and styles and electrical characteristics.
Unlike a DC motor, the current consumption of a stepper motor does not depend on the
load. They attract the most reality when they are doing nothing. So with that it turns hot. Unlike
servo motors, most steppers do not have integral position feedback. Some steps are optimized for
higher speed performance, but must be paired with a suitable drive to achieve this performance.
(b) Explain the mechanisms to control the rotation direction, rotation angle, and
rotation speed of a stepper, servo, and DC motor
DC Motor
The speed of a DC motor can be controlled in three ways: By varying the supply voltage. By varying the
and by varying the current through the field winding. By varying the armature voltage, and by
the armature resistance. The introduction of the extinguishing ratio of the worn cycle determines
If the power cycle is 50%, the motor is running at more than half the maximum speed. Each
so fast that the motor seems to rotate continuously without hesitation. We can change the direction
DC
1) By changing the polarity of applied field voltage
2) By changing the polarity of the applied voltage to the armature winding.
3) If we change both of the polarity of field and armature then the motor will rotate with previous direction.
Servo Motor
The motor is controlled by an electrical signal that determines the amount of shaft movement. In
closed-loop control, a rotation detector (encoder) is installed in the motor and transmits the
position/speed of rotation of the motor shaft back to the driver. By using map() and millis()
functions, we can control the speed of servo motor smoothly without blocking other code.
A servo is controlled by sending electrical pulses of variable width or pulse width modulation
(PWM) through the control wire. There is a minimum heart rate, a maximum heart rate and a
repetition rate. A servo motor can usually only turn 90° in either direction for a total of 180° of
movement.
For us, it's the range of motion, and instead of an input signal determining where the servo will
turn, it relates the continuous servo input to the output speed and direction. However, the
rotation angle is limited to 180 for most servo motors.
Stepper Motor
Speed of a stepper motor can be controlled by changing its switching speed or by changing the
length of the time delay loop. To reverse the direction, simply reverse the current in a set of
coils. Currently, two motors are connected in parallel and rotate in the same direction. Change
ONE of the coil pairs and you should be able to reverse both motors with the same driving
signal.
(c) Explain microcontroller protective mechanisms/components/devices in motor
interfacing with diagrams.
We need to control the motors using the microcontroller but it is not good to connect the motor
directly to the microcontroller. The maximum current that the 8051 microcontroller sinks is 15
mA at 5 V. But the motor needs more current. It needs other voltages like 6V, 12V, 24V etc.
Another important point is that the back MF produced by the motor will affect the proper
operation of the microcontroller and the reverse direction may damage the controller. We cannot
connect the motor directly. For these reasons, we cannot connect the motor directly to the
microcontroller. The motor driver IC is the interface between the microcontroller and the motor
to overcome the interaction problems. The meter driver is a small current amplifier. It receives a
low current signal and outputs a high current signal that can drive the motor. It can also control
the direction of the motor. We can use any dual H - IC Bridge like L293D.
8051
Microcontroller 5V/15mA
Power Source
L293D
Motors 12V/2mA
(d) Write an ALP to control the direction, angle, and speed of a stepper motor according to the
mechanism that you explained in Q1. (b).
Delay
Initialize Counter
Increment Counter
If
counter
=0
RET
Assume clockwise in 5 rotation and anticlockwise in 5 rotation. The PA0 drives winding Wa and
PA1 drives winding Wb. Assume the stepper motor has an initial delay of 10msec. Also assume
that the routine to this delay is already available.
START:
MOV AL, 80H
OUT CWR, AL
MOV AL, 88H; BIT PATTERN 10001000
MOV CX, 1000
AGAIN1:
OUT PORTA, AL
CALL DELAY
ROL AL, 01
DEC CX
JNZ AGAIN1
MOV AL, 88H
MOV CX, 1000
AGAIN2:
OUT PORTA, AL
CALL DELAY
ROL AL, 01
DEC CX
JNZ AGAIN2
MOV AL, 4CH
MOV CX, 21H
END
(e) Write an ALP to control the speed of a DC motor at 25%, 50%, and 75% of its full speed
using PWM. You can assume the frequency
ORG 0000H
MOV TMOD, # 00000001B
MOV TH0, #0FFH
MOV TL0, #034H
SETB P2.0
SETB TR0
JNB TF0, $
CLR TR0
CLR TF0
MOV TH0, #0FFH
MOV TR0, # 09AH
CLR P2.0
JNB TF0, $
CLR TR0
CLR TF0
END
Speed at 50%
ORG 0000H
MOV TMOD, # 00000001B
MOV TH0, #0FCH
MOV TL0, #067H
SETB P2.0
SETB TR0
JNB TF0, $
CLR TR0
CLR TF0
MOV TH0, #0FCH
MOV TR0, # 067H
CLR P2.0
JNB TF0, $
CLR TR0
CLR TF0
END
Speed at 75%
75% TH0 and TL0 = 25% TH0 and TL0 (On time)
TH0 = FF TL0 = 9A
75% TH0 and TL0 = 25% TH0 and TL0 (Off time)
TH0 = FF TL0 = 34
ORG 0000H
MOV TMOD, # 00000001B
MOV TH0, #0FFH
MOV TL0, #09AH
SETB P2.0
SETB TR0
JNB TF0, $
CLR TR0
CLR TF0
MOV TH0, #0FFH
MOV TR0, # 034H
CLR P2.0
JNB TF0, $
CLR TR0
CLR TF0
END
Q2)
(a) Draw a block diagram to interface an analogue to digital converter ADC0804 with 8051.
ADC0804
Analog to Digital Converter
8051 Microcontroller
(b) Draw a flowchart to measure analog voltage using ADC0804 with 8051.
Start
Select Analog channel
Start to conversion
Finishing of data
Conversion
End
(c) Write an ALP to implement your algorithm Q2. (b).
ORG 0000H
SJMP MAIN
ADC_DATA EQV P1
ADC_SC BIT P3.0
ADC_EOC BIT P3.1
ADC_ALE BIT P3.2
ADC_OE BIT P3.3
ADC_A BIT P3.4
ADC_B BIT P3.5
ADC_C BIT P3.6
MAIN:
MOV ADC_DATA, #0FFH Port 1 is input
SETB ADD_A
SETB ADD_B
CLR ADD_C
ACALL DELAY1
ACALL ADC_COUNT
MOV P0, A
ADC_COUNT:
SETB ADC_EOC ; Input port
CLR ADC_ALE
CLR ADC_SC
CLR ADC_OE
BACK:
SETB ADC_ALE
ACALL DELAY1
SETB ADC_SC
ACALL DELAY1
CLR ADC_ALE
CLR ADC_SC
LOOP1:
JB ADC_EOC, LOOP1 ; wait for conversion
LOOP2:
JNB ADC_EOC, LOOP2 ; output comes high
SETB ADC_OE
ACALL DELAY1
CLR ADC_OE ; Digital converted data
MOV B, #05H
DIV AB
RET
DELAY:
MOV R3, #3
LOOP3:
MOV R1, #254
LOOP4:
MOV R2, #254
LOOP5:
DJNZ R2, LOOP5
DJNZ R1, LOOP4
DJNZ R3, LOOP3
RET
DELAY1:
MOV R3, #1
LOOP6:
MOV R1, #10
LOOP7:
MOV R2, #10
LOOP8:
DJNZ R2, LOOP8
DJNZ R1, LOOP7
DJNZ R3, LOOP6
RET
END
Q3)
(a) Compare and contrast XRAM and IRAM by using examples with ALP commands.
XRAM
XRAM is known as external RAM. We can see two types of external RAM in CPU architecture.
XRAM can address 16 bit DPTR then the regular 8051 CPU can address up to 64Kb of XRAM.
Ex:
MOVX@DPTR, A ; copy data from A to the address specified in DPTR
MOVX A, @DPTR ; copy data from address specified in DPTR to A
IRAM
IRAM is known as internal RAM. This can only address by @R0, @R1 8 bits and can be store
up to 256 bytes.
EX:
MOV A, @R0 ; The content of the memory location R0 are copied to the accumulator
MOV @R1, A ; The content of the accumulator are copied to the memory location R1
(b) Design a memory system for 8051, which requires 32KB ROM and 16KB RAM using
2KB ROM chips and 4KB RAM chips. State required width of the address bus and data
bus and clearly show your calculations and RD/WR and CS signals. Assume that the
word length is 8-bit. State any other assumptions.
32KB ROM
There are 2K = 2^1×2^10 = 2^11 address spaces and 11 address lines CS
There are 32K = 2^5×2^10 = 2^15 address spaces and 15 address lines (A0 to A14) and 8 data
Number of chips = 2^15/2^11
= 2^4
=16
A10, A11, A12, A13 CS
A14 WR/RD
4*16 decoder size
16KB RAM
There are 16K = 2^4*2^10
= 2^14 address spaces and 14 address lines (A0 to A14)
There are 4K = 2^2*2^10
= 2^12 address spaces and 12 address lines
Number of chips = 2^14/2^12
= 2^2
=4
A11, A12 CS
A13 WR/RD
2*4 decoder size
c) Draw a memory map for your design in Q3. (b) (Clearly show starting address, end address,
and address line values for each chip).
b)
ORG 0000H
MOV TMOD, #00100001B
MOV TH1, #1111111111111101B
MOV SCON, #50H
SET TR1
L1:
MOV DPTER, #DATA
CLR A
MOV A, @A+DPTR
MOV SBUF, A
JNB T1, $
CLR T1
ACALL DELAY
SJUMP L1
DELAY:
MOV TH0, #0F5H (for 3 mins)
MOV TL0, #032H
SET TR0
JNB TF0, $
CLR TR0
CLR TF0
RET
DATA:
DB “@DEG 120”, 0; Message
END
Q5)
(a) You are expected to search the internet and find the suitable devices (sensors, transducers,
and/or actuators) that need to be interfaced with 8051 for the following. Justify your answers.
To measure the weight of an object
The most frequently used weight sensors are a strain gauge, capacitance, hydraulic and
pneumatic. In the above-mentioned types of sensors, the first two are electrical transducer
devices. It is a sensor used to detect a physical stimulus and generate voltage as an output. The
input interface of this load sensor module uses a sensor interface compatible with the SPI input
output port of the microcontroller. To connect the output of the load sensor, the load sensor
module uses a compact terminal that makes it easy to use. We can also use microcontroller, Load
Cell (50KG), Liquid Crystal Display (LCD), other passive and active components.
Microprocessor-based full-load systems using single-point load cells have large circuits,
complicating their design and implementation.
(b) List the model or type, measurement range that can be made, accuracy, price,
and the type of the output signal of the devices mentioned above in Q5. (a)
In strain gauge accuracies of 0.5% to 1% are typical for strain gages with a measurement limit
of up to 5% strain (50,000 µε). The accuracy of DIC strain measurements tends to be around
10% below 0.3% strain (3,000 µe), with higher accuracies near 1% above 3% strain (30,000
µe).Strain gauges are available commercially with nominal resistance values from 30 to 3000 Ω,
with 120, 350, and 1000 Ω being the most common values. Therefore, to measure the strain, you
have to accurately measure very small changes in resistance. Therefore, to measure the strain,
you have to accurately measure very small changes in resistance. For example, suppose a test
specimen undergoes a strain of 500 me. A strain gage with a GF of 2 exhibits a change in
electrical resistance of only 2 (500 x 10-6) = 0.1%. For a 120 Ω gage, this is a change of only
0.12 although it has no dimensions, strain is usually expressed in units represented as ε, which is
in/in or mm/mm. Since the magnitude of the measured strain is small, the standard practice is to
use units of micro strain (µε), which is [ε x 10^-6].
Ultrasonic sensors use sound waves above the 20 kHz range to detect objects in proximity,
similar to how bats use echolocation to maneuver without colliding into obstacles. The normal
frequency range used for ultrasonic level measurements is within a range of 40 200 KHz.
The new sensors achieve a measurement resolution of ±0.1 µm and measurement cycle of 250
µs, placing them at the highest level in the industry position sensor is a sensor that detects an
object's position. A position sensor may indicate the absolute position of the object (its location)
or its relative position (displacement) in terms of linear travel, rotational angle or three-
dimensional space.
(c) Draw simple block diagrams to depict interfacing the sensors, transducers, and/or the
actuators mentioned above in Q5. (a) With 8051
Ultrasonic sensors
IR sensors
Q6)
Industrial dumbwaiters, better known as VRC elevators, freight elevators or material elevators,
are used in a variety of commercial applications that require the lifting of goods or materials
from one floor to another. They are used to transport boxes, medical equipment, warehouse
inventory and even cars. Weight capacity—Residential dumbwaiters usually have a weight
capacity of 100 lb. to 200 lb. A commercial dumbwaiter may be purchased if a greater weight
capacity is required. Different Types of Dumbwaiter Lifts Window Type Dumbwaiter – these are
our most popular option. Floor Type Dumbwaiter – these are installed where there are goods that
need to be loaded onto a forklift, or pallet truck.
It can Loads up to 80 Kg. Three possible access points. Monobloc tractor unit, with 0.5 HP 220-
380 V electro-brake motor. Worm gear reducer in oil bath and cable reeling drum. Safety system
and mechanical parachute.48, 24 or 12 V controls with emergency stop. Electrical control panel
with main switch and limit switches. Non-slip chipboard platform floor with perimeter metal
trim. Stain less steel platform available. Also easy to install 2 m standard guide and have lifting
speed of 0.15 m/s. Also no machine room required. There some more technical features like
Maximum travel: variable up to 9 meters. Platform measures: custom built as needed. Guides:
profile rectangular steel tube. Drive: electric. Engine: 0.5 or 1 CV. Speed: 0.16 m / s. And also
supply voltage: 220 V single-phase or three-phase 220/380 V.