Simple Motor Control in Industrial Automation
Simple Motor Control in Industrial Automation
Industrial Automation
PR307 - Advanced Topics in Industrial Automation
By
Prasad Manorathna
Dept. of Production Engineering
University of Peradeniya
Sri Lanka
1
2.) Stepper Motors
• Stator is a series of coils rather than permanent
magnet.
• Rotor is a set of permanent magnets mounted
on motor output shaft.
• User does commutation: Energize the coils in
rotational sequence, rotor swings into
alignment, alternate current when rotate
radians.
• When the coil is kept energized, “holding
torque”
2
Stepper Motors
• Adv: holding torque, speed and position control
without needing encoders / feedback
• Angular resolutions of <1deg are available - high
• Precision is high.
• There are many kind of stepper motors. Unipolar
type, Bipolar type, Single-phase type, Multi-
phase type.
3
2Ø PM Uni-polar Stepper
•In the PM type stepper motor,
a permanent magnet is used
for rotor and coils are put on
stator.
•4 poles & step angle of the
rotor is 90 degrees.
•The turn of the motor is
controlled by the electric
current which pours into the
coils.
•The rotor rotational speed and
the direction of the turn can be
controlled by this control.
4
Method of running a stepper motor
•The rotor is stable in the middle of 2
poles of stator.
•When one side of the stator polarity
is changed, the bounce by the
magnetism occurs. As a result, the
direction of rotor's turn is fixed.
•Angle can be correctly controlled.
•Moreover, because the rotor is fixed
by the magnetism in the stationary
condition as shown in the principle,
the stationary power(Stationary
torque) is large. It suits the use to
make stop at some angle.
5
Method of running a stepper motor
Clockwise control
“0” - Grounding
6
Method of running a stepper motor
Counter-Clockwise control
“0” - Grounding
7
Circuit to run a stepper motor
8
3.) Servo Motors
• Operates at low / medium
voltages, ex: 5V, 24V
• Complete package of
– DC motor and gear train
– Limit stops
– Position sensing of shaft via a potentiometer / encoder
– Current sensing using CT / Hall sensor
– Integrated circuit for position control
– 3 wires:
• power, ground, pulse-width control input
• Servos to a position: ie. Electric circuit directs motor to
rotate to commanded position and keeps it there. If you
interfere, circuit reads pot and makes correction with
increased current, which increases torque
9
Controlling a servo motor using a PIC
Servo Motor
•Velocity , Position
Encoder feedback & Torque control is
possible.
Controller
10
1) Velocity
The in-built timer of the microcontroller will be used to count the number
of pulses per time period.
Count = n
2) Position
Position is proportional to the number of counts
3) Direction
15
H – bridge operation
16
Inside H Bridge circuit
17
H-bridge control using
Microcontroller
18
Microcontroller pins
I/O Port 2
I/O Port 0
I/O Port 1
19
Speed Control using Pulse Width
Modulation (PWM)
PWM applied here
20
Duty Ratio
• V_average is set by the Duty Ratio
Duty Ratio = pulse width / period
21
Getting Feedback
from the Motor
– Hexadecimal Numbers
• Each character represents a value raised to a power of 16. There are 16
characters, with the letters A through F representing the decimal values
10 through 15.
• Each character in a hex number represents 4 bits. This makes hex
numbers a convenient, compact way to express 8- or 16-bit numbers.
• Common ways of indicating hex values are:
– with a trailing h: 278h
– with a leading 0x: 0x278
– with a leading $: $278
24
Microprocessor and Memory
Address Bus
• These wires are controlled by the microprocessor to select a
particular location in memory for reading or writing. The block
diagram shows a memory chip that has 15 address wires. Since
each wire has two states (it can be a digital one or a zero), 2 to the
15th power locations are possible. 215 is precisely 32,768 locations;
thus, the system is said to have "32K" of memory (1K = 1024 bytes).
25
Data Bus
These wires are used to pass data between the microprocessor and the
memory. When data is written to the memory, the microprocessor
drives the data bus; when data is read from the memory, memory
drives the bus.
In our example, there are eight data wires (or bits). These wires can
transfer one of 28, or 256, different values per transaction. The data
size of 8 bits is commonly referred to as a byte. (a data size of 4 bits is
frequently referred to as a nibble.)
Read/Write Control Line
This single wire is driven by the microprocessor to control the function of
the memory. If the read/write control line is asserted as a logical one,
i.e., ``true'', then the memory performs a ``read'' operation. If it is
asserted as a logic zero, i.e., ``false'' then the memory performs a
``write'' operation. The relationship between logic level and voltage
level can vary, depending on the implementation.
Memory Enable Control Line
This wire, also called the E clock, connects to the enable circuitry of the
memory. When the memory is enabled, it performs either a read or
write operation as determined by the read/write line.
26
#include <AT89X51.H>
#define L293D_A P2_0 //Positive of motor
C Code for
#define L293D_B P2_1
#define L293D_E P2_2
//Negative of motor
//Enable of L293D 8051 processor
// Function Prototypes
void rotate_f(void); //Forward run funtion
void rotate_b(void); //Backward run function
void breaks(void); //Motor stop function
void delay(void); //Some delay
void rotate_b(){
L293D_A = 0; //Make positive of motor 0
L293D_B = 1; //Make negative of motor 1
L293D_E = 1; //Enable L293D
}
void breaks(){
L293D_A = 0; //Make positive of motor 0
L293D_B = 0; //Make negative of motor 0
L293D_E = 0; //Disable L293D
}
• Slow
• Requires a lot of support equipment and
software (compilers, assemblers, linkers,
function libraries, development platform,
programming hardware, etc.).
• Program memory is limited and so as the code
length
• Limited functions
• Coordination between microcontrollers need
separate hardware and complicated software
codes
29
Interfacing with PC
• Parallel Port • Serial Port
30
Interfacing with PC:
Universal Serial Bus (USB)
31
Interfacing with PC:
Industry Standard Accessories (ISA)
32
Interfacing with PC:
Peripheral Component Interface (PCI)
33
Interfacing with PC
• Parallel Port • Serial Port
34
Interfacing with PC:
Universal Serial Bus (USB)
35
Interfacing with PC:
Industry Standard Accessories (ISA)
36
Interfacing with PC:
Peripheral Component Interface (PCI)
37
Parallel Port
• port is a set of digital (logic 0 and 1) signal lines that the
microprocessor uses to exchange data with other
components as printers, modems, keyboards, displays,
etc, except memory
• Parallel port transfers multiple bits at once
• Original PC’s parallel port had
– 8 outputs
– 5 inputs
– 4 bidirectional lines
• In newer PC versions the 8 outputs may also be
programmed to work as inputs
• Types:
SPP: Standard Parallel Port
PS/2-type: Simple Bidirectional
EPP: Enhanced Parallel Port
ECP: Extended Capabilities Port
38
SPP PS/2
• Can output eight bits • The bidirectional port
at once to a enables a peripheral
peripheral
• Doesn’t have a eight to transfer eight bits
bits for input. Uses at once to a PC
Nibble mode to input • Doesn’t support the
4 bits at a time EPP or ECP modes
• Nibble mode is slow,
but has become
popular as a way to
use the parallel port
for input to PC
39
EPP ECP
• Data lines are • Same as EPP together
bidirectional with additional features
• Can read or write a as
byte of data in one – Have buffers and support
for DMA (direct memory
bus cycle including access) transfers and data
handshaking, compression.
compared to four – Useful for printers,
cycles for an SPP or
PS/2 scanners, and other
peripherals that transfer
• Can switch
large blocks of data
directions of data
transfer quickly
• Can also emulate
either SPP PS/2
40
Pin assignment
41
Parallel Port Signals,
arranged by pin
number
42
System Resources
• Every port uses a range of addresses,
though the number and location of
addresses varies.
• Many ports have an assigned IRQ
(interrupt request) level.
• The resources assigned to a port can’t
conflict with those used by other system
components, including other parallel ports
43
Addressing
44
Interrupts
• Peripheral device may use an interrupt to announce:
– ready to receive a byte
– it has a byte to send
• To use interrupts, a parallel port must have an
assigned interrupt-request level (IRQ).
• If you select no IRQ level for a port, the port will still
work in most cases, though sometimes not as
efficiently, and you can use the IRQ level for
something else
45
Finding Existing Ports
• Operating Systems include utilities for finding
existing ports and examining other system
resources.
• In WindowsTM, click on
– Control Panel,
– System,
– Devices,
– Ports,
to see the assigned address and IRQ level .
46
Analog-to-digital converter
• An analog-to-digital converter (ADC, A/D or A to
D) is a device which converts continuous signals
to discrete digital numbers.
• The reverse operation is performed by a
digital-to-analog converter (DAC).
47
Analog-to-digital converter
48
Sensors Processor Actuator
49