Unit 5

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 30

UNIT V  

                     MICRO CONTROLLER PROGRAMMING & APPLICATIONS    

UNIT V                        MICRO CONTROLLER PROGRAMMING & APPLICATIONS                  9


Data Transfer, Manipulation, Control Algorithms& I/O instructions – Simple programming exerciseskey board and
display interface – Closed loop control of servo motor- stepper motor control – Washing Machine Control              
KEY BOARD AND DISPLAY INTERFACE:
Interfacing Stepper Motor with 8051Microcontroller
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. The picture below represents the
scheme for connecting the step motor to microcontroller.

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.
Stepper motor has 6 pins. In these six pins, 2 pins are connected to the supply of 12V
and the remaining are connected to the output of the stepper motor. Stepper rotates at a
given step angle. Each step in rotation is a fraction of full cycle. This depends on the
mechanical parts and the driving method.
Similar to all the motors, stepper motors will have stator and rotor. Rotor has
permanent magnet and stator has coil. The basic stepper motor has 4 coils with 90 degrees
rotation step. These four coils are activated in the cyclic order.

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 we require small increments in rotation choose motor having smaller step angle.

 No of steps require to rotate one complete rotation = 360 deg. / step angle in
deg
 Steps per second = (rpm x steps per revolution) / 60
Example: step angle = 2°
 No of steps per revolution = 180
8051 interface to stepper motor

Stepper Motor Controller Circuit Advantages:


It consumes less power.
It requires low operating voltage
Stepper Motor Control Applications:

This circuit can be used in the robotic applications.


This can also be used in mechantronics applications.
The stepper motors can be used in disk drives, matrix printers, etc.

Program 1
Program 2

Program 3: 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

CLOSED LOOP CONTROL OF SERVO MOTOR USING MICROCONTROLLER:


Servo motor are so called “closed feedback” systems. This means that motor comes with control circuit,
which senses if motor mechanism is in desired location and if not it continuously corrects an error until motor
reaches proper point.
Servo motors are widely used in robotics, remote controlled planes, vehicles. So they come in many shapes
and sizes, but they operate in almost the same way. Usually Servo motors are controlled by computer,
microcontroller or even simple timer circuit. Of course you may find more advanced servos – R/C so called radio
controlled. But again, they are same servos just it takes signals from receiver.

PULSE FOR CONTROLLING SERVO MOTOR


Servo motor shaft is positioned with pulse width modulated signals. So all servos comes with three wires
(Power, Ground and Control). So pulses are sent via control wire. Usually in servos with rotation angle 90° signal
width vary between 1 and 2ms.
Most servo motors can rotate about 90 to 180 degrees. Some rotate through a full 360degreesormore.
However, servos are unable to continually rotate, meaning they can't be used for driving wheels, unless they
are modified but their precision positioning makes them ideal for robot legs and arms, rack and pinion steering, and
sensor scanners.
Since servos are fully self contained, the velocity and angle control loops are very easy to impliment, while
prices remain very affordable. To use a servo, simply connect the black wire to ground, the red to a 4.8-6V source,
and the yellow/white wire to a signal generator such as from a microcontroller. Varythe square wave pulse width
from 1-2 ms and the servoisnowposition/velocitycontrolled.
Pulse width modulation (PWM) is a powerful technique for controlling analog circuits with a processor's
digital outputs. PWM is employed in a wide variety of applications, ranging from measurement and communications
to power control and conversion.
The general concept is to simply send an ordinary logic square wave to servo at a specific wave length, and
servo goes to a particular angle (or velocity if servo is modified).Thewavelengthdirectlymapstoservoangle.
The blockdiagram of closed-loop control is shown in Figure.Thespeed, which is sensed by analog sensing
devices (e.g.,tachometer), is compared with the reference speed to generatethe error signal and to vary the armature
voltage of the motor.

In most digital applications,PWM (Pulse Width Modulation) is generally used to controlthe speed of the DC
motor. It is relatively easier to generatepulses of varying duty cycles with a microcontroller ormicroprocessor. The
pulses with varying duty cycle whenapplied to the armature will result in variable torqueproportional to the duty
cycle.
The control methodology used is to apply an average voltage proportional to the error between actual
position and the set point and reduce the average voltage as the current position approaches the set point.

Schematic control

WASHING MACHINE CONTROL

You might also like