Variable status bits

The workbench enables you to associate status bits to declared variables. Each variable may have, in addition to its real time value:

- 64 status bits
- a date and time stamp

Status bits and time stamps are generally set by input drivers taking care of hardware inputs, but may also be transported together with teh value of the variable on some network protocols. In addition, the IEC 61131-3 programs may access to the status bits of variables.

Refer to the following sections for detailed information:

- enabling status bits
- reading and writing status from programs
- list of status bits
- drivers supporting status bits

Important notes

  • Status bit management may be not available on some targets. Please refer to OEM instructions for further details about available features.

  • Status bit management is CPU and memory consuming and may reduce the performances of your applications.

Enabling status bits

In order to enable the management of status bits and time/date stamps by the runtime, you must check the following option in the list of compiler options from the Project Settings wizard:

    Allocate status flags for variables with embedded properties

Only variables having some properties defined (either a profile attached or embedded symbol) will get status bits. Status bits are available only for global scope variables (global, retain, IOs...) with a single data type (cannot be array or structure).

Reading and writing status from programs

The following functions are available for managing status information in the programs:

vsiGetBit : get a status bit of a variable
vsiGetDate : get the date stamp of a variable
vsiGetTime : get the time stamp of a variable
vsiSetBit : set a status bit of a variable
vsiSetDate : set the date stamp of a variable
vsiSetTime : set the time stamp of a variable
vsiStamp : update the stamp of a variable according to the current time

Below is the syntax of the functions:

bBit := vsiGetBit ( variable, bitID );
iDate := vsiGetDate ( variable );
iTime := vsiGetTime ( variable );
bOK := vsiSetBit ( variable, bitID, bBit );
bOK := vsiSetDate ( variable, iDate );
bOK := vsiSetTime ( variable, iTime );
bOK := vsiStamp ( variable );

The functions use the following arguments:

variable variable having embedded profile or symbol
bitID : DINT ID of a status bit (see list of IDs in the section below)
bBit : BOOL value of the status bit
iDate : DINT date stamp according to real time clock functions conventions
iTime : DINT time stamp according to real time clock functions conventions
bOK : BOOL TRUE if successful

See the description of real time clock functions for further information about time and date stamps.

Drivers supporting status bits

Below are runtime drivers taking care of status bits and date/time stamping:

Variable binding
Binding (spontaneous protocol) is used for real time exchange of variable values among runtimes over ETHERNET. The protocol takes care of carrying status bits. The protocol updates the date and time stamps of variables updated by the network.
The MODBUS master protocols (RTU / TCP / UDP) takes care of updating the date and time stamp of all variables updated by the network. The MODBUS stack also sets the _VSB_I_BIT status bits of received variables according to the exchange error status.
The MODBUS slave protocols (RTU / TCP / UDP) takes care of updating the date and time stamp of all variables updated by the network.
IEC 60870-5 Slave
The IEC 60870-5-101 and IEC 60870-5-104 slave protocols send the _VSB_I_BIT, _VSB_OV_BIT, _VSB_BL_BIT, _VSB_SP_BIT and _VSB_NT_BIT in the protocol telegrams for points and measures.

List of status bits

Below is the list of available status bits. Identifiers (_VSB_...) are predefined in the compiler and can be directly used in the programs:




0 _VSB_ST_M1 user defined status
1 _VSB_ST_M2 user defined status
2 _VSB_ST_M3 user defined status
3 _VSB_ST_M4 user defined status
4 _VSB_ST_M5 user defined status
5 _VSB_ST_M6 user defined status
6 _VSB_ST_M7 user defined status
7 _VSB_ST_M8 user defined status
8 _VSB_SELEC Select
9 _VSB_REV Revision
10 _VSB_DIREC Desired direction
11 _VSB_RTE Runtime exceeded
12 _VSB_MVALUE Manual value
13 _VSB_ST_14 user defined status
14 _VSB_ST_15 user defined status
15 _VSB_ST_16 user defined status
16 _VSB_GR General request
17 _VSB_SPONT Spontaneous
18 _VSB_I_BIT Invalid
19 _VSB_SUWI Summer/Winter time announcement
20 _VSB_N_UPD Switched off
21 _VSB_RT_E Realtime external
22 _VSB_RT_I Realtime internal
23 _VSB_NSORT Not sortable
24 _VSB_DM_TR Default message trafo value
25 _VSB_RM_TR Run message trafo value
26 _VSB_INFO Info for variable
27 _VSB_AVALUE Alternative value
28 _VSB_RES28 reserved
29 _VSB_ACTUAL Not updated
30 _VSB_WINTER Winter time
31 _VSB_RES31 reserved
32 _VSB_TCB0 Transmission cause
33 _VSB_TCB1 Transmission cause
34 _VSB_TCB2 Transmission cause
35 _VSB_TCB3 Transmission cause
36 _VSB_TCB4 Transmission cause
37 _VSB_TCB5 Transmission cause
38 _VSB_PN_BIT P/N bit
39 _VSB_T_BIT Test bit
40 _VSB_WR_ACK Acknoledge writing
41 _VSB_WR_SUC Writing successful
42 _VSB_NORM Normal status
43 _VSB_ABNORM Deviation normal status
44 _VSB_BL_BIT IEC status: blocked
45 _VSB_SP_BIT IEC status: substituted
46 _VSB_NT_BIT IEC status: not typical
47 _VSB_OV_BIT IEC status: overflow
48 _VSB_SE_BIT IEC status: select
49 not defined  
50 not defined  
51 not defined  
52 not defined  
53 not defined  
54 not defined  
55 not defined  
56 not defined  
57 not defined  
58 not defined  
59 not defined  
60 not defined  
61 not defined  
62 not defined  
63 not defined