- •16. ADVANCED LADDER LOGIC FUNCTIONS
- •16.1 INTRODUCTION
- •16.2 LIST FUNCTIONS
- •16.2.1 Shift Registers
- •16.2.2 Stacks
- •16.2.3 Sequencers
- •16.3 PROGRAM CONTROL
- •16.3.1 Branching and Looping
- •16.3.2 Fault Detection and Interrupts
- •16.4 INPUT AND OUTPUT FUNCTIONS
- •16.4.1 Immediate I/O Instructions
- •16.4.2 Block Transfer Functions
- •16.5 DESIGN TECHNIQUES
- •16.5.1 State Diagrams
- •16.6 DESIGN CASES
- •16.6.1 If-Then
- •16.6.2 Traffic Light
- •16.7 SUMMARY
- •16.8 PRACTICE PROBLEMS
- •16.9 PRACTICE PROBLEM SOLUTIONS
- •16.10 ASSIGNMENT PROBLEMS
- •17. OPEN CONTROLLERS
- •17.1 INTRODUCTION
- •17.3 OPEN ARCHITECTURE CONTROLLERS
- •17.4 SUMMARY
- •17.5 PRACTICE PROBLEMS
- •17.6 PRACTICE PROBLEM SOLUTIONS
- •17.7 ASSIGNMENT PROBLEMS
- •18. INSTRUCTION LIST PROGRAMMING
- •18.1 INTRODUCTION
- •18.2 THE IEC 61131 VERSION
- •18.3 THE ALLEN-BRADLEY VERSION
- •18.4 SUMMARY
- •18.5 PRACTICE PROBLEMS
- •18.6 PRACTICE PROBLEM SOLUTIONS
- •18.7 ASSIGNMENT PROBLEMS
- •19. STRUCTURED TEXT PROGRAMMING
- •19.1 INTRODUCTION
- •19.2 THE LANGUAGE
- •19.3 SUMMARY
- •19.4 PRACTICE PROBLEMS
- •19.5 PRACTICE PROBLEM SOLUTIONS
- •19.6 ASSIGNMENT PROBLEMS
- •20. SEQUENTIAL FUNCTION CHARTS
- •20.1 INTRODUCTION
- •20.2 A COMPARISON OF METHODS
- •20.3 SUMMARY
- •20.4 PRACTICE PROBLEMS
- •20.5 PRACTICE PROBLEM SOLUTIONS
- •20.6 ASSIGNMENT PROBLEMS
- •21. FUNCTION BLOCK PROGRAMMING
- •21.1 INTRODUCTION
- •21.2 CREATING FUNCTION BLOCKS
- •21.3 DESIGN CASE
- •21.4 SUMMARY
- •21.5 PRACTICE PROBLEMS
- •21.6 PRACTICE PROBLEM SOLUTIONS
- •21.7 ASSIGNMENT PROBLEMS
- •22. ANALOG INPUTS AND OUTPUTS
- •22.1 INTRODUCTION
- •22.2 ANALOG INPUTS
- •22.2.1 Analog Inputs With a PLC
- •22.3 ANALOG OUTPUTS
- •22.3.1 Analog Outputs With A PLC
- •22.3.2 Pulse Width Modulation (PWM) Outputs
- •22.3.3 Shielding
- •22.4 DESIGN CASES
- •22.4.1 Process Monitor
- •22.5 SUMMARY
- •22.6 PRACTICE PROBLEMS
- •22.7 PRACTICE PROBLEM SOLUTIONS
- •22.8 ASSIGNMENT PROBLEMS
- •23. CONTINUOUS SENSORS
- •23.1 INTRODUCTION
- •23.2 INDUSTRIAL SENSORS
- •23.2.1 Angular Displacement
- •23.2.1.1 - Potentiometers
- •23.2.2 Encoders
- •23.2.2.1 - Tachometers
- •23.2.3 Linear Position
- •23.2.3.1 - Potentiometers
- •23.2.3.2 - Linear Variable Differential Transformers (LVDT)
- •23.2.3.3 - Moire Fringes
- •23.2.3.4 - Accelerometers
- •23.2.4 Forces and Moments
- •23.2.4.1 - Strain Gages
- •23.2.4.2 - Piezoelectric
- •23.2.5 Liquids and Gases
- •23.2.5.1 - Pressure
- •23.2.5.2 - Venturi Valves
- •23.2.5.3 - Coriolis Flow Meter
- •23.2.5.4 - Magnetic Flow Meter
- •23.2.5.5 - Ultrasonic Flow Meter
- •23.2.5.6 - Vortex Flow Meter
- •23.2.5.7 - Positive Displacement Meters
- •23.2.5.8 - Pitot Tubes
- •23.2.6 Temperature
- •23.2.6.1 - Resistive Temperature Detectors (RTDs)
- •23.2.6.2 - Thermocouples
- •23.2.6.3 - Thermistors
- •23.2.6.4 - Other Sensors
- •23.2.7 Light
- •23.2.7.1 - Light Dependant Resistors (LDR)
- •23.2.8 Chemical
- •23.2.8.2 - Conductivity
- •23.2.9 Others
- •23.3 INPUT ISSUES
- •23.4 SENSOR GLOSSARY
- •23.5 SUMMARY
- •23.6 REFERENCES
- •23.7 PRACTICE PROBLEMS
- •23.8 PRACTICE PROBLEM SOLUTIONS
- •23.9 ASSIGNMENT PROBLEMS
- •24. CONTINUOUS ACTUATORS
- •24.1 INTRODUCTION
- •24.2 ELECTRIC MOTORS
- •24.2.1 Basic Brushed DC Motors
- •24.2.2 AC Motors
- •24.2.3 Brushless DC Motors
- •24.2.4 Stepper Motors
- •24.2.5 Wound Field Motors
plc analog - 22.13
important if the data is not in 2s compliment form. Word 4 indicates when data has been read from a channel. The data values for the analog inputs are stored in words from 5 to 19. In this example, the status for channel 9 are N7:11/8 (under range), N7:12/8 (over range), N7:13/8 (sign) and N7:14/8 (data read). The data value for channel 9 is in N7:13.
N7:10 |
0 |
|
|
|
1 |
|
2 |
|
3 |
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
D |
D |
D |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
u16 |
u15 |
u14 |
u13 |
u12 |
u11 |
u10 |
u9 |
u8 |
u7 |
u6 |
u5 |
u4 |
u3 |
u2 |
u1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
v16 |
v15 |
v14 |
v13 |
v12 |
v11 |
v10 |
v9 |
v8 |
v7 |
v6 |
v5 |
v4 |
v3 |
v2 |
v1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
s16 |
s15 |
s14 |
s13 |
s12 |
s11 |
s10 |
s9 |
s8 |
s7 |
s6 |
s5 |
s4 |
s3 |
s2 |
s1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
d1 |
d1 |
d1 |
d1 |
d1 |
d1 |
d1 |
d1 |
d1 |
d1 |
d1 |
d1 |
d1 |
d1 |
d1 |
d1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
d16 |
d16 |
d16 |
d16 |
d16 |
d16 |
d16 |
d16 |
d16 |
d16 |
d16 |
d16 |
d16 |
d16 |
d16 |
d16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
D - diagnostics
u - under range for input channels v - over range for input channels s - sign of data
d - data values read from inputs
Figure 22.10 Data Returned by the 1771-IFE Analog Input Card
Most new PLC programming software provides tools, such as dialog boxes to help set up the data parameters for the card. If these aids are not available, the values can be set manually in the PLC memory.
22.3 ANALOG OUTPUTS
Analog outputs are much simpler than analog inputs. To set an analog output an integer is converted to a voltage. This process is very fast, and does not experience the timing problems with analog inputs. But, analog outputs are subject to quantization errors. Figure 22.11 gives a summary of the important relationships. These relationships are almost identical to those of the A/D converter.
plc analog - 22.14
R = 2 |
N |
= Rmax – Rmin |
|
|
|
(5) |
||||||
|
|
|
|
|
||||||||
VERROR = |
|
Vmax – Vmin |
|
|
|
(6) |
||||||
|
|
|
2R |
|
|
|
|
|
||||
|
|
---------------------------- |
|
|
|
|
|
|
|
|||
VI = INT |
|
Vdesired – Vmin |
( R – 1) + Rmin |
|
(7) |
|||||||
|
|
|||||||||||
|
|
|
|
|
V |
max |
– V |
min |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
Voutput |
= |
VI – Rmin ( Vmax – Vmin) + Vmin--------------------- |
(8) |
|||||||||
|
|
|
|
( R – 1 ) |
|
|
|
|
|
where,
R, Rmin, Rmax = absolute and relative resolution of A/D converter VERROR = the maximum quantization error
VI = the integer value representing the desired voltage Voutput = the voltage output using the integer value
Vdesired = the desired analog output value
Figure 22.11 Analog Output Relationships
Assume we are using an 8 bit D/A converter that outputs values between 0V and 10V. We have a resolution of 256, where 0 results in an output of 0V and 255 results in 10V. The quantization error will be 20mV. If we want to output a voltage of 6.234V, we would specify an output integer of 159, this would result in an output voltage of 6.235V. The quantization error would be 6.235V-6.234V=0.001V.
plc analog - 22.15
Given,
N = 8, Rmin = 0
Vmax = 10V
Vmin = 0V
Vdesired = 6.234V
Calculate,
R = Rmax = 2N = 256
VERROR = |
|
V----------------------------max – Vmin |
= 0.020V |
||||||
|
|
|
|
|
2R |
|
|
|
|
V = INT |
|
|
Vin – Vmin |
( R – 1) |
+ 0 |
||||
|
|||||||||
I |
|
|
V |
|
– V |
|
|
|
|
|
|
|
|
max |
|
min |
|
|
|
|
|
|
|
|
|
|
|||
V = |
V-------------I – 0 |
( V – V ) + V |
|
||||||
C |
R – 1 |
|
|
max |
min |
min |
|||
|
|
|
|
|
=159
=6.235V
The current output from a D/A converter is normally limited to a small value, typically less than 20mA. This is enough for instrumentation, but for high current loads, such as motors, a current amplifier is needed. This type of interface will be discussed later. If the current limit is exceeded for 5V output, the voltage will decrease (so don’t exceed the rated voltage). If the current limit is exceeded for long periods of time the D/A output may be damaged.
plc analog - 22.16
ASIDE:
MSB bit 3
bit 2
Computer
bit 1
LSB bit 0
|
|
|
|
5KΩ |
10KΩ |
V– |
|
- |
Vss |
|
|
|
|
|
20KΩ |
V |
+ |
+ |
+ |
|
|
|||
|
|
|
|
0 |
|
|
|
|
Vo |
40KΩ |
|
|
|
|
|
|
|
|
- |
80KΩ |
|
|
|
|
First we write the obvious,
V + = 0 = V–
Next, sum the currents into the inverting input as a function of the output voltage and the input voltages from the computer,
|
Vb3 |
Vb2 |
Vb1 |
Vb0 |
Vo |
10--------------KΩ |
+ 20--------------KΩ |
+ 40--------------KΩ |
+ 80--------------KΩ |
= 5-----------KΩ |
|
|
Vo |
= 0.5Vb3 |
+ 0.25Vb2 + 0.125Vb1 + 0.0625Vb0 |
||
Consider an example where the binary output is 1110, with 5V for on, |
|||||
|
Vo |
= 0.5( 5V) + 0.25( 5V) + 0.125( 5V) + 0.625( 0V) = 4.375V |
Figure 22.12 A Digital-To-Analog Converter
22.3.1 Analog Outputs With A PLC
The PLC-5 ladder logic in Figure 22.13 can be used to set analog output voltages with a 1771-OFE Analog Output Card. The BTW instruction will write configuration memory to the card (the contents are described later). Values can also be read back from the card using a BTR, but this is only valuable when checking the status of the card and detecting errors. The BTW is edge triggered, so the BT10:0/EN input prevents the BTW from restarting the instruction until the previous block has been sent. The MOV instruc-
plc analog - 22.17
tion will change the output value for channel 1 on the card.
BT10:0/EN |
Block Transfer Write |
|||
|
|
|
Module Type Generic Block Transfer |
|
|
|
|
Rack 000 |
|
|
|
|
||
|
|
|
Group 3 |
|
|
|
|
||
|
|
|
Module 0 |
|
|
|
|
Control Block BT10:0 |
|
|
|
|
Data File N9:0 |
|
|
|
|
Length 13 |
|
|
|
|
Continuous No |
|
update |
|
|
||
|
|
|||
MOV |
|
|||
|
|
|
|
|
|
|
|
Source 300 |
|
|
|
|
|
|
|
|
|
Dest N9:0 |
|
|
|
|
|
|
|
|
|
||
Figure 22.13 Controlling a 1771-OFE Analog Output Card |
The configuration memory structure for the 1771-OFE Analog Output Card is shown in Figure 22.14. The card has four 12 bit output channels. The first four words set the output values for the card. Word 0 (N9:0) sets the value for channel 1, word 1 (N9:1) sets the value for channel 2, etc. Word 4 configures the card. Bit 16 (N9:4/15) will set the data format, bits 5 to 12 (/4 to /11) will enable scaling factors for channels, and bits 1 to 4 (/0 to /3) will provide signs for the data in words 0 to 3. The words from 5 to 13 allow scaling factors, so that the values in words 0 to 3 can be provided in another range of values, and then converted to the appropriate values. Good default values for the scaling factors are 0 for the lower limit and 4095 for the upper limit.