0% found this document useful (0 votes)
500 views

FC105

This document contains the code for an analogue input scaling function block that scales analog input signals within configurable high and low limits. It checks for underflow and overflow conditions, issues an error code and sets outputs accordingly. It also calculates engineering unit values from the raw input and converts the input to a normalized 0-1 scale for further processing.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
500 views

FC105

This document contains the code for an analogue input scaling function block that scales analog input signals within configurable high and low limits. It checks for underflow and overflow conditions, issues an error code and sets outputs accordingly. It also calculates engineering unit values from the raw input and converts the input to a normalized 0-1 scale for further processing.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

SIMATIC IS0000 Example 04/22/2015 11:34:14 AM

S7 Proj\Example_S7_Program\...\FC105 - <offline>

FC105 - <offline>
"SCALE" Scaling Values
Name: Family:
Author: Version: 0.0
Block version: 2
Time stamp Code: 03/29/2014 05:12:41 AM
Interface: 07/26/2012 03:32:11 AM
Lengths (block/logic/data): 00430 00286 00010

Name Data Type Address Comment


IN 0.0
I_IN Int 0.0 Analogue Input 0..10V/0..20mA/4..20mA
I_HI_LIM Real 2.0 High Limit
I_LO_LIM Real 6.0 Low Limit
I_BIPOLAR Bool 10.0 Bipolar [-27648..27648] Input?
OUT 0.0
Q_OUT Real 14.0 Converted output signal or min/max in case of over/underflow
Q_H_OK Bool 18.0 Analog Signal OK Indicator
IN_OUT 0.0
IQ_HA_OOR Bool 20.0 Out Of Range Alarm [reset in block which uses input]
IQ_COUNT Int 22.0 Count for OOR Alarm Trigger
TEMP 0.0
Underflow Bool 0.0 Underflow?
Overflow Bool 0.1 Overflow?
Raw_Relative Real 2.0 Raw Value converted to 0..1
Eng_Span Real 6.0 Engineering Values Span
RETURN 0.0
RET_VAL Word 12.0 Scale Rrror Code or 0 when OK

Block: FC105 Analogue Input Scaling function

This function substitutes Siemens FC105 "SCALE".


Allows Overrange but detects Over/Underflows.

Network: 1 Check input faulty [under/overflow]

L -32512 // Check for Underflow


L #I_IN
>=I
= #Underflow

L 32512 // Check for Overflow


>=I
= #Overflow

AN #Underflow // Give OK Bit


AN #Overflow
= #Q_H_OK

A #Underflow // Jump to issue Underflow Value


JC UNDR

A #Overflow // Jump to issue Overflow Value


JC OVER

JU AIOK // if both OK jump to conversion

Page 1 of 3
SIMATIC IS0000 Example 04/22/2015 11:34:15 AM
S7 Proj\Example_S7_Program\...\FC105 - <offline>

Network: 2 OOR: Issue Low or High Limit, Error Code 8HEX and ENO=FALSE

UNDR: L W#16#8 // Underflow


T #RET_VAL // Error Code 8HEX

L #I_LO_LIM // Set Q_OUT = Minimum


T #Q_OUT

A "GLOBAL".CLOCK.PULSE_100ms // Jump to Counter


JC CNTR

CLR // Give ENO=FALSE


SAVE
BE

OVER: L W#16#8 // Underflow


T #RET_VAL // Error Code 8HEX

L #I_HI_LIM // Set Q_OUT = Maximum


T #Q_OUT

A "GLOBAL".CLOCK.PULSE_100ms // Jump to Counter


JC CNTR

CLR // Give ENO=FALSE


SAVE
BE

Network: 3 Update Alarm Trigger Counter and trigger alarm if out of range

CNTR: L #IQ_COUNT // Update Counter


+ 1
T #IQ_COUNT
L "CONST".ANALOGUES_OOR_TIME
>=I // Set Alarm if time>Threshold
S #IQ_HA_OOR
JCN ENO0 // Jump to ENO0 when counter<limit
T #IQ_COUNT // Clamp counter to limit
ENO0: CLR // Give ENO=False
SAVE
BE

Network: 4 Calculate Eng v Span and Convert input value to relative 0..1

Calculates Engineering Values Span [Span = I_HI_LIM - I_LO_LIM]


and relative input value [0..1]

AIOK: L #I_HI_LIM // High Limit


L #I_LO_LIM // Low Limit
==R // Low==High? [Low<High: Reverse Scaling]
JC LHER // Jump to Error.
-R
T #Eng_Span // Calculated Eng Values Span

L #I_IN // Calculate relative input value


ITD // from 0 to 1
DTR
L 2.764800e+004
/R
T #Raw_Relative

AN #I_BIPOLAR // Unipolar?
JC CNVR // Jump to conversion

L 1.000000e+000 // Bipolar?
+R // Convert Relative -1..1
L 2.000000e+000 // to 0..1
/R
T #Raw_Relative

Page 2 of 3
SIMATIC IS0000 Example 04/22/2015 11:34:15 AM
S7 Proj\Example_S7_Program\...\FC105 - <offline>

Network: 5 Convert calculated relative input value to engineering units

Q_OUT:=I_LO_LIM + Raw_Relative * Eng_Span

CNVR: L #Eng_Span // Convert Relative Value


L #Raw_Relative // to Absolute
*R
L #I_LO_LIM // and add Low Limit
+R
T #Q_OUT // Issue to output

SET // Error Code = 0


L 0 // and ENO=True
T #RET_VAL
T #IQ_COUNT // Clear NG Counter
SAVE
BE

Network: 6 Issue Error Code when Low Limit = High Limit

Issues Limit Value as output, Error Code W#16#9 and ENO=FALSE

LHER: L W#16#9
T #RET_VAL
L #I_LO_LIM
T #Q_OUT
CLR
SAVE

Page 3 of 3

You might also like