Analog Value Processing: High Level
Analog Value Processing: High Level
High Level
Level
Transmitter
Low Level
Contents Page
Objectives .................................................................................................................................... 2
Using Analog Modules ……........................................................................................................ 3
Measuring Range Modules …….................................................................................................... 4
Analog Module Properties ........................................................................................................... 5
Analog Input Modules …............................................................................................................. 6
Analog Output Modules ….......................................................................................................... 7
Analog Value Representation and Measured Value Resolution .................................................. 8
Analog Value Representation of Different Measuring Ranges ................................................... 9
Analog Value Representation for the Analog Outputs .................................................................. 10
Analog Module Addresses for the S7-300 .................................................................................... 11
Scaling Analog Input Values ……………………………………................................................ 12
Unscaling Analog Output Values ................................................................................................ 13
Exercise 1: Assigning Parameters to the SM331 Analog Module ……....................................... 14
Exercise 2: Hardware Diagnosis with Diagnostic Interrupt ….……………………....................... 15
Exercise 3: Checking the Weight (OB 35) ................................................................................... 16
Physical Standard :
quantity analog signal Result :
memory :
:
PIW ... :
PIW ... :
MR ADC L PIW 304
module :::
Sensor Transducer PIW ... ..
..
..
..
• Pressure ± 500mV ..
• Temperature ± 1V ..
• Flow ± 5V ..
• Speed ± 10V ..
• pH value ± 20mA ..
• Viscosity 4 to 20mA ..
• etc. etc. Analog output module ..
..
..
..
..
..
..
..
PQW ... ..
Physical Analog PQW ...
DAC ::: T PQW 304
quantity actuator
PQW ... :
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 for each analog input channel in turn.
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 "L PIW..." load instruction to read the converted analog value.
Analog Output The "T PQW..." 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 The analog output signals are standard signals such as ± 10V or 4 to 20mA. You
can connect the analog actuators directly to the analog output modules without
using converters.
Type of Measurement You set the type of measurement and the measuring range when you set
coding keys on the measuring range module.
Special modules without coding keys have different terminals for voltage and
current measurement. Thus, you set the type of measurement by wiring the
appropriate terminal.
Measuring Range The measuring range modules with their coding keys are located on the left-
Module hand side of the module. You must set them correctly before installing the
module.
The possible settings are "A", "B", "C" and "D".
The settings for the various types of measurement and measuring ranges are
printed on the module.
Channel Groups On some modules, several channels are grouped together to form a channel
group. In this case, the coding key setting applies to the whole channel group.
Double-click
Parameter The tool for assigning parameters to analog input and output modules in
Assignment SIMATIC S7 is HW Config. The settings or parameters of all modules are
loaded 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 via the backplane bus.
Diagnostic Interrupt The module triggers a diagnostic interrupt on the CPU when an error occurs.
Then an error information is entered in the diagnostic buffer and the CPU
immediately processes the program in Diagnostic Interrupt Organization Block
OB82. In this block, the user can program the necessary response to the error
that occurred.
Which errors an analog module can recognize depends on the module type.
Error examples:
• Incorrect parameter assignment data
• Short circuit to ground (only for analog output channels)
• Wire break
• Missing load voltage L+
Hardware interrupt The module triggers a hardware interrupt when a particular event occurs (such
as exceeding a voltage limit on a channel of an analog input module). Then the
CPU immediately processes an interrupt program that the user stores in one of
OB40 to 47, to determine the response to the event.
Note: Only the first channel of a channel group can monitor the input value for the
assigned limit values!
Settings • Measuring Type: Click the field to display and select the available
measurement types (voltage, current...). The entry "deactivated" is selected
for unused channels or channel groups. On the module, these channels
have to be grounded.
• Measuring Range: Click the field to display and select the available effective
ranges for the corresponding measurement type.
• Position of Measuring Range Selection Module: When you select a
measuring type and a measuring range, a particular position becomes
necessary on the measuring range module. This is displayed.
• Integration time and Interference frequency suppression are quantities that
are interdependent.
Integration Time When you use the “HW Config” tool, the resolution is specified indirectly
through the selection of an integration time.
The following table for SM331 illustrates the relationship between integration
time, resolution and interference frequency suppression:
Integration time Resolution Interference frequency suppression
(ms) (in bits) (Hz)
2.5 9 + sign bit 400
16.6 12 + sign bit 60
20 12 + sign bit 50
100 14 + sign bit. 10
Conversion Time The (A/D) conversion time depends directly on the conversion method
(integrating method, successive approximation) of the analog input channel.
The conversion times for the individual modules can be found in the S7-300
manual.
For example: For an SM344, the conversion time for all 4 input channels is only
5ms.
Note Unused inputs should be deactivated. This then reduces the conversion time.
General Depending on the type of analog output module, voltages and/or currents can
be encoded or output (see slide).
Reaction to The behavior of analog output modules in the CPU STOP state can be
CPU STOP parameterized:
• OCV (Outputs have no current or voltage):
In the CPU STOP state, the module outputs 0V or 0mA
• KLV (Keep last value)
In the CPU STOP state, the module outputs the last encoded value (voltage
or current)
Note Unused outputs should be deactivated. This then reduces the conversion time.
8 128 80 * * * * * * * * * 0 0 0 0 0 0 0
9 64 40 * * * * * * * * * * 0 0 0 0 0 0
10 32 20 * * * * * * * * * * * 0 0 0 0 0
Reso-
lution
11 16 10 * * * * * * * * * * * * 0 0 0 0
in bits
+ sign
12 8 8 * * * * * * * * * * * * * 0 0 0
13 4 4 * * * * * * * * * * * * * * 0 0
14 2 2 * * * * * * * * * * * * * * * 0
15 1 1 * * * * * * * * * * * * * * * *
* = 0 or 1
Resolution If the resolution of an analog module is less than 16 bits, the analog value is
written into the accumulator left-justified. The unused less significant bit
positions are filled with "0"s.
Accuracy Resolutions of between 8 and 16 bits are possible, depending on the type of
module.
Overflow >= 11.759 32767 >= 22.815 32767 >=352.778 32767 >= 1000.1 32767
Voltage Current
Units
Range 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
Overrange 32511 11.7589 5.8794 11.7589 23.515 22.81 23.515
: : : : : : :
27649 10.0004 5.0002 10.0004 20.0007 20.005 20.0007
Overflow If the value to be converted reaches the overflow range, the analog output
module is disabled (0V, 0mA).
Rack 3 Power IM 640 656 672 688 704 720 736 752
Supply
(Receive)
to to to to to to to to
654 670 686 702 718 734 750 766
Rack 1 Power IM 384 400 416 432 448 464 480 496
Supply
(Receive) to to to to to to to to
398 414 430 446 462 478 494 510
Slot 2 3 4 5 6 7 8 9 10 11
Address Area The S7-300 has special address areas for analog inputs and analog outputs.
These areas are separate from the process image input (PII) and process image
output (PIQ) tables for digital input and output modules.
Each address area extends from byte 256 to byte 767. Each analog channel
occupies 2 bytes.
Access You use Load and Transfer instructions to access the analog modules.
Example: The statement "L PIW256" reads the first channel of the first module in
rack 0.
S7-400 On the S7-400, the address area for the analog modules starts at byte 512.
Δ
A B
Δ
Examples The level of a tank, whose volume is 500 liters, is to be measured in liters.
Example A shows the scaling when a sensor is used that supplies a measured
voltage of 0V when the tank is empty and a measured voltage of +10V when
the tank is full. Example B shows the scaling when a sensor is used that
supplies a measured voltage of -10V when the tank is empty and a measured
voltage of +10V when the tank is full.
Resolution In example B, the level is measured with twice the resolution or with half as
much measuring tolerance Δ, since the volume of the tank is scaled to the
greater units range of -27648 to +27648.
Scaling The analog module encrypts the voltage range of -10V to +10V in the value
range of -27648 to +27648. The conversion of this value range to the original
physical size (such as 0 l to 500 l) is called scaling.
The standard block FC 105 is used for scaling the analog value. FC 105 is
supplied with the STEP 7 software in the "Standard Library" in the "TI-S7
Converting Blocks" S7 program.
IN The analog value at input IN can be read in from the module directly or can be
passed from a data interface in INT format.
LO_LIM, HI_LIM Inputs LO_LIM (low limit) and HI_LIM (high limit) are used for specifying the
limits of the basic physical size. In the example, a conversion to the range 0 to
500 liters is made.
OUT The scaled value (physical size) is stored as a real number at output OUT
(LO_LIM <= OUT <= HI_LIM).
BIPOLAR At input BIPOLAR you can specify as to whether only positive or also negative
values are to be converted. If an operand with the state ´0´ (unipolar) is passed
to the parameter, scaling is made for the range 0 to +27648. If the operand
state is ´1´ (bipolar), scaling is made for the range -27648 to +27648.
RET_VAL The output RET_VAL supplies the value 0 when execution is error free.
OUT
27648
B
OUT
0
27648 IN
A 0.0 100.0
(LO_LIM) (HI_LIM)
unipolar (M 0.0 = ´0´)
(Actuator is energized
only with positive values)
0
IN -27648
0.0 100.0
(LO_LIM) (HI_LIM)
Examples An analog value in the range 0.0 to 100.0% that is calculated by the user program
is converted (unscaled) with FC106 to the range 0 to +27648 (uni-polar) or -
27648 to +27648 (bipolar). When the unscaled value is output to an analog output
module, this module will energize the analog actuator (such as a servo valve)
with a value such as 0V to +10V (unipolar) or -10V to +10V (bipolar).
Example A shows the scaling when an actuator is used that is to be energized
with the value 0 (0V or 0mA) when the program value is 0% and is to be
energized with maximum value ( such as +10V or 20mA) when the program value
is 100%.
Example B shows the scaling when an actuator is used that is to be energized
with the minimum value (-10V or -20mA) when the program value is 0% and is to
be energized with the maximum value (such as +10V or 20mA) when the
program value is 100%.
Unscaling A value calculated by the program - in the example shown a percentage - must
be converted (unscaled) to the value range of the analog output module.
The standard block FC 106 is used for unscaling. FC 106 is supplied with the
STEP 7 software in the "Standard Library" in the "TI-S7 Converting Blocks" S7
program.
IN The value calculated by the program must be passed in the REAL format.
LO_LIM, HI_LIM Inputs LO_LIM (low limit) and HI_LIM (high limit) specify the limits for the
program value. In the example, this is the range 0.0% to 100.0%.
OUT The unscaled value is output in the INT format at output OUT.
BIPOLAR At input BIPOLAR you can specify as to whether only positive or also negative
values are to be converted. If an operand with the state ´0´ (unipolar) is passed to
the parameter, unscaling is made for the range 0 to +27648. If the operand state
is ´1´ (bipolar), unscaling is made for the range -27648 to +27648.
RET_VAL The output RET_VAL supplies the value 0 when execution is error free.
Task You are to assign parameters to the analog module using the parameters shown
in the slide above.
Task After you have assigned parameters to your analog module in the previous
exercise and have activated the diagnostic interrupt, you are now to initiate a
diagnostic interrupt by knowingly setting the simulator voltage too high.
After the CPU has gone into the STOP state because of the diagnostic interrupt,
"troubleshoot" the "error" that occurred with the Hardware Diagnostics test
function (see slide).
Structogram OB 35
Read in weight and scale using
Library Block FC 105
Store in "MW_Weight" (MW 36)
Weight > 400 kg
NO YES
Display Weight < 100 kg
of current
weight NO YES
Weight OK: Weight invalid: M 35.0 = 0
M 35.0 = 1 Flashing light at Q 4.0
Function (OB35) The part weight (0 to 500kg) is simulated via the simulator potentiometer
Weight Check "PIW_AI1" (PIW 304) and displayed on the touchpanel screen "Conv" at the
output field "Weight" (MW 36).
As long as an invalid weight (weight < 100kg or weight > 400kg) is set…
• … the simulator indicator light "L_Weight_invalid" (Q 4.0) flashes
• … the indicator light on the light barrier bay is dark because, with an invalid
weight, no new part may be placed on the conveyor
• … no new transport function can be started
What to Do 1. In the hardware configuration of your station, set the OB35 call interval to
250ms.
2. Write a program for the OB 35 block with the required functions
3. In "FC_Signal" (FC 14) and in "FC_ConvMotor" (FC 16), program the
above-mentioned interlocks.