Mechatronics Module 3-Cnc and Module-4-Plc
Mechatronics Module 3-Cnc and Module-4-Plc
Mechatronics Module 3-Cnc and Module-4-Plc
ME 407 – MECHATRONICS
MODULE IV
Mechatronics in Computer Numerical Control (CNC) machines: Design of modern
CNC machines.
Mechatronics elements - Machine structure: guide ways, drives. Bearings: anti-friction
bearings, hydrostatic bearing and hydrodynamic bearing. Re-circulating ball screws,
pre-loading methods. Re-circulating roller screws.
Typical elements of open and closed loop control systems. Adaptive controllers for
machine tools.
Programmable Logic Controllers (PLC) –Basic structure, input/ output processing.
Programming: Timers, Internal Relays, Counters and Shift registers. Development of
simple ladder programs for specific purposes.
MACHINE STRUCTURE
The machine structure is the load carrying and supporting member of the machine tool.
All motors, drive mechanisms and other functional assemblies of the machine tools are
aligned to each other and rigidly fixed to the machine structure.
Page | 1
ME 407 Mechatronics
The machine structure is subjected to static and dynamic forces and it should not deform or
vibrate beyond the permissible limits under the action of these forces.
All components of the machine must remain in correct relative positions to maintain the
geometric accuracy, regardless of the magnitude and direction of these forces.
The machine structure configuration is also influenced by the considerations of manufacture,
assembly and operation.
Static Load:
It results from the weights of slides and the workpiece, and the forces due to cutting.
The structure should have adequate stiffness and a proper structural configuration to keep
the deformation under static loading within the permissible limits.
Generally there are two basic configurations of machine tools as shown in figure 4.1
Dynamic Load:
It is a term used for the constantly changing forces acting on the structure while movement
is taking place. These forces cause the machine system to vibrate.
The origin of such vibration is;
o Unbalanced rotating parts
o Improper meshing of gears
o Bearing irregularities
o Interrupted cuts while machining
o The effect of these vibrations can be reduced by;
o Reducing the mass of the structure
o Increasing the stiffness of the structure
o Improving the damping properties
Page | 2
ME 407 Mechatronics
Thermal Load:
Some of the local heat sources which set up thermal gradient in machine tools are;
o Electric motor
o Friction in mechanical drives and gear boxes
o Friction in bearings and guideways
o Machining process
o Temperature of surrounding objects
These heat sources may cause localised deformation, resulting in considerable inaccuracies
in machine performance.
The following steps are generally followed to reduce thermal deformation;
o External mounting of drives, i.e. motors and gear boxes
o Removing frictional heat from bearings and guideways by a proper lubricating
system.
o Efficient cooling and swarf removal system for the dissipation of heat generated
from the machining process
o Thermo – symmetric designing of the structure.
o Reducing ambient temperature by installing air conditioning units.
GUIDEWAYS
Guideways (slide ways) are linear bearings for translatory motion between two members of
a machine tool such as carriage and bed in lathe.
Guideways are used in machine tools to;
o Control the direction or line of action of the carriage or the table on which a tool
or a workpiece is held.
o To absorb all the static and dynamic forces.
The shape and size of the work produced depends on the accuracy of the movement and on
the geometric and kinematic accuracy of the guideway.
The geometric relationship of the slide (moving part) and the guideway (stationary part) to
the machine base determines the geometric accuracy of the machine.
Kinematic accuracy depends up on the straightness, flatness and parallelism errors in
guideways.
Factors considered while designing guideways;
Rigidity
Damping capability
Geometric and kinematic accuracy
Velocity of slide
Friction characteristics
Wear resistance
Provision for adjustment of play
Position in relation to work area
Protection against swarf and damage.
Guideways are primarily of two types;
o Friction guideways
o Antifriction linear motion (LM) guideways
Page | 3
ME 407 Mechatronics
FRICTION GUIDEWAYS
Friction guideways are most widely used because of their low manufacturing cost and good
damping properties.
These guideways operate under conditions of sliding friction and do not have a constant
coefficient of friction.
The coefficient of friction is very high when the movement commences and as the speed of
the slide increases, it rapidly falls and beyond a certain critical velocity it remains almost
constant.
Stick – slip phenomenon – To start the movement, the force to overcome friction has to
be correspondingly high. This force results in the drive mechanism, such as a screw, being
elastically deformed. The energy thus stored in the screw, together with the applied force,
causes the carriage to slip and move at a faster rate.
As the speed increases the friction decreases and a greater amount of movement than that
intended for the slide takes place. There is a possibility of this cycle of events repeating
itself and resulting in errors in positioning and consequently in jerky motion. This
phenomenon is known as stick – slip phenomenon.
There should be a minimum but constant friction between the surfaces in contact to avoid
this phenomeneon. It is achieved by using strips of materials such as Poly Tetra Fluoro
Ethylene (PTFE) or Turcite lining at the guideway interface.
Different types of friction guideways are;
o Vee Guideways
o Flat and Dovetail Guideways
o Cylindrical Guideways
Page | 4
ME 407 Mechatronics
Vee Guideways
The vee or inverted vee is widely used on machine tools, especially on lathe beds.
One of the advantages of vee or inverted vee is that the parallel alignment of the guideway
with the spindle axis is not affected by wear.
There is a closing action as the upper member settles on the lower member, and this
automatically maintains the alignment. Jibs are, therefore, not required with the vee
guideway to take up the clearance caused by wear.
On some machines, the angles of the vee are different so as to reduce the possibility of
uneven wearing of vee sides.
The majority of lathes have a combination of vee and flat guideways to prevent the carriage
from lifting of the guideway.
Flat or dovetail forms are commonly used in CNC machine tools. The flat guideways have
better load – bearing capabilities than the other guideways.
Jibs are used to ensure accurate fitting of the slide to both the flat and dovetail guideways.
The jibs are tapered and can be adjusted to reduce excessive clearance caused by wear.
The metal to metal contact on the vee, flat and dovetail types of guideway is normally cast
iron to cast iron. The cast iron may be heat treated to increase its hardness and the surfaces
ground to obtain the required accuracy.
Page | 5
ME 407 Mechatronics
Cylindrical Guideways
In cylindrical guideways, the bore in the carriage housing provides support all around the
guideway.
For relatively short traverse and light loads, cylindrical guideways are very efficient.
A limitation on the use of these guideways for long traverse is that if the guide bar is
supported only at each end, it may sag or bend in the centre of the span under a load.
A linear ball bush uses recirculating balls within a bush type of bearing.
These are designed to run along precision ground shafts and offer frictionless movement
over varying strokes of length with high linear precision.
The recirculating linear roller bearings are used for movement along a flat plane.
Their main characteristic feature is that there is continuous roller circulation which allows
unlimited linear movement.
It consists of hardened and precision ground supporting elements and a number of
cylindrical rollers. As in the case of roller bearings, the rollers are guided between shoulders
of the supporting elements with very close tolerances.
The grinding element prevents the rollers from falling out and sliding against each other.
Also the guiding element assists in smooth return of the rollers to the loading zone.
The rollers are in constact with guideway machined on the bed of the machine. This
arrangement provides smooth and easy movement but the machine bed has to be machined
to an accurate form. Also the machine bed surfaces coming in contact with the rollers have
to be hardened.
These bearings can be mounted horizontally for load carrying applications such as machine
tool table or they can be mounted vertically to provide support, guidance and motion for the
vertical elements of the machine tool.
Advantages:
Disadvantages:
Page | 7
ME 407 Mechatronics
Hydrostatic Guideways
The surface of the slide is separated from the guideway by a very thin film of fluid supplied
at pressures as high as 300bar.
Frictional wear and stick slip are entirely eliminated.
A high degree of dynamic stiffness and damping is obtained with these guideways.
Their application is limited due to high cost and difficulty in assembly.
Aerostatic Guideways
The slide is raised on a cushion of compressed air which entirely separates the slide and the
guideway surfaces.
The major limitation is the lower stiffness, which limits their application to positioning only
( Eg. Coordinate Measuring Machine)
DRIVES
Basic function of a CNC machine is to provide automatic and precise motion control to its
elements such work table, tool spindle etc. Drives are used to provide such kinds of
controlled motion to the elements of a CNC machine tool.
A drive system consists of drive motors and ball lead-screws.
The control unit sends the amplified control signals to actuate drive motors which in turn
rotate the ball lead-screws to position the machine table or cause rotation of the spindle.
Drives used in an automated system or in CNC system are of different types such as
electrical, hydraulic or pneumatic.
Electrical drives:
These are direct current (DC) or alternating current (AC) servo motors. They are small in
size and are easy to control.
Hydraulic drives:
These drives have large power to size ratio and provide step less motion with great
accuracy. But these are difficult to maintain and are bulky.
Generally they employ petroleum based hydraulic oil which may have fire hazards at
upper level of working temperatures.
Also hydraulic elements need special treatment to protect them against corrosion.
Pneumatic drives:
This drives use air as working medium which is available in abundant and is fire proof.
They are simple in construction and are cheaper.
However these drives generate low power, have less positioning accuracy and are noisy.
Page | 8
ME 407 Mechatronics
Spindle drives to provide the main spindle power for cutting action
Feed drives to drive the axis
SPINDLE DRIVES
The spindle drives are used to provide angular motion to the workpiece or a cutting tool.
These drives are essentially required to maintain the speed accurately within a power band
which will enable machining of a variety of materials with variations in material hardness.
The speed ranges can be from 10 to 20,000 rpm.
The machine tools mostly employ DC spindle drives. But as of late, the AC drives are
preferred to DC drives due to the advent of microprocessor-based AC frequency inverter.
High overload capacity is also needed for unintended overloads on the spindle due to an
inappropriate feed. It is desirous to have a compact drive with highly smooth operation.
FEED DRIVES
Page | 9
ME 407 Mechatronics
Variable speed DC drives are used as feed drives in CNC machine tools. However now-a-
days AC feed drives are being used.
SPINDLE BEARINGS
The rotational accuracy of the spindle is dependent on the quality and design of the bearings
used and the preloading.
The bearings should support the spindle radially and axially.
The accuracy and the quality of the work produced depends directly on the geometrical
accuracy, running accuracy and stiffness of the spindle assembly.
Various types of spindle bearings used in the design of a spindle for machine tools are;
o Hydrodynamic bearings
o Hydrostatic bearings
o Antifriction bearings
HYDRODYNAMIC BEARINGS
Hydrodynamic bearings are journal bearings with a thin film of oil between the spindle and
journal.
These are used where the load carrying capacities are low and frequent starting and stopping
of the spindle is not required.
The essential features are;
o Simplicity
o Good damping properties
o Good running accuracy.
The pressure of the oil is created within the bearings by the rotation of the spindle. As the
spindle rotates, the oil in contact with the spindle is carried into wedge shaped cavities
Page | 10
ME 407 Mechatronics
between the spindle and the bearing . the oil pressure is increased as the oil is forced through
the small clearances between the bearing and the spindle.
The main limitation of hydrodynamic bearing is that a definite clearance (50μm to 200μm)
must be provided for the oil flim to be maintained between the spindle and the bearing. This
clearance may result in the centre of a spindle in the bearing to change its position owing to
variation in the applied force.
HYDROSTATIC BEARINGS
The spindle is supported by a relatively thick film of oil supplied under pressure.
The oil is pressurized by a pump external to the bearing.
The load carrying capacity of this type of bearing is independent of the rotational speed.
These are used only where temperature effects cause problems in the part accuracy as in the
case of grinding machines and fine boring machines.
They are very expensive.
Advantages are;
o High damping properties
o High running accuracy
o High wear resistance
Page | 11
ME 407 Mechatronics
ANTIFRICTION BEARINGS
Different types of ball and roller bearings used in CNC machines are;
o Ball bearings
o Deep groove ball bearings
o Angular contact ball bearings
o Roller bearings
o Cylindrical roller bearings
o Cylindrical roller bearings (double row) with taperd bore
o Tapered roller bearings
Advantages:
Low friction
Moderate dimensions
Lesser liability to suffer from wear or incorrect adjustment
Ease of replacement
High reliability.
In planetary roller screw the rollers are threaded and gear teeth are cut on each end of the
rollers. The gear teeth mesh with an internally toothed ring on the nut which drives the roller
to provide a rolling motion between the nut and the screw.
Rollers are equally spaced and positioned using spigots which engage themselves in the
locating rings at each end of the nut.
There is no axial movement of the rollers relative to the nut.
They are capable of transmitting high loads at fast speeds.
In recircuating type the rollers are not threaded but have circular grooves of thread form
along their length. The rollers are equally spaced around the shaft and are kept in their
circumferential position by a cage. The rollers move axially relative to the nut at a distance
equal to the pitch of the screw for each rotation of the screw or nut.
There is an axial recess cut along the inside of the nut. After one rotation of the drive screw,
the rollers pass into this recess and disengage from the thread on the screw and the nut.
While they are in the recess, the edge cam on a ring inside the nut causes them to move back
to their starting positions. While one roller is disengaged, other rollers provide the driving
power.
Page | 13
ME 407 Mechatronics
They are slower in operation than the planetary type, but are capable of taking high loads
with greater accuracy.
The efficiency of the recirculating ball screw is of the order of 90% and is obtained by the
balls providing rolling motion between the screw and the nut.
The mounting arrangement of ball screw depends on its required speed, length and size.
Page | 14
ME 407 Mechatronics
Recirculating arrangements:
The balls rotate between the screw and the nut, and at some point are returned to the start of
the thread in the nut. Two types of arrangements are there;
Recirculation through an external tube – the balls at the end of the thread will be picked
up by a return tube which recirculates the balls to the beginning of the load zone by
providing continuous rolling motion
Recirculation through an insert channel – the balls are returned to the start through a
channel inside the nut.
Advantages:
PRELOADING
Pre loading is an axial or thrust load applied to a bearing that removes excess backlash.
Preloading is the process of applying initial load to the nut which will cause elastic
deformation of the screw threads in the axial direction, thereby increasing the axial rigidity
of the ball screw nut.
Preloading of ball screws may be classified as follows;
o Constant pressure preload ballscrews
Belleville spring
Coil spring
o Constant position preload ballscrews
Double nut type preload
Tension preload type
Page | 15
ME 407 Mechatronics
Tension preload
Tension preload provides the required amount of preload by the insertion of a spacer of
specified width between the two nuts.
Each nut exerts pressure on its perspective ball, thus forcing the balls away from each other.
Compression preload
In this case also the preload is achieved through the insertion of a spacer between the nuts
but the pressure is applied in the opposite direction, squeezing them together and forcing the
balls against threads of the screw shaft.
The spacer thickness depends on the amount of preload
Oversize Preload
For single nit ball screws, one type of preload is accomplished by using balls which are just
slightly larger than the space provided between the nut and screw shaft.
This method is best suited to provide comparatively light preload to the extent of eliminating
axial clearance.
In oversize ball preload, the balls have 4 point contact, thereby increasing the operational
efficiency.
Page | 16
ME 407 Mechatronics
Integral Preload
The integral preload ball screws, in outward appearance, appear the same as single nut
oversize ball or non – preloaded ball screws, however there is a dimensional allowance in
the nut internal rotating element which provides the proper amount of preload.
The nut dimensions can be made shorter compared with the double nut type.
In this method of preloading a coil spring or Belleville spring is inserted between the two
nuts to provide a constant pressure preload.
Overloading should be avoided otherwise the balls may get jammed resulting in stoppage of
the motion
By this method transmission efficiency as high as 90% can be achieved.
Page | 17
ME 407 Mechatronics
CONTROL SYSTEMS
Controlled Variable – The quantity or condition of the controlled system which can be
directly measured and controlled is called controlled variable.
Indirectly controlled variable – The quantity or condition related to controlled variable, but
cannot be measured directly is called indirectly controlled variable.
Command – The input which can be independently varied is called command.
Reference input – A standard signal used for comparison in the close – loop system.
Actuating signal – The difference between the feedback signal and reference signal is called
actuating signal.
Disturbance – Any signal other than the reference which affects the system performance is
called disturbance.
System error – The difference between the actual value and ideal value is called system
error.
Control systems are classified into the following two basic types :
An Open-loop control system is one in which the control action is independent of the desired
output. The actuating signal depends only on the input command and output has no control
over it.
The elements of an open-loop control system can usually be divided into the following two
parts:
Controller
Controlled Process
An input signal or command is applied to the controller, whose output acts as the actuating
signal; the actuating signal then controls the controlled process so that the controlled
variable will perform according to prescribed standards.
Page | 18
ME 407 Mechatronics
In simple cases, the controller can be an amplifier, mechanical linkage, filter, or other
control element, depending on the nature of the system. In more sophisticated cases, the
controller can be a computer such as a microprocessor.
Advantages:
Simple construction.
Easy maintenance.
Less costly than a closed-loop system.
No stability problem
Convenient when output is difficult to measure or measuring the output precisely is
economically not feasible.
Disadvantages:
Since the system is affected by internal and external disturbances, the output may differ
from the desired value.
For getting accurate results, this system needs frequent and careful calibrations.
Any change in system component cannot be taken care of automatically.
Presence of non-linearities causes malfunctioning.
A closed-loop system is one in which control action is somehow dependent on the output.In
this case the controlled output is fed back through a feedback element and compared with
the reference input.
Thus the actuating signal is the difference of desired output and reference input.
Feedback is that property of a closed-loop system which permits the output or some other
controlled variable of the system, to be compared with the input to the system, so that the
appropriate control action may be formed as some function of the output and input.
A feedback is said to exist in system when a closed sequence of cause and effect relations
exists between system vaariables.
Page | 19
ME 407 Mechatronics
FEEDBACK DEVICES
Position feedback devices are used to measure the displacement of position of slide or table
and send signals to the comparator to correct the position.
Different types of position feedback devices are;
o Linear transducers
Ferranti System ( Moire Fringe Digitizer)
Inductosyn
o Rotary transducers
Rotary encoder
Absolute encoder
Incremental encoder
Gray coded encoder
Resolver
FERRANTI SYSTEM
A similar device as incremental encoder, but in operation principle its slightly different.
It makes use of Moire fringe detection in order to permit easier detection of position.
In linear transducer, the optical gratings are used. When the two grating overlap each other,
a ‘Moire fringe’ pattern is formed depending on the displacement.
The moire fringe pattern is formed when the linear grating is slightly tilted with respect to
scanner unit grating.
The actual distance moved by the fringe pattern can be calculated since it depends on the
grating spacing, the angle of grating and the distance moved.
Scale grating is available for both linear and rotary forms.
INDUCTOSYN
The principle of operation is similar to a resolver with very large number of stator poles
rather than 2 and with only one rotor.
The linear system has two parts namely scale and slider. The scale is similar to stator and the
slider is similar to rotor winding.
Page | 20
ME 407 Mechatronics
They have coils in the form of hair pin turns etched on to glass, steel or aluminium plates.
The coils are bonded to the scale over an insulating layer. The slider is sliding over the scale.
When two different voltages are applied with these two sliding coils, a corresponding emf is
induced. This emf is directly proportional to the position of the slider with respect to scale.
For a machining operation the term AC denotes control systems that measures certain output
variables and uses to control speed or feed. Some of the process variables that have been
used in AC machining systems include spindle deflection or force, torque, cutting
temperature and horse power.
The adaptive control is basically a feedback system that treats the CNC as an internal unit
and in which the machining variables automatically adapt themselves to the actual
conditions of the machining process.
IP (Performance Index) - is usually an economic function such as max production rate or
minimum machining cost.
Adaptive control is not suitable for every machining situation. In general, the following
characteristics can be used to identify situations where adaptive control can be beneficially
applied.
o The in-process time consumes a significant portion of the machining cycle time.
o There are significant sources of variability in the job for which AC can
compensate.
o The cost of operating the machine tool is high.
o The typical jobs involve steels, titanium and high strength alloys.
Identification Function:
Decision Function:
Once the system performance is determined, the next function is to decide how the control
mechanism should be adjusted to improve process performance.
The decision procedure is carried out by means of a pre-programmed logic provided by the
designer
Modification Function
Page | 22
ME 407 Mechatronics
The modification involves changing the system parameters or variables so as to drive the
process towards a more optimal state
CLASSIFICATION OF AC SYSTEMS
In practice the AC system of machine tools can be classified into two types:
o AC with optimization (ACO)
o AC with constrains (ACC)
o Geometric Adaptive Control (GAC)
ACC are systems in which machining conditions such as spindle speed or feed rate are
maximized within the prescribed limits of machines and tool constrains such as maximum
torque, force or horse power.
In AC system the correct feed and speed are automatically found and it is not necessary to
spend efforts on calculations of optimum feeds and speeds.
ACC systems do not utilize a performance index and are based on maximizing a machining
variable (e.g., feed rate) subject to process and machine constraints (e.g., allowable cutting
force on the tool, or maximum power of the machine).
The objective of most ACC types of systems is to increase the MRR during rough cutting
operations.
The ACO Systems for N/C machine tools is a control system that optimizes performance
index subjects to various constraints.
It is basically a sophisticated closed loop control system, which automatically works in
optimum conditions, even in the presences of work piece and tools materials variations.
Page | 23
ME 407 Mechatronics
Drawbacks of ACO
The main problem is that this require on-line measurement of tool wear.
So far there have been no industrially acceptable methods developed for the direct
measurement of tool wear.
Indirect measurement assumes that tool wear is proportional to other measurable variables
such as cutting forces and temperatures.
The drawback of using these indirect measurements is that variations in their values can be
caused by process variations other than tool wear, such as workpiece hardness or cutting
conditions.
Thus making it difficult to identify the tool wear effect from the effect of the other parameter
variations on the measurements.
Drawback of GAC
Both the dimensional accuracy and the surface finish are affected by the flank wear and the
crater wear of the tools which deteriorate during cutting.
These variables cannot be measured in real time; neither can they be accurately predicted
from off-line tool testing.
Page | 24
ME 407 Mechatronics
A major drawback is the unavailability of suitable sensors that have a reliable operation in a
manufacturing environment . (Tool wear sensor).
Another problem is the interface of an AC system with CNC units. As yet, manufacturers
have not standardized interfaces.
All these components are housed in a suitable cabinet designed for the industrial
environment.
Processor
Memory Unit
Contains programs and data files of logic, sequencing and I/O operations.
Also called user or application memory as its contents are entered by user.
In addition, the processor also has a system memory that directs execution of control
program and coordinates I/O operations.
Power Supply
Input/Output Module
Page | 26
ME 407 Mechatronics
Programming Device
As far as the PLC user is concerned, the steps in the control program are executed
simultaneously and continuously.
In truth, a certain amount of time is required for the PLC processor to execute the user
program during one cycle of operation.
The typical operating cycle of PLC is called a scan and it consists of three parts :
o Input Scan
o Program Scan
o Output Scan
ADVANTAGES OF PLC
Reliability
Flexibility in programming and reprogramming.
Cost effective for controlling complex systems.
Small physical size, shorter project time.
High speed of operation.
Ability to communicate with computer systems in the plant.
Ease of maintenance /troubleshooting.
Reduced space.
Energy saving.
DISADVANTAGES OF PLC
PLC devices are proprietary it means that part or software of one manufacturer
can’t be used in combination with parts of another manufacturer.
Limited design and cost option
Fixed Circuit Operations.
PLCs manufacturers offer only closed architectures.
TIMERS
There are four fundamental types of timers shown in Figure.
An on-delay timer will wait for a set time after a line of ladder logic has been true before
turning on, but it will turn off immediately.
An off-delay timer will turn on immediately when a line of ladder logic is true, but it will
delay before turning off.
Consider the example of an old car. If you turn the key in the ignition and the car does not
start immediately, that is an on-delay. If you turn the key to stop the engine but the engine
doesn’t stop for a few seconds, that is an off delay.
An on-delay timer can be used to allow an oven to reach temperature before starting
production. An off delay timer can keep cooling fans on for a set time after the oven has
been turned off.
Page | 28
ME 407 Mechatronics
A retentive timer will sum all of the on or off time for a timer, even if the timer never
finished.
A nonretentive timer will start timing the delay from zero each time.
Typical applications for retentive timers include tracking the time before maintenance is
needed.
A non retentive timer can be used for a start button to give a short delay before a conveyor
begins moving.
COUNTERS
There are two basic counter types:
o count-up
o count-down.
When the input to a count-up counter goes true the accumulator value will increase by 1 (no
matter how long the input is true.) If the accumulator value reaches the preset value the
counter DN bit will be set.
A count-down counter will decrease the accumulator value until the preset value is reached.
An Allen Bradley count-up (CTU) instruction is shown in Figure above. The instruction
requires memory in the PLC to store values and status, in this case is C5:0.
The C5: indicates that it is counter memory, and the 0 indicates that it is the first location.
The preset value is 4 and the value in the accumulator is 2.
If the input A were to go from false to true the value in the accumulator would increase to 3.
If A were to go off, then on again the accumulator value would increase to 4, and the DN bit
would go on. The count can continue above the preset value.
If input B goes true the value in the counter accumulator will become zero.
Count-down counters are very similar to count-up counters. And, they can actually both be
used on the same counter memory location.
INTERNAL RELAYS
Inputs are used to set outputs in simple programs. More complex programs also use internal
memory locations that are not inputs or outputs. These are sometimes referred to as ’internal
relays’ or ’control relays’.
Knowledgeable programmers will often refer to these as ’bit memory’. In the Allen Bradley
PLCs these addresses begin with ’B3’ by default.
Page | 29
ME 407 Mechatronics
The first bit in memory is ’B3:0/0’, where the first zero represents the first 16 bit word, and
the second zero represents the first bit in the word.
The sequence of bits is shown in Figure. The programmer is free to use these memory
locations however they see fit.
SHIFT REGISTERS
A shift register is a digital memory circuit found in calculators, computers, and data-
processing systems. Bits (binary digits) enter the shift register at one end and emerge from
the other end. The two ends are called left and right.
In its most basic form, the shift register is a bidirectional FIFO (first-in first-out) circuit.
When a bit is input on the left, all the bits in the register move one place to the right, and the
rightmost bit disappears. When a bit is input on the right, all the bits move one place to the
left, and the leftmost bit disappears.
Shift register instructions are PLC output instructions that are used to load data into a bit
array, one bit at a time.
The data is shifted through the bit array, and then unloaded from the bit array one bit at a
time. Shift register instructions are useful in conveyor applications and product evaluation
(pass/fail) control.
The PLC on your trainer includes the following shift register instructions: the bit shift left
(BSL) instruction and the bit shift right (BSR) instruction.
To enter a BSL or BSR instruction, the following parameters must be programmed:
File: address of the bit array through which the bits are shifted. The array must start at
the first bit position of a 16-bit element (element 1, 2, 3, etc.) in a binary (B) data file.
Control: 3-word register (R data file) that stores the status bits of the BSL or BSR
instruction and the length of the bit array.
Page | 30
ME 407 Mechatronics
Bit Address: location of the source bit that is inserted into the array. With a BSL
instruction, this bit is inserted into the first (lowest) bit position of the array. With a
BSR instruction, this bit is inserted into the last (highest) bit position of the array.
Length: total number of bits to be shifted within the bit array
The vertical lines of the diagram represent the power rails between which circuits are
connected. The power flow is taken to be from the left-hand vertical across a rung.
Each rung on the ladder defines one operation in the control process.
A ladder diagram is read from left to right and from top to bottom. The top rung is read
from left to right. Then the second rung down is read from left to right and so on.
When the PLC is in its run mode, it goes through the entire ladder program to the end, the
end rung of the program being clearly denoted, and then promptly resumes at the start. This
procedure of going through all the rungs of the program is termed a cycle. The end rung
might be indicated by a block with the word END or RET for return, since the program
promptly returns to its beginning.
Page | 31
ME 407 Mechatronics
Each rung must start with an input or inputs and must end with at least one output. The term
input is used for a control action, such as closing the contacts of a switch, used as an input to
the PLC. The term output is used for a device connected to the output of a PLC, e.g., a
motor.
Electrical devices are shown in their normal condition. Thus a switch, which is normally
open until some object closes it, is shown as open on the ladder diagram. A switch that is
normally closed is shown closed.
A particular device can appear in more than one rung of a ladder. For example, we might
have a relay that switches on one or more devices. The same letters and/or numbers are used
to label the device in each situation.
The inputs and outputs are all identified by their addresses, the notation used depending on
the PLC manufacturer. This is the address of the input or output in the memory of the PLC.
Basic Symbols
LOGIC FUNCTIONS
AND
It is a situation where an output is not energized unless two, normally open, switches are
both closed. Switch A and switch B have both to be closed, which thus gives an AND logic
situation.
Fig 4.40 (a) AND Circuit (b) AND Logic Gate (c) AND Ladder Diagram Rung
OR
Figure below shows an electrical circuit where an output is energized when switch A or B,
both normally open, are closed. This describes an OR logic gate in that input A or input B
must be on for there to be an output.
Fig 4.41 (a) OR Circuit (b) OR Logic Gate (c) OR Ladder Diagram Rung
Page | 33
ME 407 Mechatronics
NOT
Figure below shows an electrical circuit controlled by a switch that is normally closed.
When there is an input to the switch, it opens and there is then no current in the circuit.
This illustrates a NOT gate in that there is an output when there is no input and no output
when there is an input. The gate is sometimes referred to as an inverter.
NAND
Suppose we follow an AND gate with a NOT gate. The consequence of having the NOT
gate is to invert all the outputs from the AND gate.
An alternative, which gives exactly the same results, is to put a NOT gate on each input and
then follow that with OR.
Both the inputs A and B have to be 0 for there to be a 1 output. There is an output when
input A and input B are not 1. The combination of these gates is termed a NAND gate
NOR
Suppose we follow an OR gate by a NOT gate. The consequence of having the NOT gate is
to invert the outputs of the OR gate. An alternative, which gives exactly the same results, is
to put a NOT gate on each input and then an AND gate for the resulting inverted inputs.
The combination of OR and NOT gates is termed a NOR gate. There is an output when neither input
A or input B is 1.
Page | 34
ME 407 Mechatronics
EXCLUSIVE OR (XOR)
The OR gate gives an output when either or both of the inputs are 1. Sometimes there is,
however, a need for a gate that gives an output when either of the inputs is 1 but not when
both are 1.
Such a gate is called an Exclusive OR or XOR gate. One way of obtaining such a gate is by
using NOT, AND and OR gates.
LATCHING
There are often situations where it is necessary to hold an output energized, even when the
input ceases.
A simple example of such a situation is a motor, which is started by pressing a push button
switch. Though the switch contacts do not remain closed, the motor is required to continue
running until a stop push button switch is pressed.
The term latch circuit is used for the circuit used to carry out such an operation. It is a self-
maintaining circuit in that, after being energized, it maintains that state until another input is
received.
MULTIPLE OUTPUT
With ladder diagrams, there can be more than one output connected to a contact. Figure
shows a ladder program with two output coils. When the input contacts close, both the coils
give outputs.
For the ladder rung shown in Figure below, output A occurs when input A occurs. Output B
only occurs when both input A and input B occur.
Fig 4.48 Ladder Rung with Two Inputs and Two Outputs
LADDER SYMBOLS
To enter an output
Page | 36
ME 407 Mechatronics
FUNCTION BLOCKS
The term function block diagram (FBD) is used for PLC programs described in terms of
graphical blocks. It is described as being a graphical language for depicting signal and data
flows through blocks, these being reusable software elements.
A function block is a program instruction unit which, when executed, yields one or more
output values. Thus, a block is represented in the manner shown in figure below with the
function name written in the box.
LOGIC GATES
Page | 37