IAnalog
- Namespace
- ZEquipment
Basic Interface for the analog input and output function blocks. For more information on the actual implementation of the Analog function block see Analog
INTERFACE IAnalog EXTENDS ZEquipment.IDigital, ZCore.ITrigger
- Extends
- Inherited Properties
- Inherited Methods
Properties
DecimalPlaces
PROPERTY DecimalPlaces : INT
Property Value
- INT
Simulation
This property is used to enable or disable the simulation mode for the analog terminal. Internally the pointer to the variable that is written to or read from, respectively, is swapped by toggling this property. Simulated inputs behave different with respect to actual terminals with regard to the Write method. Phyisical terminals can not be written to, for simulated terminal this is totally fine though (and even needed most of the times).
PROPERTY Simulation : BOOL
Property Value
- BOOL
ValueUnit
Physical unit of the analog value (i.e. bar, degree celsius, mm)
PROPERTY ValueUnit : STRING(20)
Property Value
- STRING(20)
Methods
Name
this method return the name that has been set with SetName
METHOD Name () : ZCore.ZString
Returns
Read
This method returns the physical actual value of the analog input or output. (see SetConversionLinear)
METHOD Read () : LREAL
Returns
- LREAL
Resolution
METHOD Resolution () : LREAL
Returns
- LREAL
SetConversionLinear
This method is used to convert the values of an actual terminal (e.g. EL3102). to a physical unit that may be used within the context of an application. Terminals usually provide startup parameters to perform data conversion on the hardware. However, in Zeugwerk Framework we prefer to convert these values on the PLC since this is much more flexible than relying on SDO parameters.
Values that are read and written to a terminal are internally normalized before applying any conversions on them. Terminals that use unsigned datatypes are normalized between [0,1] and terminals with signed datatypes are normalized between [-1,1] before applying the linear transformation that is set with this method to it. This makes it rather easy to specify linear conversion functions that are independent of the terminal resolution and the internal datatype that is used by a terminal.
For instance, a terminal that can measure 0V..10V with 16bit resolution, uses INT as datatype, such that the terminals values are in the interval [0, 65535].
If the I/O is simulated, this method initializes the physical value to 0
. Call Write
manually after this method to initialize the I/O with a value, which suites your application best in a simulated environment.
Note
This method automatically resets the physical limits However, it is possible to overwrite the limits later on if needed.
METHOD SetConversionLinear (
slope : LREAL,
intercept : LREAL,
valueUnit : STRING(20))
Inputs
slope
LREALrepresents the slope [k] of the linear function y = k*x + d
intercept
LREALrepresents the intercept [d] of the linear function y = k*x + d
valueUnit
STRING(20)Physical unit of the analog value, mainly used for logging
SetConversionScaling
This method is used to convert the values of an actual terminal (e.g. EL3102). to a phyiscal unit that may be used within the context of an application. Terminals usually provide startup parameters to perform data conversion on the hardware. However, in Zeugwerk Framework we prefer to convert these values on the PLC since this is much more flexible than relying on SDO parameters.
This method adjusts the conversion from the terminal to a physical value in a way that the value provided by the terminal is simply scaled. For advanced sensor-data conversion consider using SetConversionParameters instead.
An example could be a temperature value from a Beckhoff EL3312 EtherCAT Terminal, 2-channel analog input, temperature, thermocouple, 16bit. This terminal has a INT datatype and delivers a temperature for thermocouples with type J as 0.1 degree celsius. The rest of the scaling (resolution in bits and so on) is done by the terminal itself, here a simple decimal place scaling has to be done. This can be done by setting the scale value to 0.1
In most cases the offset can be set to zero, but sometimes it is necessary to start with a desired value. One example could be an ultra-sound sensor which has a dead-range and this value should be set as offset.
If the I/O is simulated, this method initializes the physical value to 0
. Call Write
manually after this method to initialize the I/O with a value, which suites your application best in a simulated environment.
Note
This method automatically resets the physical limits However, it is possible to overwrite the limits later on if needed.
Warning
Calling this method resets the terminal resolution, which is otherwise automatically set during construction of the object. Hence, if SetConversionParameters is called after this method for any reason, make sure to reset the terminal resolution first.
METHOD SetConversionScaling (
scale : LREAL,
offset : LREAL,
physicalUnit : STRING(20))
Inputs
scale
LREALscale as multiplier to the delivered value; e.g. a temperature terminal returns 10 which is 1 degree Celsius so we need to set 0.1 as multiplier to get Celsius
offset
LREALoffset which defines the value when the terminal transmits zero
physicalUnit
STRING(20)physical Unit, e.g. 'bar', 'mm', '°C'
SetDigitalThreshold
An analog I/O can be treated as a digital I/O by defining a threshold for on/off. For values above and below this threshold the (IsEnabled)[xref:ZEquipment.Analog#Enabled] and Enabled (and other methods coming from IDigital will behave the same as a Digital I/O, including Logic.
The parameter of this method is given in physical value of the terminal (see SetConversionLinear).
Per default digital threshold is set to 0 in physical units and the
Logic is set to (DigitalLogic.Normal)[xref:ZEquipment.DigitalLogic#Normal], where
values above the threshold mean on
and values below or equal mean off
.
METHOD SetDigitalThreshold (
threshold : LREAL)
Inputs
SetName
This method can be used to give a name to this object. This is automatically used for logging (if enabled, see SetLogger). Also, this name is used with using this instance together with an IoBridge to make it available on a HMI.
METHOD SetName (
name : ZCore.ZString)
Inputs
name
ZString
Write
This method writes the physical value to the analog output. Depending on the set linear conversion it first gets converted into the actual linked data type of the output and is then written to the fieldbus variable. However, inputs can only be writte when the function block is simulated (see SetSimulation
METHOD Write (
value : LREAL)