10 Analog Value Processing
10 Analog Value Processing
Contents 3
a
3. Analog value processing ....................................................................................... 3-2
3.1. Objectives ............................................................................................................................. 3-2
3.2. Task description .................................................................................................................... 3-3
di
3.3. Principle of analog value processing .................................................................................... 3-4
3.4. Properties of analog input modules ...................................................................................... 3-6
3.5. Properties of analog output modules .................................................................................... 3-8
In
3.6. Analog value representation and measured value resolution ............................................. 3-10
3.7. Analog value representation of different measuring ranges ............................................... 3-11
3.8. Analog value representation for the analog outputs ........................................................... 3-12
3.9. Scaling analog inputs with NORM_X and SCALE_X (1) .................................................... 3-13
3.9.1. Scaling analog inputs with NORM_X and SCALE_X (2) .................................................... 3-14
3.10. Controlling analog outputs with NORM_X and SCALE_X .................................................. 3-15
N
3.11. Comparator operations: IN_RANGE and OUT_RANGE .................................................... 3-16
AI
TR
SI
a
… be familiar with the principle of analog value processing
... be able to assign parameters to an analog module
... be able to address an analog module
di
... be able to interpret the resolution of a module
… be familiar with the operations for the analog value conversion
… be able to program a simple analog value conversion
In
... be able to evaluate the diagnostics interrupt of the analog module
N
Objectives
In this chapter, the principle of analog value processing is presented. The goal is that the
AI
participant can parameterize an analog module and of interpreting the resolution.
Furthermore, the necessary conversion operations are presented to be able to process an analog
value. The participant should be able to program a simple analog value conversion and be able to
interpret a diagnostics interrupt of an analog module.
TR
SI
a
• Pressure ± 500mV 0 0
• Temperature ± 1V IW96:P #temp IW96 #temp
• Flow ± 5V 27648 27648
di
• Speed ± 10V
• pH value ± 20mA
• Viscosity 4 to 20mA Analog output module
• etc. etc.
0.0 0.0
#temp QW80:P #temp QW80
1.0 1.0
In
Direct I/O access
Conversion
Physical Standard memory Output the Process image output table (PIQ) at
DAC the end of the cycle to the analog output
quantity analog signal
module
N
Principle of analog value processing
In a production process, there are a variety of physical quantities (such as pressure, temperature,
speed, rotational speed, pH value, and viscosity etc.) that need to be processed in the PLC for
automation purposes.
AI
Sensor
Measuring sensors respond to changes in the quantity to be measured by such things as linear
expansion, angular ductability, and alteration of electrical conductivity.
Transducer
TR
Measuring transducers convert these above-mentioned changes into standard analog signals,
such as: ± 500mV, ± 10V, ± 20mA, 4 to 20mA.
These signals are supplied to the analog input modules.
ADC
Before these analog values can be processed in the CPU, they must be converted to digital form.
The ADC (Analog-to-Digital Converter) on the analog input module handles this conversion.
The analog-to-digital conversion is performed sequentially. This means the signals are converted
SI
Result memory
The result of the conversion is stored in the result memory and remains there until it is overwritten
by a new value.
You can use the "IW...:P” addressing to read the converted analog value directly from the I/O.
Analog output
The (MOVE) transfer instruction is used to write the analog values the user program calculated to
an analog output module, where a DAC (Digital-to-Analog Converter) converts them to standard
analog signals.
Analog Actuators
You can connect standard actuators directly to the analog output modules.
a
For this purpose there are system blocks in converters in the task card "instructions”: NORM_X,
SCALE_X,
di
Direct peripheral access is identified by the ":P" addition, which can be programmed in
conjunction with the absolute address or symbolic name of the analog channel.
• Reading: current instantaneous value of the analog channel is read
• Writing: output value to the analog channel becomes process effective immediately
In
Access via process image
• Reading: The value "frozen for one cycle" from the process image of the inputs is read. This
is the value on the AI module at the beginning of the CPU cycle or start of an OB.
• - Writing: The present value is written into the process image of the outputs. This value is only
written to the AA module after the cycle or the parameterized OB has ended and only then is
N
it effective in the process.
AI
TR
SI
a
di
In
N
Analog input modules
In STEP7, analog input modules are configured and assigned parameters in the Device
configuration of the respective PLC. The settings or parameters of all modules are downloaded
into the CPU. The CPU must be in the STOP state to do this. In a subsequent CPU warm restart,
the CPU transfers these parameters to the relevant modules.
AI
Parameters
For the respective module, differentiation is made between module parameters and channel
parameters.
Module parameters
TR
• General
Name and comment for the integrated analog inputs of the CPU.
• Noise Reduction
In the noise reduction, the noise frequencies of the specified frequency (in Hz) are
suppressed by the integration time which is set.
• I/O Addresses and Hardware Identifier
The address space of the entry addresses as well as the process image is defined. The
SI
Channel parameters
• Measurement type
The type of measurement, such as voltage, is set with this parameter. An unused channel
must then be deactivated since it is otherwise also converted which would result in a longer
total conversion time of the module.
• Measuring Range (in the picture – Voltage range)
With this parameter, the measuring range of the selected type of measurement is set.
• Smoothing
a
The smoothing of analog values generates a stable analog signal for further processing.
Smoothing the analog values is recommended in case of fast signal changes (measured
value changes), for example, in the level measurement of fluctuating liquids.
• Underflow Diagnostics
di
Through this parameter, the underflow diagnostics is activated. If the measured value falls
below the underflow range of the channel, a diagnostic interrupt is triggered.
• Overflow Diagnostics
Through this parameter, the overflow diagnostics is activated. If the measured value exceeds
In
the overflow range of the channel, a diagnostic interrupt is triggered.
N
AI
TR
SI
a
di
In
N
Analog output modules
In STEP7, analog output modules are configured and assigned parameters in the Device
configuration of the respective PLC. The settings or parameters of all modules are downloaded
into the CPU. The CPU must be in the STOP state to do this. In a subsequent CPU warm restart,
the CPU transfers these parameters to the relevant modules.
AI
Parameters
For the respective module, differentiation is made between module parameters and channel
parameters.
Module parameters
TR
• General
Name and comment for the integrated analog outputs of the CPU.
• Reaction to CPU STOP
− Use substitute value
The peripheral device outputs the value previously set for the channel.
− Keep last value
The peripheral device retains the value last put out before STOP.
SI
Caution!
Make sure that the system is always in safe mode in the case of "Keep last value"!
Channel Parameters
• Output Type
The type of output, such as voltage, is set with this parameter. Unused outputs must be
deactivated since these are otherwise also converted which would result in a longer total
conversion time of the module.
• Output Range (in the picture – Voltage range)
The output range of the selected type of output is set with this parameter.
• Broken Wire Diagnostics (in Current mode)
a
With this parameter, the diagnostic Wire break is generated when there is a wire break. This
diagnostic is not noticeable in the zero range.
• Short-circuit Diagnostics (in Voltage mode)
With this parameter, a diagnostic is generated when there is a short-circuit of the output wire.
di
This diagnostic is not noticeable in the zero range.
• Overload Diagnostics
With this parameter, a diagnostic is generated when there is an overload.
• Substitute value
In
With this parameter, a substitute value is specified which the module is to output when the
CPU goes into STOP. The substitute value must be in the rated range, the over range or the
under range.
N
AI
TR
SI
8 128 80 * * * * * * * * * 0 0 0 0 0 0 0
a
9 64 40 * * * * * * * * * * 0 0 0 0 0 0
10 32 20 * * * * * * * * * * * 0 0 0 0 0
Reso-
di
lution 11 16 10 * * * * * * * * * * * * 0 0 0 0
in bits
+ sign 12 8 8 * * * * * * * * * * * * * 0 0 0
(VZ)
13 4 4 * * * * * * * * * * * * * * 0 0
In
14 2 2 * * * * * * * * * * * * * * * 0
15 1 1 * * * * * * * * * * * * * * * *
* = 0 or 1
N
Representation
Negative analog values are represented as the two's complement.
The value is positive if bit No. 15=0 and negative if bit No.15=1.
Resolution
AI
If the resolution of an analog module is less than 16 bits, the analog value is written into the
accumulator (module result memory) left-justified. The unused less significant bit positions are
filled with "0"s.
Accuracy
TR
Resolutions of between 8 and 16 bits are possible, depending on the type of module.
SI
a
Overflow >= 11.76 32767 >= 22.815 32767 >=352.778 32767 >= 1000.1 32767
di
10.00 27648 20.000 27648 300.000 27648 850.0 8500
7.50 20736 16.000 20736 225.000 20736 : :
Rated range : : : : : :
: :
-7.5 -20736 : : : : : :
-10.00 -27648 4.000 0 0.000 0 -200.0 -2000
In
- 10.0004 - 27649 3.9995 -1 -1 - 200.1 - 2001
negative
Under range : : : : : : :
values
- 11.759 - 32512 1.1852 - 4864 - 4864 - 243.0 - 2430
not
Underflow <= - 11.76 - 32768 <= 1.1845 - 32768 possible - 32768 <= - 243.1 - 32768
N
Voltage, Current (Symmetrical)
Converting the symmetrical voltage or current ranges results in a rated range of -27648 to
+27648.
• ± 80mV • ± 2,5 V • ± 3,2 mA
AI
• ± 250 mV • ± 5V • ± 10 mA
• ± 500 mV • ± 10V • ± 20 mA
• ±1V
• 0 ... 2 V • 0 ... 20 mA
• 1 ... 5 V • 4 ... 20 mA
Resistance
Converting the resistance ranges results in a rated range of 0 to +27648.
• 0 to 150 Ohm
• 0 to 300 Ohm
• 0 to 600 Ohm
SI
Temperature
Temperatures are measured with resistance thermometers or thermocouples. Converting results
in a rated range of ten times the temperature range
Voltage Current
Range Units
Output ranges: Output ranges:
0 to 10V 1 to 5V ± 10V 0 to 20mA 4 to 20mA ± 20mA
Overflow >=32767 0 0 0 0 0 0
a
27649 10.0004 5.0002 10.0004 20.0007 20.005 20.0007
di
: : :
0 0.9999 0 3.9995
Rated range - 6912 : :
: :
- 6913 0 : 0 :
: : :
: 0 : 0 :
: : :
In
- 27648 -10.0000 -20.000
1 to 5V
• 0 to 20mA
• 4 to 20mA
Overflow
If the value to be converted reaches the overflow range, the analog output module is disabled
(0V, 0mA).
SI
a
Sensor supplies only positive voltages Sensor also supplies negative voltage
di
OUT OUT
MAX = 1.0 MAX = 1.0
In
A B
Δ
Resolution
In example B, the measurement occurs with twice the resolution or with half as much measuring
TR
tolerance Δ, since the measured value is mapped to the greater units range of -27648 to +27648.
Data Types
• The parameters on the input-side can be one of the following data types:
SINT, INT, DINT, USINT, UINT, UDINT or REAL
• The parameter OUT can be one of the following data types: REAL or LREAL
SI
Parameters
• VALUE: Value which is scaled
• MIN: Lower limit of the value range
• MAX: Upper limit of the value range
• OUT: Scaled signal 0.0 to 1.0
A B
OUT
300
a
Sensor supplies only positive voltages B
di
OUT
300 0
VALUE
0.0 1.0
0
0.0 1.0
VALUE
In -300
N
SCALE_X
The "Scale" instruction scales the value at the VALUE input linearly by mapping it to a specified
value range. When the "Scale" instruction is executed, the floating-point value at the VALUE input
is scaled to the value range which was defined by the MIN and MAX parameters. The result of
the scaling is an integer which is stored at the OUT output.
AI
Example
In the example shown, the value at the VALUE input is scaled within the limits 0 to 300 for case
A. In case B, VALUE is scaled to the limits -300 to 300.
TR
The VALUE input may only be within the limits 0.0 to 1.0!
Parameters
• VALUE: Value which is scaled
• MIN: Lower limit of the value range
• MAX: Upper limit of the value range
• OUT: Result of scaling
SI
a
Calculated valve position in the
di
limits 0 to 100% is scaled to the
signal 0.0 to 1.0.
OUT OUT
1.0 27648
0.0
0 100
VALUE
In 0
0.0 1.0
VALUE
N
Controlling analog outputs (Example)
An analog value (valve position) calculated by the user program in the range 0 to 100% is
converted to the range 0 to +27648 through the combination of NORM_X and SCALE_X. In
outputting the unscaled value to an analog output module, it will control the analog actuator (for
example, a servo valve) with, for example, 0V to +10V (depending on the output range set).
AI
The example shows the scaling for an actuator that is to be controlled with the value 0 (0V or
0mA) when the program value is 0%, and with the maximum value (for example, +10V or 20mA)
when it is 100%.
TR
SI
a
di
In
100 500
IN_RANGE
OUT_RANGE
N
IN_RANGE
With the "Value within range" instruction you can query whether the value at the VAL input is
within a specific value range. You define the limits of the value range with the parameters MIN
and MAX. In executing the query, the "Value within range" instruction compares the value at the
VAL input with the values of the parameters MIN and MAX and assigns the result to the box
AI
output. If the value at the VAL input fulfills the comparison MIN <= VAL <= MAX, the box output
has signal state "1". When the comparison is not fulfilled, the box output has signal state "0".
The compare function is only executed if the values to be compared are of the same data type
and the box output is used.
OUT_RANGE
TR
With the "Value outside range" instruction you can query whether the value at the VAL input is
outside of a specific value range. The limits of the value range are defined through the
parameters MIN and MAX. In executing the query, the "Value outside range" instruction
compares the value at the VAL input with the values of the parameters MIN and MAX and
assigns the result to the box output. If the value at the VAL input fulfills the comparison MIN >
VAL or VAL > MAX, the box output has signal state "1". When the comparison is not fulfilled, the
box output has signal state "0".
The compare function is only executed if the values to be compared are of the same data type
SI
OK / NOT_OK
The OK (NOT_OK) instruction checks whether the value of the variable specified through the box
corresponds to a valid REAL or LREAL. If this is the case, the box supplies RLO '1' at its output.