Mechatronic Systems: An Introduction

advertisement
Mechatronic Systems
An Introduction
(Higher)
6526
HIGHER STILL
Spring 2000
Mechatronics
Mechatronic Systems
An Introduction
Higher
Support Materials
CONTENTS
MECHATRONICS WHAT IS IT?
The Microprocessor
a) The Central Processing Unit (CPU)
b) The Memory
c) The Bus system
Sensors and Actuators
a) The Analogue actuator
b) The Digital actuator
c) The Analogue signal
d) The Digital signal
WHAT IS A TRANSDUCER?
What is a sensor?
What is an actuator?
Well!!! Is it a sensor or is it an actuator?
a) Sensors
b) The microswitch
c) The inductive proximity sensor
d) The thermocouple
e) Flow sensors
f) The pressure transducer
g) Actuators
Hydraulic and Pneumatic Actuators
a) The hydraulic/pneumatic cylinder
b) The hydraulic/pneumatic rotary actuator
Electrical Actuators
a) The DC motor
b) The stepper motor
c) Stepper motor operation
What is control?
Closed loop control
Open loop control
DET: Mechatronic Systems: An Introduction (Higher)
1
System Inputs and Outputs
a) Processes and Sub processes
b) Input sub-processes
c) Output sub-processes
d) Interfaces
e) Buses
f) Programs
MECHATRONIC SYSTEMS EXAMINED
Automatic camera
Automatic washing machine
Automatic assembly machine
Automotive engine management system
Vending machine
Computer controlled fitness equipment
Pick and place robot
INTELIGENCE (WHERE DOES IT FIT IN)?
The Personal Computer (pc)
a) PC Architecture
b) The CPU
c) The Memory
d) The Bus Syste
e) Input and Output Units (I/O)
f) Operating system
Hardwired Logic
a) Design
b) Truth Tables
c) Boolean expression
d) The logic circuit
e) Programmable Logic Devices (PLD)
f) System On Chip (SOC)
The Application Specific Integrated Circuit (ASIC)
a) The ASIC what is it?
b) ASIC applications
c) ASIC Design
DET: Mechatronic Systems: An Introduction (Higher)
2
Microcontrollers
a) What is a microcontroller?
b) The needs of embedded control
c) The Basic Stamp microcontroller
d) The original Parallax Basic Stamp
e) The Higher Still developed Basic Stamp Controller
f) Intel 8XC196MC Industrial Motor Control Microcontroller
g) Intel Automotive 80C31BH/80C51BH/87C51 Microcontroller
Programmable Logic Controllers PLC’s
a) What is a Programmable Logic Controller?
b) PLC Central Processing Unit (CPU)
c) PLC Memory
d) PLC Input/Output
e) PLC Programming Languages
f) Ladder Logic
Controller Types Reviewed
a) PC based
b) Embedded controller
c) Microcontroller
d) Programmable Logic Controllers
e) Hardwired Logic
PROGRAMMING
Compiled Languages
Interpreted Languages
Low-Level Computer Languages
High-Level Computer Languages
a) FORTRAN
b) BASIC
c) Pascal
d) C
Very High-Level Languages
Natural Languages
Object-Oriented Programming
a) Smalltalk
b) C++
c) Turbo Pascal
DET: Mechatronic Systems: An Introduction (Higher)
3
DET: Mechatronic Systems: An Introduction (Higher)
4
MECHATRONICS: WHAT IS IT?
There is no definitive answer to this question. The word ‘mechatronics’ means
different things to different people.
In simplistic terms Mechatronics is:
the intelligent control of plant, product or process
To the author of this document, mechatronics is a combination of five distinct
disciplines:
1. Electrical engineering
2. Mechanical engineering
3. Electronic engineering
4. Software engineering
5. Control engineering
Why do we need to cover so many areas when there probably already exist many
engineers in each of the fields shown above?
In some industrial design and manufacturing companies two engineers of different
disciplines may be working together. One of the engineers sees something, which
impinges on the other engineering discipline, but rather than deal with it directly he
will talk to his manager. This manager will then talk to the second engineers’
manager the information will then travel by way of the two managers to the second
engineer.
Obviously this is an extremely wasteful process.
Most of the time this is done because of a lack of experience and knowledge of the
other engineer’s area of work.
Mechatronics overcomes this unfamiliarity and breaks down the barriers by allowing
people to work in harmony as part of a multidisciplinary engineering team. This
saves companies time and money and adds to the job satisfaction of the engineer.
What is a mechatronic system?
Mechatronics is the:
intelligent control of plant, product or process
What does this mean?
In the case of an automated system it means that, in general, underlying intelligent
controller(s) control all parts of the system (or overall process).
DET: Mechatronic Systems: An Introduction (Higher)
5
These controllers can take many forms:
• Personal Computer (PC)
• Embedded controller
• Microcontroller
• Programmable Logic Controller (PLC)
• Application Specific Integrated Circuit (ASIC)
All of these controller types, apart from the ASIC, have at their heart a device called
the microprocessor or µP. What is a microprocessor?
The Microprocessor
A microprocessor in its simplest form is a large collection of transistors arranged in
such a way as to provide blocks on a single piece of silicon otherwise known as a
Very Large Scale Integration (VLSI) device. On the silicon are constructed areas for
the following:- short-term data storage or memory, computation and logical functions
Arithmetic Logic Unit or ALU, various registers that allow for data manipulation
and a program counter. This is known collectively as the Central Processing Unit or
CPU. Control circuitry is also included in order to allow Input/Output functions or
I/O. In order that these blocks can communicate with one another links between them
are also included. This collection of inter block links are known as buses as they
transport information or data around the processor.
The Central Processing Unit (CPU)
The Central Processing Unit is the ‘brain’ of the microprocessor. All instructions are
processed by the CPU, all logic and mathematical functions are carried out by the
Arithmetic Logic Unit (ALU) and all data movement around and in and out of the
microprocessor is co-ordinated from within the CPU.
All of this co-ordination comes about because of an underlying sequence of
instructions held within memory, the program. The program can be user defined and
stored in temporary memory or it may be processor resident, put there by the
manufacturer and known as micro-code.
The Memory
Memory comes in two formats. The first type is Read Only Memory (ROM), which as
it states can only be read. No data can be written to this type of memory.
ROM generally has the program ‘burned’ into it by the manufacturer and is
permanent even when power is removed. This type of memory is said to be nonvolatile. The second type is Random Access Memory (RAM). This memory can
have data read from and or written to it repeatedly but it loses its contents when power
is removed. This type of memory is said to be volatile.
There are usually small areas of both of these types of memory manufactured into the
microprocessor. The amount of each type of memory included within each
microprocessor varies with the manufacturer.
DET: Mechatronic Systems: An Introduction (Higher)
6
The ROM area is where micro code required for the correct internal operation of the
CPU will reside.
RAM will allow dynamically changing data to be temporarily stored and used within
the operation of a user program.
Both ROM and RAM memory exists in larger amounts external to the microprocessor
as well. This is where large application programs and data would be stored and again
this memory is accessed directly by the microprocessor via the buses.
ADDRESS BUS
I/O
or
Memory
CTRL BUS
Central
Processing
Unit
CTRL BUS
Memory
or
I/O
DATA BUS
Microprocessor architecture
There are three buses involved in the processor:
The Bus system
• The data bus transfers data and instructions between memory and the CPU or
between the CPU and the memory. Data movement is bi-directional with the
direction being set by the control bus.
• The control bus carries various signals that control the way the system responds to
both internal and external commands. Internal commands include the setting of
direction of data flow on the data bus whether memory is being read from or
written to and whether the memory being accessed is actually part of the
input/output area as data handling commands differ for I/O operations. This bus
can vary considerably between different processors, is more complex than the
other buses and is dependent on the processor manufacturer (INTEL,
MOTOROLA, AMD, ZILOG….)
Note: In the diagram above the control bus marked ‘CTRL BUS’ although it
appears twice, is actually the same bus.
• The address bus allows the CPU to pinpoint individual memory locations within
the system memory map. These memory locations originate from the CPU and are
dependent on whether the information required is program code or raw data. This
bus only has to work in one direction and so is known as uni-directional.
DET: Mechatronic Systems: An Introduction (Higher)
7
Let’s have a look at the READ/WRITE sequences within the processor.
When the Central Processing Unit (CPU) accesses a program which is stored in
memory or stores information obtained from external sensors the following sequence
of events must occur:
READ (Memory)
• identify the address location in memory by placing its value on the address bus
• identify to memory that the READ function is required via the control bus
• memory makes available the data on the data bus
• processor READs the data
WRITE (Memory)
• identify the address location in memory by placing its value on the address bus
• identify to memory that the WRITE function is required via the control bus
• processor places the data on the data bus
• memory is updated to now hold the new DATA value
READ (I/O)
• identify the address location in the I/O map by placing its value on the address
bus
• identify to the I/O memory location that the READ function is required via the
control bus
• the I/O memory location makes available the data on the data bus
• processor READs the data
WRITE (I/O)
• identify the address location in the I/O map by placing its value on the address
bus
• identify to the I/O memory location the WRITE function is required via the
control bus
• processor places the data on the data bus
• the I/O memory location is updated to now hold the new DATA value
DET: Mechatronic Systems: An Introduction (Higher)
8
Sensors and Actuators
Sensors and actuators come in two main categories namely analogue and digital. An
explanation of these two terms is given.
The Analogue actuator
The analogue actuator can take up any position within the limits of its movement as in
the case of the pneumatic linear actuator shown below.
stroke length
Analogue pneumatic actuator
Similarly the speed of a rotary actuator motor is continuously changeable across its
range.
The Digital actuator
The digital actuator, shown below, will only take up position at one end or the other
of its stroke.
exhaust
fluid in
stroke length
limit sw
limit sw
Voltage
Digital pneumatic actuator
The Analogue signal
By definition analogue signals: are continuously and infinitely variable over the
range of measurement as can be seen in the graph below.
Temperature
Continuously variable analogue signal
DET: Mechatronic Systems: An Introduction (Higher)
9
In the graph above the voltage rises smoothly, it has no visible steps, as the
temperature rises. If we wish to find a value at any instant in time we will get a value
that is representative of the original signal.
Note that this is not the only waveform that constitutes an analogue signal.
Voltage
The Digital signal
By definition digital signals: are discrete signals which will not change until the next
level is reached.
Temperature
A thermometer measuring in 5o jumps.
In the graph above the voltage does not rise smoothly, it has visible steps, as the
temperature rises. If we wish to find a value at any point we will only get a value that
is as close to the nearest step value available.
DET: Mechatronic Systems: An Introduction (Higher)
10
WHAT IS A TRANSDUCER?
1
Transducer (sensor):
is any device that converts a non-electrical parameter, for example, sound, pressure,
or light into electrical signals or vice versa. The variations in the electrical parameter
are a function of the input parameter
What is a sensor?
• a microphone converts sound into electrical energy
• a thermocouple converts heat energy into a change in voltage
• a switch converts mechanical movement into one of two possible electrical states.
What is an actuator?
An actuator, in a control system, is a device which converts energy from one form
into another:
• a speaker converts electrical energy into sound
• a solenoid converts electrical energy into mechanical motion
• a motor converts electrical energy into rotational motion.
WELL!!! IS IT A SENSOR OR IS IT AN ACTUATOR?
This is a classic question, and can only be answered by asking yourself a few
questions:
• is the device doing a job, does it move something? If the answer is ‘yes’ then the
chances are that the device is an actuator
• if on the other hand it provides a changing signal then it is likely that it is a
sensor.
1
Young E.C. 1988. Dictionary of Electronics, Penguin.
DET: Mechatronic Systems: An Introduction (Higher)
11
Sensors
Below is a list of sensors commonly found in a Mechatronics system.
Sensor name
Microswitch
Float switch
Photoelectric
Type
Digital
Digital
Digital
Inductive
Digital
Conductive
Capacitive
Ultrasonic
LVDT
Linear potentiometer
Rotary potentiometer
Magnetic reed switch
Infra red
Analogue
Digital
Digital/analogue
Analogue
Analogue
Analogue
Digital
Digital
Thermocouple
Strain gauge
Piezoelectric crystal
Analogue
Analogue
Analogue
Moire fringe
Hall effect
Digital
Analogue/digital
Tacho generator
Analogue
Vane anemometer
Analogue
Usage
End stop - limit switch
Liquid level detection
Through beam
Retro-reflective
Diffuse
Background/foreground
suppression (BGS/BFS)
Fibre optic
Proximity detector
Shielded sensor
Unshielded sensor
Distance sensing
Level sensing
Proximity detector
Level/depth sensors
Linear displacement
Linear displacement
Angular displacement
End stop – limit switch
Reflective proximity can
be used for positional or as
part of a shaft encoder
arrangement to provide a
stream of pulses
Temperature measurement
Force displacement
Pressure displacement
Among others
Linear positioning
Position; can be used
within a shaft encoder to
supply a stream of pulses
Speed control; driven
permanent magnet motor
will give a voltage
proportional to the speed
of rotation
Fluid flow
We will now take a look at a few of these sensors in more detail.
DET: Mechatronic Systems: An Introduction (Higher)
12
The microswitch
Switch2:
A device that causes the operating conditions of a circuit to change between discrete
specified levels.
The ‘micro’ in microswitch refers not to the physical size of the device but the
actuation movement required to open or close the contacts from Normally Closed
(NC) to Normally Open (NO). The internal operation of the microswitch can be seen
in the figure below:
normally closed
nc
common
com
normally open
no
Microswitch
Microswitches, which are digital in operation, are used extensively to detect end of
stroke movement. The microswitch requires physical contact in order to operate, is
mechanical in operation and consequently has a restricted life due to the flexing
operation of its internal mechanism. The microswitch may also be found in a nonmechanical, non-contact, inductive proximity format as well.
The inductive proximity sensor
The inductive proximity sensor consists of a coil wound around a ferrite core at the
sensing head. A high frequency signal is applied to this, generating an oscillating
electromagnetic field around it as shown in the figure below. This is monitored by the
internal electronics.
copper
coil
electronics
Proximity detector
When a metallic object travels towards the field, electric currents are generated within
it. As the object approaches the sensing face of the sensor these currents increase in
size.
2
Young E.C. 1988. Dictionary of Electronics: Penguin.
DET: Mechatronic Systems: An Introduction (Higher)
13
The currents cause a transformer like effect and as a result the energy in the detecting
coil lessens and the oscillations reduce. As the object moves in closer the oscillations
finally stop.
Sensing distances are usually quoted by the manufacturers and are dependent on the
target material type and target size. The sensing distance quoted in the device
specifications for the proximity sensors are based on a standard target. This target
(known as a standard object) is a square plate of mild steel 1 mm thick, a primarily
ferrous object.
standard
target
Bring the target
towards the sensor
sensing distance
(operating position)
Sensing distance diagram
When the target reaches the point where the sensor operates, this is the sensing
distance as shown above.
release
position
sensing distance
(operating position)
Sensor release diagram
The sensor will release turn off at a point slightly further from the sensing face as
shown above.
Sensing distances quoted by manufacturers are against a standard mild steel object. If
however a different metal is used, the sensing distance will be reduced. These
reductions can be seen in the table below.
Mild steel
100%
Iron
100%
Stainless steel
70%
Lead
50%
Brass
40%
Aluminium
30%
Copper
25%
Sensing distance reductions
Metals with different types and thickness of plating affect the detecting distance of
inductive sensors. This effect will vary depending on the type and thickness of the
plating material.
DET: Mechatronic Systems: An Introduction (Higher)
14
Where other target materials are to be used for example paper, card or plastic other
proximity detectors exist that will sense these materials.
The thermocouple
The thermocouple, shown below is a sensor used in the monitoring of temperature.
As a sensor it has a relatively simple construction. Two wires of different metallic
materials are brought together and bonded, usually in a high temperature arc welding
process. The result of this process leaves a sensor that generates very small voltages
proportional to a rise in temperature. These voltages can be amplified and used
within a mechatronic system to allow temperature control.
welded
tip
Thermocouple
The thermocouple comes in many forms to cover the temperature ranges as listed in
the table below.
Minimum continuous
temperature
Maximum continuous
temperature
Maximum spot reading
Type J
-60
Type K Type N Type T
-200
-230
-200
Type R
-50
+1100
+400
+1350
O
C
+1100 +1300 +1320
+500
Thermocouple temperature ranges
+1400
O
C
+850
+1300
Units
O
C
Below is a graph showing a typical temperature gradient for Type K thermocouples.
The 3Graph above shows that the Type K thermocouple output is linear and usable
over quite a large range of temperatures from approximately –100OC to 400OC.
Note: thermocouples are only one of a variety of sensors available for temperature
control.
3
Courtesy of RS Components
DET: Mechatronic Systems: An Introduction (Higher)
15
Flow sensors
Measurement of flow is required in many automated processes. The simplest method
of flow measurement uses a device known as a turbine. This device, however, is by
nature intrusive. That is, it must fit inside the system and be moved directly by the
fluid being monitored, and so it must be realised that this type of device will restrict
the flow while measuring it. The diagram below shows a simple flow sensor in
operation.
sensing
coils
Flow
ω
magnetic
inserts
Flow sensor
As the liquid flows through the pipe it forces the turbine to turn. As the blades rotate
the magnetic inserts pass in close proximity to the sensing coils, this induces a current
in the coils. If these coils are placed symmetrically around the outside of the pipe
then a series of pulses will be produced. Information about speed of rotation of the
turbine can then be converted into the rate of flow of the fluid within the pipe.
For a very good description of the paddlewheel sensor, point your browser at:
http://www.sensorsmag.com/articles/1299/63_1299/main.shtml
Where you will find an article named:
Paddlewheel Flow Sensors: The Overlooked Choice
Another type of flow measurement device, which can be used without restricting the
flow of the liquid within the pipe, is the ultrasonic flowmeter. These devices can be
strapped onto the outside of the pipe and use sound to calculate rate of flow.
DET: Mechatronic Systems: An Introduction (Higher)
16
How does it work?
First a suitable site must be found, then the ‘sensor rack’ which contains an ultrasonic
transmitter and an ultrasonic receiver built in, is wrapped around the pipe see diagram
below.
direction of flow
ultrasound
transmitter
ultrasound
receiver
Pulses of sound are emitted by the transmitter, this sound is reflected by the back wall
of the pipe, but because of the fluid flow the pulses are forced to travel downstream.
Electronics within the system measure the difference in time between the pulses and
using maths the distance travelled can be calculated.
These systems are known as ‘time of flight’ measurement devices.
For a very good description of ultrasonic flowmeters, point your browser at:http://www.sensorsmag.com/articles/1097/flow1097/main.shtml
Where you will find an article named:
Ultrasonic Flowmeter Basics
These are not the only type of flow measurement device and so below are a few other
devices that can be used.
A
B
A
B
(a) Nozzle.
(b) Venturi
Both of these devices require that a difference in pressure be monitored. Operation of
these devices is described on page 15.
This leads us to the last sensing device we will examine, the pressure transducer.
DET: Mechatronic Systems: An Introduction (Higher)
17
The pressure transducer
The pressure transducer is used in many differing locations such as the monitoring of
industrial pneumatic supplies, oil pressure in hydraulic systems and gas flow to list
only a few. We will, however, examine only one use flow measurement as seen on
the previous page.
We will examine the integrated circuit type pressure sensor shown below.
stainless
steel
diaphragm
sensor
element
external
connections
Integrated circuit pressure sensor
The pressure transducer shown above has a resistive element at the heart of the sensor
unit. This is a very small strain gauge manufactured directly into a piece of silicon.
A stainless steel diaphragm protects the delicate sensor element from any direct
contact. As the pressure builds up the stainless steel diaphragm bends downwards and
as the canister is hermetically sealed the pressure on the sensor element changes. This
change in pressure causes the strain gauge to bend and so there is a change in the
resistance of the gauge.
This variable resistor forms one leg of a bridge circuit as shown below. The other
side of the strain element is the reference port that the measuring port is compared to.
All pressure transducers have two sides. Sometimes the reference side has it’s own
pressure connection and the device is known as a differential pressure transducer.
constant
current in
voltage
out
voltage
out
reference
element
sensing
element
ground
Strain gauge bridge
DET: Mechatronic Systems: An Introduction (Higher)
18
In the case of the venturi in the figure below; there are two pressure tapping points
‘A’ and ‘B’. In order that continual monitoring of the rate of flow can be carried out
the pressure difference between these two points must be known. This can be carried
out by installing either two pressure sensors as shown previously or by employing a
differential type to provide the information. The information from the transducer/s is
then used to calculate the final rate of flow.
A
B
Venturi sensor
For a good description of pressure sensor technology, point your browser at:
http://www.sensorsmag.com/articles/1198/fun1198/main.shtml
Where you will find an article called
Fundamentals Of Pressure Technology
Note: It is worth visiting the site http://www.sensorsmag.com as there is a wealth of
information on all aspects of sensors to be found here.
DET: Mechatronic Systems: An Introduction (Higher)
19
Actuators
Below is a list of actuators commonly found in a Mechatronics system:
Actuator name
Stepper motor
Solenoid
Type
Digital
Digital
Actuation
Rotational
Linear &
rotational
Pneumatic cylinder
Analogue/digital Linear
Hydraulic cylinder
Analogue/digital Linear
DC motor
Analogue
Rotational
AC motor
Analogue
Rotational
Work type
Positional
Mechanical displacement
Relay
Air flow control
Mechanical displacement
This type of device comes
in many forms from purely
digital linear operation, to
analogue linear operation
and from purely digital
rotational operation to
analogue rotational
operation
Linear or rotational
displacement
Direct drive
Servo control
Direct drive
Closed loop control such
as harmonic drive.
Hydraulic and Pneumatic Actuators
The hydraulic/pneumatic cylinder:
The word hydraulics comes from the Greek hudraulos – a musical organ driven by
waterpower. The word hydraulics is used to describe a system where mechanical
power is transmitted through a liquid that is under pressure.
The braking system in a car is usually hydraulic. The brake pedal actuates a piston
inside the master cylinder. This forces the brake fluid along a pipe, at the other end of
which the fluid enters an actuator, which usually operates another piston. This
presses the brake linings against the brake drum, which stops the car.
This is shown below:
exhaust
fluid in
Brake piston
DET: Mechatronic Systems: An Introduction (Higher)
20
Fluid forced in under pressure at the right hand side of the cylinder pushes the piston
to the left. Fluid on the left of the piston is exhausted from the connector on the lefthand side thereby forcing the internal piston to the left imparting linear motion. If on
the other hand fluid is being forced in on the left side and fluid is allowed to exhaust
on the right then the piston will move to the right, again imparting linear motion.
Hydraulic fluid is generally a mineral oil.
The same diagram and description will also suffice to explain the action of a
pneumatic system in which the oil is replaced by compressed air. The main
difference between these two systems is their ability to do work. Air is compressible
even when it has previously been compressed to 100 psi. This fact means that
pneumatic systems are limited to relatively light loads. Hydraulic systems on the
other hand can do many times more work due to the incompressibility of oil.
The hydraulic/pneumatic rotary actuator
Another type of actuator exists which will create rotary motion, as seen in the figure
below.
rotation
fluid in
exhaust
Hydraulic/pneumatic rotary actuator
Electrical Actuators
The DC motor
Many electric motors, from the motor used in a toy to the motor in a battery powered
shaver are direct-current (DC) motors. A battery is a source of DC and will power a
motor of this type. Mains electricity provides power which changes polarity fifty
times per second and is known as Alternating Current (AC), which is no use for
driving a DC motor. By adding a rectifier circuit, however, we can produce useable
DC power to drive a DC motor.
armature
brushes
stator
field coils
magnet
commutator
magnet
rotor
DC motor
DET: Mechatronic Systems: An Introduction (Higher)
21
Housed in a metal case is the stator, which is a series of permanent magnets.
Enveloped in this is the armature constructed of coils of copper wire or field coils.
As current is passed through the coils the electromagnetic action produced repels the
field of the permanent magnet and causes rotary motion. Each field coil is energised
in turn by way of the commutator and brush arrangement.
The stepper motor
Unlike a conventional DC motor, where the driven shaft simply spins, the stepper
motor rotates in small and very precise steps. If the motor has 12 steps per revolution,
then each incremental movement will be exactly 30 degrees.
Powering a stepper motor is not as simple as connecting the terminals to a power
supply, as in the DC motor. Specialised electronic circuitry is required external to the
motor in order that the motor’s movement can be controlled. The physical size of
these circuits has been radically reduced over the years to the point where now they
are available for purchase in the form of a specialised Integrated Circuit (IC). This
control IC is connected directly to a programmable unit, usually a computer, which
allows program control of the device.
Stepper motors are employed in many areas where movement must be controlled
precisely. For example in Numerically Controlled (NC) machine tools where the
workpiece must moved through fractions of a millimetre. Stepper motors can also be
found inside the printer connected to the computer, where they control both the
movement of the paper and the print head.
Stepper motor operation
The rotor, the moving part, in a stepper motor is constructed from several permanent
magnets with both North and South poles. The stator, the fixed part, is wound into a
series of electromagnets that can be switched ON and OFF.
In Diagram (a) below, the two electromagnets that are activated are at 12 o’clock and
at six o’clock, the magnetic fields generated by these electromagnets attract and hold
rigidly the rotor poles N3 and S2. Note that the rotor poles have the opposite
magnetic field to the electromagnets. Like poles repel opposites attract.
In Diagram (b) below, the winding power has now been switched to 3 o’clock and 9
o’clock; this action drags the rotor round to the 9 o’clock position. This constitutes
one step. If these coils are switched OFF and the next pair switched ON the rotor
would move one more step. If we therefore continuously switch pairs of coils ON and
OFF, in sequence, then we can produce rotational movement.
ON
OFF
Stator
Rotor
Stator
Rotor
S
N3
OFF
N
N2
N1
ON
N1
OFF
S1
S3
S3
S1
N3
N2
S2
S
ON
S2
N
ON
OFF
Diagram a
Diagram b
Stepper motor action
DET: Mechatronic Systems: An Introduction (Higher)
22
What is control?
Is a man with a box and arrow taking aim an open or closed loop control system?
Closed loop control
Closed as the man will adjust his aim to take care of wind direction or movement of
the target etc.
When the trigger is pulled and the arrow leaves the box is it an open or closed loop
system?
Open loop control
Open as the arrow can not change its trajectory whilst in flight. It cannot adjust to
compensate for unexpected external influences.
System Inputs and Outputs
All of the previously mentioned system controllers require information to be passed
from external influences to the controller (system inputs) and from the controller to
the system under control (system outputs).
External
Influences
SYSTEM
INPUTS
Controller
SYSTEM
OUTPUTS
System
Under
Control
Information transfer can take a number of forms:
• analogue signals from sensors (temperature, flow, and light level…)
• digital signals from sensors (mechanical switches, proximity detectors…)
• user inputs interface (man machine interface: keyboard or start/stop buttons…)
• analogue devices under control actuators (motors, heaters, light levels…)
• digital devices under control actuators (stepper motors, warning lights,
solenoids…)
• user outputs interface (machine man interface: monitor, head up display, mimic
diagrams…)
Digital
Sensors
Digital
Actuators
Controller
Analogue
Sensors
DET: Mechatronic Systems: An Introduction (Higher)
Analogue
Actuators
23
Processes and Sub-processes
Any processing carried out between the sensor and the controller or between the
controller and actuator is known as a sub-process.
Digital
Sensors
Analogue
Sensors
P
R
O
C
E
S
S
Controller
P
R
O
C
E
S
S
Digital
Actuators
Analogue
Actuators
Input sub-processes
Digital information may require little, if any, processing before passing to the
controller. (This might include switch de-bounce, pulse shaping and code conversion.)
Analogue information generally requires more processing to present it to the
controller in a useable condition. (This might include amplification, filtering and
analogue to digital conversion.)
Output sub-processes
Digital information may require processing before passing to the actuator. (Darlington
current drivers…)
Analogue information generally requires more processing to present it to the actuator
in a useable format. (digital to analogue conversion, filtering…)
DET: Mechatronic Systems: An Introduction (Higher)
24
Interfaces
In order to protect the system controller and the end user from possible dangers due to
the malfunction of internal or external power supplies, controllers must be isolated
from the devices connected to them. This isolation is normally placed at the interface
between the input devices and the controller or the controller and output devices.
Digital
Sensors
Digital
Actuators
Input
Interface
Controller
Output
Interface
Analogue
Sensors
Analogue
Actuators
Along with this isolation the interface may also accommodate the signal conditioning
electronics needed for both the digital and analogue inputs and outputs.
Digital
Sensors
Digital
Interface
Digital
Interface
Digital
Actuators
Analogue
Interface
Analogue
Actuators
Controller
Analogue
Sensors
Analogue
Interface
Man - machine interfaces
These come in many formats but in general allow the user to interact directly with the
overall system. (Examples are a control panel, keyboard or mouse driven graphical
representation.)
Machine - man interfaces
These allow the current system status to be displayed to the user. (Examples are a
head-up display, VDU, display panel or mimic diagram.)
Buses
The interconnections between any of the controllers and the various sub-systems are
generally known as buses. They transport information, data, around the system.
Some of these buses are internal, within the controller, some are external to the
controller.
All of these processes must interact for the overall system to operate correctly. This is
made possible by using a list of commands to control system behaviour.
Each controller has its own set of commands or language.
DET: Mechatronic Systems: An Introduction (Higher)
25
Programs
A program is a structured list of commands that can be made to collect status
information from the external sub-system sensors, process this information and act to
make the sub-systems carry out the required process steps. The program is normally
stored within the controller and each controller can have a different method of
inserting the program.
Mechatronic systems examined
Lets look at some Mechatronic systems now.
Automatic camera
Take
Photo
Use
Flash
Aperture
output
I/P
Interface
Programmable
Unit
O/P
Interface
Light
Condition
Shutter
output
Film
wind
• the user would simply indicate the use of flash or not then press the button to take
the photo
• the light condition and the user I/P information would provide I/P data for the I/P
interface
• the I/P interface would condition the I/P signals for the programmable unit
• the programmable unit would process the I/P information as per the internal
program and deliver appropriate desired O/P signals to the O/P interface
• the O/P interface would condition the O/P signals for the O/P actuators
• the aperture would be set for best photograph
• the shutter speed would be set and activated
• the film would then be wound on for the next photo.
Automatic washing machine
Door
Closed
Drawer
Closed
Program
Selected
Cold
Water
Fill
Water
Level
I/P
Interface
Programmable
Unit
Temp
Level
DET: Mechatronic Systems: An Introduction (Higher)
Motor
Wash
Cycle
Motor
Spin
Cycle
O/P
Interface
Hot
Water
Fill
Waste
Pump
26
The user would insert clothing to be washed:
• close the door; -- door closed would be sensed
• select the washing program; -- The program selection would be sensed and stored
ready for use
• put the fabric conditioning products in the drawer and close it; -- drawer closed
would be sensed
• the I/P interface would condition any sensor signals for the programmable unit
• the programmable unit would process the input signals with respect to the chosen
washing program and deliver appropriate O/P signals for the O/P actuators.
Note: this system has at least two closed loop control systems: water temperature and water level.
Automatic assembly machine
• the system is being asked to move from one location to another in order to deliver
Position
Z axis
X axis
actuator
Position
X axis
Z axis
actuator
I/P
Interface
Position
Y axis
Programmable
Unit
O/P
Interface
End
effector
Tactile
info
Y axis
actuator
a component to a pre-loaded position
• position information is fed back from all the axes (X, Y and Z along with tactile
info) via the I/P interface
• the I/P interface would condition the I/P signals for the programmable unit
• the programmable unit would process the I/P information as per the internal
program and deliver appropriate desired O/P signals (speed, velocity, position…)
to the O/P interface
• the O/P interface would condition the O/P signals for the O/P actuators
• the X axis position attained
• the Y axis position attained
• the Z axis position attained
• the end effector can be operated in order to deliver the component.
Automotive engine management system
Fuel
Level
Speed
Limiter
Engine
Speed
I/P
Interface
Throttle
Position
Programmable
Unit
Engine
Temp
DET: Mechatronic Systems: An Introduction (Higher)
O/P
Interface
Head up
Display
Fuel
Delivery
27
The Engine Management System (EMS) takes control of many aspects of the car:
• as the driver presses down on the accelerator so the information from the throttle
position sensor is passed to the I/P interface
• the I/P interface conditions the I/P signal for the programmable unit
• the programmable unit processes this signal as per the internal program and
delivers suitable O/P signals to the O/P interface
• the O/P interface conditions this signal and feeds it to the fuel delivery system
• at the same time, info from the engine speed sensor is passed to the I/P interface
which conditions the signal and passes it on to the programmable unit
• the programmable unit processes this information as per the internal program and
delivers an appropriate signal to the O/P interface
• the O/P interface conditions this O/P signal for the O/P actuators
• the speed limiter can be activated if over reving engine
• the engine speed can be sent to the head up display for the user
• the fuel level signal can be fed again through the I/P interface
• converted to a useable format
• acted on by the programmable unit processed by the internal program and provided
to the O/P interface
• the O/P interface conditions the signal for the O/P actuators
• fed to the head up display for user
• also used to display fuel consumption
• engine temperature likewise is sent to the I/P interface
• conditioned for the programmable unit
• processed by the internal program and provide the O/P interface with a signal
• the O/P interface conditions this signal for the O/P actuators
• this signal is fed into the head up display for the user
• the signal is also used to set fuel mixture levels.
Vending machine
Payment
made
Selection
Output
I/P
Interface
Programmable
Unit
Selection
made
O/P
Interface
Item
Output
• the customer would make payment – Correct payment would be sensed and
indicated at the I/P interface
• the customer would make selection – any selection made would be sensed and
indicated at the I/P interface
• the I/P interface would condition the sensor signals for the programmable unit
(controller)
• the programmable unit would process the sensor I/P signals as per the internal
program and deliver appropriate desired O/P signals to the O/P interface.
DET: Mechatronic Systems: An Introduction (Higher)
28
• the O/P interface would condition the O/P signals for the O/P actuators
• the selection O/P actuator would select the desired item
• the selected item would be delivered to the customer.
As for the remaining systems it is left up to the reader to produce their own versions.
Computer controlled fitness equipment
Pick and place robot
DET: Mechatronic Systems: An Introduction (Higher)
29
INTELIGENCE (WHERE DOES IT FIT IN)?
Control sub-systems.
The Personal Computer (PC)
IBM designed the original PC, the IBM PS/2, back in the early
seventies. This was a radical move away from the mainframe and
microcomputer of the early days. It was aimed at the business
market, for the small to medium sized office where it would be
used for word processing, databases and spreadsheets.
IBM PS/2
From the start they had very limited memory, 64K maximum, and by today’s
standards uncomfortably small hard disk drives around 10 MB, if they had a hard disk
at all. The operating system or O/S, more about this later, was a text based operating
system and not the graphical systems we are so used to today.
PC Architecture
MEMORY
INPUTS
OUTPUTS
INPUT
INTERFACE UNIT
OUTPUT
INTERFACE UNIT
ADDRESS BUS
CPU
DATA BUS
CONTROL BUS
The PC architecture
(note other format on page 3)
The CPU
The Central Processing Unit is the ‘brain’ of the microprocessor. All fetch-execute
instructions originate from the CPU, all logic and mathematical functions are carried
out within the CPU and all data movement around the microprocessor is co-ordinated
by the CPU.
All of this co-ordination comes about because of an underlying sequence of
instructions held within memory, the program. The program can be user defined or
may be processor resident, put there by the manufacturer, known as micro code and is
stored in memory.
The Memory
Memory comes in two formats. Read Only Memory (ROM); this memory as it states
can only be read from, no data can be written to this type of memory.
DET: Mechatronic Systems: An Introduction (Higher)
30
ROM generally has the program burned into it by the manufacturer and is permanent
even when power is removed. This type of memory is said to be non-volatile.
Random Access Memory (RAM); this memory can have data read from and or
written to it repeatedly but will lose its contents when power is removed. This type of
memory is said to be volatile.
There are usually small areas of both of these types of memory manufactured into the
microprocessor. The amount of each type of memory included within each
microprocessor varies with manufacturer.
The ROM area is where micro code required for the correct internal operation of the
CPU will reside.
RAM will allow dynamically changing data to be temporarily stored and used within
the operation of a user program.
Both ROM and RAM memory exists in larger amounts external to the microprocessor
as well. This is where large user written programs and data would be stored; again
this memory is accessed directly by the microprocessor via the buses.
The Bus System
There are three buses involved in the processor:
• the data bus that transfers data and instructions between memory and the CPU or
between the CPU and the memory, movement of data is bi-directional. Direction
is set using the control bus.
• The control bus carries various signals that control the way the system responds to
both internal and external commands. Internal commands include the setting of
direction of data flow on the data bus, whether memory is being read from or
written to, whether the memory being accessed is actually part of the Input/Output
area, as the data handling commands differ for I/O operations. This bus can vary
considerably between different processors, is more complex than the other buses
and is dependent on the processor manufacturer (INTEL, MOTOROLA, AMD,
ZILOG….)
• The address bus allows the CPU to pinpoint individual memory locations within
the system memory map. These memory locations originate from the CPU and are
dependent on whether the information required is program code or raw data. This
bus only has to work in one direction and so is known as uni-directional.
Input and Output Units (I/O)
Input. Communication with the computer is via some kind of input unit, which can
generally handle several peripherals. This communication is often referred to as the
man-machine interface. For example, the keyboard is an input device that interfaces
with the input unit and allows the operator to enter data, programs and operating
system commands into the computer. The mouse is another input device that allows a
graphical pointer to be easily moved about the video screen by the operator.
DET: Mechatronic Systems: An Introduction (Higher)
31
Output The computer communicates with us (the user) via the output unit, which
can generally handle several peripherals (external devices, printer, plotter, modem
etc.). This communication is known as machine-man interface. For example, the
output unit allows information from the computer to be displayed on a video monitor
or to be printed by a printer.
There are of course devices that act both as input and output devices. Examples are
disk drives, tape drives and modems.
Buses The CPU is connected to other internal parts of the computer by three sets of
parallel connections called buses, since they transport the information around the
computer. The data bus carries the data for processing and is a two-way or bidirectional system this can be 4, 8, 16 lines, each line carrying one bit at a time. The
address bus is a one-way or uni-directional system and conveys, as it’s name
implies, the various addresses required by the CPU, and has anything from 4 to 32
lines depending on the number of memory addresses. The final bus, the control bus
deals with timing signals and may have 3 to 10 or even more lines.
Operating system
Consider when we are writing and running a program in say assembly language we
start by:
• run the editor program → create a text file from the keyboard
• temporarily store the text file
• start up the compiler program
• compile the stored text file → assembly language file
• store this program
• start up the assembler
• produce a machine language file from the stored assembly language file
• finally you link the assembly language program with other pre-assembled
subroutines and library routines.
• now you can finally run your program.
For all of these above operations consider what is taking care of all the transfer of
information between keyboard and PC, between microprocessor and RAM, from
RAM to (disk drive), between the disk drive and PC etc..? These are some of the
tasks of the operating system, a large complex program that oversees the loading of
user programs (the ones you write) and utility programs (editor, compiler, assembler
linker etc.) as well as the handling of I/O and interrupts, the creation and manipulation
of files.
DET: Mechatronic Systems: An Introduction (Higher)
32
Some popular operating systems can be seen in the table below:
MS-DOS
Windows 9x
Windows NT
OS/2
UNIX
LINUX
MacOS
Vertex
Used on early IBM© PC’s and clones pre-1995; still used on some.
Used on later IBM© PC’s and clones 1995 on
Used on later IBM© PC’s and clones 1995 on
Used on IBM© PC’s successor (version also available for PC)
Created by Bell Labs; widely used on mainframe computers
Created by Linus Torvald as a UNIX-like operating system for
PC’s as UNIX does not run on PC’s
Created for Apple Mac computer systems
Created as an off-the-shelf operating system
There are also other operating systems available off-the-shelf for including in your
own designs, but they are complex.
These operating systems can be found included with some Microcontrollers and
ASICS whilst others have Operating Systems specifically written for them by the
manufacturers.
DET: Mechatronic Systems: An Introduction (Higher)
33
Hardwired logic
There is a requirement that 3 switches A, B and C activate an alarm unit (X) when the
switch configuration matches the following criteria:
The alarm (X) should sound whenever:
• Switch A is ‘HI’ and B is ‘LO’
or
• Switch A is ‘HI’ and C is ‘LO’
This problem mimics the type of safety system fitted to many industrial processes
such as the component access doors on a 10-ton machine press. Such a system has a
sensor, ‘A’, fitted to make sure the doors are firmly closed and there is no possibility
that the operators can have their hands within the press’s work envelope. The second
input, ‘B’, comes from a foot-operated switch. The third input, ‘C’, checks for the
presence of a component within the press.
Design
To start the design for this section design tools will be employed that you may well
have not come across yet. You will not be required to remember these methods, but
they are being used here to prove a point.
In the design criteria above there are three inputs to the controller and one output.
If we have three inputs then we have a possible eight combinations at these inputs.
Truth Tables
But we are only interested in certain combinations, where the output (alarm) is to be
on. This can be seen in the truth table (a) below; remember, HI = 1 and LO = 0.
Firstly we are looking for any input status line where A = 1, B = 0 and C can have any
value.
A
0
0
0
0
1
1
1
1
I/P s
B
C
0
0
0
1
1
0
1
1
0
0
0
1
1
0
1
1
Truth table (a)
O/P
X
Where these input conditions arise we want to see a HI or 1 at the output.
DET: Mechatronic Systems: An Introduction (Higher)
34
This is shown in Table (b) below:
A
0
0
0
0
1
1
1
1
I/P s
B
C
0
0
0
1
1
0
1
1
0
0
0
1
1
0
1
1
Table x (b)
O/P
X
1
1
Now we are looking for any input status line where A = 1, C = 0 and B can have any
value.
A
0
0
0
0
1
1
1
1
I/P s
B
C
0
0
0
1
1
0
1
1
0
0
0
1
1
0
1
1
Table (c)
O/P
X
1
1
Again where these input conditions arise we want to see a HI or 1 at the output:
A
0
0
0
0
1
1
1
1
I/P s
B
C
0
0
0
1
1
0
1
1
0
0
0
1
1
0
1
1
Table (d)
O/P
X
0
0
0
0
1
1
1
0
For all other input conditions we want the output to be LO or 0:
This can be seen in Table (d) above.
Boolean expression
The Boolean expression for the above truth table is:
DET: Mechatronic Systems: An Introduction (Higher)
A.B .C + A.B .C + A.B.C
35
The logic circuit
If we use standard logic gates we can put together a logic circuit that could replicate
the above requirements.
Logic schematic diagram
This type of circuit is known as hardwired logic because these gates have to be
physically wired together for the circuit to operate. Many pieces of equipment still
exist that utilise hardwire logic. The above circuit would require no fewer than four
separate integrated circuits:
1 x HEX INVERTER...
2 x QUAD 2 input AND..
1 x QUAD 2 input OR….
Programmable Logic Devices (PLD)
Unless the circuit is small or only required once, its function could be designed more
efficiently using Programmable Logic Devices PLD’s. These devices are in
integrated circuit format with arrays of INVERTERs, AND and OR gates all on one
chip. The interconnections between the gates are like a mesh of interconnected fuses.
The designer would probably design the circuit function using hardwired logic to test
its operation and then use special software and hardware to blow the individual fuses
within the IC. This would create a circuit which would operates exactly as the
hardwired logic circuit, but on a single IC.
System On Chip (SOC)
This reduction of large discrete circuits onto single IC’s is one of the biggest reasons
for the growth of the home computer market. The PC of 5 years ago required cards
that plugged into the motherboard and had such functions as VGA monitor driver
card, serial I/O, parallel I/O and the modem. Today, most of these functions are
included on the motherboard itself and are implemented in special integrated circuits.
This has all come about as the density of circuit functions in integrated circuits has
increased. This is known as System On Chip or (SOC).
DET: Mechatronic Systems: An Introduction (Higher)
36
The Application Specific Integrated Circuit (ASIC)
The ASIC what is it?
The Application Specific Integrated Circuit (ASIC) is a semi-custom or custom
device which is designed and manufactured to meet a customer’s individual
specification.
The ASIC is a large collection of transistors arranged in such a way as to provide
areas of short-term storage or memory, computation and logic functions and
input/output functions. In fact the microprocessor is a general example of an ASIC.
This does not mean that all ASIC’s are microprocessors as ASIC’s can be designed to
carry out many diverse functions. Remember the customer determines the function of
an ASIC.
ASIC applications
The Application Specific Integrated Circuit as described above is also known as a
System On Chip or SOC. Some of the applications that have been addressed by the
ASIC are as follows:
• control of camera shutter speed, focus, light level
• data acquisition systems
• in a microprocessor with A/D and D/A, pulse width modulation, timers etc (this
device is known as a microcontroller)
• in a PC to allow fast graphics to be displayed (3D accelerator)
• mobile phones (encoder/decoder chips…)
• development timer/processing circuit for accurate timing in explosive units. The
chip consists of a digital processing part, rectifier and an internal oscillator
• development and production of a chip for brake wear out applications, consists of
a digital processing unit, ROM, Digital to Analogue Converter (DAC) and an
internal oscillator
• development for acquisition of large amounts of data at particle physics
laboratories. The chip contains First In First Out (FIFO) memory and five event
memories, which are triggered externally
• development and production of a 14-channel, 10 bit A/D converter running at 80
MHz. The chip area is 16 mm2.
ASIC Design
ASICs must be extremely well designed or have as their basis a tried and trusted
system before committing them to silicon as it is a very expensive process.
The ASIC contains functional blocks which can be interconnected at silicon level.
These are known as a semi-custom device.
Alternatively, the whole device can be designed from scratch as in the case of the
custom or full-custom chip. ASICs are manufactured to a customer’s specification.
The customer tells the design house what is required.
DET: Mechatronic Systems: An Introduction (Higher)
37
Microcontrollers
What is a microcontroller?
A microcontroller is by nature, of the ASIC type. It is a System On Chip as explained
above. All microcontrollers have at their heart a microprocessor (CPU), which will
have RAM/ROM and I/O interfacing in one form or another. They will also have
some, but not necessarily all of the following:- A/D Converters, D/A Converters,
timers, serial interfaces, parallel interfaces, watchdog timers, oscillators, Pulse Width
Modulators.
The needs of embedded control
The needs of embedded control are very different from those of the standard personal
computers. For the life of the device, usually it will run only one program, apart for
the occasional program update. Because there is little support hardware; VDU,
keyboard, hard-drive or floppy disk there is little need for mass storage. Manmachine, machine-man interaction is also limited.
They are often required to operate in hostile environments such as high temperatures,
dust/corrosive atmospheres and perhaps both mechanically and electrically noisy.
The main features of a microcontroller system can be seen in the simplified diagram
below:
RAM
program
memory
PROGRAM
COUNTER
Arithmetic
Logic
Unit
ALU
clock
ROM
program
memory
I/O
ports
'Real'
world
timers
Simplified diagram of a microcontroller
4
Microcontrollers contain all the features within a single package, as opposed to the
microprocessor system where each block in the diagram above is normally a separate
integrated circuit. In general the only component that needs to be added to a
microcontroller is a clock circuit, this can take the format of either a ceramic
resonator or a quartz crystal.
To give you a feeling for the characteristics and architecture of the microcontroller
Let us examine a microcontroller that has been designed especially for use in Higher
Still courses, the Basic Stamp microcontroller.
4
Higher Still Technological Studies: System and Control
DET: Mechatronic Systems: An Introduction (Higher)
38
The Basic Stamp microcontroller
In industry microcontroller programs are normally developed using an ‘assembly’ or
‘C’ programming language. Unfortunately these languages are not particularly easy
for the beginner to understand and it can take a great deal of time and study before a
programmer is skilled enough to construct a complex program.
For this reason it is easier for the beginner to program with ‘user-friendly’ languages
such as BASIC (Beginners All-Purpose Symbolic Instruction Code). This language is
specifically designed to be ‘easily understood’ and so primarily uses standard
‘English language’ words as instructions. However, before the microcontroller can
understand the BASIC instructions, these instructions must be processed by an
interpreter into machine code. The extra processing time involved in the conversion
results in a BASIC program running slower than an equivalent machine code
program. On the good side, a microcontroller can process over one million assembler
instructions a second, so the extra processing required by the BASIC interpreter is
negligible in most cases.
BASIC
Stamp
Vin
+5V
7
6
5
4
3
2
1
0
GND
The original Parallax Basic Stamp
The original Parallax Basic Stamp
The ‘Basic Stamp’ system was developed in the early 1990s (by Parallax Inc., USA)
to enable design engineers to quickly prototype systems using microcontrollers by
programming in a modified BASIC language (called PBASIC – short for Parallax
BASIC) rather than assembler or C. The Basic Stamp system is an ideal compromise
for rapid prototyping – all the power and versatility of a microcontroller combined
with a simple programming language.
The original Parallax Basic Stamp module consisted of a small printed circuit board
with battery clip and prototyping area, see the figure above. Although suitable for
prototyping work, this module is not so appropriate for laboratory exercises, and so
the Stamp Controller has been developed for educational use. This uses identical
‘chips’ to the original module, but is configured on a larger printed circuit board with
all the necessary connectors etc. This can be seen below:
The Higher Still-developed Basic Stamp Controller
For more information on the Higher Still-developed Basic Stamp Controller, please
refer to Outcome 3 Microcontrolled Mechatronic Systems Student notes section of
the Higher Still Technological Studies support notes.
DET: Mechatronic Systems: An Introduction (Higher)
39
COMPUTER LINK
V+
0
1
2
3
POWER
BROWN OUT
REGULATOR
EEPROM
MICROCONTROLLER
0V
7
6
5
4
RESET
CLOCK
V+
0V
INPUT
OUTPUT
4 MHz
0
1
2
3
4
5
6
7
0 V V+
V+
V+
0
0
7
7
1
1
6
6
2
2
5
5
3
3
4
0V
4
0V
STAMP CONTROLLER
(C) REVOLUTION EDUCATION
The Higher Still-developed Basic Stamp Microcontroller
DET: Mechatronic Systems: An Introduction (Higher)
40
In order that you get a balanced introduction to microcontrollers, the following two
Intel microcontroller examples show their diversity:
Intel 8XC196MC Industrial Motor Control Microcontroller
Specifications:
•
•
16 Kbytes of on chip ROM
•
•
High performance CHMOS 16-bit
CPU
488 bytes of on-chip RAM
Up to 53 I/O lines
•
•
•
Event Processor Array
•
•
Two 16 bit timers
•
•
13 channel 8/10 bit A/D with sample / •
hold with zero offset adjustment
•
Flexible 8/16 bit external bus
•
3 µS 32/16 divide
Register to register architecture
Peripheral Transaction Server (PTS)
with 11 prioritised sources
(EPA) – 4 high-speed
capture/compare modules -- 4 highspeed compare modules
3-phase complementary waveform
generator
14 prioritised interrupt sources
•
•
1.75 µS 16 x 16 multiply
Idle and power down modes
Architecture:
VREF
ANGND
NMI
16
CPU
A/D
CONVERTER
488
BYTE
REGISTER
FILE
MICROCODE
ENGINE
S/H
MUX
16K ON-CHIP
ROM/OTPROM
(OPTIONAL)
INTERRUPT
CONTROLLER
ALU
PERIPHERAL
TRANSACTION
SERVER
MEMORY
CONTROLLER
8
QUEUE
16
TIMER 0
TIMER 1
PORT 0-1
A/D
PORT 0-1
EVENT
PROCESSOR
ARRAY
2 PWM
PORT 3
ADDR/DATA
BUS
PORT 4
3-PHASE
WAVEEFORM
GENERATOR
PORT O/1
PORT O/1
EPA
PORT 2
PORT 6
PORT 5
CONTROL
SIGNALS
WATCHDOG
TIMER
EXTINT
Intel 8XC196MC Industrial Motor Control Microcontroller
DET: Mechatronic Systems: An Introduction (Higher)
41
Intel Automotive 80C31BH/80C51BH/87C51 Microcontroller
Specifications
•
High performance CHMOS processor
•
Extended automotive temperature
range (-40 to 125OC)
Power control mode
•
4K byte on-chip ROM/EPROM
•
128 x 8-bit RAM
•
32 programmable I/O lines
•
Two 16-bit timer/counters
•
5 interrupt sources
•
Quick-pulse EPROM programming
•
•
Boolean processor
•
2 level program memory lock
EPROM
Programmable serial port
•
TTL and CMOS compatible logic
level
•
64K external data memory space
•
Idle and power down modes
RAM ADDR.
REGISTER
•
RAM
PORT 0
DRIVERS
PORT 2
DRIVERS
PORT 0
LATCH
PORT 2
LATCH
EPROM
ROM
PROGRAM
ADDR
REGISTER
ACC
B
REGISTER
TMP 2
TIMING
AND
CONTROL
ALE
EA
RST
INSTRUCTION
REGISTER
ALU
PSEN
OSC.
XTAL 1
BUFFER
TMP 2
INTERRUPT, SERIAL PORT,
AND TIMER BLOCKS
PC
INCREMENTER
PROGRAM
COUNTER
PSW
DPTR
PORT 1
LATCH
PORT 3
LATCH
PORT 1
DRIVERS
PORT 3
DRIVERS
XTAL 2
Intel Automotive 80C31BH/80C51BH/87C51 Microcontroller
DET: Mechatronic Systems: An Introduction (Higher)
42
As you can see from the previous pages microcontrollers are varied in the way they
are put together. It is entirely possible to pick up an ‘off the shelf’ microcontroller for
just about any system. This, their size, their relative cost and their availabilty makes
them ideal for embedding in control systems which require little if no interference or
maintenance.
In the first Intel example the microcontroller has been designed specifically to deal
with an industry wide problem, the control of an AC motor. Motor control can be
carried out using discrete electronic circuitry but with this device fewer components
means less chance of circuit failure.
A 3-phase waveform generator is included on chip to be used in conjunction with an
‘inverter’ driver, which is a special arrangement of diodes. The device comes in
either a 64 pin format or in the 84 lead package.
The second example is an 8-bit microcontroller designed specifically for the
automotive area. The device comes in either a 40-pin or in a 44 pin package.
There are many other microcontroller manufacturers producing devices for an everwidening number of diverse applications.
Programmable Logic Controllers PLC’s
What is a Programmable Logic Controller?
The Programmable Logic Controller (PLC) is a device, which was developed to
replace sequential relay circuits employed for plant control. The PLC operates by
examining the state of all inputs and depending upon their status, changing the outputs
to reflect the needs of the system.
PLC’s are employed in many ‘real world’ applications and are widely employed in
industrial locations. Machining, packaging, material handling, automated assembly
and many other situations. Just about any application that needs electrical control
could employ a PLC.
Control Bus
Address Bus
Data Bus
CPU
INPUT/
OUTPUT
MEMORY
CLOCK
External/Internal Bus Interface
The PLC consists of a Central Processing Unit (CPU), an area of memory and an area
to handle inputs and outputs. The PLC can be considered to be a box full of hundreds
or even thousands of separate relays, counters, timers and data storage locations.
These counters, timers etc. do not physically exist but rather they are simulated and
can be seen as software counters, timers etc.
INPUT
MODULE
OUTPUT
MODULE
PROGRAM
INPUT
PLC Architecture
DET: Mechatronic Systems: An Introduction (Higher)
43
PLC Central Processing Unit (CPU)
The Central Processing Unit controls and processes all of the operations within the
PLC. In order that the CPU can organise the timing synchronising of these internal
operations, a clock signal is required. This clock signal is generally between 1 and 8
MHz, in fact it is this frequency that determines the operating speed of the PLC.
PLC Memory
As with previous devices examined the PLC requires two types of memory.
ROM; for storage of permanent program information, data and operating system.
RAM; for storage of user programs and input/output buffering for dynamic data.
As previously discussed ROM memory is classed as non-volatile and RAM is classed
as volatile, although the RAM may have an appropriate battery back up in order to
protect system integrity when power is removed from the unit.
Another form of memory also used within the PLC is Electrically Erasable
Programmable Read Only Memory (EEPROM) which allows the user to replace the
code held on this type of ROM. This allows the user program to be downloaded and
held permanently on the PLC. Another good reason for EEPROM is that the system
then becomes very flexible, programs can be written well away from the system,
downloaded onto an EEPROM chip taken to the system and the EEPROMs can be
swapped without the need for a programmer to be present.
PLC Input/Output
The input/output modules provide the signal conditioning and isolation that allow
sensors and actuators to be connected directly to the PLC. Larger PLC’s allow for a
variety of input and output voltage and current configurations. Common input
voltages are 5V (TTL) and 24V (standard signal voltage). Common output voltages
are 24V and 240V often specified as transistor, relay or triac type.
Relay outputs are able to switch currents of around 2 amps, but are relatively slow.
Transistor outputs allow faster switching than relays. Triac outputs allow control of
AC devices. Optoisolators allow for isolation in both the transistor and triac outputs.
PLC Programming Languages
With PLCs, there is more than one way to program them. This can be carried out
either by hand held programmer or download directly from a PC. There also exists
more than one type of programming language.
Some of these languages are as follows:
• statement listing
• matrix programming
• ladder logic.
The latter, ladder logic, is by far the most commonly used program language, but
each PLC manufacturer tends to use their own dialect.
The Higher Still Mechatronics unit uses a PLC simulator to provide information. A
demonstration version of this simulator can be found at:
http://www.bytronic.com
DET: Mechatronic Systems: An Introduction (Higher)
44
Ladder Logic
What is ladder logic?
It is the graphical representation of how the system should react to changes at both its
inputs and its outputs.
The graphic symbols usually used are as follows:
Input rung of the ladder logic program
Output rung of the ladder logic program
or
Normally Open Input
Equivalent switch schematic
Normally Closed Input
Equivalent switch schematic
Output Devices
The LOGIC in ladder logic programs is implemented in the way these inputs and
output symbols are connected. Below is a single rung of a ladder logic program.
In 1
In 2
out 1
Simple (one rung) Ladder Logic Program (and function)
The way the inputs are connected determines the logic of the rung. In the example
above In 1 is ANDed with In 2.
In the example below In 1 is ORed with In 2.
In 1
out 1
In 2
Simple (one rung) Ladder Logic Program (or function)
The PLC has evolved to deal with digital switching but can be used to carry out
analogue control provided the correct analogue units have been added to the system.
These modules, usually provided by the same manufactured, allow the PLC to stay a
very flexible device. A minimal system usually forms the basis for a control problem
and extra modules are added as your system’s requirement grows.
For more information about program writing in ladder logic and using LadSIM and
the ladder logic simulation program see the Programmable Controlled Systems (D147
12) Support notes.
DET: Mechatronic Systems: An Introduction (Higher)
45
Controller Types Reviewed
Just to wind things up let’s review the controller types examined:
PC-based
Widely available and can carry out both Analogue and Digital control, (requires the
addition of the correct I/O card, uses memory for storage of the current
measured values and the program. Has the advantage of massive processing
power: Useful where image recognition is required or any other number
crunching process)
Embedded controller
Widely employed where there is no need, or room, for a full-blown PC. (Can be a
chopped version of the standard PC or a custom built ASIC or a microcontroller
based system)
Microcontroller
Widely employed in many household, automotive and industrial devices. (Usually on
a single chip and consists of a single microprocessor with built in analogue and
digital interfacing capability along with program storage area, memory, support
chips and circuitry)
Programmable Logic Controllers
Widely used in industry to control automated systems. (Consists of a
microprocessor, memory, solid state switches (relays) and can also be capable of
analogue and mathematical functions, usually by way of add on modules).
Hardwired Logic
Was once widely employed in many household, automotive and industrial devices.
(Usually on a printed circuit board it has no microprocessor or built in analogue
and digital interfacing capability. The circuits are individually designed for
specific tasks and require a complete re-design, test and re-build, in order to
control a new system).
DET: Mechatronic Systems: An Introduction (Higher)
46
PROGRAMMING
There are many different ways of visualising the internal architecture of the
microprocessor.
In the early days, computers were programmed by setting switches and by using patch
leads (this was the program). We have evolved since the days of toggle switches and
patch leads and now have these wonderful things called programming languages.
Without going into too much theory of computer science, the PC sitting on your desk
cannot, and never will be able to directly understand any word you care to say to it. If
you could open it up, apply your fingers to the internal tracks on the circuit board, and
tap out an electronic rhythm of 1s and 0s, then you might be approaching something
that could be called PC communication.
Writing computer programs this way would be tedious, error prone, and in reality
virtually impossible.
Traditionally programming languages have been divided into two forms, interpreted
and compiled.
Interpreted languages have a reputation for isolating their users from the system,
shielding them from the harsh realities of computer use and generally giving them a
very soft introduction to programming. Interpreted languages allocate the memory
requirements without the users knowledge. They also tend to be a lot slower and a lot
less slick than their compiled counterparts.
The reason for this latter point is simple. The interpreter adds code overheads which
are extra to the program. This makes the resulting machine code less efficient than a
version specifically tailored for the processor’s architecture.
Compiled Languages
A computer compiler takes your instructions and keywords (programs) and translates
them into the electronic 1s and 0s that the computer needs in order to be able to go
and do what you want it to do.
The original program is called the source program, sometimes referred to as the
source code. The machine language form of this program, after compilation, is called
the object code.
Once it has been translated into object code, it is linked with small, standard
procedure programs called library routines. It is these library routines that have
made compiled languages like C so popular due to the ability to selectively include
library files for different processor types, thus allowing cross platform compilation.
Compiled languages execute faster than interpreted programs, as they do not have the
burden of the underlying interpreter. Programmers using compiled language must
have a much better understanding of the memory requirements for their programs as
compilers leave this entirely up to the user.
DET: Mechatronic Systems: An Introduction (Higher)
47
Interpreted Languages
An interpreted program, on the other hand, does not immediately do what you want
it to do. It needs a program that sits in between the machine and your program.
When you run your program you are really running the interpreter which then happily
plods through your code one line at a time, transferring translated, interpreted
statements to the computer in a format it understands. It's a slow process, like talking
to someone through an interpreter.
Interpreted languages can alerts users to errors in statements at time of execution.
Interpreted languages also allow the user to execute a single statement before it is
included in the program.
This difference in languages is generally categorised into High-Level and Low-Level
Languages
Low-level languages (first and second-generation languages) provide binary
instructions for the computer to execute: these are known as machine languages.
High-level languages (third-generation languages) use English-like instructions that
cause the computer to carry out binary commands. They work at the level of the
programmer rather than at the level of the machine.
Low-Level Computer Languages
Machine Language (1st Generation Languages)
Expressed in binary, octal, or hexadecimal codes
Depends on the processor type
Assembly Language (2nd Generation Languages)
Expressed in abbreviations of commands: (mnemonics)
Depends on the processor type
User has complete control over the computers operations.
Executes faster than high level
High-Level Computer Languages
FORTRAN
FORmula TRANslator.
First high-level language, released in 1956.
Designed for scientific, mathematical, and engineering applications:
Compiled language - once compiled, extremely fast execution.
BASIC
Beginners All-purpose Symbolic Instruction Code.
Designed to be easy to learn, yet retain the formula translation characteristics
of FORTRAN. First used in 1964.
Current versions are much more powerful than early, simpler versions.
Very popular on personal computers.
Interpreted language, but compilers are available.
DET: Mechatronic Systems: An Introduction (Higher)
48
Pascal
Developed as a teaching language.
First released in 1971.
Programs must be written in a manner that meets accepted programming
standards. Enforces structured programming.
Now used for commercial applications as well as for teaching.
Most versions are compiled, but an interpreted version is available.
C
Developed at Bell Labs in 1974.
Produces machine-language code that executes extremely fast.
Allows a high degree of control over the machine.
Easily portable among computers and operating systems.
Many commercial programs are written in C.
Compiled language.
Very High-Level Languages
Often known as fourth-generation languages (4GLs).
Move the programmer even further away from the machine-code level than
high-level or third-generation languages.
They are usually nonprocedural - a user need write only what is to be done,
not how.
Natural Languages
Natural languages are closer to everyday human languages.
Natural languages excel at easy data access and are most commonly used to
interact with databases.
Object-Oriented Programming
Use objects (self-contained items that combine data and algorithm) instead of
structured programming.
Object-oriented programming languages:
Smalltalk
C++
Turbo Pascal
Your choice of programming languages should not be based solely on the ease of a
language to learn, however. You should also think carefully about the sort of tasks
you are likely to want your programs to perform. As noted, Perl is very well suited for
text manipulations and related tasks, but C would probably be preferred for a program
that needs to do a good deal of ‘number crunching’.
DET: Mechatronic Systems: An Introduction (Higher)
49
Download