Professional Documents
Culture Documents
9720098-010 TriStation 1131 Libraries Reference (Nov 2010)
9720098-010 TriStation 1131 Libraries Reference (Nov 2010)
9720098-010 TriStation 1131 Libraries Reference (Nov 2010)
Libraries Reference
Invensys, the Invensys logo, Triconex, Tricon, Trident, and TriStation are trademarks of Invensys plc, its
subsidiaries and affiliates. All other brands may be trademarks of their respective owners.
Preface ix
Summary of Sections. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
Related Documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
Product and Training Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . x
Technical Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . x
We Welcome Your Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
Chapter 1 Introduction 1
How to Use This Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Name and Brief Description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Parameters and Return Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Description and Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Runtime Errors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Application Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Sample Projects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
BOOL_TO_DWORD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
BYPASS_BOOL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
BYPASS_DINT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
BYPASS_REAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
CEIL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
CHK_ERR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
CLR_ERR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
CONCAT_DT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
COS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
CSCHED . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
CSCHED_I . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
CSCHED_R. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
CTD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
CTU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
CTUD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
DATE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
DINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
DINT_TO_DWORD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
DINT_TO_INT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
DINT_TO_LREAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
DINT_TO_REAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
DIV. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
DT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
DT_TO_DATE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
DT_TO_TOD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
DWORD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
DWORD_TO_BOOL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
DWORD_TO_DINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
EQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
EXP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
EXPFLTR. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
EXPT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
F_TRIG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
FLOOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
GASDETR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
GATDIS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
GATENB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
GE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
GetDelta_DINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
GetDelta_REAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
GetDeltaT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
GetTimer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
GT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
INFINITY_LREAL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
INFINITY_REAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
INT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
INT_TO_DINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
INT_TO_LREAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
INT_TO_REAL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
INTGTOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
INTGTOR_R. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
IsFinite_LREAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
IsFinite_REAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
IsNan_LREAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
IsNan_REAL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
LE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
LEADLAG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
LEADLAG_R . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
LIMIT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
LINEMNTR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
LN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
LOG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
LOOPDETR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
LREAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
LREAL_TO_DINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
LREAL_TO_INT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
LREAL_TO_REAL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
LT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
MAX. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
MBCTRL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
MBREAD_BOOL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
MBREAD_DINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
MBREAD_REAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
MBREAD_REAL_TRD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
MBWRITE_BOOL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
MBWRITE_DINT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
MBWRITE_REAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
MBWRITE_REAL_TRD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198
MEDSEL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
MIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
MINUS_INFINITY_LREAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
MINUS_INFINITY_REAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
MOD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
MOVE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
MUL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
MUX. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
NAN_LREAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
NAN_REAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
NE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
NOT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
NUMBITS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
NUMBITS_DWORD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220
OR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
OVDDISABLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
OVDENABLE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
PACK16. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
PACK32. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
PAGE_EJECT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
PERDEV . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
PID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230
PID_R. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
POLY4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
POLY5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
PRINT_BOOL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
PRINT_CDT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238
PRINT_CRLF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
PRINT_CTOD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242
PRINT_DINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244
PRINT_REAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246
PRINT_STRING. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248
PRNTR_FLUSH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250
R_TRIG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
REAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254
REAL_TO_DINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256
REAL_TO_INT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258
REAL_TO_LREAL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260
ReportBadParam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
ROL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
ROR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
RS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264
RTC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
SCALE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
SEL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
SHL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
SHR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270
SIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271
SOECLR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
SOESTAT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274
SOESTOP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276
SOESTRT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278
SQRT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280
SR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
STRING . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
SUB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284
SYS_AI32_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
SYS_AO04_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
SYS_APP_HALT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
SYS_CLEAR_FLTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
SYS_CM_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
SYS_CRITICAL_IO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
SYS_DI16_AI16_STATUS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
SYS_DI32_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302
SYS_DO16_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304
SYS_HRDI32_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306
SYS_IO_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309
SYS_IOP_STATUS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311
SYS_MP_EXT_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
SYS_MP_RESET_PORTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
SYS_MP_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319
SYS_OVD_INHIBIT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322
SYS_PI06_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324
SYS_RO32_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327
SYS_SDO16_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329
SYS_SERIAL_PORT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332
SYS_SET_APP_LOCK. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334
SYS_SET_PROG_ALARM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336
SYS_SET_REMOTE_WRT_ENBL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338
SYS_SHUTDOWN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340
SYS_SYSTEM_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342
SYS_VOTE_MODE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345
TAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347
TCJ_CONV . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348
TCK_CONV . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350
TDD_I . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352
TDD_R. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353
TDE_I. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355
TDE_R . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356
TIME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358
TIME_TO_SECS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359
TIME_TO_SECS_REAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360
TIMEADJ. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361
TIMESET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363
TMR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365
TMR_I . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367
TMR_R . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369
TOD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371
TOF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372
TOGGLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375
TON . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377
TP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379
TP_I . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381
TP_R. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383
TR_64_POINT_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385
TR_CALENDAR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387
TR_CHASSIS_STATUS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389
TR_CLEAR_FLTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391
TR_CRITICAL_IO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392
TR_MP_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395
TR_PEER_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397
TR_POINT_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399
TR_PORT_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 401
TR_PROGRAM_STATUS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403
TR_SCAN_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405
TR_SHUTDOWN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407
TR_SLOT_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409
TR_URCV_BOOL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411
TR_URCV_DINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413
TR_URCV_DINT_32 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415
TR_URCV_REAL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417
TR_URCV_REAL_32. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419
TR_USEND_BOOL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 421
TR_USEND_DINT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423
TR_USEND_DINT_32. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425
TR_USEND_REAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427
TR_USEND_REAL_32 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429
TR_VOTE_MODE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 431
TRUNC_LREAL_TO_DINT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433
TRUNC_LREAL_TO_INT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435
TRUNC_REAL_TO_DINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437
TRUNC_REAL_TO_INT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439
TSCHED . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441
TSCHED_I . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443
TSCHED_R . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445
UNPACK16 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447
UNPACK32 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449
X_OF_N. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 451
XOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453
Index 491
The Triconex® libraries include IEC-compliant functions and function blocks which are part of the
TriStation™ 1131 Developer’s Workbench software.
This reference guide provides detailed descriptions of each of the functions and function blocks in the
libraries. The functions and function blocks described herein can be used in applications created with
TriStation 1131 versions 4.0 and later.
Note For detailed information about the libraries released with each version of TriStation 1131, refer to
the Product Release Notice for TriStation 1131, available on the Invensys Global Customer Support
(GCS) Web site.
Summary of Sections
• Chapter 1, Introduction—Explains how the functions and function blocks are described.
• Chapter 2, Functions and Data Types—Describes the parameters, return values, runtime error
flags, and usage constraints for each function and function block.
• Appendix A, Modbus Protocol—Provides information about Modbus protocol including
Modbus message formats and error codes.
• Appendix B, Peer-to-Peer Parameters—Provides detailed information about the Peer-to-Peer
input and output parameters, and runtime errors.
Related Documents
• TriStation 1131 Developer’s Guide
• Safety Considerations Guides for Tricon, Trident, and Tri-GP Systems
• Product Release Notice for TriStation 1131
Web Site
http://www.iom.invensys.com
Technical Support
Customers in the U.S. and Canada can obtain technical support from the Invensys Global Customer
Support (GCS) center at the numbers below. International customers should contact their regional
support center.
Telephone
Toll-free number 866-746-6477, or
Toll number 508-549-2424 (outside U.S.)
Fax
Toll number 508-549-4999
Web Site
http://support.ips.invensys.com/ (registration required)
E-mail
iom.support@invensys.com
BOOL_TO_DWORD
Converts a Boolean (BOOL) value to a DWORD value.
Syntax
The syntax is depicted in Structured Text (ST) language. This is an example:
Syntax
w := BOOL_TO_DWORD(b);
Input Parameters
A table of input parameters shows the name, data type, and description of each input parameter that is
passed to the function or function block. This is an example:
Output Parameters
A table of output parameters shows the name, data type, and description of each function block output.
This is an example:
Return Value
A table shows the data type and description of the value returned by the function. This is an example:
Description
The CEIL function returns the next higher integer greater than or equal to x.
Example
VAR x : REAL END_VAR;
x := ceil(6.04 ); (* result is 7.0 *)
Runtime Errors
The Runtime Errors section includes the conditions, return values, and error flags returned if a runtime
error occurs. This is an example:
Runtime Errors
Application Notes
The Application Notes section indicates how the function, function block, or data type can be used. These
properties are indicated:
• Application Type on page 4
• Function Block Usage on page 5
• CEM Enabled on page 6
Application Type
The Application Type indicates whether a function, function block, or data type can be used in a safety
program or control program. The purpose of this designation is to reduce the interaction between safety
programs and control programs running on the same controller.
Each element (program, function, function block, or data type) is specified as a safety element or a control
(non-safety) element:
• A safety element can be used in a safety element or a control (non-safety) element.
• A control (non-safety) element can only be used in a control (non-safety) element.
A safety element must be made up entirely of other safety elements. A control (non-safety) element can
use a safety element or a control element.
Attempting to use a non-safety element in a safety element results in one of these errors:
WF0050: Element is not a safety element (indicated by Red X).
WF0051: Safety element uses non-safety element.
Safety element OK OK
Option Description
Exactly Once Each function block instance should be executed exactly once per scan.
Only Once Each function block instance should be executed only once per scan, but does not need to
be executed every scan.
Space Saver Each function block instance can be executed more than once per scan to reduce memory
usage and increase performance. See Using a Space Saver Function Block on page 6.
Internal State Each function block instance may have an internal state which is remembered from one
execution to the next and from one scan to the next. There are no restricitons on usage of a
function block labeled internal state; that is, you can execute the function block instance
more than once per scan, or you can skip scans.
CEM Enabled
A CEM Enabled function or function block can be used in the CEM matrix as indicated by one of these
statements:
• Can be used in CEM Cause cells.
• Can be used in CEM Cause and Effect cells.
• Can be used in CEM Cause, Effect, and Intersection cells.
• Can be used in CEM Effect cells.
• Can be used in CEM Cause and Intersection cells.
• Can be used in CEM Intersection cells.
Library
The Library section identifies the libraries that the function or function block is included in. TriStation
1131 includes these libraries:
• Standard Library (STDLIB) complies with the IEC 61131-3 standard
• Standard Sheet Library (STDSHEET) for all Triconex controllers (used only for selecting a sheet
template in a new function block diagram)
• Triconex Library (TCXLIB) for all Triconex controllers
• Tricon™ Library (TR1LIB or Tx1Lib) for Tricon controllers
• Trident™ Library (TRDLIB) for Trident and Tri-GP controllers
• Alarms Library (ALARMS) for all Triconex controllers (first released with TriStation 4.7.0)
Sample Projects
Several of the functions or function blocks described in this reference are used in the sample projects
provided with TriStation 1131. These sample projects provide examples for how to use the selected
function or function block.
Starting with TriStation 1131 v4.7.0, sample projects are found in the following locations on the PC where
you installed TriStation 1131 (where x.x.x is the TriStation 1131 version number):
This section describes the functions, function blocks, and data types included in TriStation 1131 Libraries.
ABS
Calculates the absolute value of a number.
Syntax
k := ABS(m)
m ANY_NUM A number.
Description
The ABS function returns the absolute value of a number. The absolute value is the magnitude —that is,
the value with the sign removed.
Example
VAR k : DINT; END_VAR
k := ABS( 1234 ); (* result is 1234 *)
k := ABS( –1234 ); (* result is 1234 *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
ACOS
Calculates the principal arc cosine of a real number.
Syntax
y := ACOS( x )
x ANY_REAL A real number between –1.0 and 1.0 whose arc cosine is to be
calculated.
Description
The ACOS function calculates the principal arc cosine of a real number. The result is in radians from 0.0
to 3.14159.
Example
VAR y : REAL; END_VAR
y := ACOS( 1.0 ); (* result is 0.0 *)
y := ACOS( –1.0 ); (* result is 3.14159 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the error flags
to true, and resets ENO to false. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
ADD
Calculates the sum of two operands.
Description
ADD can be used as an operator or as a function.
ADD Operator
The add operator (+) is used in Structured Text to calculate the sum of two operands. The operations that
can be performed are shown in this table.
Calculates the sum of two numeric ANY_NUM ANY_NUM The sum of the operands.
values.
Calculates the sum of two time TIME TIME The sum of the operands.
periods.
Adds a time operand to a date and DT + TIME DT The date and time operand plus the
time operand. time operand.
Adds a time operand to a time of TOD + TIME TOD The time-of-day operand plus the time
day operand. operand.
ADD Function
In the graphical languages, the ADD extensible function is used instead of the add operator. Extensible
functions can operate on up to 50 input parameters. The operations that can be performed using the ADD
extensible function are shown in this table.
Calculates the sum of two time inputs. TIME TIME The sum of the inputs.
Adds a time input to a date and time DT + TIME DT The date and time input plus the
input. time input.
Adds a time input to a time of day TOD + TIME TOD The time-of-day input plus the
input. time input.
Example
Runtime Errors
If the date and time is out of range Invalid date BADPARAM, ERROR
Upon detection of a runtime error condition, the function returns the indicated value, sets the error flags
to true, and resets ENO to false. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
AIN
Converts an analog input to a real number.
Syntax
y := AIN( MX, IN, MN )
Description
The AIN function converts an analog input to a real number. The range of IN is 819 to 4095, which
corresponds to 4 to 20 milliamps or 1 to 5 volts. The return value is a real number (in engineering units)
scaled to the range from MN to MX. MN is the value returned when the input corresponds to 4 milliamps
or 1 volt, or is less than 819. MX is the value returned when the input corresponds to 20 milliamps or
5 volts, or is greater than or equal to 4095.
Example
VAR y : REAL; END_VAR
y := AIN( 100.0, 4095, 0.0 ); (* result is 100.0 *)
y := AIN( 100.0, 2457, 0.0 ); (* result is 50.0 *)
y := AIN( 100.0, 819, 0.0 ); (* result is 0.0 *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Triconex (TCXLIB)
AIN_BP
Converts a differential bipolar analog input to a real number.
Syntax
y := AIN_BP( MX, IN, MN )
Description
The AIN_BP function converts a differential bipolar analog input to a real number. The range of IN is -
16383 to 16383, which corresponds to -20 to 20 milliamps or -5 to 5 volts. The return value is a real number
(in engineering units) scaled to the range from MN to MX. MN is the value returned when the input
corresponds to -20 milliamps or -5 volts, or is less than -16383. MX is the value returned when the input
corresponds to 20 milliamps or 5 volts, or is greater than or equal to 16383. The scaling equation
implemented in this function is equal to
IN – LO-
-------------------- MX – MN + MN
HI – LO
Example
VAR y : REAL; END_VAR
y := AIN_BP( 100.0, 16383, 0.0 ); (* result is 100.0 *)
y := AIN_BP( 100.0, 0, 0.0 ); (* result is 50.0 *)
y := AIN_BP( 100.0, -16383, 0.0 ); (* result is 0.0 *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Triconex (TCXLIB)
This function was added to the library in v1.31 of TCXLIB, first released with TriStation 1131 v4.1.419.
AIN_BP12
Converts a 12-bit differential bipolar analog input to a real number.
Syntax
y := AIN_BP12( MX, IN, MN )
Description
The AIN_BP12 function converts a 12-bit differential bipolar analog input to a real number. The typical
range of IN is -4095 to 4095. The return value is a real number (in engineering units) scaled to the range
from MN to MX. MN is the value returned when the input is -4095. MX is the value returned when the
input is +4095. AIN_BP12 clamps the analog input to the range of -4095 to +4095. The scaling equation
implemented in this function is approximately equivalent to
IN – LO-
-------------------- MX – MN + MN
HI – LO
Engineering
Units
MX
-4095 Machine
Count
+4095
MN
Example
The BPAO module (model 3807) provides a 12-bit bipolar analog input that measures the voltage across
the load coil. Input value -4095 corresponds to -10 volts. Input value +4095 corresponds to +10 volts. The
following example function call converts the input to a voltage:
in y
-4095 -10.0
0 0.0
+4095 +10.0
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Triconex (TCXLIB)
This function was added to the library in v1.32 of TCXLIB, first released with TriStation 1131 v4.3.
AIN_HR
Converts a high-resolution analog input to a real number.
Syntax
y := AIN_HR( MX, IN, MN )
Description
The AIN_HR function converts a high-resolution analog input to a real number. The range of IN is 3276
to 16383, which corresponds to 4 to 20 milliamps or 1 to 5 volts. The return value is a real number (in
engineering units) scaled to the range from MN to MX. MN is the value returned when the input
corresponds to 4 milliamps or 1 volt, or is less than 3276. MX is the value returned when the input
corresponds to 20 milliamps or 5 volts, or is greater than or equal to 16383. The scaling equation
implemented in this function is equal to
IN – LO-
-------------------- MX – MN + MN
HI – LO
Example
VAR y : REAL; END_VAR
y := AIN_HR( 100.0, 16383, 0.0 ); (* result is 100.0 *)
y := AIN_HR( 100.0, 9829, 0.0 ); (* result is 50.0 *)
y := AIN_HR( 100.0, 3276, 0.0 ); (* result is 0.0 *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Triconex (TCXLIB)
This function was added to the library in v1.31 of TCXLIB, first released with TriStation 1131 v4.1.419.
ALARM_DEVIATION_DINT
Generates deviation alarms for DINT tagnames.
Syntax
My_DevAlm(SOURCE:=Tagname_2_DevByp.VALUE, BYPASS:=Tagname_2_DevByp.BYPASSED,
SETPOINT:=55, ACK_REQUEST:=Tagname_1, DISABLE_REQUEST:=Tagname_4,
AUTOMATIC_RESET:=Tagname_3, MANUAL_RESET_REQUEST:=Tagname_6, DEADBAND:=2,
TIME_DELAY:=T#5ms, RINGBACK:=TRUE, HIGH_HIGH_LIMIT:=10, HIGH_HIGH_SEVERITY:=400,
HIGH_LIMIT:=5, HIGH_SEVERITY:=300, LOW_LIMIT:=-5, LOW_SEVERITY:=200, LOW_LOW_LIMIT:=-
10, LOW_LOW_SEVERITY:=100);
SOURCE DINT Input value for which deviation alarm will be generated. May
be connected to a tagname, or to the output of
BYPASS_DINT.
SETPOINT DINT Value from which the deviation alarm will be generated.
BYPASS BOOL If true, the source has been bypassed with the
BYPASS_VALUE (from the BYPASS_DINT function block).
Note: SOURCE = BYPASS_VALUE only when you use the
BYPASS_DINT function block along with
ALARM_DEVIATION_DINT. The output of
BYPASS_DINT (VALUE) should be connected to the
SOURCE input of ALARM_DEVIATION_DINT.
Additionally, BYPASS_REQ on BYPASS_DINT
should be true. Simply setting BYPASS to true will
not bypass the alarm. You must use BYPASS_DINT
to bypass the value, while
ALARM_DEVIATION_DINT’s BYPASS input also
should be true so that you obtain the correct alarm
status.
DISABLE_REQUEST BOOL If true, alarms will not be generated (all alarms disabled).
DEADBAND DINT Specifies the difference between the alarm limit and the input
value before an alarm goes inactive.
TIME_DELAY TIME Specifies the time delay for an alarm to go active upon
detection of an alarm condition.
HIGH_HIGH_LIMIT DINT Specifies the High High alarm limit for the SOURCE.
When SOURCE is greater than SETPOINT +
HIGH_HIGH_LIMIT, then HIGH_HIGH_ACTIVE becomes
true, and subsequently, the output parameter ACTIVE
becomes true.
HIGH_HIGH_SEVERITY DINT Specifies the severity for the High High limit.
HIGH_LIMIT DINT Specifies the High alarm limit for the SOURCE.
When SOURCE is greater than SETPOINT + HIGH_LIMIT,
then HIGH_ACTIVE becomes true, and subsequently, the
output parameter ACTIVE becomes true.
LOW_LIMIT DINT Specifies the Low alarm limit for the SOURCE.
When SOURCE is less than SETPOINT - LOW_LIMIT, then
LOW_ACTIVE becomes true, and subsequently, the output
parameter ACTIVE becomes true.
LOW_LOW_LIMIT DINT Specifies the Low Low alarm limit for the SOURCE.
When SOURCE is less than SETPOINT - LOW_LOW_LIMIT,
then LOW_LOW_ACTIVE becomes true, and subsequently,
the output parameter ACTIVE becomes true.
LOW_LOW_SEVERITY DINT Specifies the severity for the Low Low limit.
ACTIVE BOOL If true, an alarm is active. If false, there are no active alarms.
Description
The ALARM_DEVIATION_DINT function generates deviation alarms (Low Low, Low, High, High
High) for DINT tagnames.
Deviation alarms are commonly used to report an excess deviation between a process value’s desired
setpoint level, and the actual measured level. They typically relate to instruments (for example, a
temperature meter). A deviation alarm becomes active when the deviation exceeds or drops below a
defined limit.
For example, assume the setpoint has been set to 10, the High limit is set to 2, and the Low limit is set to
-1. If the process value drops below 9, the Low deviation alarm is generated. If the process value goes
above 12, the High deviation alarm is generated. If the setpoint is changed to 11, the new deviation values
will be 10 and 13, respectively.
The input parameter SOURCE is the process value being measured.
The DEADBAND input parameter specifies the difference between the alarm limit and the input value
that will cause an alarm to go inactive. For example, assume the following limit settings:
• Setpoint = 40
• HIGH_HIGH_LIMIT = 10
• HIGH_LIMIT = 5
• LOW_LIMIT = 4
• LOW_LOW_LIMIT = 6
• DEADBAND = 2
The High High alarm will go inactive if SOURCE is less than 48. The High alarm will go inactive if
SOURCE is less than 43. The Low alarm will go active if SOURCE is greater than 38. The Low Low alarm
will go inactive if SOURCE is greater than 36.
The TIME_DELAY input parameter specifies how long before an alarm will go active once the alarm
condition is detected. For example, if TIME_DELAY is configured as 5 seconds, and the High alarm is set
for 100, once the value exceeds 100, ALARM_DEVIATION_DINT will wait 5 seconds before generating
the High alarm. Use of the TIME_DELAY parameter can help prevent nuisance alarms that may be
generated due to process noise.
Example
VAR My_Deviation_Alarm: DEVIATION_ALARM_DINT; END_VAR
VAR_EXTERNAL My_Tagname: DINT;
Tagname2:BOOL;Tagname3:BOOL; Tagname4:BOOL; Tagname5:BOOL;Tagname6:BOOL;
END_VAR
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Process Alarm Library (ALARMS)
This library was first released with TriStation 1131 v4.7.0, but can be used with all TriStation 1131 versions.
ALARM_DEVIATION_REAL
Generates deviation alarms for REAL tagnames.
Syntax
My_DevAlm(SOURCE:=Tagname_2_DevByp.VALUE, BYPASS:=Tagname_2_DevByp.BYPASSED,
SETPOINT:=55, ACK_REQUEST:=Tagname_1, DISABLE_REQUEST:=Tagname_4,
AUTOMATIC_RESET:=Tagname_3, MANUAL_RESET_REQUEST:=Tagname_6DEAD, BAND:=2.0,
TIME_DELAY:=T#5ms, RINGBACK:=TRUE, HIGH_HIGH_LIMIT:=10.0, HIGH_HIGH_SEVERITY:=400,
HIGH_LIMIT:=5.0, HIGH_SEVERITY:=300, LOW_LIMIT:=-5.0, LOW_SEVERITY:=200,
LOW_LOW_LIMIT:=-10.0, LOW_LOW_SEVERITY:=100);
SOURCE DINT Input value for which deviation alarm will be generated. May
be connected to a tagname, or to the output of
BYPASS_REAL.
SETPOINT DINT Value from which the deviation alarm will be generated.
BYPASS BOOL If true, the source has been bypassed with the
BYPASS_VALUE (from the BYPASS_REAL function block).
Note: SOURCE = BYPASS_VALUE only when you use the
BYPASS_REAL function block along with
ALARM_DEVIATION_REAL. The output of
BYPASS_REAL (VALUE) should be connected to the
SOURCE input of ALARM_DEVIATION_REAL.
Additionally, BYPASS_REQ on BYPASS_REAL
should be true. Simply setting BYPASS to true will
not bypass the alarm. You must use BYPASS_REAL
to bypass the value, while
ALARM_DEVIATION_REAL’s BYPASS input also
should be true so that you obtain the correct alarm
status.
DISABLE_REQUEST BOOL If true, alarms will not be generated (all alarms disabled).
DEADBAND DINT Specifies the difference between the alarm limit and the input
value before an alarm goes inactive.
TIME_DELAY TIME Specifies the time delay for an alarm to go active upon
detection of an alarm condition.
HIGH_HIGH_LIMIT DINT Specifies the High High alarm limit for the SOURCE.
When SOURCE is greater than SETPOINT +
HIGH_HIGH_LIMIT, then HIGH_HIGH_ACTIVE becomes
true, and subsequently, the output parameter ACTIVE
becomes true.
HIGH_HIGH_SEVERITY DINT Specifies the severity for the High High limit.
HIGH_LIMIT DINT Specifies the High alarm limit for the SOURCE.
When SOURCE is greater than SETPOINT + HIGH_LIMIT,
then HIGH_ACTIVE becomes true, and subsequently, the
output parameter ACTIVE becomes true.
LOW_LIMIT DINT Specifies the Low alarm limit for the SOURCE.
When SOURCE is less than SETPOINT - LOW_LIMIT, then
LOW_ACTIVE becomes true, and subsequently, the output
parameter ACTIVE becomes true.
LOW_LOW_LIMIT DINT Specifies the Low Low alarm limit for the SOURCE.
When SOURCE is less than SETPOINT - LOW_LOW_LIMIT,
then LOW_LOW_ACTIVE becomes true, and subsequently,
the output parameter ACTIVE becomes true.
LOW_LOW_SEVERITY DINT Specifies the severity for the Low Low limit.
ACTIVE BOOL If true, an alarm is active. If false, there are no active alarms.
Description
The ALARM_DEVIATION_REAL function generates deviation alarms (Low Low, Low, High, High
High) for REAL tagnames.
Deviation alarms are commonly used to report an excess deviation between a process value’s desired
setpoint level, and the actual measured level. They typically relate to instruments (for example, a
temperature meter). A deviation alarm becomes active when the deviation exceeds or drops below a
defined limit.
For example, assume the setpoint has been set to 10, the High limit is set to 2, and the Low limit is set to
-1. If the process value drops below 9, the Low deviation alarm is generated. If the process value goes
above 12, the High deviation alarm is generated. If the setpoint is changed to 11, the new deviation values
will be 10 and 13, respectively.
The input parameter SOURCE is the process value being measured.
The DEADBAND input parameter specifies the difference between the alarm limit and the input value
that will cause an alarm to go inactive. For example, assume the following limit settings:
• Setpoint = 40
• HIGH_HIGH_LIMIT = 10
• HIGH_LIMIT = 5
• LOW_LIMIT = 4
• LOW_LOW_LIMIT = 6
• DEADBAND = 2
The High High alarm will go inactive if SOURCE is less than 48. The High alarm will go inactive if
SOURCE is less than 43. The Low alarm will go active if SOURCE is greater than 38. The Low Low alarm
will go inactive if SOURCE is greater than 36.
The TIMEDELAY input parameter specifies how long before an alarm will go active once the alarm
condition is detected. For example, if TIMEDELAY is configured as 5 seconds, and the High alarm is set
for 100, once the value exceeds 100, ALARM_DEVIATION_REAL will wait 5 seconds before generating
the High alarm. Use of the TIMEDELAY parameter can help prevent nuisance alarms that may be
generated due to process noise.
Example
VAR My_Deviation_Alarm: ALARM_DEVIATION_REAL; END_VAR
VAR_EXTERNAL My_Tagname: REAL;
Tagname2:BOOL;Tagname3:BOOL; Tagname4:BOOL; Tagname5:BOOL;Tagname6:BOOL;
END_VAR
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Process Alarm Library (ALARMS)
This library was first released with TriStation 1131 v4.7.0, but can be used with all TriStation 1131 versions.
ALARM_LEVEL_DINT
Generates level alarms for DINT tagnames.
Syntax
My_LvlAlm(SOURCE:=Tagname_2_LvByp.VALUE, BYPASS:=Tagname_2_LvByp.BYPASSED,
ACK_REQUEST:=Tagname_1, DISABLE_REQUEST:=Tagname_5, AUTOMATIC_RESET:=Tagname_3,
MANUAL_RESET_REQUEST:=Tagname_6, DEADBAND:=5, TIME_DELAY:=T#10ms, RINGBACK:=TRUE,
HIGH_HIGH_LIMIT:=90, HIGH_HIGH_SEVERITY:=400, HIGH_LIMIT:=80, HIGH_SEVERITY:=300,
LOW_LIMIT:=20, LOW_SEVERITY:=200, LOW_LOW_LIMIT:=10, LOW_LOW_SEVERITY:=100);
SOURCE DINT Input value for which level alarm will be generated. May be
connected to a tagname, or to the output of BYPASS_DINT.
BYPASS BOOL If true, the source has been bypassed with the
BYPASS_VALUE (from the BYPASS_DINT function block).
Note: SOURCE = BYPASS_VALUE only when you use the
BYPASS_DINT function block along with
ALARM_LEVEL_DINT. The output of
BYPASS_DINT (VALUE) should be connected to the
SOURCE input of ALARM_LEVEL_DINT.
Additionally, BYPASS_REQ on BYPASS_DINT
should be true. Simply setting BYPASS to true will
not bypass the alarm. You must use BYPASS_DINT
to bypass the value, while ALARM_LEVEL_DINT’s
BYPASS input also should be true so that you obtain
the correct alarm status.
DISABLE_REQUEST BOOL If true, alarms will not be generated (all alarms disabled).
DEADBAND DINT Specifies the difference between the alarm limit and the input
value before an alarm goes inactive.
TIME_DELAY TIME Specifies the time delay for an alarm to go active upon
detection of an alarm condition.
HIGH_HIGH_LIMIT DINT Specifies the High High alarm limit for the SOURCE.
When SOURCE is greater than HIGH_HIGH_LIMIT, then
HIGH_HIGH_ACTIVE becomes true, and subsequently, the
output parameter ACTIVE becomes true.
HIGH_HIGH_SEVERITY DINT Specifies the severity for the High High limit.
HIGH_LIMIT DINT Specifies the High alarm limit for the SOURCE.
When SOURCE is greater than HIGH_LIMIT, then
HIGH_ACTIVE becomes true, and subsequently, the output
parameter ACTIVE becomes true.
LOW_LIMIT DINT Specifies the Low alarm limit for the SOURCE.
When SOURCE is less than LOW_LIMIT, then
LOW_ACTIVE becomes true, and subsequently, the output
parameter ACTIVE becomes true.
LOW_LOW_LIMIT DINT Specifies the Low Low alarm limit for the SOURCE.
When SOURCE is less than LOW_LOW_LIMIT, then
LOW_LOW_ACTIVE becomes true, and subsequently, the
output parameter ACTIVE becomes true.
LOW_LOW_SEVERITY DINT Specifies the severity for the Low Low limit.
ACTIVE BOOL If true, an alarm is active. If false, there are no active alarms.
Description
The ALARM_LEVEL_DINT function generates level alarms (Low Low, Low, High, High High) for DINT
tagnames.
Level alarms are commonly used to report when a limit is exceeded. They typically relate to instruments
(for example, a temperature meter). A level alarm becomes active when the observed value is above a
high limit, or below a low limit.
The input parameter SOURCE is the process value being measured.
The DEADBAND input parameter specifies the difference between the alarm limit and the input value
that will cause an alarm to go inactive. For example, if a High alarm is set for 100, and the DEADBAND
is set to 10, the alarm will go active at 100, and inactive at 90. If a Low alarm is set for 100, it will go active
at 100, and inactive at 110.
The TIME_DELAY input parameter specifies how long before an alarm will go active once the alarm
condition is detected. For example, if TIME_DELAY is configured as 5 seconds, and the High alarm is set
for 100, once the value exceeds 100, ALARM_LEVEL_DINT will wait 5 seconds before generating the
High alarm. Use of the TIME_DELAY parameter can help prevent nuisance alarms that may be generated
due to process noise.
Example
VAR My_Level_Alarm: ALARM_LEVEL_DINT; END_VAR
VAR_EXTERNAL My_Tagname: DINT; Tagname2:BOOL; Tagname3:BOOL; Tagname4:BOOL;
Tagname5:BOOL; Tagname6:BOOL;
END_VAR
);
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Process Alarm Library (ALARMS)
This library was first released with TriStation 1131 v4.7.0, but can be used with all TriStation 1131 versions.
ALARM_LEVEL_REAL
Generates level alarms for REAL tagnames.
Syntax
My_LvlAlm(SOURCE:=Tagname_2_LvByp.VALUE, BYPASS:=Tagname_2_LvByp.BYPASSED,
ACK_REQUEST:=Tagname_1, DISABLE_REQUEST:=Tagname_5, AUTOMATIC_RESET:=Tagname_3,
MANUAL_RESET_REQUEST:=Tagname_6, DEADBAND:=5.0, TIME_DELAY:=T#10ms, RINGBACK:=TRUE,
HIGH_HIGH_LIMIT:=90.0, HIGH_HIGH_SEVERITY:=400, HIGH_LIMIT:=80.0, HIGH_SEVERITY:=300,
LOW_LIMIT:=20.0, LOW_SEVERITY:=200, LOW_LOW_LIMIT:=10.0, LOW_LOW_SEVERITY:=100);
SOURCE DINT Input value for which level alarm will be generated. May be
connected to a tagname, or to the output of BYPASS_REAL.
BYPASS BOOL If true, the source has been bypassed with the
BYPASS_VALUE (from the BYPASS_REAL function block).
Note: SOURCE = BYPASS_VALUE only when you use the
BYPASS_REAL function block along with
ALARM_LEVEL_REAL. The output of
BYPASS_REAL (VALUE) should be connected to the
SOURCE input of ALARM_LEVEL_REAL.
Additionally, BYPASS_REQ on BYPASS_REAL
should be true. Simply setting BYPASS to true will
not bypass the alarm. You must use BYPASS_REAL
to bypass the value, while ALARM_LEVEL_REAL’s
BYPASS input also should be true so that you obtain
the correct alarm status.
DISABLE_REQUEST BOOL If true, alarms will not be generated (all alarms disabled).
DEADBAND DINT Specifies the difference between the alarm limit and the input
value before an alarm goes inactive.
TIME_DELAY TIME Specifies the time delay for an alarm to go active upon
detection of an alarm condition.
HIGH_HIGH_LIMIT DINT Specifies the High High alarm limit for the SOURCE.
When SOURCE is greater than HIGH_HIGH_LIMIT, then
HIGH_HIGH_ACTIVE becomes true, and subsequently, the
output parameter ACTIVE becomes true.
HIGH_HIGH_SEVERITY DINT Specifies the severity for the High High limit.
HIGH_LIMIT DINT Specifies the High alarm limit for the SOURCE.
When SOURCE is greater than HIGH_LIMIT, then
HIGH_ACTIVE becomes true, and subsequently, the output
parameter ACTIVE becomes true.
LOW_LIMIT DINT Specifies the Low alarm limit for the SOURCE.
When SOURCE is less than LOW_LIMIT, then
LOW_ACTIVE becomes true, and subsequently, the output
parameter ACTIVE becomes true.
LOW_LOW_LIMIT DINT Specifies the Low Low alarm limit for the SOURCE.
When SOURCE is less than LOW_LOW_LIMIT, then
LOW_LOW_ACTIVE becomes true, and subsequently, the
output parameter ACTIVE becomes true.
LOW_LOW_SEVERITY DINT Specifies the severity for the Low Low limit.
ACTIVE BOOL If true, an alarm is active. If false, there are no active alarms.
Description
The ALARM_LEVEL_REAL function generates level alarms (Low Low, Low, High, High High) for REAL
tagnames.
Level alarms are commonly used to report when a limit is exceeded. They typically relate to instruments
(for example, a temperature meter). A level alarm becomes active when the observed value is above a
high limit, or below a low limit.
The input parameter SOURCE is the process value being measured.
The DEADBAND input parameter specifies the difference between the alarm limit and the input value
that will cause an alarm to go inactive. For example, if a High alarm is set for 100, and the DEADBAND
is set to 10, the alarm will go active at 100, and inactive at 90. If a Low alarm is set for 100, it will go active
at 100, and inactive at 110.
The TIME_DELAY input parameter specifies how long before an alarm will go active once the alarm
condition is detected. For example, if TIME_DELAY is configured as 5 seconds, and the High alarm is set
for 100, once the value exceeds 100, ALARM_LEVEL_REAL will wait 5 seconds before generating the
High alarm. Use of the TIME_DELAY parameter can help prevent nuisance alarms that may be generated
due to process noise.
Example
VAR My_Level_Alarm: ALARM_LEVEL_DINT; END_VAR
VAR_EXTERNAL My_Tagname: DINT; Tagname2:BOOL; Tagname3:BOOL; Tagname4:BOOL;
Tagname5:BOOL; Tagname6:BOOL;
END_VAR
);
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Process Alarm Library (ALARMS)
This library was first released with TriStation 1131 v4.7.0, but can be used with all TriStation 1131 versions.
ALARM_ROC_DINT
Generates rate of change alarms for DINT tagnames.
Syntax
My_ROCAlm(SOURCE:=Tagname_2_ROCByp.VALUE, BYPASS:=Tagname_2_ROCByp.BYPASSED,
RATE_OF_CHANGE:=T#5s, ACK_REQUEST:=Tagname_1, DISABLE_REQUEST:=Tagname_5,
AUTOMATIC_RESET:=Tagname_3, MANUAL_RESET_REQUEST:=Tagname_6, DEADBAND:=2,
TIME_DELAY:=T#5ms, RINGBACK:=TRUE, HIGH_HIGH_LIMIT:=6, HIGH_HIGH_SEVERITY:=400,
HIGH_LIMIT:=3, HIGH_SEVERITY:=300, LOW_LIMIT:=3, LOW_SEVERITY:=200, LOW_LOW_LIMIT:=6,
LOW_LOW_SEVERITY:=100);
SOURCE DINT Input value for which a rate of change alarm will be
generated. May be connected to a tagname, or to the output
of BYPASS_DINT.
BYPASS BOOL If true, the source has been bypassed with the
BYPASS_VALUE (from the BYPASS_DINT function block).
Note: SOURCE = BYPASS_VALUE only when you use the
BYPASS_DINT function block along with
ALARM_ROC_DINT. The output of BYPASS_DINT
(VALUE) should be connected to the SOURCE input
of ALARM_ROC_DINT. Additionally,
BYPASS_REQ on BYPASS_DINT should be true.
Simply setting BYPASS to true will not bypass the
alarm. You must use BYPASS_DINT to bypass the
value, while ALARM_ROC_DINT’s BYPASS input
also should be true so that you obtain the correct
alarm status.
DISABLE_REQUEST BOOL If true, alarms will not be generated (all alarms disabled).
DEADBAND DINT Specifies the difference between the alarm limit and the input
value before an alarm goes inactive.
TIME_DELAY TIME Specifies the time delay for an alarm to go active upon
detection of an alarm condition.
HIGH_HIGH_LIMIT DINT Specifies the High High alarm limit for the SOURCE.
When SOURCE is greater than HIGH_HIGH_LIMIT, then
HIGH_HIGH_ACTIVE becomes true, and subsequently, the
output parameter ACTIVE becomes true.
HIGH_HIGH_SEVERITY DINT Specifies the severity for the High High limit.
HIGH_LIMIT DINT Specifies the High alarm limit for the SOURCE.
When SOURCE is greater than HIGH_LIMIT, then
HIGH_ACTIVE becomes true, and subsequently, the output
parameter ACTIVE becomes true.
LOW_LIMIT DINT Specifies the Low alarm limit for the SOURCE.
When SOURCE is less than LOW_LIMIT, then
LOW_ACTIVE becomes true, and subsequently, the output
parameter ACTIVE becomes true.
LOW_LOW_LIMIT DINT Specifies the Low Low alarm limit for the SOURCE.
When SOURCE is less than LOW_LOW_LIMIT, then
LOW_LOW_ACTIVE becomes true, and subsequently, the
output parameter ACTIVE becomes true.
LOW_LOW_SEVERITY DINT Specifies the severity for the Low Low limit.
ACTIVE BOOL If true, an alarm is active. If false, there are no active alarms.
Description
The ALARM_ROC_DINT function generates rate of change alarms for DINT tagnames.
Rate of change alarms are commonly used to report an unusual change or lack of change in a measured
value, relative to the speed at which the value has changed. They typically relate to instruments (for
example, a temperature meter). A rate of change alarm becomes active when the rate at which the value
changes exceeds or drops below a defined limit.
The rate of change is measured in units of time (such as seconds, minutes, or hours). For example, a tank
may have a High limit for the rate of change of its level (measured in meters) of 4 meters/minute. If the
tank level changes at a rate greater than 4 meters/minute, then a High alarm is generated.
The input parameter SOURCE is the process value being measured.
The DEADBAND input parameter specifies the difference between the alarm limit and the input value
that will cause an alarm to go inactive. For example, if a High alarm is set for 100, and the DEADBAND
is set to 10, the alarm will go active at 100, and inactive at 90. If a Low alarm is set for 100, it will go active
at 100, and inactive at 110.
The TIME_DELAY input parameter specifies how long before an alarm will go active once the alarm
condition is detected. For example, if TIME_DELAY is configured as 5 seconds, and the High alarm is set
for 100, once the value exceeds 100, ALARM_ROC_DINT will wait 5 seconds before generating the High
alarm. Use of the TIME_DELAY parameter can help prevent nuisance alarms that may be generated due
to process noise.
Example
VAR My_RateOfChange_Alarm: ALARM_ROC_DINT; END_VAR
VAR My_BYPASS_DINT:BYPASS_DINT; END_VAR
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Process Alarm Library (ALARMS)
This library was first released with TriStation 1131 v4.7.0, but can be used with all TriStation 1131 versions.
ALARM_ROC_REAL
Generates reate of change alarms for REAL tagnames.
Syntax
My_ROCAlm(SOURCE:=Tagname_2_ROCByp.VALUE, BYPASS:=Tagname_2_ROCByp.BYPASSED,
RATE_OF_CHANGE:=T#5s, ACK_REQUEST:=Tagname_1, DISABLE_REQUEST:=Tagname_5,
AUTOMATIC_RESET:=Tagname_3, MANUAL_RESET_REQUEST:=Tagname_6, DEADBAND:=2.0,
TIME_DELAY:=T#5ms, RINGBACK:=TRUE, HIGH_HIGH_LIMIT:=6.0, HIGH_HIGH_SEVERITY:=400,
HIGH_LIMIT:=3.0, HIGH_SEVERITY:=300, LOW_LIMIT:=3.0, LOW_SEVERITY:=200,
LOW_LOW_LIMIT:=6.0, LOW_LOW_SEVERITY:=100);
SOURCE DINT Input value for which a rate of change alarm will be
generated. May be connected to a tagname, or to the output
of BYPASS_REAL.
BYPASS BOOL If true, the source has been bypassed with the
BYPASS_VALUE (from the BYPASS_REAL function block).
Note: SOURCE = BYPASS_VALUE only when you use the
BYPASS_REAL function block along with
ALARM_ROC_REAL. The output of BYPASS_REAL
(VALUE) should be connected to the SOURCE input
of ALARM_ROC_REAL. Additionally,
BYPASS_REQ on BYPASS_REAL should be true.
Simply setting BYPASS to true will not bypass the
alarm. You must use BYPASS_REAL to bypass the
value, while ALARM_ROC_REAL’s BYPASS input
also should be true so that you obtain the correct
alarm status.
DISABLE_REQUEST BOOL If true, alarms will not be generated (all alarms disabled).
DEADBAND DINT Specifies the difference between the alarm limit and the input
value before an alarm goes inactive.
TIME_DELAY TIME Specifies the time delay for an alarm to go active upon
detection of an alarm condition.
HIGH_HIGH_LIMIT DINT Specifies the High High alarm limit for the SOURCE.
When SOURCE is greater than HIGH_HIGH_LIMIT, then
HIGH_HIGH_ACTIVE becomes true, and subsequently, the
output parameter ACTIVE becomes true.
HIGH_HIGH_SEVERITY DINT Specifies the severity for the High High limit.
HIGH_LIMIT DINT Specifies the High alarm limit for the SOURCE.
When SOURCE is greater than HIGH_LIMIT, then
HIGH_ACTIVE becomes true, and subsequently, the output
parameter ACTIVE becomes true.
LOW_LIMIT DINT Specifies the Low alarm limit for the SOURCE.
When SOURCE is less than LOW_LIMIT, then
LOW_ACTIVE becomes true, and subsequently, the output
parameter ACTIVE becomes true.
LOW_LOW_LIMIT DINT Specifies the Low Low alarm limit for the SOURCE.
When SOURCE is less than LOW_LOW_LIMIT, then
LOW_LOW_ACTIVE becomes true, and subsequently, the
output parameter ACTIVE becomes true.
LOW_LOW_SEVERITY DINT Specifies the severity for the Low Low limit.
ACTIVE BOOL If true, an alarm is active. If false, there are no active alarms.
Description
The ALARM_ROC_REAL function generates rate of change alarms for REAL tagnames.
Rate of change alarms are commonly used to report an unusual change or lack of change in a measured
value, relative to the speed at which the value has changed. They typically relate to instruments (for
example, a temperature meter). A rate of change alarm becomes active when the rate at which the value
changes exceeds or drops below a defined limit.
The rate of change is measured in units of time (such as seconds, minutes, or hours). For example, a tank
may have a High limit for the rate of change of its level (measured in meters) of 4 meters/minute. If the
tank level changes at a rate greater than 4 meters/minute, then a High alarm is generated.
The input parameter SOURCE is the process value being measured.
The DEADBAND input parameter specifies the difference between the alarm limit and the input value
that will cause an alarm to go inactive. For example, if a High alarm is set for 100, and the DEADBAND
is set to 10, the alarm will go active at 100, and inactive at 90. If a Low alarm is set for 100, it will go active
at 100, and inactive at 110.
The TIME_DELAY input parameter specifies how long before an alarm will go active once the alarm
condition is detected. For example, if TIME_DELAY is configured as 5 seconds, and the High alarm is set
for 100, once the value exceeds 100, ALARM_ROC_REAL will wait 5 seconds before generating the High
alarm. Use of the TIME_DELAY parameter can help prevent nuisance alarms that may be generated due
to process noise.
Example
VAR My_RateOfChange_Alarm: ALARM_ROC_REAL; END_VAR
VAR My_BYPASS_REAL:BYPASS_REAL; END_VAR
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Process Alarm Library (ALARMS)
This library was first released with TriStation 1131 v4.7.0, but can be used with all TriStation 1131 versions.
ALARM_TRIP
Generates trip alarms for BOOL tagnames.
Syntax
My_TripAlarm(SOURCE:=Tagname_1_TRIPByp.VALUE, BYPASS:=Tagname_1_TRIPByp.BYPASSED,
ACK_REQUEST:=Tagname_3, DISABLE_REQUEST:=Tagname_5, AUTOMATIC_RESET:=Tagname_4,
MANUAL_RESET_REQUEST:=Tagname_6, TIME_DELAY:=T#200ms, RINGBACK:=TRUE, SEVERITY:=200,
NORMAL_STATE:=FALSE);
SOURCE DINT Input value for which trip alarm will be generated. May be
connected to a tagname, or to the output of BYPASS_BOOL.
BYPASS BOOL If true, the source has been bypassed with the
BYPASS_VALUE (from the BYPASS_BOOL function block).
Note: SOURCE = BYPASS_VALUE only when you use the
BYPASS_BOOL function block along with
ALARM_TRIP. The output of BYPASS_BOOL
(VALUE) should be connected to the SOURCE input
of ALARM_TRIP. Additionally, BYPASS_REQ on
BYPASS_BOOL should be true. Simply setting
BYPASS to true will not bypass the alarm. You must
use BYPASS_BOOL to bypass the value, while
ALARM_TRIP’s BYPASS input also should be true so
that you obtain the correct alarm status.
NORMAL_STATE BOOL Specifies the healthy state of a point. If the value of SOURCE
changes its state, and the current state is not equal to
NORMAL_STATE, then a trip alarm is generated.
DISABLE_REQUEST BOOL If true, alarms will not be generated (all alarms disabled).
AUTOMATIC_RESET BOOL If true, when the generated alarm returns to normal, it is
acknowledged automatically.
TIME_DELAY TIME Specifies the time delay for an alarm to go active upon
detection of an alarm condition.
ACTIVE BOOL If true, an alarm is active. If false, there are no active alarms.
Description
The ALARM_TRIP function generates a trip alarm when there is a mismatch between the current state
and the normal state for a BOOL tagname.
Trip alarms are intended to represent an equipment trip condition. A trip alarm is generated when the
monitored piece of equipment experiences an abnormal fault (such as a motor shutting down due to an
overload condition).
The input parameter SOURCE is the process value being monitored. The input parameter
NORMAL_STATE indicates which of the possible input values indicates the normal condition of the
equipment being monitored. When the value of the tagname referenced by the SOURCE parameter is not
equal to the value of NORMAL_STATE, then the trip alarm is generated.
The TIME_DELAY input parameter specifies how long before the trip alarm will go active once the alarm
condition is detected. For example, if TIME_DELAY is configured as 5 seconds, and the
NORMAL_STATE is set for True, once the state changes to False, ALARM_TRIP will wait 5 seconds
before generating the trip alarm. Use of the TIME_DELAY parameter can help prevent nuisance alarms
that may be generated due to process noise.
Example
VAR My_TripAlarm:ALARM_TRIP ; END_VAR
VAR_EXTERNAL My_Tagname: BOOL ; END_VAR
MY_TripAlarm(SOURCE:=My_Tagname,
BYPASS:=False(or any BOOL tag), ACK_REQUEST:=False(or any BOOL tag),
DISABLE_REQUEST:=False(or any BOOL tag), AUTOMATIC_RESET:=false(or any BOOL tag),
MANUAL_RESET_REQUEST:=true(or any BOOL tag), TIME_DELAY:=T#10ms(or any TIME tag),
RINGBACK:=TRUE(or any BOOL tag), SEVERITY:=200(or any DINT tag),
NORMAL_STATE:=FALSE);
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Process Alarm Library (ALARMS)
This library was first released with TriStation 1131 v4.7.0, but can be used with all TriStation 1131 versions.
AND
Performs a logical AND of two or more Boolean operands or a bitwise AND of two or more bit-strings.
Syntax
b := b1 AND b2 AND ... AND bn ;
Description
In graphical languages, the AND function returns the logical AND of Boolean operands or the bitwise
AND of bit-strings. In Structured Text, the AND operator is used instead of the AND function.
The maximum number of function inputs is 50.
All operands must be the same type as the return value, either all BOOL or all DWORD.
If the operand type is BOOL, then the result is true if all operands are true. The result is false if any
operand is false.
b1 b2 b1 OR b2
If the operand type is DWORD, then the result is the bitwise AND of all the operands. In other words, the
value in each bit position of the result is the AND of all the values in the same bit position.
w1 w2 w1 AND w2
Example
Note that on the Controller Panel, you will see the example values in hex. The hex values of the operands
are w1=16#00000007, w2=16#00000003, w3=16#00000005, and the hex values of the results are
16#00000001 and 16#00000005.
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Can be used in CEM Cause cells.
Library
Standard (STDLIB)
AOUT
Converts a real number to an analog output.
Syntax
k := AOUT( MX, IN, MN )
Description
The AOUT function converts a real number to an analog output (in machine counts) that is typically in
the range of 819 to 4095. MN is the input value required to drive 4 milliamps or 1 volt in the field. MX is
the input value required to drive 20 milliamps or 5 volts in the field. AOUT does not clamp the analog
output to the range of 819 to 4095.
Example
VAR k : DINT; END_VAR
k := AOUT( 100.0, 100.0, 0.0 ); (* result is 4095 *)
k := AOUT( 100.0, 50.0, 0.0 ); (* result is 2457 *)
k := AOUT( 100.0, 0.0, 0.0 ); (* result is 819 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the error flags
to true, and resets ENO to false. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Triconex (TCXLIB)
AOUT_BP12
Converts a real number to a 12-bit differential bipolar analog output.
Syntax
y := AOUT_BP12( MX, IN, MN )
MX REAL The engineering unit value for the maximum machine count of
+4095.
MN REAL The engineering unit value for the minimum machine count of -
4095.
Description
The AOUT_BP12 function converts a real number to a 12-bit differential bipolar analog output (in
machine counts). When the input equals MN, the return value is -4095. When the input equals MX, the
return value is +4095. AOUT_BP12 does not clamp the analog output to the range of -4095 to +4095. The
scaling equation implemented in this function is approximately equivalent to
IN – MN-
------------------------- HI – LO + LO
MX – MN
Machine
Count
+4095
MN Engineering
Units
MX
-4095
Example
The BPAO module (model 3807) provides a 12-bit bipolar analog output that ranges from -60ma to
+60ma. An input value of -60ma corresponds to a machine count of -4095. An input value of +60ma
corresponds to a machine count of +4095. The following example function call converts the current (in
ma) to machine count:
in y
-60.0 -4095
0.0 0
+60.0 +4095
Runtime Errors
None
Application Notes
Can be used in Safety or Control applications.
Library
Triconex (TCXLIB)
This function was added to the library in v1.32 of TCXLIB, first released with TriStation 1131 v4.3.
ARRAY32_BOOL
Stores an array of 32 Boolean values.
Syntax
ARRAY32_BOOL(READ:=b1, WRITE:=b2, INDEX:=k, IN:=b3)
Description
The ARRAY32_BOOL function block stores an array of 32 Boolean values. The INDEX input selects one
of the 32 array elements. If WRITE is true, then the data input value IN is copied to the selected array
element. If READ is true, then the value in the selected array element is copied to OUT.
This table shows the outputs for a combination of inputs.
True True In-range True Value in the selected Writes IN to selected array element.
array element
Example
Runtime Errors
If INDEX is out-of-range (less than 1 or greater than 32). OUT is false BADPARAM, ERROR
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
• Can be used in Safety or Control applications.
• Internal State: a single instance can be executed more than once per scan. However, you should
be aware of the internal states that are used from one scan to the next.
Library
Triconex (TCXLIB)
ARRAY32_DINT
Stores an array of 32 integers.
Syntax
ARRAY32_DINT(READ:=b1, WRITE:=b2, INDEX:=k, IN:=b3)
Description
The ARRAY32_DINT function block stores an array of 32 integers. The INDEX input selects one of the 32
array elements. If WRITE is true, then the data input value IN is copied to the selected array element. If
READ is true, then the value in the selected array element is copied to OUT. This table shows the outputs
for a combination of inputs.
True True In-range True Value in the selected Writes IN to selected array element.
array element
Example
Runtime Errors
If INDEX is out-of-range (less than 1 or greater than 32). OUT is 0 BADPARAM, ERROR
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
• Can be used in Safety or Control applications.
• Internal State: a single instance can be executed more than once per scan. However, you should
be aware of the internal states that are used from one scan to the next.
Library
Triconex (TCXLIB)
ARRAY32_REAL
Stores an array of 32 real numbers.
Syntax
ARRAY32_REAL(READ:=b1, WRITE:=b2, INDEX:=k, IN:=b3)
Description
The ARRAY32_REAL function block stores an array of 32 real numbers. The INDEX input selects one of
the 32 array elements. If WRITE is true, then the data input value IN is copied to the selected array
element. If READ is true, then the value in the selected array element is copied to OUT.
This table shows the outputs for a combination of inputs.
True True In-range True Value in the selected Writes IN to selected array element.
array element
Example
Runtime Errors
If INDEX is out-of-range (less than 1 or greater than 32). OUT is 0 BADPARAM, ERROR
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
• Can be used in Safety or Control applications.
• Internal State: a single instance can be executed more than once per scan. However, you should
be aware of the internal states that are used from one scan to the next.
Library
Triconex (TCXLIB)
ASIN
Calculates the principal arc sine of a real number.
Syntax
Y := ASIN( x )
x ANY_REAL The real number between –1.0 and 1.0 whose arc sine is to be calculated.
Description
The ASIN function calculates the principal arc sine of a real number. The result is in radians from –1.5708
to +1.5708.
Example
VAR y : REAL; ND VAR
y := ASIN( 1.0 ); (* result is +1.5708 *)
y := ASIN( –1.0 ); (* result is –1.5708 *)
Runtime Errors
If X is not a number or the absolute value of x is greater than 1.0. NAN BADPARAM, ERROR
Upon detection of a runtime error condition, the function returns the indicated value, sets the error flags
to true, and resets ENO to false. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
ATAN
Calculates the principal arc tangent of a real number.
Syntax
Y := ATAN( x )
Description
The ATAN function calculates the principal arc tangent of a real number. The result is in radians from –
1.5708 to +1.5708.
Example
VAR y : REAL; END_VAR
y := ATAN( 1.0 ); (* result is +0.785398 *)
y := ATAN( –1.0 ); (* result is –0.785398 *)
y := ATAN( 10.0 ); (* result is +1.47113 *)
y := ATAN( –10.0 ); (* result is –1.47113 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the error flags
to true, and resets ENO to false. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
BLINK
Generates a pulse output.
Syntax
BLINK(IN:=b1, RESET:=b2, T_ON:=t1, T_OFF:=t2)
Description
The BLINK function block generates a pulse output intended to repeatedly turn an indicator on and off.
The IN input enables blinking. The RESET input resets the Q output to false and initiates the pulse-off
period. T_ON specifies how long the pulse is on; T_OFF specifies how long the pulse is off.
Example
This example blinks an alarm indicator at a rate of 1 second on and 500 milliseconds off.
VAR_OUTPUT INDICATOR : BOOL; END_VAR
VAR BLINK_ALARM : BLINK; END_VAR
BLINK_ALARM(IN:=TRUE,RESET:=FALSE,T_ON:=t#1s,T_OFF:=t#500ms);
INDICATOR := BLINK_ALARM.Q ;
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
• Can be used in CEM Cause, Effect, and Intersection cells.
Library
Triconex (TCXLIB)
BLINK_I
Generates a pulse output.
Syntax
BLINK_I(IN:=b1, RESET:=b2, T_ON:=t1, T_OFF:=t2)
Description
The BLINK_I function block generates a pulse output intended to repeatedly turn an indicator on and off.
The IN input enables blinking. The RESET input resets the Q output to false and initiates the pulse-off
period. T_ON specifies how long the pulse is on; T_OFF specifies how long the pulse is off.
Example
This example blinks an alarm indicator at a rate of one second on and one-half second off.
VAR_OUTPUT INDICATOR : BOOL; END_VAR
VAR BLINK_ALARM : BLINK_I; END_VAR
BLINK_ALARM(IN:=TRUE,RESET:=FALSE,T_ON:=t#1s,T_OFF:=t#500ms);
INDICATOR := BLINK_ALARM.Q ;
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Exactly Once: each instance should be executed exactly once per scan.
• Can be used in CEM Cause, Effect, and Intersection cells.
Library
Triconex (TCXLIB)
BLINK_R
Generates a pulse output.
Syntax
BLINK_R(IN:=b1, RESET:=b2, T_ON:=t1, T_OFF:=t2)
Description
The BLINK_R function block generates a pulse output intended to repeatedly turn an indicator on and
off. The IN input enables blinking. The RESET input resets the Q output to false and initiates the pulse-
off period. T_ON specifies how long the pulse is on; T_OFF specifies how long the pulse is off.
Example
This example blinks an alarm indicator at a rate of one second on and one-half second off.
VAR_OUTPUT INDICATOR : BOOL; END_VAR
VAR BLINK_ALARM : BLINK_I; END_VAR
BLINK_ALARM(IN:=TRUE,RESET:=FALSE,T_ON:=t#1s,T_OFF:=t#500ms);
INDICATOR := BLINK_ALARM.Q ;
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Exactly Once: each instance should be executed exactly once per scan.
• Can be used in CEM Cause, Effect, and Intersection cells.
Library
Triconex (TCXLIB)
BOOL
A BOOL data type is one bit in length and has two possible values: false (0) or true (1).
Attribute Description
Keyword/type BOOL
Description Boolean
Size 1 bit
Result if upper limit is less than intermediate value Intermediate Value MOD 2
Application Notes
• Can be used in Safety or Control applications.
• Can be used in CEM Cause, Effect, and Intersection cells.
BOOL_TO_DWORD
Converts a Boolean (BOOL) value to a DWORD value.
Syntax
w := BOOL_TO_DWORD(b);
Description
The BOOL_TO_DWORD function converts a Boolean (BOOL) value to a DWORD value.
Note IEC 1131-3 requires strict data type checking. It does not permit assigning the value of a variable
directly to a variable of a different data type. When it is necessary to use variables of different
data types, an explicit conversion must be made using a data type conversion function.
Example
VAR b : BOOL; w : DWORD; END_VAR;
b := TRUE;
w := BOOL_TO_DWORD( b ); (* result is 16#0001 *)
b := FALSE;
w := BOOL_TO_DWORD( b ); (* result is 16#0000 *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
BYPASS_BOOL
Bypasses an alarm generated from a BOOL alarm function block.
Syntax
Tagname_2_LvByp(TAG_VALUE:=Tagname_2, BYPASS_VALUE:=TRUE, BYPASS_REQ:=Tagname_4);
Description
The BYPASS_BOOL function can be used to bypass an alarm that is generated from a BOOL alarm
function block (ALARM_TRIP).
If the input parameter BYPASS_REQ is true, the source value (TAG_VALUE) will be bypassed and the
output parameter VALUE will have the same value as BYPASS_VALUE. The output parameter VALUE
should be connected to the SOURCE input parameter of a BOOL alarm function block. Additionally,
BYPASS_REQ should be true.
Simply setting the BOOL alarm function block’s BYPASS input to true will not bypass the alarm. You
must use BYPASS_BOOL to bypass the value, while the BOOL alarm function block’s BYPASS input also
should be true so that you obtain the correct alarm status.
Example
VAR My_BYPASS_BOOL:BYPASS_BOOL; END_VAR
VAR My_Trip_Alarm: ALARM_TRIP; END_VAR
VAR_EXTERNAL
My_SourceTagname: BOOL;
My_BypassTagname: BOOL;
END_VAR
My_BYPASS_BOOL(TAG_VALUE:=My_SourceTagname, BYPASS_VALUE:=TRUE,
BYPASS_REQ:=My_BypassTagname);
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Process Alarm Library (ALARMS)
This library was initially released with TriStation 1131 v4.7.0, but can be used with all TriStation 1131 versions.
BYPASS_DINT
Bypasses an alarm generated from a DINT alarm function block.
Syntax
Tagname_2_LvByp(TAG_VALUE:=Tagname_2, BYPASS_VALUE:=55, BYPASS_REQ:=Tagname_4);
Description
The BYPASS_DINT function can be used to bypass an alarm that is generated from a DINT alarm
function block (ALARM_LEVEL_DINT, ALARM_DEVIATION_DINT, or ALARM_ROC_DINT).
If the input parameter BYPASS_REQ is true, the source value (TAG_VALUE) will be bypassed and the
output parameter VALUE will have the same value as BYPASS_VALUE. The output parameter VALUE
should be connected to the SOURCE input parameter of a DINT alarm function block. Additionally,
BYPASS_REQ should be true.
Simply setting the DINT alarm function block’s BYPASS input to true will not bypass the alarm. You must
use BYPASS_DINT to bypass the value, while the DINT alarm function block’s BYPASS input also should
be true so that you obtain the correct alarm status.
Example
The following example bypasses a deviation alarm SOURCE input with the configured bypass value (55)
when BYPASS_REQ is True (Tagname4).
VAR My_Deviation_Alarm: ALARM_DEVIATION_DINT; END_VAR
VAR My_BYPASS_DINT:BYPASS_DINT; END_VAR
VAR_EXTERNAL
My_Tagname: DINT;
Tagname2:BOOL;Tagname3:BOOL; Tagname4:BOOL; Tagname5:BOOL;Tagname6:BOOL;
END_VAR
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Process Alarm Library (ALARMS)
This library was initially released with TriStation 1131 v4.7.0, but can be used with all TriStation 1131 versions.
BYPASS_REAL
Bypasses an alarm generated from a REAL alarm function block.
Syntax
Tagname_2_LvByp(TAG_VALUE:=Tagname_2, BYPASS_VALUE:=55.25, BYPASS_REQ:=Tagname_4);
Description
The BYPASS_REAL function can be used to bypass an alarm that is generated from a REAL alarm
function block (ALARM_LEVEL_REAL, ALARM_DEVIATION_REAL, or ALARM_ROC_REAL).
If the input parameter BYPASS_REQ is true, the source value (TAG_VALUE) will be bypassed and the
output parameter VALUE will have the same value as BYPASS_VALUE. The output parameter VALUE
should be connected to the SOURCE input parameter of a REAL alarm function block. Additionally,
BYPASS_REQ should be true.
Simply setting the REAL alarm function block’s BYPASS input to true will not bypass the alarm. You
must use BYPASS_REAL to bypass the value, while the REAL alarm function block’s BYPASS input also
should be true so that you obtain the correct alarm status.
Example
The following example bypasses a deviation alarm SOURCE input with the configured bypass value (55)
when BYPASS_REQ is True (Tagname4).
VAR My_Deviation_Alarm: ALARM_DEVIATION_REAL; END_VAR
VAR My_BYPASS_REAL:BYPASS_REAL; END_VAR
VAR_EXTERNAL
My_Tagname: REAL;
Tagname2:BOOL;Tagname3:BOOL; Tagname4:BOOL; Tagname5:BOOL;Tagname6:BOOL;
END_VAR
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Process Alarm Library (ALARMS)
This library was initially released with TriStation 1131 v4.7.0, but can be used with all TriStation 1131 versions.
CEIL
Returns the next higher integer.
Syntax
y := CEIL( x )
Description
The CEIL function returns the next higher integer greater than or equal to x.
Example
VAR x : REAL END_VAR;
x := ceil(6.04 ); (* result is 7.0 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the error flags
to true, and resets ENO to false. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
CHK_ERR
Checks for runtime errors.
Syntax
CHK_ERR( CI:=TRUE )
ERROR BOOL True if any of the following outputs (except UNDERFLOW) are true.
Description
The CHK_ERR function block reads the runtime error flags.
When an error is detected while building or compiling a program, the error is considered a build error or
a compile error. When an error is detected while the program is running in an emulator or controller, the
error is considered a runtime error.
There are four mechanisms for detection, reporting, and handling of runtime errors.
• A function can return an error number or Boolean value indicating success or failure or type of
error. See the Return Value section for a function to see the error codes for that function.
• A function block can output an error number or Boolean value indicating success or failure or
type of error. See the Output Parameters section for a function block to see the error codes for
the function block.
• A function or operator can reset ENO to false, indicating a runtime error. ENO is the variable
specified by IEC1131-3 for handling errors. In typical usage, a caller sets ENO to true before
calling the function. If the function detects a runtime error, the function resets ENO to false.
After calling the function, the caller tests ENO. For example, the caller can continue normal
operation if ENO is true, or handle the error if ENO is false. Note that the value of ENO is
undefined after calling a function block. See the Runtime Errors section for a function to
determine when the function resets ENO.
• A function, function block, or operator can set runtime error flags. The caller can use the
CHK_ERR function block to read the runtime error flags. The caller can use the Triconex
(TCXLIB) function block to reset the runtime error flags to false. The runtime error flags are
automatically reset to false at the start of each scan. See the Runtime Errors section for a function
to see which runtime error flags can be set by the function.
This table shows the runtime error flags and the effect on ENO for each runtime error condition.
Note When the ERROR flag is true, it indicates a design flaw in the application that should be
corrected. For example, you should never have a divide by zero error because the program
should check the divisor before doing the division. To find such errors, a good practice is to add
a CHK_ERR function block at the end of the last program and set an alarm if the ERROR output
is true.
Divide by zero is detected by the divide operator / , the MOD operator, the DIV function, and the MOD
function when the divisor is zero.
Floating point overflow is detected by floating point arithmetic when the result is infinity, that is, when
the result is out of range.
Floating point underflow is detected by the exponential operator ** , the EXP function, and the Standard
(STDLIB) function. Underflow occurs when the result is very close to zero. Since underflow is not an
error, an underflow condition does not set the ERROR flag and does not reset ENO to false.
Bad parameter is detected by library functions and user-defined functions when a parameter is not in the
specified range. A user-defined function can use the ReportBadParam function to report a bad parameter
error.
A type conversion error is detected by a conversion function ( like REAL_TO_DINT ) when the converted
result is out-of-range.
A string length error is detected when a string is too long, that is, too many characters.
A subrange bound error is detected when a result is out-of-range, that is, not in the specified subrange. If
the subrange data type feature is not implemented, then the RANGE flag is always false (reserved for
future use).
An array index error is detected when an array index is out-of-bounds—the index bounds are specified
in the declaration of each array. By default, if the ARRAYERR flag is true at the end of the last program,
the control program traps and the main processors reset to the safe state. To avoid a trap, use the Triconex
(TCXLIB) function block to clear the ARRAYERR flag at the end of the last program.
An internal error is an error in the implementation code, that is, not a user programming error. An
example is an error in an interface between a compiler and a library, or between a library and an operation
system. Such errors may occur during development of Triconex software, but should never occur in
released software. In most recent releases, such errors result in a trap and reset the main processors to the
safe state. In other words, the INTERNALERR flag is always false when a user program reads it.
The OTHER error flag is reserved for future use.
Example
For runtime error examples, see one of these sample projects:
• Exmodbus.pt2 (Tricon controllers)
• Tdmodbus.pt2 (Trident or Tri-GP controllers)
Note See Sample Projects on page 7 for information about where to find these projects on the PC where
you installed TriStation 1131.
These examples, MY_FUNCTION and MY_PROGRAM, illustrate how to report a runtime error, how to
stop execution using ENO, and how to read the runtime error flags using the CHK_ERR function block.
FUNCTION MY_FUNCTION : DINT
VAR_INPUT
k : DINT ;
END_VAR
VAR
unused : BOOL ;
END_VAR
MY_FUNCTION := 0 ;
IF k < 0 THEN
(*
* The following statement
* sets the ERROR flag to true,
* sets the BADPARAM flag to true,
* and resets ENO to false.
*)
unused := ReportBadParam(0) ;
ELSE
MY_FUNCTION := k ;
END_IF ;
END_FUNCTION
PROGRAM MY_PROGRAM
VAR
FLAGS : CHK_ERR ;
n : DINT ;
END_VAR
FLAGS() ;
ENO := true ;
IF ENO THEN
n := MY_FUNCTION( 1 ) ;
(* ENO is still true because the parameter was OK. *)
END_IF ;
IF ENO THEN
n := MY_FUNCTION( -1 ) ;
(* ENO is now false because MY_FUNCTION detected a runtime error. *)
END_IF ;
IF ENO THEN
(* The following statement is not executed because ENO is false. *)
n := n + 1 ;
END_IF ;
FLAGS() ;
(* FLAGS.ERROR is true and FLAGS.BADPARAM is true. *)
END_PROGRAM
Runtime Errors
None—CHK_ERR reads, but does not change, the runtime error flags.
Application Notes
• Can be used in Safety or Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
Triconex (TCXLIB)
CLR_ERR
Clears the runtime errors read by the CHK_ERR function block.
Syntax
CLR_ERR( CI:=TRUE )
Description
The CLR_ERR function block clears the runtime errors read by the CHK_ERR function block.
Example
In this example, the program checks for runtime errors in the middle and end of the program. CLR_ERR
clears the errors after each error check.
PROGRAM CLR_ERR_EXAMPLE
VAR
CHECK_ERRORS : CHK_ERR;
CLEAR_ERRORS : CLR_ERR;
ERRORS_A, ERRORS_B : BOOL;
END_VAR
(* Program code *)
:
CHECK_ERRORS( CI := TRUE );
IF (CHECK_ERRORS.ERROR = TRUE ) THEN ERRORS_A := TRUE; END_IF;
CLEAR_ERRORS( CI := TRUE );
:
(* More program code *)
:
IF (CHECK_ERRORS.ERROR = TRUE ) THEN ERRORS_B := TRUE; END_IF;
CLEAR_ERRORS( CI := TRUE );
END_PROGRAM
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
Triconex (TCXLIB)
CONCAT_DT
Concatenates date and time-of-day values.
Syntax
datetime := CONCAT_DT( d, t )
Description
The CONCAT_DT function concatenates a date with a time of day and returns a date-and-time value.
Example
VAR d : DATE; t : TOD; datetime : DT; END_VAR
d := D#2002-01-01;
t := TOD#10:32:12;
datetime := CONCAT_DT( d, t ); (*result is DT#2002-01-01-10:32:12*)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the error flags
to true, and resets ENO to false. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
COS
Calculates the cosine of an angle.
Syntax
y := COS( x ) ;
Description
The COS function returns the cosine of an angle given in radians. The result is in the range –1 to 1.
Example
VAR y : REAL; END_VAR
y := COS( 3.14159 ); {* result is -1.0 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the error flags
to true, and resets ENO to false. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
CSCHED
Schedules the execution of selected program logic after a specified number of scans.
Syntax
CSCHED( CI:=b1, NSCANS:=m1, NOFFSET:=m2 )
NOFFSET DINT The number of scans before the Q output is set to true for the first
time.
Q BOOL True if the specified number of scans occur. Q holds true for one
scan, then returns to false.
ACTUAL TIME The elapsed time from the last setting of the Q output.
Description
The CSCHED function block is used to schedule the execution of selected program logic after a specified
number of scans occur. Output Q is true after the specified number of scans occur and holds true for one
scan. By testing the output Q, sections of the control program can execute periodically. This function
block must be invoked exactly once per scan. Otherwise, the scan count is incorrect.
Example
This example causes selected statements to be executed every 100 scans after the first 500 scans.
VAR EXEC_LOGIC : CSCHED; END_VAR
EXEC_LOGIC(CI := TRUE, NSCANS := 100, NOFFSET := 500 );
IF ( EXEC_LOGIC.Q = TRUE ) THEN
(* execute these statements *)
END_IF
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Exactly Once: each instance should be executed exactly once per scan.
Library
Triconex (TCXLIB)
CSCHED_I
Schedules the execution of selected program logic after a specified number of scans.
Syntax
CSCHED_I( CI:=b1, NSCANS:=m1, NOFFSET:=m2 )
NOFFSET DINT The number of scans before the Q output is set to true for the first time.
Q BOOL True if the specified number of scans have occurred. Q holds true for one scan, then
returns to false.
ACTUAL DINT The elapsed time in milliseconds from the last setting of the Q output.
Description
The CSCHED_I function block is used to schedule the execution of selected program logic after a
specified number of scans occur. Output Q is true after the specified number of scans occur and holds true
for one scan. By testing the output Q, sections of the control program can execute periodically. This
function block must be invoked exactly once per scan. Otherwise, the scan count is incorrect.
Note CSCHED_I differs from CSCHED in that the ACTUAL elapsed time is represented in
milliseconds and is a DINT data type.
Example
This example causes selected statements to be executed every 100 scans after the first 500 scans.
VAR EXEC_LOGIC : CSCHED_I; END_VAR
EXEC_LOGIC(CI := TRUE, NSCANS := 100, NOFFSET := 500 );
IF ( EXEC_LOGIC.Q = TRUE ) THEN
(* execute these statements *)
END_IF
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Exactly Once: each instance should be executed exactly once per scan.
Library
Triconex (TCXLIB)
CSCHED_R
Schedules the execution of selected program logic after a specified number of scans.
NOFFSET DINT The number of scans before the Q output is set to true for the first time.
Q BOOL True if the specified number of scans occur. Q holds true for one scan, then returns
to false.
ACTUAL REAL The elapsed time in seconds from the last setting of the Q output.
Description
The CSCHED_R function block is used to schedule the execution of selected program logic after a
specified number of scans occur. Output Q is true after the specified number of scans occur and holds true
for one scan. By testing the output Q, sections of the control program can execute periodically. This
function block must be invoked exactly once per scan. Otherwise, the scan count is incorrect.
Note CSCHED_R differs from CSCHED in that the ACTUAL elapsed time is represented in seconds
and is a REAL data type.
Example
This example causes selected statements to be executed every 100 scans after the first 500 scans.
VAR EXEC_LOGIC : CSCHED_R; END_VAR
EXEC_LOGIC(CI := TRUE, NSCANS := 100, NOFFSET := 500 );
IF ( EXEC_LOGIC.Q = TRUE ) THEN
(* execute these statements *)
END_IF
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Exactly Once: each instance should be executed exactly once per scan.
Library
Triconex (TCXLIB)
CTD
Down counter. Signals when a value reaches zero while counting down from a preset value (PV).
Syntax
CTD( CD:=b1, LD:=b2, PV:=m )
Description
The CTD function block decrements a value and signals when it reaches zero or less. Setting the LD input
to true causes the counter's current value to be initialized by the PV. While the input CD is true, the CV
decrements by one each time CTD is executed. The countdown stops when CV reaches –32768. Output Q
is true when CV is less than or equal to zero.
Example
This example counts down from 500 to zero. When zero is reached, the counter is reset and the
countdown is repeated.
VAR
COUNTDOWN : CTD;
RESET : BOOL := TRUE;
END_VAR;
COUNTDOWN( CD := TRUE, LD := RESET, PV := 500 );
RESET := COUNTDOWN.Q;
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
• Can be used in CEM Cause and Effect cells.
• IEC 1131-3 specifies that the CTD function block counts down the number of rising-edge
triggers detected at the CD input. In the Triconex implementation, the CD input is not a rising-
edge trigger. The countdown progresses as long as the CD input remains true.
Library
Standard (STDLIB)
CTU
Up counter. Signals when a count reaches a preset value (PV).
Syntax
CTU( CU:=b1, R:=b2, PV:=m )
Description
The CTU function block increments a value and signals when it reaches the value specified by the PV
input. Setting the R input to true resets the CV to zero. While the input CU is true, the CV increments by
one each time CTU is executed. The count up stops when CV reaches 32,767. Output Q is true when CV
is greater than or equal to PV.
Example
This example counts up from zero to 500. When 500 is reached, the counter is reset and the count-up
from zero is repeated.
VAR
COUNTUP : CTU;
RESET : BOOL := TRUE;
END_VAR;
COUNTUP( CU := TRUE, R := RESET, PV := 500 );
RESET := COUNTUP.Q;
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
• Can be used in CEM Cause and Effect cells.
• IEC 1131-3 specifies that the CTU function block count up the number of rising-edge triggers
detected at the CU input. In the Triconex implementation, the CU input is not a rising-edge
trigger. The count-up progresses as long as the CU input remains true.
Library
Standard (STDLIB)
CTUD
Up-down counter. Signals when a count reaches either zero or a preset value (PV).
Syntax
CTUD( CU:=b1, CD:=b2, R:=b3, LD:=b4, PV:=m )
Description
The CTUD function block increments and decrements a value, and signals when it counts down to zero
or counts up to the value specified by the PV input. Setting the R input to true resets the CV to zero.
Setting the LD input to true causes the counter's CV to be initialized by the PV. When the input CU is true
and CD is false, the CV increments by one each time CTU is executed. When the input CD is true and CU
is false, the CV decrements by one each time CTU is executed. The count up stops when CV reaches 32767;
the count down stops when CV reaches –32768. Output QU is true when CV is greater than or equal to
PV. Output QD is true when CV is less than or equal to zero.
Example
This example counts up from zero to 500. When 500 is reached, the counter counts back down to zero.
VAR
COUNT : CTUD;
COUNTUP, RESET : BOOL := TRUE;
COUNTDN, BOOL := FALSE;
END_VAR;
COUNT( CU:=COUNTUP, CD:= COUNTDN, R:=RESET, LD:=FALSE, PV:=500 );
RESET := FALSE;
IF ( COUNT.QU = TRUE ) THEN
COUNTUP := FALSE;
COUNTDN := TRUE;
ELSIF ( COUNT.QD = TRUE ) THEN
COUNTUP := TRUE;
COUNTDN := FALSE;
END_IF
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
• Can be used in CEM Cause and Effect cells.
• IEC 1131-3 specifies that the CTUD function block count up the number of rising-edge triggers
detected at the CU input and count down the number of rising-edge triggers detected at the CD
input. In the Triconex implementation, these inputs are not rising-edge triggers. The CU and CD
inputs enable counting up and counting down.
Library
Standard (STDLIB)
DATE
A DATE data type refers to a specific date expressed as the year, month, and day.
Attribute Description
Keyword/type DATE
Description Date
Size 64 bits
Syntax D#CCYY-MM-DD
Application Notes
• Can be used in Safety or Control applications.
• Can be used in CEM Cause, Effect, and Intersection cells.
DINT
A DINT data type is a double integer, 32 bits in length.
Attribute Description
Keyword/type DINT
Size 32 bits
Default value 0
Result if intermediate valuea is less than lower limit –2**31 or V modulo 2**32
Result if upper limit is less than intermediate valuea 2**31–1 or V modulo 2**32
a. If the intermediate conversion value is out of range (for example, when converting LREAL to DINT), the return
value is the smallest or greatest double integer.
Application Notes
• Can be used in Safety or Control applications.
• Can be used in CEM Cause, Effect, and Intersection cells.
DINT_TO_DWORD
Converts a 32-bit integer to a DWORD value.
Syntax
w := DINT_TO_DWORD(k);
Description
The DINT_TO_DWORD function converts a 32-bit integer to a DWORD value.
Note IEC 1131-3 requires strict data type checking. It does not permit assigning the value of a variable
directly to a variable of a different data type. When it is necessary to use variables of different
data types, an explicit conversion must be made using a data type conversion function.
Example
VAR k : DINT; w : DWORD; END_VAR;
k := 256;
w := DINT_TO_DWORD( k ); (* result is 16#0100 *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
DINT_TO_INT
Converts a 32-bit integer to a 16-bit integer.
Syntax
m := DINT_TO_INT(k);
Description
The DINT_TO_INT function converts a 32-bit integer to a 16-bit integer.
Note IEC 1131-3 requires strict data type checking. It does not permit assigning the value of a variable
directly to a variable of a different data type. When it is necessary to use variables of different
data types, an explicit conversion must be made using a data type conversion function.
Example
VAR k : DINT; m : INT; END_VAR;
k := 1234;
m := DINT_TO_INT( k ); (* result is 1234 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the error flags
to true, and resets ENO to false. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
DINT_TO_LREAL
Converts a 32-bit integer to a 64-bit long real number.
Syntax
x := DINT_TO_LREAL(k);
Description
The DINT_TO_LREAL function converts a 32-bit integer to a 64-bit long real number.
Note IEC 1131-3 requires strict data type checking. It does not permit assigning the value of a variable
directly to a variable of a different data type. When it is necessary to use variables of different
data types, an explicit conversion must be made using a data type conversion function.
Example
VAR k : DINT; x : LREAL; END_VAR;
k := 1234;
x := DINT_TO_LREAL( k ); (* result is 1234.0 *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
DINT_TO_REAL
Converts a 32-bit integer to a 32-bit real number.
Syntax
x := DINT_TO_REAL( k );
Description
The DINT_TO_REAL function converts a 32-bit integer to a 32-bit real number.
Note IEC 1131-3 requires strict data type checking. It does not permit assigning the value of a variable
directly to a variable of a different data type. When it is necessary to use variables of different
data types, an explicit conversion must be made using a data type conversion function.
Example
VAR k : DINT; x : REAL; END_VAR;
k := 1234;
x := DINT_TO_REAL( k ); (* result is 1234.0 *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
DIV
Divides two numbers.
Syntax
z := x / y ;
Description
The DIV function divides two numbers and can be used as an operator or as a function.
The operations that can be performed are shown in this table.
a. The numerator, denominator and quotient must the same numerical data type.
Example
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the error flags
to true, and resets ENO to false. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
DT
A DT data type represents a date and time of day. To specify the time of day, you can use fractions (FFF)
of a second. Values are stored internally in microseconds and displayed in the TriStation 1131 Controller
Panel in milliseconds.
Attribute Description
Keyword/type DT
Size 64 bits
Syntax DT#CCYY-MM-DD-HH:MM:SS
or
DT#CCYY-MM-DD-HH:MM:SS.FFF
or
DATE_AND_TIME#CCYY-MM-DD-HH:MM:SS
Application Notes
• Can be used in Safety or Control applications.
• Can be used in CEM Cause, Effect, and Intersection cells.
DT_TO_DATE
Extracts the date from a date and time value.
Syntax
d := DT_TO_DATE(dtm);
dtm DT The date and time from which to extract the date.
Description
The DT_TO_DATE function extracts the date from the date portion of a DT data type value.
Example
VAR d : DATE; END_VAR
d := DT_TO_DATE( DT#2002-02-06-06:28:15 ); (* result is DATE#2002-02-06 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the error flags
to true, and resets ENO to false. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
DT_TO_TOD
Extracts the time of day from a date and time value.
Syntax
t := DT_TO_TOD(dtm);
dtm DT The date and time from which to extract the time of day.
Description
The DT_TO_TOD function extracts the time of day portion of a TD data type value.
Example
VAR t: TOD; END_VAR
t := DT_TO_TOD( DT#2002-02-06-06:28:15 ); (* result is TOD#06:28:15 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the error flags
to true, and resets ENO to false. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
DWORD
A DWORD data type is a double word, 32 bits in length. The result is always in the range from 0 to
16#FFFFFFFF. If the intermediate value is out of range, then the result is the least-significant 32 bits of the
intermediate value. For example, if you shift 16#FFFFFFFF to the left once, the intermediate value is
16#1FFFFFFFE and the result is 16#FFFFFFFE.
Attribute Description
Keyword/type DWORD
Size 32 bits
Default value 0
Lower limit 0
Application Notes
• Can be used in Safety or Control applications.
• Can be used in CEM Cause, Effect, and Intersection cells.
DWORD_TO_BOOL
Converts a DWORD value to a Boolean (BOOL) value.
Syntax
b := DWORD_TO_BOOL(w)
Description
The DWORD_TO_BOOL function converts a DWORD value to a Boolean (BOOL) value. The return value
equals the value of the least significant bit of the DWORD.
Example
VAR b : BOOL; END_VAR
b := DWORD_TO_BOOL(16#00000001); (* result is TRUE (1) *)
b := DWORD_TO_BOOL(16#00000002); (* result is FALSE (0) *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
DWORD_TO_DINT
Converts a DWORD value to a DINT value (32-bit signed integer).
Syntax
k := DWORD_TO_DINT(w)
Table 99 Parameter
Description
The DWORD_TO_DINT function converts a DWORD value to a DINT value (32-bit signed integer).
Example
VAR k : DINT; END_VAR
k := DWORD_TO_DINT( 16#000000FF ); (* result is 255 *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
EQ
Compares two operands for equality.
Syntax
b := x = y;
Description
The EQ function is used in graphical languages to determine if two operands are equal. In Structured
Text, the = operator is used to determine equality. The result is true if the operands are equal; otherwise
the result is false.
The operands can be any data type, but both operands must be the same data type. For type REAL or
LREAL, if either operand is not a number (NAN), the result is undefined.
Example
Structured Text
VAR b : BOOL; END_VAR
b := 10 = 11; (* result is FALSE *)
b := 11 = 11; (* result is TRUE *)
b := 'abcd' = 'abcd'; (* result is TRUE *)
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Can be used in CEM Cause cells.
Library
Standard (STDLIB)
EXP
Calculates the natural exponential for a real number.
Syntax
x := EXP(y)
Description
The EXP function calculates the natural exponential for a real number. EXP returns e raised to the power
specified by the real number parameter. The constant e is 2.71828182845904, the base for natural
logarithms.
Example
VAR x : REAL; END_VAR
x := EXP(1.0); (* result is 2.71828 *)
x := EXP(2.0); (* result is 7.38906 *)
x := EXP(3.0); (* result is 20.0855 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the error flags
to true, and resets ENO to false. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Underflow occurs when the result is very close to zero. Since underflow is not an error, an underflow
condition does not set the ERROR flag and does not reset ENO to false.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
EXPFLTR
Provides an exponential filter to smooth a noisy input data value.
Syntax
MYFILTER(CI:=b1, RESET:=b2, INPUT:=x1, FACTOR:=x2, IOUTPUT:=x3);
y := MYFILTER.IOUTPUT;
RESET BOOL Resets the output to the initial value supplied by IOUTPUT.
FACTOR REAL The smoothing factor is greater than or equal to 0.0 and less than or equal to1.0.
Description
The EXPFLTR function block provides an exponential filter to smooth a noisy input data value.
Example
The following example has a constantly changing input that is being filtered by a factor of 0.5. On the
graph, the gray line is RAWVALUE and the black line is MYFILTER.OUTPUT.
VAR MYFILTER : EXPFLTR; END_VAR
MYFILTER
CI:=TRUE,RESET:=INITFLTR,INPUT:=RAWVALUE,FACTOR:=REAL#0.5,IOUTPUT:= REAL#2.0);
FILTER_VALUE := MYFILTER.OUTPUT;
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
• Can be used in Safety or Control applications.
• Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
Library
Standard (STDLIB)
EXPT
Raises a value to a specified power.
Syntax
z := x ** y;
Description
The EXPT function raises a value to a specified power. EXPT is used in graphical languages to raise a real
value to a power specified by an exponent. In Structured Text, the ** operator is used for exponentiation.
Both the value to be raised and the return value must be the same data type (REAL or LREAL). The
exponent may be a REAL, LREAL, DINT, or INT data type.
Example
Structured Text
VAR z : REAL; END_VAR
z := 10.0 ** 2; (* result is 100.0 *)
Runtime Errors
If y = –1.#INF and x is less than or equal to –1.0 and less than 0.0. NAN BADPARAM, ERROR
If x = –1.#INF and y is greater than 0.0 and is an odd integer. –INF None
If x = –1.#INF and y is greater than 0.0 and is an even integer. +INF None
If y = -1.#INF and x is greater than or equal to 0.0 and less than +INF None
1.0.
If y = +1.#INF and x is greater than –1.0 and is less than 1.0. 0.0 None
Upon detection of a runtime error condition, the function returns the value and sets the error flag
indicated in the runtime error table above, sets the ERROR status flag, and resets ENO to false. For more
about error flags and runtime errors, see the CHK_ERR function block.
Underflow occurs when the result is very close to zero. Since underflow is not an error, an underflow
condition does not set the ERROR flag and does not reset ENO to false.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
F_TRIG
Triggers on the falling edge of the CLK input.
Syntax
F_TRIG(CLK:=b)
Description
The F_TRIG function block detects a change in state of the CLK input from true to false. When the change
is detected, the Q output is set to true for one function block execution.
Example
This examples maintains a count of the number of times unit power has been lost.
VAR POWER_OK, POWER_FAILED : BOOL; END_VAR
VAR POWER_FAIL_COUNT : DINT; END_VAR
VAR POWER_MONITOR : F_TRIG; END_VAR
POWER_MONITOR( CLK:=POWER_OK );
IF ( POWER_MONITOR.Q = TRUE ) THEN POWER_FAIL_COUNT := POWER_FAIL_COUNT + 1;
END_IF;
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
• Can be used in CEM Cause, Effect, and Intersection cells.
Library
Standard (STDLIB)
FLOOR
Truncates a real number to an integer.
Syntax
y := FLOOR( x );
Description
The FLOOR function truncates a real number to the largest integer that is less than or equal to x. In other
words, the function drops the fraction from the number.
Example
VAR y : REAL; END_VAR
y := FLOOR( 23.45986 ); (* result is 23.0 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the error flags
to true, and resets ENO to false. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
GASDETR
Processes analog inputs from a gas detector and generates alarms.
Syntax
MY_GASDETR(CI:=b1, INPUT:=n1, INHIBIT:=b2, RESET:=b3, OPFLIM:=n2, SHFLIM:=n3,
CALBLIM:=n4, OVRFLIM:=n5, GDMAXAV:=n6, GDMINAV:=n7, GDMAXEU:=x1, GDMINEU:=x2,
GHIALIM:=x3, GLOALIM:=x4 );
y := MY_GASDETR.OUTPUT;
Description
The GASDETR function block processes analog inputs from a gas detector and generates alarms by
computing the gas concentration GDVALUE in engineering units and the low-gas and high-gas status of
the detector.
GASDETR also monitors the analog inputs and sets these status indicators:
• Short-circuit fault
• Open-circuit fault
• Over-range fault
• Detector in calibration
GASDETR generates alarms from the status values. However, alarms can be inhibited by setting the
alarm INHIBIT input, while the status indicators are unaffected by the alarm INHIBIT input.
All alarm outputs are latched after they are set, until reset by the RESET input. The function packs all the
status, alarm, inhibit, and reset bits into the OUTPUT variable.
Parameters include the limits that are used to check for these faults and limits:
• Open-circuit faults
• Short-circuit faults
• Over-range faults
• Calibration status
• Low-gas alarm limit
• High-gas alarm limit
The minimum and maximum analog input and engineering values are also provided so that GASDETR
can convert an analog input into a gas concentration. RESET clears the alarms even when CI is false.
RESET clears the alarms before executing the other operations. If RESET and CI are both false, no
operation occurs.
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
Library
Standard (STDLIB)
GATDIS
Disables remote writes to aliased variables in a Tricon controller.
Syntax
GATDIS(CI:=b)
Description
In a Tricon controller, the GATDIS function block disables remote writes for all ranges of read/write
aliased variables that were previously enabled by Tricon (TX1LIB), thereby restricting write operations
by external hosts. GATDIS must be executed after the Tricon (TX1LIB) function. For more information,
see Tricon (TX1LIB) on page 123.
Example
VAR GATE_IS_DISABLED : BOOL ; END_VAR
VAR DISABLED_GATE : GATDIS ; END_VAR
DISABLE_GATE(TRUE);
GATE_IS_DISABLED = GATDIS.CO ;
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
Library
Tricon (TX1LIB)
GATENB
Enables remote writes to aliased variables in a Tricon controller.
Syntax
GATENB(CI:=b,DRWFRST:=k1,DRWLAST:=k2,IRWFRST:=k3,IRWLAST:=k4,RRWFRST:=k5,KRWLAST:=k6
DRWFRST DINT The starting alias number for memory discrete (BOOL) read/write range.
DRWLAST DINT The ending alias number for memory discrete (BOOL) read/write range.
IRWFRST DINT The starting alias number for memory integer (DINT) read/write range.
IRWLAST DINT The ending alias number for memory integer (DINT) read/write range.
RRWFRST DINT The starting alias number for memory real read/write range.
RRWLAST DINT The ending alias number for memory real read/write range.
Description
In a Tricon controller, the GATENB function block opens a gate for external-host read/writes to a
specified range of Modbus aliased variables when the controller is operating in RUN mode.
In a safety shutdown application, the keyswitch is typically set to RUN mode for normal operation.
However, this mode does not support Modbus writes from external hosts. To solve this problem,
TriStation 1131 provides gated-access function blocks to programmatically enable and disable external-
host writes to a Tricon controller.
GATENB allows you to specify a range of aliases for each of these data types:
• Discrete Read/Write
• Integer Read/Write
• Real Read/Write
You should use only one GATENB function block in a program. If you do not want to specify alias ranges
for certain data types, leave their starting and ending values at zero (the default).
Example
This example opens a gate for external-host writes to selected Modbus read/write memory BOOL and
DINT variables.
VAR ENABLE_GATE : GATENB; END_VAR
ENABLE_GATE( CI:=TRUE,DRWFRST:=2001, DRWLAST:=2020,
IRWFRST:=40251,IRWLAST:=40258,
RRWFRST:=0, RRWLAST:=0 );
Runtime Errors
If this is a second function block with the same specified alias range CO=false None
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
• Can be used in Safety or Control applications.
• Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
Library
Tricon (TX1LIB)
GE
Determines if one operand is greater than or equal to another operand.
Syntax
b := x >= y ;
Description
The GE function is used in graphical languages to determine if one operand is greater than or equal to
another operand. In Structured Text, the operator is used. The result is true if one operand is greater
than or equal to another operand; otherwise the result is false.
The operands can be any of these data types:
• BOOL
• DATE
• DINT
• DT
• DWORD
• INT
• LREAL
• REAL
• STRING
• TIME
• TOD
Both operands must be the same data type. For type REAL or LREAL data types, if either operand is not
a number (NAN), the result is undefined.
Examples
Structured Text
VAR b : BOOL; END_VAR
b := 10 >= 11; (* result is FALSE *)
b := 11 >= 11; (* result is TRUE *)
b := 11 >= 10; (* result is TRUE *)
b := 'abce' >= 'abcd'; (* result is TRUE *)
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Can be used in CEM Cause cells.
Library
Standard (STDLIB)
GetDelta_DINT
Returns the scan period for the previous scan in milliseconds.
Syntax
t := GetDelta_DINT()
Description
The GetDelta_DINT function returns the scan period for the previous scan in milliseconds. The scan
period is measured from the start of the previous scan to the start of the current scan. GetDelta_DINT can
only be used in Structured Text programs because it has no input parameters, which are required in FBD,
LD, and CEMPLE programs.
GetDelta_DINT does not comply with the statement in IEC 1131-3 that “…invocation of a function with
the same arguments (input parameters) shall always yield the same value (output).” GetDelta_DINT
yields the same value for every invocation within one scan, but yields different values for different scans.
Example
VAR t : DINT ; END_VAR
t := GetDelta_DINT();
(* Result is 100 if the measured scan period is 100 milliseconds. *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Triconex (TCXLIB)
GetDelta_REAL
Returns the scan period for the previous scan in seconds.
Syntax
t := GetDelta_REAL()
Description
The GetDelta_REAL function returns the scan period for the previous scan in seconds. The scan period is
measured from the start of the previous scan to the start of the current scan. GetDelta_REAL can only be
used in Structured Text programs because it has no input parameters, which are required in FBD, LD, and
CEMPLE programs.
GetDelta_REAL does not comply with the statement in IEC 1131-3 that “…invocation of a function with
the same arguments (input parameters) shall always yield the same value (output).” GetDelta_REAL
yields the same value for every invocation within one scan, but yields different values for different scans.
Example
VAR t : REAL ; END_VAR
t := GetDelta_REAL();
(* Result is 0.1 if the measured scan period is 100 milliseconds. *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Triconex (TCXLIB)
GetDeltaT
Returns the scan period for the previous scan.
Syntax
t := GetDeltaT()
Description
The GetDeltaT function returns the scan period for the previous scan. The scan period is measured from
the start of the previous scan to the start of the current scan. GetDeltaT can only be used in Structured
Text programs because it has no input parameters, which are required in FBD, LD, and CEMPLE
programs.
GetDeltaT does not comply with the statement in IEC 1131-3 that “…invocation of a function with the
same arguments (input parameters) shall always yield the same value (output).” GetDeltaT yields the
same value for every invocation within one scan, but yields different values for different scans.
Example
VAR t : TIME ; END_VAR
t := GetDeltaT();
(* Result is T#100ms if the measured scan period is 100 milliseconds. *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Triconex (TCXLIB)
GetTimer
Returns a date and time value that can be used to calculate the elapsed time between two events.
Syntax
dt := GetTimer()
Description
The GetTimer function returns a date and time value that can be used in conjunction with a previously
returned date and time value to calculate an elapsed time. GetTimer can only be used in Structured Text
programs because it has no input parameters, which are required in FBD, LD, and CEM programs.
The GetTimer function does not comply with the statement in IEC 61131-3 that: “… invocation of a
function with the same arguments (input parameters) shall always yield the same value (output).” The
GetTimer function yields the same value for every invocation within one scan, but yields different values
on different scans. The return value always increases from one scan to the next.
Example
This example calculates the time between two events: Event1 and Event2.
VAR
Event1, Event2 : BOOL;
T1, T2 : DT;
ElapsedTime : TIME;
END_VAR
IF Event1 then
T1 := GetTimer();
END_IF;
IF Event2 then
T2 := GetTimer();
ElapsedTime := T2 - T1;
END_IF;
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
GT
Determines if two operands have a greater-than-or-equal-to relationship.
Syntax
b := x > y;
Description
The GT function is used in graphical languages to determine if two operands have a greater-than-or-
equal-to relationship. In Structured Text, the >=operator is used. The result is true if the operands have
a greater-than-or-equal-to relationship; otherwise the result is false.
The operands can be any of these data types:
• BOOL
• DATE
• DINT
• DT
• DWORD
• INT
• LREAL
• REAL
• STRING
• TIME
• TOD
Both operands must be the same data type. For type REAL or LREAL data types, if either operand is not
a number (NAN), the result is undefined.
Example
Structured Text
VAR b : BOOL; END_VAR
b := 10 >= 11; (* result is FALSE *)
b := 11 >= 10; (* result is TRUE *)
b := 'abce' >= 'abcd'; (* result is TRUE *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
INFINITY_LREAL
Returns plus infinity.
Syntax
y := INFINITY_LREAL();
NA NA No inputs.
Description
The INFINITY_LREAL function returns plus infinity.
Example
VAR y : LREAL ; END_VAR;
y := INFINITY_LREAL(); (* result is plus infinity *)
(* Note: on the controller panel, the value shown is 1.#INF *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
INFINITY_REAL
Returns plus infinity.
Syntax
y := INFINITY_REAL();
NA NA No inputs.
Description
The INFINITY_REAL function returns plus infinity.
Example
VAR y : REAL ; END_VAR;
y := INFINITY_REAL(); (* result is plus infinity *)
(* Note: on the controller panel, the value shown is 1.#INF *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
INT
An INT data type is an integer, 16 bits in length. Arithmetic operators ADD, SUB, and MUL are
implemented with 32-bit arithmetic and the container for INT is 32 bits. The ADD, SUB, and MUL
operations do not check the range of results and can have resultant values out of the specified range (–
32768 and +32767). For example, using the SUB function to subtract 1 from -32768 results in –32769
(clearly out of range) without clearing ENO or reporting a BADPARAM error. However, an out-of-range
value does display “Inv INT” on the Controller Panel.
To verify that output values from these functions are within range, connect the output terminal to the
INT_TO_DINT function, which converts the integer output to double integer and does a range check for
the integer output.
An INT data type cannot be used as a program input or output.
Attribute Description
Keyword/type INT
Description Integer
Size 32 bits
Default value 0
Application Notes
• Can be used in Safety or Control applications.
• Can be used in CEM Cause, Effect, and Intersection cells.
INT_TO_DINT
Converts a 16-bit integer to a 32-bit integer.
Syntax
m := INT_TO_DINT(k);
Description
The INT_TO_DINT function converts a 16-bit integer to a 32-bit integer.
Note IEC 1131-3 requires strict data type checking. It does not permit assigning the value of a variable
directly to a variable of a different data type. When it is necessary to use variables of different
data types, an explicit conversion must be made using a data type conversion function.
Example
VAR k : INT; m : DINT; END_VAR;
k := 1234;
m := INT_TO_DINT( k ); (* result is 1234 *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
INT_TO_LREAL
Converts a 16-bit integer to a 64-bit long real number.
Syntax
x := INT_TO_LREAL(k);
Description
The INT_TO_LREAL function converts a 16-bit integer to a 64-bit long real number.
Note IEC 1131-3 requires strict data type checking. It does not permit assigning the value of a variable
directly to a variable of a different data type. When it is necessary to use variables of different
data types, an explicit conversion must be made using a data type conversion function.
Example
VAR k : INT; x : LREAL; END_VAR;
k := 1234;
x := INT_TO_LREAL( k ); (* result is 1234.0 *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
INT_TO_REAL
Converts a 16-bit integer to a 32-bit real number.
Syntax
x := INT_TO_REAL(k);
Description
The INT_TO_REAL function converts a 16-bit integer to a 32-bit real number.
Note IEC 1131-3 requires strict data type checking. It does not permit assigning the value of a variable
directly to a variable of a different data type. When it is necessary to use variables of different
data types, an explicit conversion must be made using a data type conversion function.
Example
VAR k : INT; x : REAL; END_VAR;
k := 1234;
x := INT_TO_REAL( k ); (* result is 1234.0 *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
INTGTOR
Integrates the INPUT parameter, ignoring noise-level values less than or equal to MINLVL.
Syntax
MY_INTGTOR(CI:=b1, RESET:=b2, INPUT:=x1, MINLVL:=x2, GAIN:=x3, DELTAT := GetDeltaT(),
IOUTPUT:=x4 );
y := MY_INTGTOR.OUTPUT ;
Description
The INTGTOR function block integrates the INPUT parameter, ignoring noise-level values less than or
equal to MINLVL. The result is OUTPUT.
CI is the control input. CI enables evaluation. If CI is false, then the integration step is not executed. See
DELTAT herein for suggested scheduling alternatives. The default initial value of CI is true.
RESET initializes OUTPUT to the value of argument IOUTPUT. The default initial value is 0.0. If RESET
and CI are both false, no operation occurs.
INPUT is the input value to be integrated.
MINLVL is a lower limit for the input value. If the input value is below this lower limit, then the
integration step is skipped and the result OUTPUT does not change. The default lower limit is zero.
GAIN is a gain factor. The input value is multiplied by the gain factor.
DELTAT is the time between executions. To schedule execution using a CSCHED or TSCHED function
block, connect the DELTAT input to the ACTUAL output of the CSCHED or TSCHED function block, and
connect the CI input to the Q output of the CSCHED or TSCHED function block. To schedule execution
every scan, connect the DELTAT input to the ouput of a Triconex (TCXLIB) function, and set CI=true.
IOUTPUT is an optional initial output value. If the RESET input is true, then the function block copies
IOUTPUT to OUTPUT. The default initial value is zero.
CO is the control ouput. CO follows CI. CO=true indicates that evaluation was enabled.
OUTPUT is the result, the integral of the input value. The result unit is the input unit multiplied by
seconds and multiplied by the gain factor. The equation for the integration step is:
OUTPUT := OUTPUT + GAIN * INPUT * TIME_TO_SECS_REAL(DELTAT) ;
Example
VAR MY_INTGTOR : INTGTOR ; END_VAR
VAR y : REAL ; END_VAR
MY_INTGTOR( INPUT:=1.0, GAIN:=1.0, DELTAT := GetDeltaT() ) ;
y := MY_INTGTOR.OUTPUT; (* if the scan period is always 0.16 seconds, then the result
for the first 3 scans is 0.16, 0.32, 0.48 *)
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
Library
Triconex (TCXLIB)
INTGTOR_R
Integrates the INPUT parameter, ignoring noise-level values less than or equal to MINLVL.
Syntax
MY_INTGTOR(CI:=b1, RESET:=b2, INPUT:=x1, MINLVL:=x2, GAIN:=x3, IOUTPUT:=x4 );
y := MY_INTGTOR.OUTPUT ;
Description
The INTGTOR_R function block integrates the INPUT parameter, ignoring noise-level values less than or
equal to MINLVL. The result is OUTPUT.
INTGTOR_R is smaller and faster than INTGTOR, but does not provide the scheduling alternatives of
INTGTOR, which means INTGTOR_R must be executed and enabled every scan.
CI is the control input. CI enables evaluation. If CI is false, then the integration step is not executed. The
default initial value of CI is true.
RESET initializes OUTPUT to the value of argument IOUTPUT. The default initial value is 0.0. If RESET
and CI are both false, no operation occurs.
INPUT is the input value to be integrated.
MINLVL is a lower limit for the input value. If the input value is below this lower limit, then the
integration step is skipped and the result OUTPUT does not change. The default lower limit is zero.
GAIN is a gain factor. The input value is multiplied by the gain factor.
IOUTPUT is an optional initial output value. If the RESET input is true, then the function block copies
IOUTPUT to OUTPUT. The default initial value is zero.
CO is the control ouput. CO follows CI. CO=true indicates that evaluation was enabled.
OUTPUT is the result, the integral of the input value. The result unit is the input unit multiplied by
seconds and multiplied by the gain factor. The equation for the integration step is:
OUTPUT := OUTPUT + GAIN * INPUT * GetDelta_REAL() ;
Example
VAR MY_INTGTOR : INTGTOR_R ; END_VAR
VAR y : REAL ; END_VAR
MY_INTGTOR( INPUT:=1.0, GAIN:=1.0 ) ;
y := MY_INTGTOR.OUTPUT; (* if the scan period is always 0.16 seconds, then the result
for the first 3 scans is 0.16, 0.32, 0.48 *)
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Exactly Once: each instance should be executed exactly once per scan.
Library
Triconex (TCXLIB)
IsFinite_LREAL
Returns true if a number is finite.
Syntax
b := IsFinite_LREAL( x );
x LREAL A number
Description
The IsFinite_LREAL function returns true if input x is a finite number; false if x is plus infinity, minus
infinity, or not a number (NAN).
Example
VAR x : LREAL ; b : BOOL ; END_VAR;
x := 0.0 ;
b := IsFinite_LREAL( x ); (* result is true *)
x := 1.0 / x ;
b := IsFinite_LREAL( x ); (* result is false *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
IsFinite_REAL
Returns true if a number is finite.
Syntax
b := IsFinite_REAL( x );
x REAL A number
Description
The IsFinite_REAL function returns true if input x is a finite number; false if x is plus infinity, minus
infinity, or not a number (NAN).
Example
VAR x : REAL ; b : BOOL ; END_VAR;
x := 0.0 ;
b := IsFinite_REAL( x ); (* result is true *)
x := 1.0 / x ;
b := IsFinite_REAL( x ); (* result is false *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
IsNan_LREAL
Returns true if the operand is not a number (NAN).
Syntax
b := IsNan_LREAL( x );
Description
The IsNan_LREAL function returns true if input x is a not a number (NAN); false if x is a finite number,
plus infinity, or minus infinity.
Example
VAR x : LREAL ; b : BOOL ; END_VAR;
x := 0.0 ;
b := IsNan_LREAL( x ); (* result is false *)
x := SQRT(-1.0) ;
b := IsNan_LREAL( x ); (* result is true *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
IsNan_REAL
Returns true if the operand is not a number (NAN).
Syntax
b := IsNan_REAL( x );
Description
The IsNan_REAL function returns true if input x is a not a number (NAN); false if x is a finite number,
plus infinity, or minus infinity.
Example
VAR x : REAL ; b : BOOL ; END_VAR;
x := 0.0 ;
b := IsNan_REAL( x ); (* result is false *)
x := SQRT(-1.0) ;
b := IsNan_REAL( x ); (* result is true *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
LE
Determines if one operand is less than or equal to another operand.
Syntax
b := x <= y ;
Description
The LE function is used in graphical languages to determine if one operand is greater than or equal to
another operand. In Structured Text, the <=operator is used. The result is true if one operand is less than
or equal to another operand; otherwise the result is false.
The operands can be any of these data types:
• BOOL
• DATE
• DINT
• DT
• DWORD
• INT
• LREAL
• REAL
• STRING
• TIME
• TOD
Both operands must be the same data type. For type REAL or LREAL data types, if either operand is not
a number (NAN), the result is undefined.
Example
Structured Text
VAR b : BOOL; END_VAR
b := 10 <= 11; (* result is TRUE *)
b := 11 <= 11; (* result is TRUE *)
b := 11 <= 10; (* result is FALSE *)
b := 'abce' <= 'abcd'; (* result is FALSE *)
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Can be used in CEM Cause cells.
Library
Standard (STDLIB)
LEADLAG
Provides the normal lead-lag compensation commonly used in the process control industry.
Syntax
MY_LEADLAG(CI:=b1, IN:=x1, GAIN:=x2, TAU1:=x3, TAU2:=x4, AUTO_MAN:=b2,
DELTAT:=GetDeltaT() ) ;
y := MY_LEADLAG.OUT ;
AUTO_MAN BOOL Controls auto/manual status of LEADLAG (auto =1, manual = 0).
Description
The LEADLAG function block provides the normal lead-lag compensation commonly used in the process
control industry. If input TAU1 is greater than input TAU2, then OUT is a lead. If TAU2 is greater than
TAU1, then OUT is a lag.
CI is the control input. CI enables evaluation. If CI is false, then the integration step is not executed. See
DELTAT herein for suggested scheduling alternatives. The default initial value of CI is true.
IN is the input value.
GAIN is a gain factor. The input value is multiplied by the gain factor.
TAU1 is the lead time constant in seconds.
TAU2 is the lag time constant in seconds.
AUTO_MAN controls whether the mode of operation is automatic (AUTO_MAN=1) or manual
(AUTO_MAN=0). In manual mode, the function block copies the input value times the gain to the output
value. In automatic mode, the function block calculates the output value as a function of input value,
previous input value, previous output value, gain, lead time constant, lag time constant, and time
between evaluations.
DELTAT is the time between executions. To schedule execution using a CSCHED or TSCHED function
block, connect the DELTAT input to the ACTUAL output of the CSCHED or TSCHED function block, and
connect the CI input to the Q output of the CSCHED or TSCHED function block. To schedule execution
every scan, connect the DELTAT input to the ouput of a GetDeltaT function, and set CI=true.
CO is the control ouput. CO follows CI. CO=true indicates that evaluation was enabled.
OUT is the result. The result unit is the input unit multiplied by the gain factor.
If AUTO_MAN=0 then the equation for the output is:
OUT := GAIN * IN ;
Runtime Errors
None.
Application Notes
• Can be used in Control applications.
• Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
Library
Triconex (TCXLIB)
LEADLAG_R
Provides the normal lead-lag compensation commonly used in the process control industry.
Syntax
MY_LEADLAG_R(CI:=b1, IN:=x1, GAIN:=x2, TAU1:=x3, TAU2:=x4, AUTO_MAN:=b2 ) ;
y := MY_LEADLAG_R.OUT ;
AUTO_MAN BOOL Controls auto/manual status of LEADLAG_R (auto =1, manual = 0).
Description
The LEADLAG_R function block provides the normal lead-lag compensation commonly used in the
process control industry. If input TAU1 is greater than input TAU2, then OUT is a lead. If TAU2 is greater
than TAU1, then OUT is a lag.
LEADLAG_R is smaller and faster than LEADLAG, but does not provide the scheduling alternatives of
LEADLAG, which means LEADLAG_R must be executed and enabled every scan.
CI is the control input. CI enables evaluation. If CI is false, then no operation occurs. The default initial
value of CI is true.
IN is the input value.
GAIN is a gain factor. The input value is multiplied by the gain factor.
TAU1 is the lead time constant in seconds.
TAU2 is the lag time constant in seconds.
AUTO_MAN controls whether the mode of operation is automatic (AUTO_MAN=1) or manual
(AUTO_MAN=0). In manual mode, the function block copies the input value times the gain to the output
value. In automatic mode, the function block calculates the output value as a function of input value,
previous input value, previous output value, gain, lead time constant, lag time constant, and time
between evaluations.
CO is the control ouput. CO follows CI. CO=true indicates that evaluation was enabled.
OUT is the result. The result unit is the input unit multiplied by the gain factor.
If AUTO_MAN=0 then the equation for the output is:
OUT := GAIN * IN ;
Runtime Errors
None.
Application Notes
• Can be used in Control applications only.
• Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
Library
Triconex (TCXLIB)
LIMIT
Returns a value between a minimum limit and a maximum limit.
Syntax
y := LIMIT( low, x, high ) ;
Description
The LIMIT function returns a value between a minimum limit and a maximum limit.
If the input value is between the minimum limit and the maximum limit, then the return value equals the
input value. If the input value is less than or equal to the minimum limit, then the return value equals the
minimum limit. If the input value is greater than or equal to the maximum limit, then the return value
equals the maximum limit.
The LIMIT function can be used with these data types:
• BOOL
• DATE
• DINT
• DT
• DWORD
• INT
• LREAL
• REAL
• TIME
• TOD
All operands must be the same data type as the data type for the return value. For data type REAL or
LREAL, if any operand is not a number (NAN), the result is NAN.
Note STRING data types are not supported for this function.
Example
VAR x, y : REAL ; END_VAR
x := 5.0 ;
y := LIMIT( 10.0, x, 20.0 ) ; (* result is 10.0 *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
LINEMNTR
Monitors an analog current loop.
Syntax
MY_LINEMNTR_R(CI:=b1, INPUT:=n1, LNOPLIM:=n2, LNSHLIM:=n3, LMONLIM:=n4 ) ;
IS_ON := MY_LINEMNTR_R.OUTPUT ;
IS_SHORTED := MY_LINEMNTR_R.LNSHORT ;
IS_OPEN := MY_LINEMNTR_R.LNOPEN ;
Description
The LINEMNTR function block monitors an input from an analog current loop.
First, the function block compares the analog input value with the open-circuit fault limit. If the analog
input value is less than or equal to the open-circuit fault limit, then there is not enough current flowing
in the current loop, which means there is an open circuit fault, and the function block sets ouput
LNOPEN=true.
If there is no open-circuit fault, then the function block compares the analog input value with the short-
circuit fault limit. If the analog input value is greater than or equal to the short-circuit fault limit, then
there is too much current flowing in the current loop, which means there is a short circuit fault, and the
function block sets output LNSHORT=true.
If there is neither an open-circuit fault nor a short-circuit fault, then the function block compares the
analog input value with the "contact input on" limit which is a current threshold that distinguishes data
0 from data 1. If the analog input value is greater than or equal to the "contact input on" limit, then the
function block sets OUTPUT=1; otherwise, OUTPUT=0.
CI is the control input. CI enables evaluation. If CI is false, then there is no operation. The default initial
value of CI is true.
INPUT is an analog input value that represents (for example, is proportional to) the monitored current.
LNOPLIM is the open-circuit fault limit. The circuit is open if INPUT is less than or equal to LNOPLIM.
LNSHLIM is the short-circuit fault limit. The circuit is shorted if INPUT is greater than or equal to
LNSHLIM.
LMONLIM is a threshold. The circuit is On, that is, OUTPUT=1, if there are no faults and INPUT is greater
than or equal to LMONLIM.
CO is the control ouput. CO follows CI. CO=true indicates that evaluation was enabled.
OUTPUT indicates whether the circuit is On. If there is no open-circuit and no short-circuit and INPUT
is greater than or equal to the threshold LMONLIM, then OUTPUT=1, indicating that the circuit is On. If
INPUT is less than the threshold LMONLIM or if there is an open-circuit or short-circuit, then OUPUT=0.
LNSHORT indicates a short-circuit fault. LNSHORT=true if INPUT is greater than or equal to LNSHLIM
and there is no open-circuit fault.
LNOPEN indicates an open-circuit fault. LNOPEN=true if INPUT is less than or equal to LNOPLIM.
Example
VAR MY_LINEMNTR : LINEMNTR ; END_VAR
VAR IS_ON, IS_SHORTED, IS_OPEN : BOOL ; END_VAR
MY_LINEMNTR
(
LNOPLIM:=819,
LMONLIM:=2000,
LNSHLIM:=4000,
INPUT:=4010
);
IS_OPEN := MY_LINEMNTR.LNOPEN; (* result is false *)
IS_SHORTED := MY_LINEMNTR.LNSHORT; (* result is true *)
IS_ON := MY_LINEMNTR.LNSHORT; (* result is false *)
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
Triconex (TCXLIB)
LN
Calculates the natural logarithm of a real number.
Syntax
y := LN( x );
Description
The LN function calculates the natural logarithm of a real number.
Example
VAR y : REAL; END_VAR
y := LN( 1.0 ); (* result is 0.0 *)
y := LN( 2.718282 ); (* result is 1.0 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the error flags
to true, and resets ENO to false. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
LOG
Calculates the common (base-ten) logarithm of a real number.
Syntax
y := LOG( x );
Description
The LOG function calculates the common (base-ten) logarithm of a real number.
Example
VAR y : REAL; END_VAR
y := LOG( 1.0 ); (* result is 0.0 *)
y := LOG( 10.0 ); (* result is 1.0 *)
y := LOG( 100.0 ); (* result is 2.0 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the error flags
to true, and resets ENO to false. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
LOOPDETR
Processes an analog input from a detector or group of detectors in an analog current loop.
Syntax
MY_LOOPDETR(IN:=b1, INPUT:=n1, INHIBIT:=b2, RSTIN:=b3, OPFLIM:=n2, SHFLIM:=n3,
TRALIM:=n4, HITRIP:=b4, RSTTIME:=t1, DELTAT:=t2);
HITRIP BOOL The loop high trip alarm flag (high = 1, low = 0).
Description
The LOOPDETR function block processes an analog input from a detector or group of detectors in an
analog current loop.
If the INHIBIT input is not set, the alarm flags that correspond to the status flags are set. The setting of
the alarms can be inhibited by setting the INHIBIT input, but the status bits are unaffected. All alarms,
once set, are latched until reset by the RSTIN input.
The LOOPDETR function also supports an output RSTCNTR to provide an external reset that is required
by some detectors. When the RSTIN input is set, the RSTOUT output is set for RSTTIME milliseconds.
OUTPUT is set if any of the fault or trip status bits are set.
The HITRIP input controls the trip alarm limit TRALIM. If the HITRIP input is 1, then the trip alarm
occurs if the detector value is above the trip alarm limit. If the HITRIP input is 0, then the trip alarm occurs
if the detector value is below the trip alarm limit.
RSTIN clears the alarms even when CI is false. RSTIN clears the alarms before executing the other
operations. If RSTIN and CI are both false, no operation occurs.
In TriStation MSW, RSTIN was both an input and an output, and LOOPDETR cleared RSTIN when the
reset counter was less than or equal to zero. In TriStation 1131, RSTIN is an input, not an output, and
LOOPDETR does not write RSTIN. You must use RSTOUT, not RSTIN, to detect a counter less than or
equal to zero. An instance of LOOPDETR can be invoked no more than once per scan.
To execute each scan, connect the DELTAT input to the DELTAT output of a Triconex (TCXLIB)()
function.
Note To schedule execution using a CSCHED or TSCHED function block, connect the DELTAT input
to the ACTUAL output of a CSCHED or TSCHED function block.
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
Library
Triconex (TCXLIB)
LREAL
An LREAL data type is 64 bits in length and has 15 decimal digits of precision. In TriStation 1131, the
LREAL data type follows the IEC-559 Standard floating-point format.
Attribute Description
Keyword/type LREAL
Size 64 bits
The smallest positive number that can be stored in The smallest positive number that can be stored in an
an LREAL variable is: LREAL variable is:
2–1022 = 2.2250738585072014E–308. 2–1074 = 4.9406564584124654E–324.
The precision changes abruptly from 17 digits to 0 The precision changes gradually from 17 digits to 1 digit
digits when the value changes from a number as the value changes from
greater than 2–1023 to a number less than 2–1023. 2–1023 to 2–1074.
The maximum relative error changes abruptly from The maximum relative error changes gradually from 2–53
2–53 to 1 when the value changes from a number to 1 as the value changes from 2–1023 to 2–1074.
greater than 2–1023 to a number less than 2–1023.
For values from 2–1075 to 2–1022, the maximum For values from 2–1075 to 2–1022, the maximum absolute
absolute error equals the value. error is a constant 2–1075.
This table shows how the precision changes as LREAL numbers approach zero.
5.0E–308 17 digits
5.0E–309 16 digits
5.0E–310 15 digits
. .
. .
. .
5.0E–322 3 digits
5.0E–323 2 digits
5.0E–324 1 digits
0.0 0 digits
Absolute error is the absolute value of x – a, where x is the exact value and a is the actual value stored.
Relative error is the absolute value of (x – a)/x, where x is the exact value and a is the actual value stored.
This table shows how gradual underflow affects absolute error and relative error as LREAL numbers
approach zero.
Application Notes
• Can be used in Safety or Control applications.
• Can be used in CEM Cause, Effect, and Intersection cells.
LREAL_TO_DINT
Converts a 64-bit long real number to a 32-bit integer.
Syntax
k := LREAL_TO_DINT(x);
Description
The LREAL_TO_DINT function converts a 64-bit long real number to a 32-bit integer. The result is
rounded to the nearest integer.
Note IEC 1131-3 requires strict data type checking. It does not permit assigning the value of a variable
directly to a variable of a different data type. When it is necessary to use variables of different
data types, an explicit conversion must be made using a data type conversion function.
Example
VAR k : DINT; x : LREAL; END_VAR;
x := -123.6;
k := LREAL_TO_DINT( x ); (* result is -124 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the error flags
to true, and resets ENO to false. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
LREAL_TO_INT
Converts a 64-bit long real number to a 16-bit integer.
Syntax
k := LREAL_TO_INT(x);
Description
The LREAL_TO_INT function converts a 64-bit long real number to a 16-bit integer. The result is rounded
to the nearest integer.
Note IEC 1131-3 requires strict data type checking. It does not permit assigning the value of a variable
directly to a variable of a different data type. When it is necessary to use variables of different
data types, an explicit conversion must be made using a data type conversion function.
Example
VAR k : DINT; x : LREAL; END_VAR;
x := -123.6;
k := LREAL_TO_INT( x ); (* result is -124 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the error flags
to true, and resets ENO to false. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
LREAL_TO_REAL
Converts a 64-bit long real number to a 32-bit real number.
Syntax
y := LREAL_TO_REAL(x);
Description
The LREAL_TO_REAL function converts a 64-bit long real number to a 32-bit real number.
Note IEC 1131-3 requires strict data type checking. It does not permit assigning the value of a variable
directly to a variable of a different data type. When it is necessary to use variables of different
data types, an explicit conversion must be made using a data type conversion function.
Example
VAR x : LREAL END_VAR;
VAR y : REAL END_VAR;
x := 6.25;
y = LREAL_TO_REAL(x); (* result is 6.25 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the error flags
to true, and resets ENO to false. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
LT
Determines if one operand is less than another operand.
Syntax
b := x < y ;
Description
The LT function is used in graphical languages to determine if one operand is less than another operand.
In Structured Text, the operator is used. The result is true if one operand is less than another operand;
otherwise the result is false.
The operands can be any of these data types:
• BOOL
• DATE
• DINT
• DT
• DWORD
• INT
• LREAL
• REAL
• STRING
• TIME
• TOD
Both operands must be the same data type. For type REAL or LREAL data types, if either operand is not
a number (NAN), the result is undefined.
Example
Structured Text
VAR b : BOOL; END_VAR
b := 10 < 11; (* result is TRUE *)
b := 11 < 11; (* result is FALSE *)
b := 11 < 10; (* result is FALSE *)
b := 'abce' < 'abcd'; (* result is FALSE *)
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Can be used in CEM Cause cells.
Library
Standard (STDLIB)
MAX
Finds the maximum of the input values.
Syntax
M := MAX( I1, I2, ..., In ) ;
Description
The MAX function returns the maximum of input values I1 ... In.
The maximum number of function inputs is 50.
The function can be used with these data types:
• BOOL
• DATE
• DINT
• DT
• DWORD
• INT
• LREAL
• REAL
• TIME
• TOD
All operands must have the same data type as the return value. For data type REAL or LREAL, if any
operand is not a number (NAN), the result is NAN.
Note STRING data types are not supported for this function.
Example
VAR y : REAL ; END_VAR
y := MAX( 10.0, 15.0, 20.0 ) ; (* result is 20.0 *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
MBCTRL
Sets time-out and retry values for a Modbus master port.
Syntax
MY_MBCTRL(CI:=b1, PORT:=n1, TIME_OUT:=n2, RETRIES:=n3 );
TIME_OUT DINT The time, in seconds, to wait for a response from the slave during an MBREAD or
MBWRITE operation.Default is 3 seconds.
See the entries for the MBREAD functions (pages 180 – 188) and MBWRITE
functions (pages 191 – 198) for error codes.
RETRIES DINT The number of retries for a failed inquiry. The default is zero.
Description
The MBCTRL function block sets time-out and retry values for a Modbus master port.
If CI = false, no operation occurs (no values are changed). If CI = true, the time-out is changed to
TIME_OUT and the number of retries is changed to RETRIES. To set the time-out or number of retries to
a value other than the default, execute the function block once with CI = true at the beginning of the first
scan.
For examples of using the MBCTRL function block, see one of these sample projects:
• Exmodbus.pt2 (Tricon controllers)
• Tdmodbus.pt2 (Trident or Tri-GP controllers)
Note See Sample Projects on page 7 for information about where to find these projects on the PC where
you installed TriStation 1131.
Example
VAR MY_MBCTRL : MBCTRL ; END_VAR
VAR bInitialized : BOOL ; END_VAR
(*
* Increase the port 1 time-out to 4 seconds
* and the number of retries to 3.
*)
MY_MBCTRL( CI:=not bInitialized, PORT:=1, TIME_OUT:=4, RETRIES:=3 ) ;
bInitialized := true ;
Runtime Errors
See the description for the STATUS output for runtime error conditions and codes.
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
• Can be used in Safety or Control applications.
• Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
Library
• Tricon (TR1LIB/TX1LIB)
• Trident/Tri-GP (TRDLIB)
MBREAD_BOOL
Reads Boolean values from a Modbus slave.
Syntax
MY_MBREAD_BOOL(ACTIVE:=b1, ALIAS:=n1, N:=n2, PORT:=n3, STATION:=n4 );
ACTIVE BOOL Requests a Modbus read operation when the internal status equals 0 or 3.
Description
The MBREAD_BOOL function block reads Boolean values from a Modbus slave.
On each scan, the sequence of Modbus function block calls must be the same, from the start of the first
program to the end of the last program. A change detected in the sequence of Modbus function blocks
causes error status 106.
Note The number of Modbus reads and writes per scan is limited.
Example
For examples of using the MBREAD_BOOL function block, see these sample projects:
• Exmodbus.pt2 (For Tricon controllers)
• Tdmodbus.pt2 (For Trident or Tri-GP controllers)
Note See Sample Projects on page 7 for information about where to find these projects on the PC where
you installed TriStation 1131.
Runtime Errors
See the description for the STATUS output for runtime error conditions and codes. Upon detection of a
runtime error condition, the function block returns the indicated values and sets the error flags to true.
For more information about error flags and runtime errors, see the CHK_ERR function block.
Application Notes
• Can be used in Safety or Control applications.
• Exactly Once: each instance should be executed exactly once per scan.
Library
• Tricon (TR1LIB/TX1LIB)
• Trident/Tri-GP (TRDLIB)
MBREAD_DINT
Reads integers from a Modbus slave.
Syntax
MY_MBREAD_DINT(ACTIVE:=b1, ALIAS:=n1, N:=n2, PORT:=n3, STATION:=n4 );
ACTIVE BOOL Requests a Modbus read operation when the internal status equals 0 or 3.
Description
The MBREAD_DINT function block reads integers from a Modbus slave. The type of the data output
(D01..D32) is DINT, which is a 32-bit integer. However, the corresponding data from the Modbus is only
16 bits. The 16-bit value from the Modbus slave is in the least significant 16 bits of the DINT, with zero in
the most significant 16 bits of the DINT.
On each scan, the sequence of Modbus function block calls must be the same, from the start of the first
program to the end of the last program. A change detected in the sequence of Modbus function blocks
causes error status 106.
Note The number of Modbus reads and writes per scan is limited.
Example
For examples of using the MBREAD_DINT function block, see these sample projects:
• Exmodbus.pt2 (For Tricon controllers)
• Tdmodbus.pt2 (For Trident or Tri-GP controllers)
Note See Sample Projects on page 7 for information about where to find these projects on the PC where
you installed TriStation 1131.
Runtime Errors
See the description for the STATUS output for runtime error conditions and codes.
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
• Can be used in Safety or Control applications.
• Exactly Once: each instance should be executed exactly once per scan.
Library
• Tricon (TR1LIB/TX1LIB)
• Trident/Tri-GP (TRDLIB)
MBREAD_REAL
Reads real numbers from a Modbus slave.
The Modbus slave should be a Tricon controller. Use MBREAD_REAL_TRD if the Modbus slave is a
Trident or Tri-GP controller, or a non-Triconex device.
Syntax
MY_MBREAD_REAL(ACTIVE:=b1, ALIAS:=n1, N:=n2, PORT:=n3, STATION:=n4, SPECIAL:=b2 );
ACTIVE BOOL Requests a Modbus read operation when the internal status equals 0 or 3.
ALIAS DINT The starting alias of the slave. If SPECIAL = false, then the starting alias is the same
as the configured alias in the slave (if the slave is a Tricon controller).
ALIAS Ranges:
• 32001–32120 = Input real, read only.
• 33001–34000 = Memory real, read only.
• 41001–42000 = Memory real, read/write.
If SPECIAL = true, then the starting alias is a special alias and must be an odd
number. If the slave is a Tricon controller, the configured alias in the slave is
mapped to two SPECIAL ALIASES.
SPECIAL ALIAS Ranges:
• 34001–34240 = Input real, read only.
• 44001–44240 = Input real, read only.
• 35001–37000 = Memory real, read only.
• 45001–47000 = Memory real, read only.
• 42001–44000 = Memory real, read/write.
SPECIAL BOOL True if special aliases are used. For more information, see Description on page 185.
Description
The MBREAD_REAL function block reads real numbers from a Modbus slave.
The Modbus slave should be a Tricon controller. Use MBWRITE_REAL_TRD if the Modbus slave is a
Trident or Tri-GP controller, or a non-Triconex device.
On each scan, the sequence of Modbus function block calls must be the same, from the start of the first
program to the end of the last program. A change detected in the sequence of Modbus function blocks
causes error status 106.
Note The number of Modbus reads and writes per scan is limited.
Example
For examples of using the MBREAD_REAL function block, see these sample projects:
• Exmodbus.pt2 (For Tricon controllers)
• Tdmodbus.pt2 (For Trident or Tri-GP controllers)
Note See Sample Projects on page 7 for information about where to find these projects on the PC where
you installed TriStation 1131.
Runtime Errors
See the description for the STATUS output for runtime error conditions and codes.
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
• Can be used in Safety or Control applications.
• Exactly Once: each instance should be executed exactly once per scan.
Library
• Tricon (TR1LIB/TX1LIB)
• Trident/Tri-GP (TRDLIB)
MBREAD_REAL_TRD
Reads real numbers from a Modbus slave.
The Modbus slave should be a Trident or Tri-GP controller, or a non-Triconex device. Use
MBREAD_REAL if the Modbus slave is a Tricon controller.
Syntax
MY_MBREAD_REAL_TRD(ACTIVE:=b1, ALIAS:=n1, N:=n2, PORT:=n3, STATION:=n4 );
ACTIVE BOOL Requests a Modbus read operation when the internal status equals 0 or 3.
Description
The MBREAD_REAL_TRD function block reads real numbers from a Modbus slave.
The Modbus slave should be a Trident or Tri-GP controller, or a non-Triconex device. Use
MBREAD_REAL if the Modbus slave is a Tricon controller.
The function block reads two 16-bit values from two consecutive aliases (ALIAS and ALIAS+1) and
concatenates the two values to form the first 32-bit REAL value (D01). The 16 most significant bits are at
ALIAS, and the 16 least significant bits are at ALIAS+1. For example, to read a REAL value from aliases
35003 and 35004, set ALIAS=35003, and N=1.
On each scan, the sequence of Modbus function block calls must be the same, from the start of the first
program to the end of the last program. A change detected in the sequence of Modbus function blocks
causes error status 106.
Note The number of Modbus reads and writes per scan is limited.
Example
For examples of using Modbus Read function blocks, see these sample projects:
• Exmodbus.pt2 (For Tricon controllers)
• Tdmodbus.pt2 (For Trident or Tri-GP controllers)
Note See Sample Projects on page 7 for information about where to find these projects on the PC where
you installed TriStation 1131.
Runtime Errors
See the description for the STATUS output for runtime error conditions and codes.
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
Can be used in Safety or Control applications.
Library
• Tricon (TR1LIB/TX1LIB)
• Trident/Tri-GP (TRDLIB)
MBWRITE_BOOL
Writes Boolean values to a Modbus slave.
Syntax
MY_MBWRITE_BOOL(ACTIVE:=b1, ALIAS:=n1, N:=n2, PORT:=n3, STATION:=n4, D01 := b2 );
ACTIVE BOOL Requests a Modbus write operation when the internal status equals 0 or 3.
Description
The MBWRITE_BOOL function block writes Boolean values to a Modbus slave.
On each scan, the sequence of Modbus function block calls must be the same, from the start of the first
program to the end of the last program. A change detected in the sequence of Modbus function blocks
causes error status 106.
Note The number of Modbus reads and writes per scan is limited.
Example
For examples of using the MBWRITE_BOOL function block, see these sample projects:
• Exmodbus.pt2 (For Tricon controllers)
• Tdmodbus.pt2 (For Trident or Tri-GP controllers)
Note See Sample Projects on page 7 for information about where to find these projects on the PC where
you installed TriStation 1131.
Runtime Errors
See the description for the STATUS output for runtime error conditions and codes.
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
• Can be used in Safety or Control applications.
• Exactly Once: each instance should be executed exactly once per scan.
Library
• Tricon (TR1LIB/TX1LIB)
• Trident/Tri-GP (TRDLIB)
MBWRITE_DINT
Writes the least significant 16 bits of a DINT to a Modbus slave.
Syntax
MY_MBWRITE_DINT(ACTIVE:=b1, ALIAS:=n1, N:=n2, PORT:=n3, STATION:=n4, D01 := n5 );
ACTIVE BOOL Requests a Modbus write operation when the internal status equals 0 or 3.
Description
The MBWRITE_DINT function block writes the least significant 16 bits of a DINT to a Modbus slave.
On each scan, the sequence of Modbus function block calls must be the same, from the start of the first
program to the end of the last program. A change detected in the sequence of Modbus function blocks
causes error status 106.
Note The number of Modbus reads and writes per scan is limited.
Example
For examples of using the MBWRITE_DINT function block, see these sample projects:
• Exmodbus.pt2 (For Tricon controllers)
• Tdmodbus.pt2 (For Trident or Tri-GP controllers)
Note See Sample Projects on page 7 for information about where to find these projects on the PC where
you installed TriStation 1131.
Runtime Errors
See the description for the STATUS output for runtime error conditions and codes.
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
• Can be used in Safety or Control applications.
• Exactly Once: each instance should be executed exactly once per scan.
Library
• Tricon (TR1LIB/TX1LIB)
• Trident/Tri-GP (TRDLIB)
MBWRITE_REAL
Allows a Triconex Modbus master controller to write real numbers to a Trident or Tri-GP Modbus slave
controller, or to a non-Triconex device.
Syntax
MY_MBWRITE_REAL(ACTIVE:=b1, ALIAS:=n1, N:=n2, PORT:=n3, STATION:=n4, SPECIAL:=b2,
D01:=x1 );
ACTIVE BOOL Requests a Modbus write operation when the internal status equals 0 or 3.
SPECIAL BOOL True if special aliases are used. For more information, see Special Alias Mapping in
Tricon Controller on page 197.
Description
The MBWRITE_REAL function block writes real numbers to a Modbus slave.
The Modbus slave should be a Tricon controller. Use MBWRITE_REAL_TRD if the Modbus slave is a
Trident or Tri-GP controller, or a non-Triconex device.
On each scan, the sequence of Modbus function block calls must be the same, from the start of the first
program to the end of the last program. A change detected in the sequence of Modbus function blocks
causes error status 106.
Note The number of Modbus reads and writes per scan is limited.
bits are at ALIAS+1. The starting ALIAS must be odd. For example, to write a real value to SPECIAL
ALIASES 42003 and 42004, set SPECIAL=true, ALIAS=42003, and N=1.
Example
For examples of using the MBWRITE_REAL function block, see these sample projects:
• Exmodbus.pt2 (For Tricon controllers)
• Tdmodbus.pt2 (For Trident or Tri-GP controllers)
Note See Sample Projects on page 7 for information about where to find these projects on the PC where
you installed TriStation 1131.
Runtime Errors
See the description for the STATUS output for runtime error conditions and codes.
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
• Can be used in Safety or Control applications.
• Exactly Once: each instance should be executed exactly once per scan.
Library
• Tricon (TR1LIB/TX1LIB)
• Trident/Tri-GP (TRDLIB)
MBWRITE_REAL_TRD
Writes real numbers to a Modbus slave.
The Modbus slave should be a Trident or Tri-GP controller, or a non-Triconex device. Use
MBWRITE_REAL if the Modbus slave is a Tricon controller.
Syntax
MY_MBWRITE_REAL_TRD(ACTIVE:=b1, ALIAS:=n1, N:=n2, PORT:=n3, STATION:=n4, D01:=x1 );
ACTIVE BOOL Requests a Modbus write operation when the internal status equals 0 or 3.
Description
The MBWRITE_REAL_TRD function block writes real numbers to a Modbus slave.
The Modbus slave should be a Trident or Tri-GP controller, or a non-Triconex device. Use
MBWRITE_REAL if the Modbus slave is a Tricon controller.
The function block splits the first 32-bit REAL value (D01) into two 16-bit values and writes the two 16-
bit values to two consecutive aliases (ALIAS and ALIAS+1). The 16 most significant bits are at ALIAS,
and the 16 least significant bits are at ALIAS+1. For example, to write a REAL value to aliases 42003 and
42004, set ALIAS=42003 and N=1.
On each scan, the sequence of Modbus function block calls must be the same, from the start of the first
program to the end of the last program. A change detected in the sequence of Modbus function blocks
causes error status 106.
Note The number of Modbus reads and writes per scan is limited.
Example
For examples of using Modbus Write function blocks, see these sample projects:
• Exmodbus.pt2 (For Tricon controllers)
• Tdmodbus.pt2 (For Trident or Tri-GP controllers)
Note See Sample Projects on page 7 for information about where to find these projects on the PC where
you installed TriStation 1131.
Runtime Errors
See the description for the STATUS output for runtime error conditions and codes.
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
Can be used in Safety or Control applications.
Library
• Tricon (TR1LIB/TX1LIB)
• Trident/Tri-GP (TRDLIB)
MEDSEL
Returns the median of the input numbers.
Syntax
y := MEDSEL( x1, x2, ..., xn ) ;
Description
The MEDSEL function returns the median of the input numbers. If the number of inputs is odd, the
median is the middle number. If the number of inputs is even, the median is the average of the two middle
numbers, which means half the numbers are greater than the median and half the numbers are smaller.
The maximum number of function inputs is 50.
All inputs must have the same data type as the return value. If any operand is not a number (NAN), the
result is NAN.
Example
VAR y : REAL ; END_VAR
y := MEDSEL( 15.0, 10.0, 20.0 ) ; (* result is 15.0 *)
y := MEDSEL( 15.0, 10.0, 20.0, 30.0 ) ; (* result is 17.5 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the error flags
to true, and resets ENO to false. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
MIN
Find the minimum of the input values.
Syntax
M := MIN( I1, I2, ..., In ) ;
Description
The MIN function returns the minimum of input values I1 ... In.
The maximum number of function inputs is 50.
The function can be used with these data types:
• BOOL
• DATE
• DINT
• DT
• DWORD
• INT
• LREAL
• REAL
• TIME
• TOD
All operands must have the same data type as the return value. For data type REAL or LREAL, if any
operand is not a number (NAN), the result is NAN.
Note STRING data types are not supported for this function.
Example
VAR m : DINT ; END_VAR
m := MIN( 3, 1, 2 ); (* Result is 1 *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
MINUS_INFINITY_LREAL
Returns minus infinity.
Syntax
y := MINUS_INFINITY_LREAL();
NA NA No inputs.
Description
The MINUS_INFINITY_LREAL function returns minus infinity.
Example
VAR y : LREAL ; END_VAR;
y := MINUS_INFINITY_LREAL(); (* result is minus infinity *)
(* Note: on the controller panel, the value shown is -1.#INF *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
MINUS_INFINITY_REAL
Returns minus infinity.
Syntax
y := MINUS_INFINITY_REAL();
NA NA No inputs.
Description
The MINUS_INFINITY_REAL function returns minus infinity.
Example
VAR y : REAL ; END_VAR;
y := MINUS_INFINITY_REAL(); (* result is minus infinity *)
(* Note: on the controller panel, the value shown is -1.#INF *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
MOD
Divides two integers and returns the remainder.
Syntax
i := j MOD k ;
Description
The MOD (modulus) function divides one integer by another and returns the remainder.
Both operands must have the same data type as the return value.
Example
VAR i : DINT ; END_VAR
i := 5 MOD 3 ; (* result is 2 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the error flags
to true, and resets ENO to false. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
MOVE
Assigns an input value to an output value.
Syntax
OUT := IN ;
Description
In a graphical language, the MOVE function assigns an input value to an output value.
In Structured Text, use an assignment statement instead of the MOVE function.
Example
VAR OUT : DINT ; END_VAR
OUT := 3 ; (* move 3 to variable OUT *)
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Can be used in CEM Cause, Effect, and Intersection cells.
Library
Standard (STDLIB)
MUL
Multiplies two or more numbers, or multiplies a time by a number.
Syntax
P := I1 * I2 * ... * In ;
T2 := T1 * N ;
N ANY_NUM A number.
TIME Product.
Description
In a graphical language, the MUL function multiplies two or more numbers, up to a maximum of 50, or
multiplies a time by a number.
In Structured Text, the multiply operator * multiplies two numbers or multiplies a time by a number.
The product of two or more numbers is a number. The data types of all the numbers must be the same.
The product of a time and a number is a time. The number can be any numeric data type.
Example
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the error flags
to true, and resets ENO to false. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
MUX
Selects a value from multiple inputs.
Syntax
v := MUX( K, I0, I1, ..., In-1 ) ;
Description
The MUX function selects a value from multiple inputs, depending on an input selector (K).
The maximum number of data values is 49.
Normally, the value of K should be from 0 to n-1, where n is the number of data inputs. In this case, the
function returns IK. If K is less than 0, the function returns I0. If K is greater than n-1, the function returns
In-1.
The data values can be any data type, but all data values must have the same data type as the return value.
Example
VAR v : REAL ; END_VAR
v := MUX( 2, 0.0, 1.0, 2.0, 3.0 ) (* result is 2.0 *)
Runtime Errors
If K is greater than the index number of the last input. Last input In-1 BADPARAM, ERROR
Upon detection of a runtime error condition, the function returns the indicated value, sets the error flags
to true, and resets ENO to false. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
NAN_LREAL
Returns not a number (NAN).
Syntax
y := NAN_LREAL();
NA NA No inputs.
Description
The NAN_LREAL function returns not a number (NAN).
Example
VAR y : LREAL ; END_VAR;
y := NAN_LREAL(); (* result is not a number NAN *)
(* Note: on the controller panel, the value shown is -1.#IND *)
(* IND is an abbreviation for indefinite *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
NAN_REAL
Returns not a number (NAN).
Syntax
y := NAN_REAL();
NA NA No inputs.
Description
The NAN_REAL function returns not a number (NAN).
Example
VAR y : REAL ; END_VAR;
y := NAN_REAL(); (* result is not a number NAN *)
(* Note: on the controller panel, the value shown is -1.#IND *)
(* IND is an abbreviation for indefinite *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
NE
Compares two operands for inequality.
Syntax
b := x <> y;
Description
The NE function is used in graphical languages to determine if two operands are not equal. In Structured
Text, the <> operator is used to determine inequality. The result is true if the operands are not equal;
otherwise the result is false.
The operands can be any data type, but both operands must be the same data type. For type REAL or
LREAL, if either operand is not a number (NAN), the result is undefined.
Example
Structured Text
VAR b : BOOL; END_VAR
b := 10 <> 11; (* result is TRUE *)
b := 11 <> 11; (* result is FALSE *)
b := 'abcd' <> 'abcd'; (* result is FALSE *)
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Can be used in CEM Cause cells.
Library
Standard (STDLIB)
NOT
Performs a logical negation of a Boolean operand or a bitwise complement of a bit-string.
Syntax
v := not b ;
b ANY_BIT Operand
ANY_BIT NOT b
Description
In graphical languages, the NOT function returns the logical negation of a Boolean operand or the bitwise
complement of a bit-string. In Structured Text, the NOT operator is used instead of the NOT function.
If the operand type is BOOL, then the result is true if the operand if false, and the result is false if the
operand is true.
b NOT b
FALSE TRUE
TRUE FALSE
If the operand type is DWORD, then each bit of the DWORD is inverted. This means if the operand bit is
a 0, then the corresponding result bit is 1, and if the operand bit is a 1, then the corresponding result bit
is a 0.
Bit Complement
0 1
1 0
The operand and the return value are the same data type, that is, they are both BOOL or both DWORD.
Example
Note that on the Controller Panel, you will see the example values in hex. The value of operand w1 is
16#AAAAAAAA, and the value of result w is 16#55555555.
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Can be used in CEM Cause, Effect, and Intersection cells.
Library
Standard (STDLIB)
NUMBITS
Counts the number of Boolean parameters with value true.
Syntax
n := NUMBITS(b1, b2, ... , bn) ;
Description
The NUMBITS function counts the number of parameters with value equal to true.
The maximum number of function inputs is 50.
Example
n := NUMBITS(TRUE, FALSE, TRUE, TRUE); (* result is 3 *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
NUMBITS_DWORD
Counts the number of 1-bits in a DWORD.
Syntax
n := NUMBITS_DWORD( w ) ;
w DWORD A bit-string
Description
The NUMBITS_DWORD function counts the number of 1-bits in a DWORD.
Example
VAR n : DINT ; w : DWORD ; END_VAR
w := 2#00000000000000000000000011111111 ;
n := NUMBITS_DWORD( w ); (* result is 8 *)
Note that on the Controller Panel, you will see the example operand w displayed in hex: 16#000000FF.
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Triconex (TCXLIB)
OR
Performs a logical OR of two or more Boolean operands or a bitwise OR of two or more bit-strings.
Syntax
b := b1 OR b2 OR ... OR bn ;
ANY_BIT b1 OR b2 OR ... OR bn
Description
In graphical languages, the OR function returns the logical OR of Boolean operands or the bitwise OR of
bit-strings. In Structured Text, the OR operator is used instead of the OR function.
The maximum number of function inputs is 50.
All operands must be the same type as the return value either all BOOL or all DWORD.
If the operand type is BOOL, then the result is true if any operand is true. The result is false if all operands
are false.
b1 b2 b1 OR b2
If the operand type is DWORD, then the result is the bitwise OR of all the operands. In other words, the
value in each bit position of the result is the inclusive OR of all the values in the same bit position.
w1 w2 w1 OR w2
Example
Note that on the Controller Panel, you will see the example values in hex. The hex values of the operands
are w1=16#00000001, w2=16#00000002, w3=16#00000004, and the hex values of the results are
16#00000007 and 16#00000005.
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Can be used in CEM Cause cells.
Library
Standard (STDLIB)
OVDDISABLE
Disables output voter diagnostics (OVD) for a selected Digital Output (DO) Module.
Syntax
MY_OVDDISABLE( CI:=b1, CHASSIS:=n1, SLOT:=n2 ) ;
Description
The OVDDISABLE function block disables output voter diagnostics (OVD) for the Digital Output (DO)
Module selected by CHASSIS and SLOT.
Example
VAR MY_OVDDISABLE : OVDDISABLE ; END_VAR
(* Disable OVD for the module in chassis 9 slot 5. *)
MY_OVDDISABLE( CI:=true, CHASSIS:=9, SLOT:=5 ) ;
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
• Can be used in Safety or Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
Tricon (TR1LIB/TX1LIB)
OVDENABLE
Enables output voter diagnostics (OVD) for a selected Digital Output (DO) Module.
Syntax
MY_OVDENABLE( CI:=b1, CHASSIS:=n1, SLOT:=n2 ) ;
Description
The OVDENABLE function block disables output voter diagnostics (OVD) for the Digital Output (DO)
Module selected by CHASSIS and SLOT.
Example
VAR MY_OVDENABLE : OVDENABLE ; END_VAR
(* Enable OVD for the module in chassis 9 slot 5. *)
MY_OVDENABLE( CI:=true, CHASSIS:=9, SLOT:=5 ) ;
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
• Can be used in Safety or Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
Tricon (TR1LIB/TX1LIB)
PACK16
Packs 16 bits into a DWORD.
Syntax
w := PACK16(IN01, IN02, ... , IN16) ;
Description
The PACK16 function packs 16 bits into a DWORD. The 16 bits are packed into the least significant 16 bits
of a 32-bit DWORD. The values for the 16 bits are given in 16 Boolean parameters. The first parameter,
IN01, is packed into the least significant bit of the result.
Example
w := PACK16(0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0);
(* result is 2#00000000000000000000000000111100 *)
Note that the result displayed on the controller panel is in hex, i.e., 16#0000003C.
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Triconex (TCXLIB)
PACK32
Packs 32 bits into a DWORD.
Syntax
w := PACK32(IN01, IN02, ... , IN32) ;
Description
The PACK32 function packs 32 bits into a DWORD. The values for the 32 bits are given in 32 Boolean
parameters. The first parameter, IN01, is packed into the least significant bit of the result.
Example
w := PACK32(0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0) ;
(* result is 2#00000000000000000000000000111100 *)
Note that the result displayed on the controller panel is in hex, i.e., 16#0000003C.
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Triconex (TCXLIB)
PAGE_EJECT
Ejects paper (feeds the form) to the top of the next page.
Syntax
MY_PAGE_EJECT( CI:=b1, PRINTER:=n1 ) ;
Description
The PAGE_EJECT function block ejects paper (feeds the form) to the top of the next page.
CI is the control input. CI enables evaluation. If CI is true, then perform the print operation. If CI is false,
then do nothing. The default initial value of CI is true.
PRINTER is a number that identifies the printer or print server. The valid range is different for different
controllers. For the Tricon controller, all values are valid—however, the function block prints to port 5 if
PRINTER=5, but prints to port 10 if PRINTER is any other number. For the Trident or Tri-GP controller,
the valid range is 1 through 10.
CO is the control ouput. CO follows CI if no runtime error is detected. CO=true indicates that the function
block was enabled and executed successfully, with no runtime error. CO=false and CI=true indicates a
runtime error was detected. CO=false and CI=false indicates no operation.
Example
VAR MY_PAGE_EJECT : PAGE_EJECT ; END_VAR
(* Eject a page on printer 5. *)
MY_PAGE_EJECT( PRINTER:=5 ) ;
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
If the PRINTER parameter is invalid, then the function block aborts the print operation.
Note that this function block simply adds the print operation to a buffer and does not check the status of
the printer or print server. To read printer status (like printer ready, buffer overflow, bytes free, bytes
used), see SYS_CM_STATUS or TR_PORT_STATUS.
Application Notes
• Can be used in Safety or Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
• Tricon (TR1LIB/TX1LIB)
• Trident/Tri-GP (TRDLIB)
PERDEV
Computes percent deviation.
Syntax
b := PERDEV( NAME1, NAME2, SPAN, FRACTION );
Description
The PERDEV function computes percent deviation. This function is used to measure a signal as a ratio,
regardless of the engineering units used. PERDEV computes the difference between the NAME1 and
NAME2 inputs, divides this difference by the SPAN, and then takes the absolute value of the result.
The result is a floating-point number between 0.0 and 1.0, which is then compared to the reference input
FRACTION. If the measured ratio is less than or equal to the reference fraction, the return value is true.
Otherwise, the return value is false.
Example
VAR b: BOOL ; END_VAR
b := PERDEV( 10.0, 30.0, 100.0, 0.5 ) ; (* result is TRUE *)
b := PERDEV( 10.0, 80.0, 100.0, 0.5 ) ; (* result is FALSE *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Triconex (TCXLIB)
PID
Performs the proportional integral derivative (PID) algorithm.
Syntax
MY_PID( SP:=x1, CV:=x2, CI:=b1, PV:=x3, AUTO_MAN:=b2, RATE:=x4, RESET:=x5, KPB:=x6,
MAXCV:=x7, MINCV:=x8, MAXRATE:=x9, DELTAT:=t1 ) ;
Description
The PID function block performs the proportional integral derivative (PID) algorithm. PID provides for
anti-reset windup, bumpless transfer, and limitation of the maximum rate of change for the control
variable. Bumpless transfer is handled in the setpoint-tracking form. Neither the SP nor the PV argument
is limited in its dynamic range.
To impose limitations, use the LIMIT function prior to calling PID. The control variable CV is typically
scaled to range from 0 to 100 percent. KPB represents the proportional gain. For direct-acting control, PID
is programmed for KPB to be positive (that is to say, increasing the control variable causes an increasing
process variable).
For reverse-acting control (increasing the control variable causes a decreasing process variable), KPB
should be negative. You should determine the value of KPB by making control changes and observing
the effect on the process variable being controlled. For example, if a 5 percent change in the control
variable causes a 150-unit change in the process variable, then the process gain is 150/5 or 30. KPB is
typically set near the reciprocal of the process gain.
The integral time constant RESET adjusts the integral action of the PID. If RESET is increased, the integral
action is decreased and the response is slower. If RESET is decreased, the integral action is increased and
the response is faster. To avoid excessive integral action, RESET should be set initially to a few seconds.
The derivative time constant RATE is used to provide damping of the control loop response. As RATE is
increased, the derivative action is increased and a damping action is applied to the response. Typically
RATE is set to a value of one second or less; in many cases, it can be set to zero.
Note To schedule execution using a CSCHED or TSCHED function block, connect the DELTAT input
to the ACTUAL output of a CSCHED or TSCHED function block, and connect the CI input to the
Q output.
Runtime Errors
None.
Application Notes
• Can be used in Control applications.
• Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
Library
Triconex (TCXLIB)
PID_R
Performs the proportional integral derivative (PID) algorithm.
Syntax
MY_PID_R( SPIN:=x1, CVIN:=x2, CI:=b1, PV:=x3, AUTO_MAN:=b2, RATE:=x4, RESET:=x5,
KPB:=x6, MAXCV:=x7, MINCV:=x8, MAXRATE:=x9, DLT:=x10 ) ;
x1 := MY_PID_R.SPOUT ;
x2 := MY_PID_R.CVOUT ;
Description
The PID_R function block performs the proportional integral derivative (PID) algorithm. PID provides
for anti-reset windup, bumpless transfer, and limitation of the maximum rate of change for the control
variable. Bumpless transfer is handled in the setpoint-tracking form.
Neither the SP nor the PV argument is limited in its dynamic range. To impose limitations, use the LIMIT
function prior to calling PID. The control variable CV is typically scaled to range from 0 to 100 percent.
KPB represents the proportional gain. For direct-acting control, PID is programmed for KPB to be positive
(that is, increasing the control variable causes an increasing process variable).
For reverse-acting control (increasing the control variable causes a decreasing process variable), KPB
should be negative. You should determine the value of KPB by making control changes and observing
the effect on the process variable being controlled. For example, if a 5 percent change in the control
variable causes a 150-unit change in the process variable, then the process gain is 150/5 or 30. KPB is
typically set near the reciprocal of the process gain.
The integral time constant RESET adjusts the integral action of the PID. If RESET is increased, the integral
action is decreased and the response is slower. If RESET is decreased, the integral action is increased and
the response is faster. To avoid excessive integral action, initially you should set RESET to a few seconds.
Rate Parameter
The derivative time constant RATE is used to provide damping of the control loop response. As RATE is
increased, the derivative action is increased and a damping action is applied to the response. Typically
RATE is set to a value of one second or less; in many cases, it can be set to zero.
Runtime Errors
None.
Application Notes
• Can be used in Control applications.
• Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
Library
Triconex (TCXLIB)
POLY4
Returns the value of a polynomial with four coefficients.
Syntax
y := POLY4( X, C0, C1, C2, C3 ) ;
C0 LREAL Coefficient 0.
C1 LREAL Coefficient 1.
C2 LREAL Coefficient 2.
C3 LREAL Coefficient 3.
Description
The POLY4 function returns the value of a polynomial with four coefficients (C0 + C1*X + C2*X*X +
C3*X*X*X, where X is the variable and C0, C1, C2, C3 are the coefficients).
Example
VAR x, y, c0, c1, c2, c3 : LREAL ; END_VAR
x := 10.0 ;
c0 := 1.0 ;
c1 := 2.0 ;
c2 := 3.0 ;
c3 := 4.0 ;
y := POLY4(x, c0, c1, c2, c3) ; (* result is 4321.0 );
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Triconex (TCXLIB)
POLY5
Returns the value of a polynomial with five coefficients.
Syntax
y := POLY4( X, C0, C1, C2, C3, C4 ) ;
C0 LREAL Coefficient 0.
C1 LREAL Coefficient 1.
C2 LREAL Coefficient 2.
C3 LREAL Coefficient 3.
C4 LREAL Coefficient 4.
Description
The POLY5 function returns the value of a polynomial with five coefficients (C0 + C1*X + C2*X*X +
C3*X*X*X X + C4*X*X*X*X, where X is the variable and C0, C1, C2, C3, C4 are the coefficients).
Example
VAR x, y, c0, c1, c2, c3, c4 : LREAL ; END_VAR
x := 10.0 ;
c0 := 1.0 ;
c1 := 2.0 ;
c2 := 3.0 ;
c3 := 4.0 ;
c4 := 5.0 ;
y := POLY5(x, c0, c1, c2, c3, c4) ; (* result is 54321.0 );
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Triconex (TCXLIB)
PRINT_BOOL
Prints a three-character field containing either Off or On.
Syntax
MY_PRINT_BOOL( CI:=b1, PRINTER:=n1, IN:=b2 ) ;
Description
The PRINT_BOOL function block prints a three-character field containing either Off or On. (On is left-
justified in the field.) Prints Off if IN is false or 0. Prints On if IN is true or 1. When printed, each argument
is preceded by a blank space.
CI is the control input. CI enables evaluation. If CI is true, then perform the print operation. If CI is false,
then do nothing. The default initial value of CI is true.
PRINTER is a number that identifies the printer or print server. The valid range is different for different
controllers.
• For the Tricon controller, all values are valid, however, the function block prints to port 10 if
PRINTER=10, but prints to port 5 if PRINTER is any other number.
• For the Trident v1.x controller, the valid range is 1 through 10.
• For the Trident v2.x or Tri-GP controller, the PRINTER parameter must be 5 or 10. The Left and
Right CM ports cannot have the same PRINTER parameter.
IN is the Boolean value to be printed. If IN=false, then print "Off". If IN=true, then print "On ".
CO is the control ouput. CO follows CI if no runtime error is detected. CO=true indicates that the function
block was enabled and executed successfully, with no runtime error. CO=false and CI=true indicates a
runtime error was detected. CO=false and CI=false indicates no operation.
Example
VAR MY_PRINT_BOOL : PRINT_BOOL ; END_VAR
(* Print "Off" on printer 5. *)
MY_PRINT_BOOL( PRINTER:=5, IN:=FALSE ) ;
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
If the PRINTER parameter is invalid, then the function block aborts the print operation.
Note that this function block simply adds the print operation to a buffer and does not check the status of
the printer or print server. To read printer status (like printer ready, buffer overflow, bytes free, bytes
used), see SYS_CM_STATUS or TR_PORT_STATUS.
Application Notes
• Can be used in Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
• Tricon (TR1LIB/TX1LIB)
• Trident/Tri-GP (TRDLIB)
PRINT_CDT
Prints the current date and time of day.
Syntax
MY_PRINT_CDT( CI:=b1, PRINTER:=n1 ) ;
Description
The PRINT_CDT function block prints the current date and time of day in this format:
mm/dd/yy hh:mm:ss.msec
When printed, each argument is preceded by a blank space.
CI is the control input. CI enables evaluation. If CI is true, then perform the print operation. If CI is false,
then do nothing. The default initial value of CI is true.
PRINTER is a number that identifies the printer or print server. The valid range is different for different
controllers.
• For the Tricon controller, all values are valid, however, the function block prints to port 10 if
PRINTER=10, but prints to port 5 if PRINTER is any other number.
• For the Trident v1.x controller, the valid range is 1 through 10.
• For the Trident v2.x or Tri-GP controller, the PRINTER parameter must be 5 or 10. The Left and
Right CM ports cannot have the same PRINTER parameter.
CO is the control ouput. CO follows CI if no runtime error is detected. CO=true indicates that the function
block was enabled and executed successfully, with no runtime error. CO=false and CI=true indicates a
runtime error was detected. CO=false and CI=false indicates no operation.
Example
VAR MY_PRINT_CDT : PRINT_CDT ; END_VAR
(* Print current date and time on printer 5. *)
MY_PRINT_CDT( PRINTER:=5 ) ;
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
If the PRINTER parameter is invalid, then the function block aborts the print operation.
Note that this function block simply adds the print operation to a buffer and does not check the status of
the printer or print server. To read printer status (like printer ready, buffer overflow, bytes free, bytes
used), see SYS_CM_STATUS or TR_PORT_STATUS.
Application Notes
• Can be used in Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
• Tricon (TR1LIB/TX1LIB)
• Trident/Tri-GP (TRDLIB)
PRINT_CRLF
Prints a new line (a carriage return and line feed).
Syntax
MY_PRINT_CRLF( CI:=b1, PRINTER:=n1 ) ;
Description
The PRINT_CRLF function block prints a new line (a carriage return and line feed).
CI is the control input. CI enables evaluation. If CI is true, then perform the print operation. If CI is false,
then do nothing. The default initial value of CI is true.
PRINTER is a number that identifies the printer or print server. The valid range is different for different
controllers.
• For the Tricon controller, all values are valid, however, the function block prints to port 10 if
PRINTER=10, but prints to port 5 if PRINTER is any other number.
• For the Trident v1.x controller, the valid range is 1 through 10.
• For the Trident v2.x or Tri-GP controller, the PRINTER parameter must be 5 or 10. The Left and
Right CM ports cannot have the same PRINTER parameter.
CO is the control ouput. CO follows CI if no runtime error is detected. CO=true indicates that the function
block was enabled and executed successfully, with no runtime error. CO=false and CI=true indicates a
runtime error was detected. CO=false and CI=false indicates no operation.
Example
VAR MY_PRINT_CRLF : PRINT_CRLF ; END_VAR
(* Print a carriage return and line feed on printer 5. *)
MY_PRINT_CRLF( PRINTER:=5 ) ;
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
If the PRINTER parameter is invalid, then the function block aborts the print operation.
Note that this function block simply adds the print operation to a buffer and does not check the status of
the printer or print server. To read printer status (like printer ready, buffer overflow, bytes free, bytes
used), see SYS_CM_STATUS or TR_PORT_STATUS.
Application Notes
• Can be used in Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
• Tricon (TR1LIB/TX1LIB)
• Trident/Tri-GP (TRDLIB)
PRINT_CTOD
Prints the current time of day.
Syntax
MY_PRINT_CTOD( CI:=b1, PRINTER:=n1 ) ;
Description
The PRINT_CTOD function block prints the current time of day in this format:
hh:mm:ss.msec
When printed, each argument is preceded by a blank space.
CI is the control input. CI enables evaluation. If CI is true, then perform the print operation. If CI is false,
then do nothing. The default initial value of CI is true.
PRINTER is a number that identifies the printer or print server. The valid range is different for different
controllers.
• For the Tricon controller, all values are valid, however, the function block prints to port 10 if
PRINTER=10, but prints to port 5 if PRINTER is any other number.
• For the Trident v1.x controller, the valid range is 1 through 10.
• For the Trident v2.x or Tri-GP controller, the PRINTER parameter must be 5 or 10. The Left and
Right CM ports cannot have the same PRINTER parameter.
CO is the control ouput. CO follows CI if no runtime error is detected. CO=true indicates that the function
block was enabled and executed successfully, with no runtime error. CO=false and CI=true indicates a
runtime error was detected. CO=false and CI=false indicates no operation.
Example
VAR MY_PRINT_CTOD : PRINT_CTOD ; END_VAR
(* Print the current time of day on printer 5. *)
MY_PRINT_CTOD( PRINTER:=5 ) ;
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
If the PRINTER parameter is invalid, then the function block aborts the print operation.
Note that this function block simply adds the print operation to a buffer and does not check the status of
the printer or print server. To read printer status (like printer ready, buffer overflow, bytes free, bytes
used), see SYS_CM_STATUS or TR_PORT_STATUS.
Application Notes
• Can be used in Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
• Tricon (TR1LIB/TX1LIB)
• Trident/Tri-GP (TRDLIB)
PRINT_DINT
Prints a double integer right-justified in an eight-character field.
Syntax
MY_PRINT_DINT( CI:=b1, PRINTER:=n1, IN:=n2 ) ;
Description
The PRINT_DINT function block prints a double integer right-justified in an eight-character field. If the
value is negative, the minus (–) sign immediately precedes the value. When printed, each argument is
preceded by a blank space.
CI is the control input. CI enables evaluation. If CI is true, then perform the print operation. If CI is false,
then do nothing. The default initial value of CI is true.
PRINTER is a number that identifies the printer or print server. The valid range is different for different
controllers.
• For the Tricon controller, all values are valid, however, the function block prints to port 10 if
PRINTER=10, but prints to port 5 if PRINTER is any other number.
• For the Trident v1.x controller, the valid range is 1 through 10.
• For the Trident v2.x or Tri-GP controller, the PRINTER parameter must be 5 or 10. The Left and
Right CM ports cannot have the same PRINTER parameter.
IN represents the integer value to be printed, right-justified in an eight-character field. If the value is
negative, the minus (–) sign immediately precedes the value. When printed, each argument is preceded
by a blank space.
CO is the control ouput. CO follows CI if no runtime error is detected. CO=true indicates that the function
block was enabled and executed successfully, with no runtime error. CO=false and CI=true indicates a
runtime error was detected. CO=false and CI=false indicates no operation.
Example
VAR MY_PRINT_DINT : PRINT_DINT ; END_VAR
(* Print " 999" on printer 5. *)
MY_PRINT_DINT( PRINTER:=5, IN:=999 ) ;
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
If the PRINTER parameter is invalid, then the function block aborts the print operation.
Note that this function block simply adds the print operation to a buffer and does not check the status of
the printer or print server. To read printer status (like printer ready, buffer overflow, bytes free, bytes
used), see SYS_CM_STATUS or TR_PORT_STATUS.
Application Notes
• Can be used in Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
• Tricon (TR1LIB/TX1LIB)
• Trident/Tri-GP (TRDLIB)
PRINT_REAL
Prints a real (floating-point) value right justified in an eight-character field.
Syntax
MY_PRINT_REAL( CI:=b1, PRINTER:=n1, IN:=x1, PRECISION:=n2 ) ;
Description
The PRINT_REAL function block prints a real (floating-point) value right justified in an eight-character
field. If the value is negative, a minus (–) sign immediately precedes the first printed digit. The
PRECISION argument specifies the number of decimal places. The default is 4 decimal places.
If a real number does not fit in the eight-character field, then significance to the right of the decimal point
is reduced. If this fails, then the number is printed in scientific notation. When printed, each argument is
preceded by a blank space.
CI is the control input. CI enables evaluation. If CI is true, then perform the print operation. If CI is false,
then do nothing. The default initial value of CI is true.
PRINTER is a number that identifies the printer or print server. The valid range is different for different
controllers.
• For the Tricon controller, all values are valid, however, the function block prints to port 10 if
PRINTER=10, but prints to port 5 if PRINTER is any other number.
• For the Trident v1.x controller, the valid range is 1 through 10.
• For the Trident v2.x or Tri-GP controller, the PRINTER parameter must be 5 or 10. The Left and
Right CM ports cannot have the same PRINTER parameter.
IN represents the real number to be printed, right-justified in an eight-character field. If the number is
negative, a minus (–) sign immediately precedes the first printed digit. The PRECISION argument
specifies the number of decimal places. The default is 4 decimal places.
CO is the control ouput. CO follows CI if no runtime error is detected. CO=true indicates that the function
block was enabled and executed successfully, with no runtime error. CO=false and CI=true indicates a
runtime error was detected. CO=false and CI=false indicates no operation.
Example
VAR MY_PRINT_REAL : PRINT_REAL ; END_VAR
(* Print " 1.0625" on printer 5. *)
MY_PRINT_REAL( PRINTER:=5, IN:=1.0625 ) ;
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
If the PRINTER parameter is invalid, then the function block aborts the print operation.
Note that this function block simply adds the print operation to a buffer and does not check the status of
the printer or print server. To read printer status (like printer ready, buffer overflow, bytes free, bytes
used), see SYS_CM_STATUS or TR_PORT_STATUS.
Application Notes
• Can be used in Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
• Tricon (TR1LIB/TX1LIB)
• Trident/Tri-GP (TRDLIB)
PRINT_STRING
Prints a string of text (not including quotation marks).
Syntax
MY_PRINT_STRING( CI:=b1, PRINTER:=n1, IN:=s1 ) ;
Description
The PRINT_STRING function block prints a string of text (not including quotation marks).
CI is the control input. CI enables evaluation. If CI is true, then perform the print operation. If CI is false,
then do nothing. The default initial value of CI is true.
PRINTER is a number that identifies the printer or print server. The valid range is different for different
controllers.
• For the Tricon controller, all values are valid, however, the function block prints to port 10 if
PRINTER=10, but prints to port 5 if PRINTER is any other number.
• For the Trident v1.x controller, the valid range is 1 through 10.
• For the Trident v2.x or Tri-GP controller, the PRINTER parameter must be 5 or 10. The Left and
Right CM ports cannot have the same PRINTER parameter.
IN represents the string to be printed.
CO is the control ouput. CO follows CI if no runtime error is detected. CO=true indicates that the function
block was enabled and executed successfully, with no runtime error. CO=false and CI=true indicates a
runtime error was detected. CO=false and CI=false indicates no operation.
Example
VAR MY_PRINT_STRING : PRINT_STRING ; END_VAR
(* Print "Now is the time." on printer 5. *)
MY_PRINT_BOOL( PRINTER:=5, IN:=’Now is the time.’ ) ;
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
If the PRINTER parameter is invalid, then the function block aborts the print operation.
Note that this function block simply adds the print operation to a buffer and does not check the status of
the printer or print server. To read printer status (like printer ready, buffer overflow, bytes free, bytes
used), see SYS_CM_STATUS or TR_PORT_STATUS.
Application Notes
• Can be used in Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
• Tricon (TR1LIB/TX1LIB)
• Trident/Tri-GP (TRDLIB)
PRNTR_FLUSH
Clears the print buffer for the specified printer without printing the contents of the buffer.
Syntax
MY_PRNTR_FLUSH( CI:=b1, PRINTER:=n1 ) ;
Description
The PRNTR_FLUSH function block clears the print buffer for the specified printer without printing the
contents of the buffer.
CI is the control input. CI enables evaluation. If CI is true, then perform the print operation. If CI is false,
then do nothing. The default initial value of CI is true.
PRINTER is a number that identifies the printer or print server. The valid range is different for different
controllers.
• For the Tricon controller, all values are valid, however, the function block prints to port 10 if
PRINTER=10, but prints to port 5 if PRINTER is any other number.
• For the Trident v1.x controller, the valid range is 1 through 10.
• For the Trident v2.x or Tri-GP controller, the PRINTER parameter must be 5 or 10. The Left and
Right CM ports cannot have the same PRINTER parameter.
CO is the control ouput. CO follows CI if no runtime error is detected. CO=true indicates that the function
block was enabled and executed successfully, with no runtime error. CO=false and CI=true indicates a
runtime error was detected. CO=false and CI=false indicates no operation.
Example
VAR MY_PRNTR_FLUSH : PRNTR_FLUSH ; END_VAR
(* Clear the print buffer for printer 5. *)
MY_PRNTR_FLUSH( PRINTER:=5 ) ;
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
If the PRINTER parameter is invalid, then the function block aborts the print operation.
Note that this function block simply adds the print operation to a buffer and does not check the status of
the printer or print server. To read printer status (like printer ready, buffer overflow, bytes free, bytes
used), see SYS_CM_STATUS or TR_PORT_STATUS.
Application Notes
• Can be used in Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
• Tricon (TR1LIB/TX1LIB)
• Trident/Tri-GP (TRDLIB)
R_TRIG
Detects a rising edge.
Syntax
MY_R_TRIG( CLK:=b1 ) ;
b2 := MY_R_TRIG.Q ;
Description
The R_TRIG function block sets the output Q on the rising edge of the CLK input. A rising edge is a
change from false to true (0 to 1). The output Q is true if the input CLK was false during the previous
evaluation but true during the current evaluation of the function block instance; otherwise, the output Q
is false.
Example
VAR CHECK_FOR_RISING_EDGE : R_TRIG ; END_VAR
VAR b : BOOL ; END_VAR
b := 0 ; (* no rising edge *)
CHECK_FOR_RISING_EDGE( CLK:=b ); (* Q is FALSE *)
b := 1 ; (* rising edge, 0 to 1 *)
CHECK_FOR_RISING_EDGE( CLK:=b ); (* Q is TRUE *)
b := 1 ; (* no rising edge *)
CHECK_FOR_RISING_EDGE( CLK:=b ); (* Q is FALSE *)
b := 0 ; (* no rising edge *)
CHECK_FOR_RISING_EDGE( CLK:=b ); (* Q is FALSE *)
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan. However, to prevent missing an edge, the instance should be executed
after every possible change in input value, which could be every scan or even more than once
per scan.
• Can be used in CEM Cause and Effect cells.
Library
Standard (STDLIB)
REAL
A REAL data type is 32 bits in length and has 6 decimal digits of precision. In TriStation 1131, the REAL
data type follows the IEC-559 Standard Floating-Point format.
Attribute Description
Keyword/type REAL
Size 32 bits
The smallest positive number that can be stored in a The smallest positive number that can be stored in a
REAL variable is: REAL variable is:
2–126 = 1.175494351E-38. 2–149 = 1.401298464E–45.
The precision changes abruptly from 7 digits to 0 The precision changes gradually from 7 digits to 1 digit
digits when the value changes from a number greater as the value changes from 2–127 to 2–149.
than 2–127 to a number less than 2–127.
The maximum relative error changes abruptly from 2– The maximum relative error changes gradually from 2–
24 to 1 when the value changes from a number greater 24to 1 as the value changes from 2–127 to
than 2–127 to a number less than 2–127. 2 .
–149
For values from 2–150 to 2–126, the maximum absolute For values from 2–150 to 2–126, the maximum absolute
error equals the value. error is a constant 2–150.
This table shows how the precision changes as numbers approach zero.
1.5E–39 7 digits
1.5E–40 6 digits
1.5E–41 5 digits
1.5E–42 4 digits
1.5E–43 3 digits
1.5E–44 2 digits
1.5E–45 1 digits
0.0 0 digits
Absolute error is the absolute value of x – a, where x is the exact value and a is the actual value stored.
Relative error is the absolute value of (x – a)/x, where x is the exact value and a is the actual value stored.
This table shows how gradual underflow affects absolute error and relative error as REAL numbers
approach zero.
Application Notes
• Can be used in Safety or Control applications.
• Can be used in CEM Cause, Effect, and Intersection cells.
REAL_TO_DINT
Converts a 32-bit real number to a 32-bit integer.
Syntax
k := REAL_TO_DINT( x );
Description
The REAL_TO_DINT function converts a 32-bit real number to a 32-bit integer. The result is rounded to
the nearest integer.
Note IEC 1131-3 requires strict data type checking. It does not permit assigning the value of a variable
directly to a variable of a different data type. When it is necessary to use variables of different
data types, an explicit conversion must be made using a data type conversion function.
Example
VAR k : DINT; x : REAL; END_VAR;
x := -123.6;
k := REAL_TO_DINT( x ); (* result is -124 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the error flags
to true, and resets ENO to false. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
REAL_TO_INT
Converts a 32-bit real number to a 16-bit integer.
Syntax
k := REAL_TO_INT( x );
Description
The REAL_TO_INT function converts a 32-bit real number to a 16-bit integer. The result is rounded to the
nearest integer.
Note IEC 1131-3 requires strict data type checking. It does not permit assigning the value of a variable
directly to a variable of a different data type. When it is necessary to use variables of different
data types, an explicit conversion must be made using a data type conversion function.
Example
VAR k : INT; x : REAL; END_VAR;
x := -123.6;
k := REAL_TO_INT( x ); (* result is -124 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the error flags
to true, and resets ENO to false. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
REAL_TO_LREAL
Converts a 32-bit real number to a 64-bit long real number.
Syntax
y := REAL_TO_LREAL( x );
Description
The REAL_TO_LREAL function converts a 32-bit real number to a 64-bit long real number.
Note IEC 1131-3 requires strict data type checking. It does not permit assigning the value of a variable
directly to a variable of a different data type. When it is necessary to use variables of different
data types, an explicit conversion must be made using a data type conversion function.
Example
VAR x : REAL END_VAR;
VAR y : LREAL END_VAR;
x := 6.25;
y = REAL_TO_LREAL(x); (* result is 6.25 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the error flags
to true, and resets ENO to false. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
ReportBadParam
Reports a bad parameter error.
Syntax
b1 := ReportBadParam(I1) ;
Description
The ReportBadParam function resets ENO and sets the BAD PARAM and ERROR status flags.
When a Triconex library function detects a bad parameter, the function typically resets ENO and sets the
BADPARAM status flag. A user-defined function can call ReportBadParam() to do the same thing.
A programmer can use ENO to isolate an error or to stop execution after detection of an error.
A programmer can use the status flags to read what errors have been detected. The CHK_ERR function
block reads the status flags.
Example
VAR NOT_USED, b1, b2 : BOOL ; STATUS : CHK_ERR ; END_VAR
ENO := true ;
NOT_USED := ReportBadParam(0) ;
b1 := ENO ; (* result is false *)
STATUS() ;
b2 := STATUS.BADPARAM ; (* result is true *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
ROL
Rotates left N bits, where N is the shift count.
Syntax
w := ROL( IN, N ) ;
IN ANY_BIT Operand
Description
The ROL function rotates left N bits, where N is the shift count. If N is negative, then rotating left N bits
is equivalent to rotating right –N bits.
Example
VAR w1, w2, w3 : DWORD; END_VAR
w1 := 16#12345678 ;
w2 := ROL( w1, 4) ; (* 16#23456781 *)
w3 := ROL( w1, -4) ; (* 16#81234567 *)
(*
* Remember that 1 hex digit is 4 bits,
* so shifting 4 bits is the same as shifting 1 hex digit.
*)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
ROR
Rotates right N bits, where N is the shift count.
Syntax
w := ROR( IN, N ) ;
IN ANY_BIT Operand.
Description
The ROR function rotates right N bits, where N is the shift count. If N is negative, then rotating right N
bits is equivalent to rotating left –N bits.
Example
VAR w1, w2, w3 : DWORD; END_VAR
w1 := 16#12345678 ;
w2 := ROR( w1, 4) ; (* 16#81234567 *)
w3 := ROR( w1, -4) ; (* 16#23456781 *)
(*
* Remember that 1 hex digit is 4 bits,
* so shifting 4 bits is the same as shifting 1 hex digit.
*)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
RS
RS is a bistable function block (reset dominant).
Syntax
RS( S:=b1, R1:=b2 ) ;
b3 := SR.Q1
S BOOL Set.
R1 BOOL Reset.
Q1 BOOL State
Description
The RS function block is a latch with the reset input dominant over the set input. The R1 input resets Q1
to false. The S input sets Q1 to true if R1 is false. If R1 is false and S is false, then Q1 does not change.
S R1 Q1
Example
VAR MY_RS : RS ; END_VAR
MY_RS( S:=FALSE, R1:=TRUE ); (* Q1 is FALSE *)
MY_RS( S:=FALSE, R1:=FALSE ); (* Q1 is FALSE *)
MY_RS( S:=TRUE, R1:=TRUE ); (* Q1 is FALSE *)
MY_RS( S:=TRUE, R1:=FALSE ); (* Q1 is TRUE *)
MY_RS( S:=FALSE, R1:=FALSE ); (* Q1 is TRUE *)
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
• Can be used in CEM Cause and Effect cells.
Library
Standard (STDLIB)
RTC
Provides a real-time clock.
Syntax
MY_RTC( IN:=b1, PDT:=dt1 ) ;
Description
The RTC function block provides a real-time clock. Output CDT gives the current system date and time.
Output Q is a copy of input IN.
These are deviations from the IEC 61131-3 standard:
• TriStation 1131 does not allow the program to set the system date and time, therefore RTC does
not use the PDT input.
• TriStation 1131 names the enable input IN because the name EN has a special meaning for
functions (the standard conflicts with itself).
• Output CDT is valid even when input IN is false.
Example
VAR MY_RTC : RTC ; END_VAR
MY_RTC() ; (* Output CDT is the current date and time. *)
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
Standard (STDLIB)
SCALE
Scales a value from one engineering unit to another.
Syntax
y := SCALE( INPUT, MAX1, MIN1, MAX2, MIN2 )
Description
The Scale function scales a value from one engineering unit to another. The function returns the scaled
value.
The equation for the return value is:
SCALE := ((INPUT - MIN1)/(MAX1 - MIN1))* (MAX2 - MIN2) + MIN2 ;
Example
VAR y : REAL; END_VAR
y := SCALE( 8.0, 10.0, 5.0, 100.0, 50.0 ); (* result is 80.0 *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Triconex (TCXLIB)
SEL
Selects one of two data values.
Syntax
v := SEL( G, IN0, IN1 ) ;
Description
The SEL function selects one of two data values depending on an input selector (G). If G is false, the return
value is the first data value IN0. If G is true, the return value is the second data value IN1.
The data values can be any data type, but both data values must have the same data type as the return
value.
Example
v := SEL( G, IN0, IN1 ) ;
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
SHL
Shifts left N bits, where N is the shift count.
Syntax
w := SHL( IN, N ) ;
IN ANY_BIT Operand
Description
The SHL function shifts left N bits, where N is the shift count. If N is negative, then shifting left N bits is
equivalent to shifting right –N bits. Bits shifted into an operand are zero. Bits shifted out of an operand
are lost. If the shift count is greater than or equal to the size of the operand, the result is zero.
Example
VAR w1, w2, w3 : DWORD; END_VAR
w1 := 16#12345678 ;
w2 := SHL( w1, 4) ; (* 16#23456780 *)
w3 := SHL( w1, -4) ; (* 16#01234567 *)
(*
* Remember that 1 hex digit is 4 bits,
* so shifting 4 bits is the same as shifting 1 hex digit.
*)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
SHR
Shifts right N bits, where N is the shift count.
Syntax
w := SHR( IN, N ) ;
IN ANY_BIT Operand
Description
The SHR function shifts right N bits, where N is the shift count. If N is negative, then shifting right N bits
is equivalent to shifting left –N bits. Bits shifted into an operand are zero. Bits shifted out of an operand
are lost. If the shift count is greater than or equal to the size of the operand, then the result is zero.
Example
VAR w1, w2, w3 : DWORD; END_VAR
w1 := 16#12345678 ;
w2 := SHR( w1, 4) ; (* 16#01234567 *)
w3 := SHR( w1, -4) ; (* 16#23456780 *)
(*
* Remember that 1 hex digit is 4 bits,
* so shifting 4 bits is the same as shifting 1 hex digit.
*)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
SIN
Calculates the sine of an angle.
Syntax
y := SIN( x ) ;
Description
The SIN function returns the sine of an angle given in radians. The result is in the range -1 to 1.
Example
VAR y : REAL; END_VAR
y := SIN( 1.570796 ); {* result is 1.0 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the error flags
to true, and resets ENO to false. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
SOECLR
Clears a sequence of events (SOE) block.
Syntax
MY_SOECLR( CI:=b1, BLOCK:=n1 ) ;
Description
The SOECLR function block clears a sequence of events (SOE) block. SOECLR removes all entries from
the block and writes a SOECLR time stamp into the block. You must stop event collection (using
SOESTOP) before clearing the block.
If the SOECLR operation is successful, the output status is 2, indicating that the block is cleared. If the
event collection was not stopped before the SOECLR operation was attempted, the output status is 0, 1,
or 3.
If CI is false, no operation occurs (no output changes).
Example
For examples of using SOE function blocks, see these SOE sample projects:
• ExSOE.pt2 (For Tricon controllers)
• TdSOE.pt2 (For Trident or Tri-GP controllers)
Note See Sample Projects on page 7 for information about where to find these projects on the PC where
you installed TriStation 1131.
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
• Can be used in Safety or Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
• Tricon (TR1LIB/TX1LIB)
• Trident/Tri-GP (TRDLIB)
SOESTAT
Returns status for a sequence of events (SOE) block.
Syntax
MY_SOESTAT( CI:=b1, BLOCK:=n1 ) ;
Description
The SOESTAT function block returns status for a sequence of events (SOE) block, including the number
of 8-byte entries that are used, and the number of 8-byte entries that are free.
If CI is false, no operation occurs.
Example
For examples of using SOE function blocks, see these SOE sample projects:
• ExSOE.pt2 (For Tricon controllers)
• TdSOE.pt2 (For Trident or Tri-GP controllers)
Note See Sample Projects on page 7 for information about where to find these projects on the PC where
you installed TriStation 1131.
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
• Can be used in Safety or Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
• Tricon (TR1LIB/TX1LIB)
• Trident/Tri-GP (TRDLIB)
SOESTOP
Writes a time stamp into a sequence of events (SOE) block, and changes the state of the block from
collecting to stopped.
Syntax
MY_SOESTOP( CI:=b1, BLOCK:=n1 ) ;
Description
The SOESTOP function block writes a time stamp into a sequence of events (SOE) block, and changes the
state of the block from collecting to stopped. Event collection stops until the next SOESTRT operation.
If the SOESTOP operation is successful, the output status is 2, indicating that the event collection is
stopped. If CI is false, no operation occurs (no output changes).
Example
For examples of using SOE function blocks, see these SOE sample projects:
• ExSOE.pt2 (For Tricon controllers)
• TdSOE.pt2 (For Trident or Tri-GP controllers)
Note See Sample Projects on page 7 for information about where to find these projects on the PC where
you installed TriStation 1131.
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
• Can be used in Safety or Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
• Tricon (TR1LIB/TX1LIB)
• Trident/Tri-GP (TRDLIB)
SOESTRT
Starts sequence of events (SOE) collection for an SOE block.
Syntax
MY_SOESTRT( CI:=b1, BLOCK:=n1 ) ;
Description
The SOESTRT function block starts sequence of events (SOE) collection for an SOE block. The Main
Processor writes an SOESTRT time stamp entry into the block and changes the state of the block from not
started or stopped to collecting. If the SOESTRT operation is successful, the output status is 1, indicating
that the block is collecting data.
If CI is false, no operation occurs (no output changes).
The SOESTRT function block must be executed for each SOE block you want to collect events from.
Note The SOESTRT function block is executed once per scan, which means the resulting STAT output
is valid only for that scan.
Example
For examples of using SOE function blocks, see these SOE sample projects:
• ExSOE.pt2 (For Tricon controllers)
• TdSOE.pt2 (For Trident or Tri-GP controllers)
Note See Sample Projects on page 7 for information about where to find these projects on the PC where
you installed TriStation 1131.
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
• Can be used in Safety or Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
• Tricon (TR1LIB/TX1LIB)
• Trident/Tri-GP (TRDLIB)
SQRT
Calculates the square root of a number.
Syntax
y := SQRT( x ) ;
Description
The SQRT function returns the square root of a number.
Example
VAR y : REAL; END_VAR
y := SQRT( 4.0 ); {* result is 2.0 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the error flags
to true, and resets ENO to false. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
SR
SR is a bistable function block (set dominant).
Syntax
SR( S1:=b1, R:=b2 ) ;
b3 := SR.Q1
S1 BOOL Set
R BOOL Reset
Q1 BOOL State
Description
The SR function block is a latch with the set input dominant over the reset input. The S1 input sets Q1 to
true. The R input resets Q1 to false if S1 is false. If S1 is false and R is false, then Q1 does not change.
S1 R Q1
Example
VAR MY_SR : SR ; END_VAR
MY_SR( S1:=FALSE, R:=TRUE ); (* Q1 is FALSE *)
MY_SR( S1:=FALSE, R:=FALSE ); (* Q1 is FALSE *)
MY_SR( S1:=TRUE, R:=TRUE ); (* Q1 is TRUE *)
MY_SR( S1:=TRUE, R:=FALSE ); (* Q1 is TRUE *)
MY_SR( S1:=FALSE, R:=FALSE ); (* Q1 is TRUE *)
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
• Can be used in CEM Cause and Effect cells.
Library
Standard (STDLIB)
STRING
A STRING data type is an alphanumeric sequence, up to 132 characters in length, which is delimited by
single quotation marks ( ' ). The count of 132 characters does not include the null terminator or the single
quotation mark.
Attribute Description
Keyword/type STRING
Application Notes
• Can be used in Safety or Control applications.
• Can be used in CEM Cause, Effect, and Intersection cells.
SUB
Calculates the difference between two operands.
x ANY_NUM Minuend
y ANY_NUM Subtrahend
d1 DT Minuend
t TIME Subtrahend
DT The difference d1 - t
t1 TIME Minuend
t2 TIME Subtrahend
t TIME Subtrahend
Description
The subtract operator (–) is used in Structured Text to calculate the difference between two operands.
In the graphical languages, the SUB function is used instead of the subtract operator.
The subtract operator and SUB function:
• Subtract a number from another number
• Subtract a time from a date and time
• Subtract a time from a time
• Subtract a time from a time of day
Example
Runtime Errors
If the date and time is out of range Invalid date BADPARAM, ERROR
Upon detection of a runtime error condition, the function returns the indicated value, sets the error flags
to true, and resets ENO to false. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
SYS_AI32_STATUS
Syntax
MY_SYS_AI32_STATUS( CI:=b1, IOP:=n1, SLOT:=n2 ) ;
TMR BOOL Three channels are operating without fatal faults detected.
GE_DUAL BOOL At least two channels are operating without fatal faults detected.
GE_SINGLE BOOL At least one channel is operating without fatal faults detected.
Description
The SYS_AI32_STATUS function block gets the status of an Analog Input Module in a Trident or Tri-GP
controller.
Example
VAR MY_AI : SYS_AI32_STATUS ; END_VAR
VAR AI_ACTIVE : BOOL ; END_VAR
MY_AI( CI:=TRUE, IOP:=1, SLOT:=5 ) ;
AI_ACTIVE := MY_AI.LEFT_ACTIVE OR MY_AI.RIGHT_ACTIVE ;
(*
* Result : AI_ACTIVE is TRUE if there is
* an active AI32 module in slot 5.
*)
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
• Can be used in Safety or Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
Trident/Tri-GP (TRDLIB)
SYS_AO04_STATUS
Gets the status of an Analog Output Module.
Syntax
MY_SYS_AO04_STATUS( CI:=b1, IOP:=n1, SLOT:=n2 ) ;
TMR BOOL Three channels are operating without fatal faults detected.
GE_DUAL BOOL At least two channels are operating without fatal faults detected.
GE_SINGLE BOOL At least one channel are operating without fatal faults detected.
Description
The SYS_AO04_STATUS function block gets the status of an Analog Output Module.
Example
VAR MY_AO : SYS_AO04_STATUS ; END_VAR
VAR AO_ACTIVE : BOOL ; END_VAR
MY_AO( CI:=TRUE, IOP:=1, SLOT:=5 ) ;
AO_ACTIVE := MY_AO.LEFT_ACTIVE OR MY_AO.RIGHT_ACTIVE ;
(*
* Result : AO_ACTIVE is TRUE if there is
* an active AO04 module in slot 5.
*)
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
• Can be used in Safety or Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
Trident/Tri-GP (TRDLIB)
SYS_APP_HALT
Halts the application.
Syntax
n1 := SYS_APP_HALT( b1 ) ;
APP_HALT BOOL True means halt the application; false means do not halt.
Description
The SYS_APP_HALT function halts the application. Halting the application stops execution of the control
program at the end of the current scan and initializes the variables.
APP_HALT enables the function. If APP_HALT is true, then halt the application. If APP_HALT is false,
then do not halt.
Example
(* Halt the application. *)
VAR n : DINT; END_VAR
n := SYS_APP_HALT( TRUE ); {* result is 0 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the error flags
to true, and resets ENO to false. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Trident/Tri-GP (TRDLIB)
SYS_CLEAR_FLTS
Clear all faults in the system.
Syntax
n1 := SYS_CLEAR_FLTS( b1 ) ;
CLEAR_FLTS BOOL True means clear faults; false means do not clear.
Description
The SYS_CLEAR_FLTS clears all faults in the system.
Halting the application stops execution of the control program at the end of the current scan and
initializes the variables.
CLEAR_FLTS enables the function. If APP_HALT is true, then halt the application. If APP_HALT is false,
then do not halt.
Example
(* Clear system faults. *)
VAR n : DINT; END_VAR
n := SYS_CLEAR_FLTS( TRUE ); {* result is 0 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the error flags
to true, and resets ENO to false. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Trident/Tri-GP (TRDLIB)
SYS_CM_STATUS
Gets the status of a Trident or Tri-GP Communication Module (CM).
Syntax
MY_SYS_CM_STATUS( CI:=b1, IOP:=n1, SLOT:=n2 ) ;
ELAPSED_SERIAL_1 DINT The milliseconds since the last message was received on serial
port 1.
ELAPSED_SERIAL_2 DINT The milliseconds since the last message was received on serial
port 2.
ELAPSED_SERIAL_3 DINT The milliseconds since the last message was received on serial
port 3.
Description
The SYS_CM_STATUS function block gets the status of a Communications Module. The status
information for serial ports only applies to ports used as Modbus slaves.
Example
VAR MY_CM : SYS_CM_STATUS ; END_VAR
VAR CM_ACTIVE : BOOL ; END_VAR
MY_CM( CI:=TRUE, IOP:=0, SLOT:=2 ) ;
CM_ACTIVE := MY_CM.ACTIVE ;
(*
* Result : CM_ACTIVE is TRUE if there is
* an active CM module in slot 2.
*)
Runtime Errors
If ERROR_NUM is non-zero Reset all outputs except ERROR_NUM to zero. BADPARAM, ERROR
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
• Can be used in Safety or Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
Trident/Tri-GP (TRDLIB)
SYS_CRITICAL_IO
Accumulates the status of safety-critical I/O modules.
Syntax
MY_SYS_CRITICAL_IO( CI:=b1, RESET:=b2, IOP:=n1, SLOT:=n2, APP:=n3, RELAY_OK:=b3 ) ;
TMR BOOL Three channels are operating without faults on all critical I/O module.
GE_DUAL BOOL At least two channels are operating without faults on all critical I/O
module.
GE_SINGLE BOOL At least one channel is operating without faults on all critical I/O module.
Description
The SYS_CRITICAL_IO function block accumulates the status of safety-critical I/O modules. For more
information, see the Safety Considerations Guide for your controller.
• APP := DE_ENERGIZED
• RELAY_OK := false
To get the status of a safety-critical I/O module:
• For each module, invoke specifying the input values:
— IOP
— SLOT
— APP
— RELAY_OK
For example, if IOP 1 SLOT 1 is a critical DO module with a relay, and SCIO is the function block
instance name:
SCIO( IOP:=1, SLOT:=1, APP:=RELAY,RELAY_OK:=RELAY1_OK );
• Read the output values:
— CO
— TMR
— GE_DUAL
— GE_SINGLE
Example
For shutdown examples, see this sample project:
• TdTUV.pt2 (For Trident or Tri-GP controllers)
Note See Sample Projects on page 7 for information about where to find this project on the PC where
you installed TriStation 1131.
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
Can be used in Safety or Control applications.
Library
Trident/Tri-GP (TRDLIB)
SYS_DI16_AI16_STATUS
Gets the status of a combo AI/DI input module.
Syntax
MY_SYS_DI16_AI16_STATUS( CI:=b1, IOP:=n1, SLOT:=n2 ) ;
TMR BOOL Three channels are operating without faults on all critical I/O
modules.
GE_DUAL BOOL At least two channels are operating without faults on all critical
I/O modules.
GE_SINGLE BOOL At least one channel is operating without faults on all critical
I/O modules.
Description
The SYS_DI16_A16_STATUS function block gets the status of a combo AI/DI input module.
Example
VAR MY_AIDI : SYS_DI16_AI16_STATUS ; END_VAR
VAR AIDI_ACTIVE : BOOL ; END_VAR
MY_AIDI( CI:=TRUE, IOP:=1, SLOT:=5 ) ;
AIDI_ACTIVE := MY_AIDI.LEFT_ACTIVE OR MY_AIDI.RIGHT_ACTIVE ;
(*
* Result : AIDI_ACTIVE is TRUE if there is
* an active AI/DI combo module in slot 5.
*)
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
• Can be used in Safety or Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
Trident/Tri-GP (TRDLIB)
This function was added to the library in v1.114 of TRDLIB, first released with TriStation 1131 v4.3.
SYS_DI32_STATUS
Gets the status of a discrete input module.
Syntax
MY_SYS_DI32_STATUS( CI:=b1, IOP:=n1, SLOT:=n2 ) ;
TMR BOOL Three channels are operating without faults on all critical I/O
module.
GE_DUAL BOOL At least two channels are operating without faults on all critical
I/O module.
GE_SINGLE BOOL At least one channel is operating without faults on all critical
I/O module.
a. Because there are no field diagnostics or voter diagnostics for the DI32 module, the NO_FLD_FLTS and
NO_VOTER_FLTS outputs are always true after successfully reading the DI32 status.
Description
The SYS_DI32_STATUS function block gets the status of a discrete input module.
Example
VAR MY_DI : SYS_DI32_STATUS ; END_VAR
VAR DI_ACTIVE : BOOL ; END_VAR
MY_DI( CI:=TRUE, IOP:=1, SLOT:=5 ) ;
DI_ACTIVE := MY_DI.LEFT_ACTIVE OR MY_DI.RIGHT_ACTIVE ;
(*
* Result : DI_ACTIVE is TRUE if there is
* an active DI32 module in slot 5.
*)
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
• Can be used in Safety or Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
Trident/Tri-GP (TRDLIB)
SYS_DO16_STATUS
Gets the status of a discrete output module.
Syntax
MY_SYS_DO16_STATUS( CI:=b1, IOP:=n1, SLOT:=n2 ) ;
TMR BOOL Three channels are operating without fatal faults detected.
GE_DUAL BOOL At least two channels are operating without fatal faults detected.
GE_SINGLE BOOL At least one channel are operating without fatal faults detected.
Description
The SYS_DO16_STATUS function block gets the status of a discrete output module.
Example
VAR MY_DO : SYS_DO16_STATUS ; END_VAR
VAR DO_ACTIVE : BOOL ; END_VAR
MY_DO( CI:=TRUE, IOP:=1, SLOT:=5 ) ;
DO_ACTIVE := MY_DO.LEFT_ACTIVE OR MY_DO.RIGHT_ACTIVE ;
(*
* Result : DO_ACTIVE is TRUE if there is
* an active DO16 module in slot 5.
*)
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
• Can be used in Safety or Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
Trident/Tri-GP (TRDLIB)
SYS_HRDI32_STATUS
Gets the status of a high resolution discrete input module.
Syntax
MY_SYS_HRDI32_STATUS( CI:=b1, IOP:=n1, SLOT:=n2 ) ;
TMR BOOL Three channels are operating without faults on all critical I/O
module.
GE_DUAL BOOL At least two channels are operating without faults on all critical
I/O module.
GE_SINGLE BOOL At least one channel is operating without faults on all critical
I/O module.
a. Because there are no field diagnostics or voter diagnostics for the HRDI32 module, the NO_FLD_FLTS and
NO_VOTER_FLTS outputs are always true after successfully reading the HRDI32 status.
Description
The SYS_HRDI32_STATUS function block gets the status of a high-resolution discrete input module.
CO is the control ouput. CO follows CI if no runtime error is detected. CO=true indicates that the function
block was enabled and executed successfully, with no runtime error. CO=false and CI=true indicates a
runtime error was detected. CO=false and CI=false indicates no operation.
Example
VAR MY_HRDI : SYS_HRDI32_STATUS ; END_VAR
VAR HRDI_ACTIVE : BOOL ; END_VAR
MY_HRDI( CI:=TRUE, IOP:=1, SLOT:=5 ) ;
HRDI_ACTIVE := MY_HRDI.LEFT_ACTIVE OR MY_HRDI.RIGHT_ACTIVE ;
(*
* Result : HRDI_ACTIVE is TRUE if there is
* an active HRDI32 module in slot 5.
*)
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
• Can be used in Safety or Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
Trident/Tri-GP (TRDLIB)
This function was added to the library in v1.120 of TRDLIB, first released with TriStation 1131 v4.6.
SYS_IO_STATUS
Gets the status of an I/O module.
Syntax
MY_SYS_IO_STATUS( CI:=b1, IOP:=n1, SLOT:=n2 ) ;
TMR BOOL Three channels are operating without fatal faults detected.
GE_DUAL BOOL At least two channels are operating without fatal faults detected.
GE_SINGLE BOOL At least one channel are operating without fatal faults detected.
Description
The SYS_IO_STATUS function block gets the status of an I/O module.
Example
VAR MY_IO : SYS_IO_STATUS ; END_VAR
VAR IO_ACTIVE : BOOL ; END_VAR
MY_IO( CI:=TRUE, IOP:=1, SLOT:=5 ) ;
IO_ACTIVE := MY_IO.LEFT_ACTIVE OR MY_IO.RIGHT_ACTIVE ;
(*
* Result : IO_ACTIVE is TRUE if there is
* an active IO module in slot 5.
*)
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
• Can be used in Safety or Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
Trident/Tri-GP (TRDLIB)
SYS_IOP_STATUS
Gets the status of a Trident or Tri-GP I/O Processor.
Syntax
MY_SYS_IOP_STATUS( CI:=b1, IOP:=n1 ) ;
TMR BOOL Three channels are operating without fatal faults detected.
GE_DUAL BOOL At least two channels are operating without fatal faults detected.
GE_SINGLE BOOL At least one channel is operating without fatal faults detected.
IO_TMR BOOL Three channels are operating without fatal faults detected on the
I/O string.
IO_GE_Dual BOOL At least two channels are operating without fatal faults detected
on the I/O string.
IO_GE_Single BOOL At least one channel is operating without fatal faults detected on
the I/O string.
Description
The SYS_IOP_STATUS function block gets the status of an I/O Processor.
Example
VAR MY_IOP : SYS_IOP_STATUS ; END_VAR
VAR NO_IOP_FAULTS : BOOL ; END_VAR
MY_IOP( CI:=TRUE, IOP:=1 ) ;
NO_IOP_FAULTS := MY_IOP.NO_FLTS ;
(*
* Result : NO_IOP_FAULTS is TRUE if there are
* no failed modules detected on the IOP.
*)
Runtime Errors
If ERROR_NUM is non-zero Reset all outputs except ERROR_NUM to zero. BADPARAM, ERROR
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
• Can be used in Safety or Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
Trident/Tri-GP (TRDLIB)
SYS_MP_EXT_STATUS
Gets the extended status of a Trident or Tri-GP Main Processor Module.
Syntax
MY_SYS_MP_EXT_STATUS( CI:=b1 ) ;
BRDCSTS_PORT_LEFT DINT The number of broadcast messages received on the left port.
RSPNS_PORT_LEFT DINT The number of response messages sent on the left port.
BAD_MSGS_PORT_LEFT DINT The number of bad messages received on the left port.
ELAPSED_PORT_LEFT DINT The number of milliseconds since last message was received on
left port.
BRDCSTS_PORT_MID DINT The number of broadcast messages received on the middle port.
RSPNS_PORT_MID DINT The number of response messages sent on the middle port.
BAD_MSGS_PORT_MID DINT The number of bad messages received on the middle port.
ELAPSED_PORT_MID DINT The number of milliseconds since last message was received on
middle port.
BRDCSTS_PORT_RIGHT DINT The number of broadcast messages received on the right port.
RSPNS_PORT_RIGHT DINT The number of response messages sent on the right port.
BAD_MSGS_PORT_RIGHT DINT The number of bad messages received on the right port.
ELAPSED_PORT_RIGHT DINT The number of milliseconds since last message was received on
right port.
Description
The SYS_MP_EXT_STATUS function block gets the extended status of a Main Processor module. You
should use SYS_MP_STATUS when employing BOOL MP status variables and SYS_MP_EXT_STATUS
when using DINT MP status variables.
Example
VAR MY_MPX : SYS_MP_EXT_STATUS ; END_VAR
VAR DELTA : DINT ; END_VAR
MY_MPX( CI:=TRUE ) ;
DELTA := MY_MPX.ACTUAL_SCAN_TIME ;
(*
* Result : DELTA is the actual scan period in milliseconds.
*)
Runtime Errors
If ERROR_NUM is non-zero Reset all outputs except ERROR_NUM to zero. BADPARAM, ERROR
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
• Can be used in Safety or Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
Trident/Tri-GP (TRDLIB)
SYS_MP_RESET_PORTS
Reset statistics for Modbus ports on the MP.
Syntax
n1 := SYS_MP_RESET_PORTS( RESET_PORT_LEFT, RESET_PORT_MID, RESET_PORT_RIGHT ) ;
RESET_PORT_LEFT BOOL Reset statistics for the left Modbus port on the MP.
RESET_PORT_MID BOOL Reset statistics for the middle Modbus port on the MP.
RESET_PORT_RIGHT BOOL Reset statistics for the right Modbus port on the MP.
Description
The SYS_MP_RESET_PORTS function block resets statistics for Modbus ports on the MP.
Each Boolean input controls one Modbus port on the main processor (MP). Calling the function with a
Boolean input true resets statistics for the corresponding Modbus port. If a Boolean input is false, then do
not reset statistics for the corresponding Modbus port.
Example
(* Reset statistics for the left port on the MP. *)
VAR n : DINT; END_VAR
n := SYS_MP_RESET_PORTS( TRUE, FALSE, FALSE );
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the error flags
to true, and resets ENO to false. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Trident/Tri-GP (TRDLIB)
SYS_MP_STATUS
Gets the status of the Trident or Tri-GP Main Processor Modules.
Syntax
MY_SYS_MP_STATUS( CI:=b1 ) ;
GE_DUAL BOOL At least two channels are operating without fatal faults
detected.
Description
The SYS_MP_STATUS function block gets the status of Trident or Tri-GP Main Processor modules. Use
the SYS_MP_STATUS function block with BOOL MP status variables and the SYS_MP_EXT_STATUS
function block with DINT MP status variables.
Example
VAR MY_MP : SYS_MP_STATUS ; END_VAR
VAR MP_TEMPERATURE_OK : BOOL ; END_VAR
MY_MP( CI:=TRUE ) ;
MP_TEMPERATURE_OK := MY_MP.TEMP_OK ;
(*
* Result : MP_TEMPERATURE_OK is TRUE if
* the MP temperature is OK.
*)
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
• Can be used in Safety or Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
Trident/Tri-GP (TRDLIB)
SYS_OVD_INHIBIT
Inhibits output voter diagnostics.
Syntax
n1 := SYS_OVD_INHIBIT( IOP, SLOT, IOVD_01_16 ) ;
Description
The SYS_OVD_INHIBIT function block turns output voter diagnostic inhibits on or off.
When enabled, the Trident or Tri-GP DO or SDO module runs output voter diagnostics on each output
point. The application program can call SYS_OVD_INHIBIT to control the OVD inhibit for each point.
Each bit 01..16 of IOVD_01_16 controls the running of OVD for the corresponding point on the output
module. If the bit value is one, then inhibit diagnostics for that point. If the bit value is zero, then run the
diagnostics for that point.
Invoke SYS_DO16_STATUS or SYS_SDO16_STATUS to read whether OVD is running for each point.
Points on the Trident or Tri-GP SDO module are configured for supervision in
WARNING TriStation 1131.
Using the SYS_OVD_INHIBIT function block to inhibit OVDs on an SDO point
overrides the TriStation 1131 supervisory configuration and results in loss of
supervision of that point.
See the TriStation 1131 Developer’s Guide for more information about configuring
the Trident or Tri-GP SDO module.
Programming tip: the bit numbers in parameter IOVD_01_16 are the same as the bit numbers in the
PACK16 function, so if you prefer using separate Boolean inputs, you can use PACK16.
The format of IOVD_01_16 parameter is:
* bit --> |32 ... 17|16 ... 01|
* output point --> |16 ... 01|
* where the most significant bits 17..32 are not used.
Example
(* Inhibit voter diagnostic for chassis 1 slot 5 points 01 thru 06. *)
VAR n : DINT; END_VAR
n := SYS_OVD_INHIBIT( 1, 5, 2#00000000000000000000000000111111 );
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the error flags
to true, and resets ENO to false. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Trident/Tri-GP (TRDLIB)
SYS_PI06_STATUS
Gets the status of a Trident/Tri-GP Pulse Input or Enhanced Pulse Input Module.
Syntax
MY_SYS_PI06_STATUS( CI:=b1, IOP:=n1, SLOT:=n2 ) ;
TMR BOOL Three channels are operating without fatal faults detected.
GE_DUAL BOOL At least two channels are operating without fatal faults detected.
GE_SINGLE BOOL At least one channel is operating without fatal faults detected.
INPUT_STABLE_1 BOOL The measured input for pulse input 1 or enhanced pulse input 1
is stable.
INPUT_STABLE_2 BOOL The measured input for pulse input 2 or enhanced pulse input 2
is stable.
INPUT_STABLE_3 BOOL The measured input for pulse input 3 or enhanced pulse input 3
is stable.
INPUT_STABLE_4 BOOL The measured input for pulse input 4 or enhanced pulse input 4
is stable.
INPUT_STABLE_5 BOOL The measured input for pulse input 5 or enhanced pulse input 5
is stable.
INPUT_STABLE_6 BOOL The measured input for pulse input 6 or enhanced pulse input 6
is stable.
SIGNAL_PRESENT_2 BOOL The frequency of pulse input 2 or enhanced pulse input 2 is >=
0.5 Hz.
SIGNAL_PRESENT_3 BOOL The frequency of pulse input 3 or enhanced pulse input 3 is >=
0.5 Hz.
SIGNAL_PRESENT_4 BOOL The frequency of pulse input 4 or enhanced pulse input 4 is >=
0.5 Hz.
SIGNAL_PRESENT_5 BOOL The frequency of pulse input 5 or enhanced pulse input 5 is >=
0.5 Hz.
SIGNAL_PRESENT_6 BOOL The frequency of pulse input 6 or enhanced pulse input 6 is >=
0.5 Hz.
Description
The SYS_PI06_STATUS function block gets the status of a Trident or Tri-GP Pulse Input or Enhanced
Pulse Input Module.
Example
VAR MY_PI : SYS_PI06_STATUS ; END_VAR
VAR PI_ACTIVE : BOOL ; END_VAR
MY_PI( CI:=TRUE, IOP:=1, SLOT:=5 ) ;
PI_ACTIVE := MY_PI.LEFT_ACTIVE OR MY_PI.RIGHT_ACTIVE ;
(*
* Result : PI_ACTIVE is TRUE if there is an active PI06 module in slot 5.
*)
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
• Can be used in Safety or Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
Trident/Tri-GP (TRDLIB)
SYS_RO32_STATUS
Gets the status of a Trident/Tri-GP Relay Output Module.
Syntax
MY_SYS_RO32_STATUS( CI:=b1, IOP:=n1, SLOT:=n2 ) ;
TMR BOOL Three channels are operating without fatal faults detected.
GE_DUAL BOOL At least two channels are operating without fatal faults detected.
GE_SINGLE BOOL At least one channel is operating without fatal faults detected.
Description
The SYS_RO32_STATUS function block gets the the status of a Relay Output module.
If CI = false, then CO = false and no operation occurs (no output changes). If CI = true, then CO = true if
no errors occur (ERROR_NUM=0).
Example
VAR MY_RO : SYS_RO32_STATUS ; END_VAR
VAR RO_ACTIVE : BOOL ; END_VAR
MY_RO( CI:=TRUE, IOP:=1, SLOT:=5 ) ;
RO_ACTIVE := MY_RO.LEFT_ACTIVE OR MY_RO.RIGHT_ACTIVE ;
(*
* Result : RO_ACTIVE is TRUE if there is
* an active RO32 module in slot 5.
*)
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
• Can be used in Safety or Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
Trident/Tri-GP (TRDLIB)
SYS_SDO16_STATUS
Gets the status of a supervised discrete output module.
Syntax
MY_SYS_SDO16_STATUS( CI:=b1, IOP:=n1, SLOT:=n2 ) ;
TMR BOOL Three channels are operating without fatal faults detected.
GE_DUAL BOOL At least two channels are operating without fatal faults detected.
GE_SINGLE BOOL At least one channel are operating without fatal faults detected.
SPRVSD_ON_01_16 DWORD Supervision status for points 01-16. TRUE: Supervision enabled.
FALSE: Supervision disabled.
Description
The SYS_SDO16_STATUS function block gets the status of a supervised discrete output module.
CO is the control ouput. CO follows CI if no runtime error is detected. CO=true indicates that the function
block was enabled and executed successfully, with no runtime error. CO=false and CI=true indicates a
runtime error was detected. CO=false and CI=false indicates no operation.
Example
VAR MY_SDO : SYS_SDO16_STATUS ; END_VAR
VAR SDO_ACTIVE : BOOL ; END_VAR
MY_SDO( CI:=TRUE, IOP:=1, SLOT:=5 ) ;
SDO_ACTIVE := MY_SDO.LEFT_ACTIVE OR MY_SDO.RIGHT_ACTIVE ;
(*
* Result : SDO_ACTIVE is TRUE if there
* is an active SDO16 module in slot 5.
*)
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
• Can be used in Safety or Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
Trident/Tri-GP (TRDLIB)
This function was added to the library in v1.120 of TRDLIB, first released with TriStation 1131 v4.6.
SYS_SERIAL_PORT
Resets statistics for one or more serial ports.
Syntax
MY_SYS_SERIAL_PORT( CI:=b1, IOP:=n1, RESET_STATS_SERIAL_1:=b2,
RESET_STATS_SERIAL_2:=b3, RESET_STATS_SERIAL_3:=b4 ) ;
Description
The SYS_SERIAL_PORT function block resets statistics for one or more serial ports.
CI is a control input. If CI is false, then CO is false and there is no operation, which means that new
requests are ignored. If CI is true, then CO is false if there are errors (ERROR_NUM not zero). If CI is true,
then CO is true if there are no errors (ERROR_NUM = 0).
Each input RESET_STATS_SERIAL_n is a request to reset the statistics for port "n". The function block
latches the request until the port acknowledges the request, that is, until the transition of
STATS_RESET_SERIAL_n from false to true.
Each output STATS_RESET_SERIAL_n is true when the statistics are reset, false otherwise.
Invoke SYS_CM_STATUS to read statistics for each serial port. The statistics for serial port 1 are
MSGS_SERIAL_1, BRDCSTS_SERIAL_1, RSPNS_SERIAL_1, and BAD_MSGS_SERIAL_1, and similarly
for ports 2 and 3.
Example
(* Reset statistics for all three ports. *)
VAR MY_SYS_SERIAL_PORT : SYS_SERIAL_PORT; END_VAR
MY_SYS_SERIAL_PORT( RESET_STATS_SERIAL_1:=TRUE, RESET_STATS_SERIAL_2:=TRUE,
RESET_STATS_SERIAL_3:=TRUE );
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
• Can be used in Safety or Control applications.
• Exactly Once: each instance should be executed exactly once per scan.
Library
Trident/Tri-GP (TRDLIB)
SYS_SET_APP_LOCK
Turns the application lock on or off.
Syntax
n1 := SYS_SET_APP_LOCK( b1 ) ;
Description
The SYS_SET_APP_LOCK function turns the application lock on or off.
The application lock controls the TriStation 1131 permissions for performing application changes. When
locked, TriStation 1131 cannot download changes, download all, set variable values, or disable points on
a Trident or Tri-GP controller.
Example
(* Lock the application. *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the error flags
to true, and resets ENO to false. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Trident/Tri-GP (TRDLIB)
SYS_SET_PROG_ALARM
Turns the programmable alarm on or off.
Syntax
n1 := SYS_SET_PROG_ALARM( b1 ) ;
VALUE BOOL True means alarm on; false means alarm off.
Description
The SYS_SET_PROG_ALARM function turns the programmable alarm on or off.
The programmable alarm is a blue indicator lamp on the Trident or Tri-GP MP module.
Invoke function block SYS_MP_STATUS to read PROG_ALARM_ON.
Example
(* Turn the blue programmable alarm indicator on. *)
VAR n : DINT; END_VAR
n := SYS_SET_PROG_ALARM( TRUE ); {* result is 0 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the error flags
to true, and resets ENO to false. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Trident/Tri-GP (TRDLIB)
SYS_SET_REMOTE_WRT_ENBL
Turns remote write enable on or off.
Syntax
n1 := SYS_SET_REMOTE_WRT_ENBL( b1 ) ;
VALUE BOOL True means enable writes; false means disable writes.
Description
The SYS_SET_REMOTE_WRT_ENBL function turns remote write enable on or off. Remote write enable
controls permission for external hosts to write to an aliased variable on a Trident or Tri-GP controller.
Invoke function block SYS_MP_STATUS to read REMOTE_WRT_ENBL.
Example
(* Allow writes from remote hosts. *)
VAR n : DINT; END_VAR
n := SYS_SET_REMOTE_WRT_ENBL( TRUE ); {* result is 0 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the error flags
to true, and resets ENO to false. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Trident/Tri-GP (TRDLIB)
SYS_SHUTDOWN
Enables a system shutdown according to industry guidelines.
Syntax
MY_SYS_SHUTDOWN( CI:=b1, IO_CO:=b2, IO_TMR:=b3, IO_GE_DUAL:=b4, IO_GE_SINGLE:=b5,
IO_NO_VOTER_FAULTS:=b6, MAX_TIME_DUAL:=t1, MAX_TIME_SINGLE:=t2, MAX_SCAN_TIME:=t3 ) ;
IO_TMR BOOL Three channels are operating without faults on every critical I/O
module.
IO_GE_DUAL BOOL At least two channels are operating without faults on every critical
I/O module.
IO_GE_SINGLE BOOL At least one channel is operating without faults on every critical I/O
module.
MAX_TIME_SINGLE TIME The maximum time of continuous operation permitted with one
channel operating.
TMR BOOL Three channels are operating without fatal faults detected.
DUAL BOOL At least two channels are operating without fatal faults
detected.
SINGL BOOL At least one channel is operating without fatal faults detected.
Description
The SYS_SHUTDOWN function block enables a system shutdown according to industry guidelines. For
more information, see the Safety Considerations Guide for your controller.
Example
For shutdown examples, see this sample project:
• TdTUV.pt2 (For Trident or Tri-GP controllers)
Note See Sample Projects on page 7 for information about where to find this project on the PC where
you installed TriStation 1131.
Runtime Errors
If ERROR is non-zero Set alarm outputs to true, reset the other BOOL BADPARAM, ERROR
outputs to false, and reset TIME_LEFT to zero.
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
If a programming error or configuration error occurs, then CO is false and the error number is non-zero.
For error numbers, see the description of the ERROR output.
Application Notes
Can be used in Safety or Control applications.
Library
Trident/Tri-GP (TRDLIB)
SYS_SYSTEM_STATUS
Gets the status of an entire Trident or Tri-GP system, including Main Processors, I/O modules,
communication, power, and time.
Syntax
MY_SYS_SYSTEM_STATUS( CI:=b1 ) ;
TMR BOOL Three channels are operating without fatal faults detected.
GE_DUAL BOOL At least two channels are operating without fatal faults
detected.
GE_SINGLE BOOL At least one channel is operating without fatal faults detected.
IO_TMR BOOL Three channels are operating without fatal faults detected on
the I/O string.
IO_GE_Dual BOOL At least two channels are operating without fatal faults
detected on the I/O string.
IO_GE_Single BOOL At least one channel is operating without fatal faults detected
on the I/O string.
Description
The SYS_SYSTEM_STATUS function block gets the status of an entire Trident or Tri-GP system,
including Main Processors, I/O modules, communication, power, and time.
If CI = false, then CO = false and no operation occurs (no output changes). If CI = true, then CO = true if
no errors occur (ERROR_NUM=0).
Each digit of the DWORD for the NODE_OK... parameters corresponds to four nodes in the given range
of the parameter. The following diagram illustrates which nodes each digit corresponds to:
NODE_OK_01_32 or NODE_REDUNDANT_01_32
Layout
Digit 1 2 3 4 5 6 7 8
Node Number
32
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
09
08
07
06
05
04
03
02
01
NODE_OK_33_64 or NODE_REDUNDANT_33_64
Layout
Digit 1 2 3 4 5 6 7 8
Node Number
64
63
62
61
60
59
58
57
56
55
54
53
52
51
50
49
48
47
46
45
44
43
42
41
40
39
38
37
36
35
34
33
For example, if the DWORD for NODE_OK_01_32 contains "5000," reading right to left indicates:
0 = 0000, Nodes 1-4 Not OK
0 = 0000, Nodes 5-8 Not OK
0 = 0000, Nodes 9-12 Not OK
5 = 0101, Nodes 13 and 15 OK, Nodes 14 and 16 Not OK
Example
VAR MY_SYS : SYS_SYSTEM_STATUS ; END_VAR
VAR NO_SYSTEM_FAULTS : BOOL ; END_VAR
MY_SYS( CI:=TRUE ) ;
NO_SYSTEM_FAULTS := MY_SYS.NO_FLTS ;
(*
* Result : NO_SYSTEM_FAULTS is TRUE if there are
* no failed modules detected in the system.
*)
Runtime Errors
If ERROR_NUM is non-zero Reset all outputs except ERROR_NUM to zero. BADPARAM, ERROR
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
• Can be used in Safety or Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
Trident/Tri-GP (TRDLIB)
SYS_VOTE_MODE
Converts redundancy status.
Syntax
MY_SYS_VOTE_MODE( CI:=b1, IN_TMR:=b2, GE_DUAL:=b3, GE_SINGLE:=b4 ) ;
Description
The SYS_VOTE_MODE function block converts redundancy status, as shown in this truth table.
T T T T F F F
F T T F T F F
F F T F F T F
F F F F F F T
Othera F F F F
a. If an error in the inputs occurs, then CO is false, the mode outputs are
false, and the function block reports a bad parameter error
(BADPARAM).
Example
For shutdown examples, see this sample project:
• TdTUV.pt2 (For Trident or Tri-GP controllers)
Note See Sample Projects on page 7 for information about where to find this project on the PC where
you installed TriStation 1131.
Runtime Errors
If the inputs do not match one of the first four Reset all BOOL outputs to false BADPARAM, ERROR
rows of the truth table
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
• Can be used in Safety or Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
Trident/Tri-GP (TRDLIB)
TAN
Calculates the tangent of an angle.
Syntax
y := TAN( x ) ;
Description
The TAN function returns the tangent of an angle given in radians.
Example
VAR y : REAL; END_VAR
y := TAN( 3.141593/4.0 ); {* result is 1.0 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the error flags
to true, and resets ENO to false. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
TCJ_CONV
Converts a Type J thermocouple input into degrees Celsius and returns the result.
Syntax
y := TCJ_CONV( MC, CONVM, CONVB, COLDJNC ) ;
MC DINT The machine count input from thermocouple wire to be converted (0–4095).
CONVM REAL The conversion from machine counts to millivolts (see the Thermocouple and
Amplifier specification sheets).
CONVB REAL The conversion bias from machine count to millivolts (see the Thermocouple and
Amplifier specification sheets).
Description
The TCJ_CONV function converts a Type J thermocouple input into degrees Celsius and returns the
result.
First, a thermocouple input machine count (MC) from an Analog Input Module is converted to millivolts
using a bias and scale factor. Next, the millivolts are corrected by cold-junction compensation using a
quartic equation, which is a function of cold-junction temperature. Lastly, the temperature in degrees
Celsius is computed using a set of quartic equations, which are functions of the corrected millivolts.
Temperatures ranging from –200° C to 1200° C are supported for Type J thermocouples. The cold-junction
compensation temperature must be in the range from –20° C to 500° C.
Note Conversion from millivolts to degrees Celsius is based on the Type J quartic equation
approximation done in four ranges. If the intermediate result is outside the calculable range, the
function returns either –10000 or 10000. For example, if coldJnc < –20 or result < –200, then return
–10000; if coldJnc > 500 or result > 1200, then return +10000
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Triconex (TCXLIB)
TCK_CONV
Converts a Type K thermocouple input into degrees Celsius and returns the result.
Syntax
y := TCJ_CONV( MC, CONVM, CONVB, COLDJNC ) ;
CONVM REAL The conversion from machine counts to millivolts (see the Thermocouple and
Amplifier specification sheets).
CONVB REAL The conversion bias from machine count to millivolts (see the Thermocouple and
Amplifier specification sheets).
Description
The TCK_CONV function converts a Type K thermocouple input into degrees Celsius and returns the
result.
First, a thermocouple input machine count MC from an Analog Input Module is converted to millivolts
using a bias and scale factor. Next, the millivolts are corrected by cold-junction compensation, using a
quartic equation, which is a function of cold-junction temperature. Lastly, the temperature in degrees
Celsius is computed using a set of quartic equations, which are functions of the corrected millivolts.
Temperatures ranging from –200° C to 1370° C are supported for Type K thermocouples. The cold-
junction compensation temperature must be in the range from –20° C to 500° C.
Note Conversion from millivolts to degrees Celsius is based on the Type K quartic equation
approximation done in three ranges. If the intermediate result is outside the calculable range, the
function returns either –10000 or 10000. For example, if coldJnc < –20 or output < –200, then
output = –10000; if coldJnc > 500 or output > 1370, then output = +10000.
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Triconex (TCXLIB)
TDD_I
Provides a time delay to de-energize.
Syntax
MY_TDD_I( I1:=b1, TGT:=n1 ) ;
Description
The TDD_I function block provides a time delay to de-energize. The delay time is given in integer
milliseconds. If the input is true, then the output is true. After the input changes to false, the output
remains true for the specified delay time, then the output changes to false.
Note If TGT is within one scan period of 2147483647 milliseconds (25 days), then the time accumulator
can overflow to a negative value.
You must invoke an instance of TDD_I exactly once per scan.
Example
VAR MY_TDD_I : TDD_I ; END_VAR
VAR b1, b2 : BOOL ; END_VAR
MY_TDD_I( I1:=b1, 10000 ) ;
b2 := MY_TDD_I.Q1 ;
(* result: The delay time is about 10 seconds from the falling edge of b1 to the falling
edge of b2. *)
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Exactly Once: each instance should be executed exactly once per scan.
• Can be used in CEM Cause, Effect, and Intersection cells.
Library
Standard (STDLIB)
TDD_R
Provides a time delay to de-energize.
Syntax
MY_TDD_R( I1:=b1, TGT:=x1 ) ;
Description
The TDD_R function block provides a time delay to de-energize. The delay time is given in real seconds.
If the input is true, then the output is true. After the input changes to false, the output remains true for
the specified delay time, then the output changes to false.
You must invoke an instance of TDD_R exactly once per scan.
Note The rounding error in the time accumulator increases with time until the accumulator eventually
stops. The rounding error in seconds is less than ACC ACC (50,000,000 T), where ACC is
the accumulated time in seconds and T is the scan period in seconds. The accumulator stops after
ACC > 16,000,000 T. For example, if the scan period is 20 milliseconds, then after one hour, the
rounding error is less than 13 seconds.
Example
VAR MY_TDD_R : TDD_R ; END_VAR
VAR b1, b2 : BOOL ; END_VAR
MY_TDD_R( I1:=b1, 10.0 ) ;
b2 := MY_TDD_R.Q1 ;
(* result: The delay time is about 10 seconds from the falling edge of b1 to the falling
edge of b2. *)
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Exactly Once: each instance should be executed exactly once per scan.
• Can be used in CEM Cause, Effect, and Intersection cells.
Library
Standard (STDLIB)
TDE_I
Provides a time delay to energize.
Syntax
MY_TDE_I( I1:=b1, TGT:=n1 ) ;
Description
The TDE_I function block provides a time delay to energize. The delay time is given in integer
milliseconds. If the input is false, then the output is false. After the input changes to true, the output
remains false for the specified delay time, then the output changes to true.
Note If TGT is within one scan period of 2147483647 milliseconds (25 days), then the time accumulator
can overflow to a negative value.
You must invoke an instance of TDE_I exactly once per scan.
Example
VAR MY_TDE_I : TDE_I ; END_VAR
VAR b1, b2 : BOOL ; END_VAR
MY_TDE_I( I1:=b1, 10000 ) ;
b2 := MY_TDE_I.Q1 ;
(* result: The delay time is about 10 seconds from the rising edge of b1 to the rising
edge of b2. *)
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Exactly Once: each instance should be executed exactly once per scan.
• Can be used in CEM Cause, Effect, and Intersection cells.
Library
Standard (STDLIB)
TDE_R
Provides a time delay to energize.
Syntax
MY_TDE_R( I1:=b1, TGT:=x1 ) ;
Description
The TDE_R function block provides a time delay to energize. The delay time is given in real seconds. If
the input is false, then the output is false. After the input changes to true, the output remains false for the
specified delay time, then the output changes to true.
You must invoke an instance of TDE_R exactly once per scan.
Note The rounding error in the time accumulator increases with time until the accumulator eventually
stops. The rounding error in seconds is less than ACC ACC (50,000,000 T), where ACC is
the accumulated time in seconds and T is the scan period in seconds. The accumulator stops after
ACC > 16,000,000 T. For example, if the scan period is 20 milliseconds, then after one hour, the
rounding error is less than 13 seconds.
Example
VAR MY_TDE_R : TDE_R ; END_VAR
VAR b1, b2 : BOOL ; END_VAR
MY_TDE_R( I1:=b1, 10.0 ) ;
b2 := MY_TDE_R.Q1 ;
(* result: The delay time is about 10 seconds from the rising edge of b1 to the rising
edge of b2. *)
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Exactly Once: each instance should be executed exactly once per scan.
• Can be used in CEM Cause, Effect, and Intersection cells.
Library
Standard (STDLIB)
TIME
A TIME data type refers to a period of time (duration) in days, hours, minutes, seconds, and milliseconds.
The range is 9999 years and the precision is 0.1 milliseconds.
Attribute Description
Keyword/type TIME
Description Duration
Size 64 bits
Syntax TIME#11d
or
TIME#22.2h
or
TIME#33.3m
or
TIME#44.4s
or
TIME#55.5ms
or
TIME#11d22h33m44s55.5ms
or
T#11d22h33m44s55.5ms
or
T#44.4s
Note In TriStation 1131 v4.4 and later, the syntax of the TIME data type is not case-sensitive.
Application Notes
• Can be used in Safety or Control applications.
• Can be used in CEM Cause, Effect, and Intersection cells.
TIME_TO_SECS
Converts time to number of seconds.
Syntax
y := TIME_TO_SECS( t ) ;
Description
The TIME_TO_SECS function converts time to number of seconds.
Example
VAR t : TIME ; y : LREAL ; END_VAR
t := T#500ms ;
y := TIME_TO_SECS( t ) ; (* result is 0.5 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the error flags
to true, and resets ENO to false. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
TIME_TO_SECS_REAL
Converts time to number of seconds.
Syntax
y := TIME_TO_SECS_REAL( t ) ;
Description
The TIME_TO_SECS_REAL function converts time to number of seconds.
Example
VAR t : TIME ; y : REAL ; END_VAR
t := T#500ms ;
y := TIME_TO_SECS( t ) ; (* result is 0.5 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the error flags
to true, and resets ENO to false. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
TIMEADJ
Adjusts the calendar clock.
Syntax
MY_TIMEADJ( CI:=b1, MS:=n1 ) ;
Description
The TIMEADJ function block adjusts the calendar clock.
CI is the control input. Call the function block with CI=true to adjust the clock. Then change CI to false
for the next evaluation.
Note You must clear CI to 0 (False) after adjusting the clock.
MS is the number of milliseconds, positive or negative, by which the clock should be adjusted.
CO is the control output. The function block sets CO to true after the clock is adjusted. CO is false if CI is
false or if an error is detected.
Triconex recommends using the TIMEADJ function block no more than once a
CAUTION day. Using TIMEADJ more frequently can result in excessive time adjustments to
a network and may result in Main Processor re-education.
Example
(*
* Subtract 700 milliseconds from the clock.
*)
VAR MY_TIMEADJ : TIMEADJ ; END_VAR
VAR DO_ADJUST : BOOL ; END_VAR
MY_TIMEADJ( CI:=DO_ADJUST, MS:=-700 ) ;
DO_ADJUST := false ;
Runtime Errors
If the adjusted time is before 00:00:00 on January 1, 1970 or after CO=false BADPARAM, ERROR
23:59:59 on December 31, 2029
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
• Can be used in Safety or Control applications.
• Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
Library
Triconex (TCXLIB)
TIMESET
Sets the calendar clock.
Syntax
MY_TIMESET( CI:=b1, GMT:=n1, MS:=n2 ) ;
GMT DINT The number of seconds elapsed since 00:00:00 Greenwich mean time, January 1, 1970.
GMT must be a positive number.
MS DINT The number of milliseconds (0–999) past the time given in GMT.
Description
The TIMESET function block sets the calendar clock to the time given in GMT and MS.
CI is the control input. Call the function block with CI=true to set the calendar clock. Then change CI to
false for the next evaluation.
Note You must clear CI to 0 (False) after adjusting the clock.
GMT is the Greenwich mean time given in number of seconds elapsed since 00:00:00 on January 1, 1970.
GMT must be a positive number.
MS is the number of milliseconds (0-999) past the time given in GMT.
CO is the control output. CO=true indicates that the time was successfully set. CO=false indicates that the
time was not set. CO is false if an error is detected—for example, if MS is less than 0 or greater than 999.
As a general rule, do not set the time back to previous dates.
Triconex recommends using the TIMESET function no more than once a day.
CAUTION Using TIMESET more frequently can result in excessive time adjustments to a
network and may result in Main Processor re-education. Tricon version 9
systems do not allow you to set the time to a date earlier than December 31, 1993.
Example
(*
* Set the time and date
* to 18:43:53 on February 24, 2003
* plus 160 milliseconds.
*)
VAR MY_TIMESET : TIMESET ; END_VAR
VAR SET_THE_TIME : BOOL ; END_VAR
MY_TIMESET( CI:=SET_THE_TIME, GMT:=1046112233, MS:=160 ) ;
SET_THE_TIME := false ;
Runtime Errors
The range of GMT is 0 <= GMT <= 1893455999 seconds, which represents 00:00:00 on January 1, 1970 to
23:59:59 on December 31, 2029.
The range of MS is 0 <= MS <= 999 milliseconds.
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
• Can be used in Safety or Control applications.
• Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
Library
Triconex (TCXLIB)
TMR
Provides a timer to replace the functionality of the TMR coil in TriStation MSW.
Syntax
MY_TMR( IN:=b1, RESET:=b2, PT:=t1, IT:=t2 ) ;
Description
The TMR function block replaces the functionality of the TMR coil in TriStation MSW.
While the input IN is true, the timer increments the elapsed time accumulator until its value is greater
than or equal to the preset time (input PT). After the preset time is reached, the output Q remains true
until reset.
RESET clears Q and copies IT to ET.
Input IN adds the previous scan period to ET. If IN is true and ET is greater than or equal to PT, then the
function block copies PT to ET and sets Q. If IN is false, then ET holds its current value until reset
PT is the preset time which means the timer expires when ET is greater than or equal to PT.
IT is the initial time that is loaded into ET. The default initial value is T#0s.
Q indicates when the timer expires. Q is set to true when ET increases to PT or beyond. RESET clears Q.
ET is the elapsed time during which input IN is true.
Example
VAR MY_TMR : TMR ; END_VAR
VAR b1, b2 : BOOL ; END_VAR
MY_TMR( IN:=b1, RESET:=NOT b1, PT:=T#10s ) ;
b2 := MY_TMR.Q ;
(* result: The delay time is about 10 seconds from the rising edge of b1 to the rising
edge of b2. *)
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Exactly Once: each instance should be executed exactly once per scan.
• Can be used in CEM Cause, Effect, and Intersection cells.
Library
Triconex (TCXLIB)
TMR_I
Provides a timer to replace the functionality of the TMR coil in TriStation MSW.
Syntax
MY_TMR_I( IN:=b1, RESET:=b2, PT:=n1 ) ;
Description
The TMR_I function block replaces the functionality of the TMR coil in TriStation MSW. It differs from
TMR in that the time is in milliseconds.
While the input IN is true, the timer increments the elapsed time accumulator until its value is greater
than or equal to the preset time (input PT). After the preset time is reached, the output Q remains true
until reset.
RESET clears Q and resets ET to 0.
Input IN adds the previous scan period to ET. If IN is true and ET is greater than or equal to PT, then the
function block copies PT to ET and sets Q. If IN is false, then ET holds its current value until reset
PT is the preset time in milliseconds which means the timer expires when ET is greater than or equal to
PT.
Q indicates when the timer expires. Q is set to true when ET increases to PT or beyond. RESET clears Q.
ET accumulates the elapsed time in milliseconds while input IN is true. ET starts at 0 milliseconds. While
input IN is true, the timer adds the previous scan period to ET until its value is greater than or equal to
PT. After the preset time is reached, the timer sets ET equal to PT.
Note If PT is within one scan period of 2147483647 milliseconds (25 days), then the elapsed time
accumulator can overflow to a negative value.
You must invoke an instance of TMR_I exactly once per scan.
Example
VAR MY_TMR_I : TMR_I ; END_VAR
VAR b1, b2 : BOOL ; END_VAR
MY_TMR_I( IN:=b1, RESET:=NOT b1, PT:=10000 ) ;
b2 := MY_TMR_I.Q ;
(* result: The delay time is about 10 seconds from the rising edge of b1 to the rising
edge of b2. *)
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Exactly Once: each instance should be executed exactly once per scan.
• Can be used in CEM Cause, Effect, and Intersection cells.
Library
Triconex (TCXLIB)
TMR_R
Provides a timer to replace the functionality of the TMR coil in TriStation MSW.
Syntax
MY_TMR_R( IN:=b1, RESET:=b2, PT:=x1 ) ;
Description
The TMR_R function block replaces the functionality of the TMR coil in TriStation MSW. It differs from
TMR in that the time is in seconds.
While the input IN is true, the timer increments the elapsed time accumulator until its value is greater
than or equal to the preset time (input PT). After the preset time is reached, the output Q remains true
until reset.
RESET clears Q and resets ET to 0.0.
Input IN adds the previous scan period to ET. If IN is true and ET is greater than or equal to PT, then the
function block copies PT to ET and sets Q. If IN is false, then ET holds its current value until reset
PT is the preset time in milliseconds which means the timer expires when ET is greater than or equal to
PT.
Q indicates when the timer expires. Q is set to true when ET increases to PT or beyond. RESET clears Q.
ET accumulates the elapsed time in seconds while input IN is true. ET starts at 0.0 seconds. While input
IN is true, the timer adds the previous scan period to ET until its value is greater than or equal to PT. After
the preset time is reached, the timer sets ET equal to PT.
You must invoke an instance of TMR_R exactly once per scan.
Note The rounding error in the elapsed time accumulator increases with time until the accumulator
eventually stops. The rounding error in seconds is less than ET ET (50,000,000 T), where ET
is the elapsed time in seconds and T is the scan period in seconds. The elapsed time accumulator
stops after ET > 16,000,000 T. For example, if the scan period is 20 milliseconds, then after one
hour, the rounding error is less than 13 seconds.
Example
VAR MY_TMR_R : TMR_R ; END_VAR
VAR b1, b2 : BOOL ; END_VAR
MY_TMR_R( IN:=b1, RESET:=NOT b1, PT:=10.0 ) ;
b2 := MY_TMR_R.Q ;
(* result: The delay time is about 10 seconds from the rising edge of b1 to the rising
edge of b2. *)
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Exactly Once: each instance should be executed exactly once per scan.
• Can be used in CEM Cause, Effect, and Intersection cells.
Library
Triconex (TCXLIB)
TOD
A TOD data type refers to a specific time of day expressed in hours, minutes, seconds, and fractions (FFF)
of a second. The precision is 0.001 seconds.
Attribute Description
Keyword/type TOD
Size 64 bits
Syntax TOD#HH:MM:SS
or
TOD#HH:MM:SS.FFF
or
TIME_OF_DAY#HH:MM:SS
Application Notes
• Can be used in Safety or Control applications.
• Can be used in CEM Cause, Effect, and Intersection cells.
TOF
Delays the falling edge of a pulse.
Syntax
MY_TOF( IN:=b1, PT:=t1 ) ;
Description
The TOF function block provides a delay of duration PT from the falling edge of input IN to the falling
edge of output Q.
IN is the input pulse. The falling edge of IN starts the timer. While IN is false, after a delay of duration
PT, the timer changes Q to false. If at any time the input IN changes to true, the timer resets, changing Q
to true and ET to zero.
PT gives the duration of the delay.
Q is the output pulse. Q is initially true. Q changes from true to false after the specified delay time. Q
changes from false to true when the input changes from false to true.
ET gives the elapsed time from the falling edge of IN, while IN is false and Q is true. While IN is false and
Q is false, ET is equal to PT. If IN is true, then ET is zero.
If input IN is true, then TOF sets output Q to true and the elapsed time to zero. If the width of input IN is
less than PT, then output Q does not change, but while IN is false, output ET still gives the elapsed time
since the falling edge of input IN.
If the initial value of input IN is false, then the timer does not start and Q remains false until input IN
changes to true.
Example
VAR MY_TOF : TOF ; END_VAR
VAR b1, b2 : BOOL ; END_VAR
MY_TOF( IN:=b1, PT:=T#10s ) ;
b2 := MY_TOF.Q ;
(* result: The delay time is about 10 seconds from the falling edge of b1 to the falling
edge of b2. *)
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
• Can be used in CEM Cause, Effect, and Intersection cells.
Library
Standard (STDLIB)
TOGGLE
Replaces the functionality of the TGL coil in TriStation MSW.
Syntax
MY_TOGGLE( IN:=b1, RESET:=b2 ) ;
Description
The TOGGLE function block replaces the functionality of the TGL coil in TriStation MSW.
IN toggles Q if RESET is false. Toggle means to change the state, that is, from false to true or true to false.
RESET resets Q (to false).
Q is the output that toggles.
IN RESET Q
Example
VAR MY_TOGGLE : TOGGLE ; END_VAR
MY_TOGGLE( IN:=FALSE, RESET:=TRUE ); (* Q is FALSE *)
MY_TOGGLE( IN:=FALSE, RESET:=FALSE ); (* Q is FALSE *)
MY_TOGGLE( IN:=TRUE, RESET:=TRUE ); (* Q is FALSE *)
MY_TOGGLE( IN:=TRUE, RESET:=FALSE ); (* Q is TRUE *)
MY_TOGGLE( IN:=FALSE, RESET:=FALSE ); (* Q is TRUE *)
MY_TOGGLE( IN:=TRUE, RESET:=FALSE ); (* Q is FALSE *)
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
• Can be used in CEM Cause, Effect, and Intersection cells.
Library
Triconex (TCXLIB)
TON
Delays the rising edge of a pulse.
Syntax
MY_TON( IN:=b1, PT:=t1 ) ;
Description
The TON function block provides a delay of duration PT from the rising edge of input IN to the rising
edge of output Q.
IN is the input pulse. The rising edge of IN starts the timer. While IN is true, after a delay of duration PT,
the timer changes Q to true. If at any time the input IN changes to false, the timer resets, changing Q to
false and ET to zero.
PT gives the duration of the delay.
Q is the output pulse. Q is initially false. Q changes from false to true after the specified delay time. Q
changes from true to false when the input changes from true to false.
Output ET (elapsed time) gives the time since the rising edge of input IN. The maximum value of ET is PT.
ET gives the elapsed time from the rising edge of IN, while IN is true and Q is false. While IN is true and
Q is true, ET is equal to PT. If IN is false, then ET is zero.
If the width of input IN is less than PT, then output Q does not change.
Example
VAR MY_TON : TON ; END_VAR
VAR b1, b2 : BOOL ; END_VAR
MY_TON( IN:=b1, PT:=T#10s ) ;
b2 := MY_TON.Q ;
(* result: The delay time is about 10 seconds from the rising edge of b1 to the rising
edge of b2. *)
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
• Can be used in CEM Cause, Effect, and Intersection cells.
Library
Standard (STDLIB)
TP
Generates a timed pulse.
Syntax
MY_TP( IN:=b1, PT:=t1 ) ;
Description
The TP function block generates a pulse of duration PT starting on the rising edge of input IN.
IN is an input pulse. The rising edge of IN starts the timer, setting Q to true. While Q is true, the timer
ignores IN.
PT gives the requested duration of the pulse. When Q is true and ET is greater than or equal to PT, the
timer resets Q to false.
Q is the output pulse. The timer sets Q true on the rising edge of IN. Q remains true for time PT, and then
changes to false.
ET is the elapsed time from the rising edge of Q while Q is true. After the falling edge of Q, ET is equal to
PT while input IN remains true. ET is zero if IN and Q are both false.
Example
VAR MY_TP : TP ; END_VAR
VAR b1, b2 : BOOL ; END_VAR
MY_TP( IN:=b1, PT:=T#10s ) ;
b2 := MY_TP.Q ;
(* The result b2 is a pulse of approximately 10 seconds following the rising edge of
b1. *)
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
• Can be used in CEM Cause, Effect, and Intersection cells.
Library
Standard (STDLIB)
TP_I
Generates a timed pulse.
Syntax
MY_TP_I( IN:=b1, PT:=n1 ) ;
Description
The TP_I function block generates a pulse of width PT milliseconds starting on the rising edge of input IN.
IN is an input pulse. The rising edge of IN starts the timer, setting Q to true. While Q is true, the timer
ignores IN.
PT gives the requested duration of the pulse in milliseconds. When Q is true and the pulse width is
greater than or equal to PT milliseconds, the timer resets Q to false.
Q is the output pulse. The timer sets Q true on the rising edge of IN. Q remains true for time PT
milliseconds, and then changes to false.
Note If PT is within one scan period of 2147483647 milliseconds (25 days), then the time accumulator
can overflow to a negative value.
You must invoke an instance of TP_I exactly once per scan.
Example
VAR MY_TP_I : TP_I ; END_VAR
VAR b1, b2 : BOOL ; END_VAR
MY_TP_I( IN:=b1, PT:=10000 ) ;
b2 := MY_TP_I.Q ;
(* The result b2 is a pulse of approximately 10 seconds following the rising edge of
b1. *)
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Exactly Once: each instance should be executed exactly once per scan.
• Can be used in CEM Cause, Effect, and Intersection cells.
Library
Standard (STDLIB)
TP_R
Generates a timed pulse.
Syntax
MY_TP_R( IN:=b1, PT:=x1 ) ;
Description
The TP_R function block generates a pulse of width PT seconds starting on the rising edge of input IN.
IN is an input pulse. The rising edge of IN starts the timer, setting Q to true. While Q is true, the timer
ignores IN.
PT gives the requested duration of the pulse in seconds. When Q is true and the pulse width is greater
than or equal to PT seconds, the timer resets Q to false.
Q is the output pulse. The timer sets Q true on the rising edge of IN. Q remains true for time PT seconds,
and then changes to false.
You must invoke an instance of TP_R exactly once per scan.
Note The rounding error in the time accumulator increases with time until the accumulator eventually
stops. The rounding error in seconds is less than ACC ACC (50,000,000 T), where ACC is
the accumulated time in seconds and T is the scan period in seconds. The accumulator stops after
ACC > 16,000,000 T. For example, if the scan period is 20 milliseconds, then after one hour, the
rounding error is less than 13 seconds.
Example
VAR MY_TP_R : TP_R ; END_VAR
VAR b1, b2 : BOOL ; END_VAR
MY_TP_R( IN:=b1, PT:=10.0 ) ;
b2 := MY_TP_R.Q ;
(* The result b2 is a pulse of approximately 10 seconds following the rising edge of
b1. *)
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Exactly Once: each instance should be executed exactly once per scan.
• Can be used in CEM Cause, Effect, and Intersection cells.
Library
Standard (STDLIB)
TR_64_POINT_STATUS
Gets point information, specifically LOAD/FUSE and diagnostic status for up to 64 points, from a Tricon
controller.
Syntax
MY_TR_64_POINT_STATUS( CI:=b1, CHASSIS:=n1, SLOT:=n2 ) ;
FUSE_01_32 DWORD The status of a point on a module (point 01 is least significant bit, point 32 is
most significant bit).
• 0 =Good point
• 1 =Bad point
FUSE_33_64 DWORD The status of a point on a module (point 33 is least significant bit, point 64 is
most significant bit).
FAULT_01_32 DWORD The diagnostic status of a point on a module (point 01 is least significant bit,
point 32 is most significant bit).
If an output module:
• 0 = Point passed output voter diagnostic (OVD) most significant bit.
• 1 = Point failed OVD.
If an input module:
• 0 =Point passed the compare test.
• 1 =Point failed the compare test.
FAULT_33_64 DWORD The diagnostic status of a point on a module (point 33 is least significant bit,
point 64 is most significant bit).
Description
The TR_64_POINT_STATUS function block gets point information, specifically LOAD/FUSE and
diagnostic status for up to 64 points, from a Tricon controller.
Example
(* Get the status for chassis 1 slot 5. *)
VAR MY_TR_64_POINT_STATUS : TR_64_POINT_STATUS ; END_VAR
MY_TR_64_POINT_STATUS( CI:=TRUE, CHASSIS:=1, SLOT:=5 ) ;
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
• Can be used in Safety or Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, Using a Space Saver Function Block on page 6.
Library
Tricon (TR1LIB/TX1LIB)
TR_CALENDAR
Gets calendar values from a Tricon controller.
Syntax
MY_TR_CALENDAR( CI:= b1 ) ;
Description
The TR_CALENDAR function block gets the date and time from a Tricon controller.
Example
(*
* Get the current day of the month.
*)
VAR NOW : TR_CALENDAR ; END_VAR
VAR TODAY : DINT ; END_VAR
NOW() ;
TODAY := NOW.DAY
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
Tricon (TR1LIB/TX1LIB)
TR_CHASSIS_STATUS
Gets the chassis status from a Tricon controller.
Syntax
MY_TR_CHASSIS_STATUS( CI:=b1, CHASSIS:=n1 ) ;
UPPERPOWER BOOL True if the upper power supply in the chassis has a fault.
LOWERPOWER BOOL True if the lower power supply in the chassis has a fault.
Description
The TR_CHASSIS_STATUS function block gets the chassis status from a Tricon controller.
Example
(* Get the status for chassis 3. *)
VAR MY_TR_CHASSIS_STATUS : TR_CHASSIS_STATUS ; END_VAR
MY_TR_CHASSIS_STATUS( CHASSIS:=3 ) ;
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
• Can be used in Safety or Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
Tricon (TR1LIB/TX1LIB)
TR_CLEAR_FLTS
Clears all faults in the system.
Syntax
ERROR_NUMBER := TR_CLEAR_FLTS( CLEAR_FLTS := TRUE );
Description
The TR_CLEAR_FLTS function clears all alarms from the system. If the input is true, all alarms are
cleared.
Example
(* Clear fault alarms. *)
VAR ERROR_NUMBER : DINT ; END_VAR
ERROR_NUMBER := TR_CLEAR_FLTS( CLEAR_FLTS := TRUE );
Runtime Errors
Upon detection of a runtime error, the function resets ENO and sets the BADPARAM status flag. For
more information about error flags and runtime errors, see the CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Tricon (TX1LIB)
This function was added to the library in v1.62 of TX1LIB, first released with TriStation 1131 v4.1.419.
TR_CRITICAL_IO
Accumulates the status of safety-critical I/O modules in a Tricon controller.
Syntax
MY_TR_CRITICAL_IO( CI:=b1, INIT:=b2, CHASSIS:=n1, SLOT:=n2, APP:=n3, RELAY_OK:=b3 ) ;
TMR BOOL Three channels are operating without fatal faults on critical I/O modules
detected.
GE_DUAL BOOL Two channels are operating without fatal faults on critical I/O modules
detected.
GE_SINGLE BOOL At least one channel is operating without faults on critical I/O modules
detected.
Description
The TR_CRITICAL_IO function block accumulates the status of all safety-critical I/O modules in a Tricon
controller. For more information, see the Safety Considerations Guide for Tricon Systems.
Example
For shutdown examples, see this sample project:
• ExTUV.pt2 (For Tricon controllers)
Note See Sample Projects on page 7 for information about where to find this project on the PC where
you installed TriStation 1131.
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
Can be used in Safety or Control applications.
Library
Tricon (TR1LIB/TX1LIB)
TR_MP_STATUS
Gets the status of the Main Processor.
Syntax
MY_TR_MP_STATUS( CI:=b1 ) ;
MPBAD BOOL Two MPs are out-of-sync or have failed, or the controller is running in simplex
mode.
Description
The TR_MP_STATUS function block gets the status of the Main Processor.
Example
(* Get the main processor status. *)
VAR MY_TR_MP_STATUS : TR_MP_STATUS ; END_VAR
MY_TR_MP_STATUS() ;
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
Tricon (TR1LIB/TX1LIB)
TR_PEER_STATUS
Gets the Peer-to-Peer status of a node.
Syntax
MY_TR_PEER_STATUS( CI:=b1, NODE:=n1 ) ;
COMM_OK BOOL One path going to the specified node from this node is OK.
COMM_REDUNDANT BOOL Two paths going to the specified node from this node are OK.
Description
The TR_PEER_STATUS function block gets the Peer-to-Peer status of a node.
Example
For Peer-to-Peer examples, see these sample projects:
• ExPeer.pt2 (For Tricon controllers)
• TdPeer.pt2 (For Trident or Tri-GP controllers)
Note See Sample Projects on page 7 for information about where to find these projects on the PC where
you installed TriStation 1131.
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
• Can be used in Safety or Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
Tricon (TR1LIB/TX1LIB)
TR_POINT_STATUS
Gets the status of a point from a Tricon controller.
Syntax
MY_TR_POINT_STATUS( CI:=b1, CHASSIS:=n1, SLOT:=n2, POINT:=n3 ) ;
LOADFUSE BOOL The output point has a fault and the load/fuse indicator on the module is on.
FAULT BOOL The output point has an OVD failure or an input point has a compare error.
Description
The TR_POINT_STATUS function block gets the status of a point from a Tricon controller.
Example
(* Get the status for chassis 1 slot 5 point 7. *)
VAR MY_TR_POINT_STATUS : TR_POINT_STATUS ; END_VAR
MY_TR_POINT_STATUS( CI:=TRUE, CHASSIS:=1, SLOT:=5, POINT:=7 ) ;
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
• Can be used in Safety or Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
Tricon (TR1LIB/TX1LIB)
TR_PORT_STATUS
Gets the status of a Tricon Communication Module (TCM), Network Communication Module (NCM), or
an Advanced Communication Module (ACM).
Syntax
MY_TR_PORT_STATUS( CI:=b1 ) ;
NCM_NET1R_OK BOOL Port 1 of a communication module in the right slot is. operational.
Description
The TR_PORT_STATUS function block gets the status of aTricon Communication Module (TCM),
Network Communication Module (NCM), or an Advanced Communication Module (ACM). The NET1
status is not used with the ACM. When there is more than one communication module installed, and both
are in the same type of slot (left or right), the corresponding status (NET1L/NET2L, and NET1R/NET2R,
respectively) are not defined.
Example
(* Get the port status. *)
VAR MY_TR_PORT_STATUS : TR_PORT_STATUS ; END_VAR
MY_TR_PORT_STATUS() ;
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
Tricon (TR1LIB/TX1LIB)
TR_PROGRAM_STATUS
Gets the status of a Tricon program.
Syntax
MY_TR_PROGRAM_STATUS( CI:=b1 ) ;
WRITE_ENABLED BOOL True if write access from an external host is enabled for any
ALIAS.
Description
The TR_PROGRAM_STATUS function block gets the status of a program.
When DISABLE_NOT_ALLOWED is false (0), a user can disable points, and a program instance calls a
function to store the value of an output point.
When DISABLE_NOT_ALLOWED is true (1), a user cannot disable points and the scan time is shorter
because a program instance stores the value of an output point without calling a function.
Example
(* Get the program status. *)
VAR MY_TR_PROGRAM_STATUS : TR_PROGRAM_STATUS ; END_VAR
MY_TR_PROGRAM_STATUS() ;
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
Tricon (TR1LIB/TX1LIB)
TR_SCAN_STATUS
Gets the status of a scan.
Syntax
MY_TR_SCAN_STATUS( CI:=b1 ) ;
SCANSURPLUS DINT The average surplus scan time for last 100 scans.
SCANDELTA DINT The measured scan time, in milliseconds, for the current scan.
DELTAT TIME The measured scan time for the current scan.
SCANOVERRUN DINT The average number of scan overruns for the last 100 scans.
Description
The TR_SCAN_STATUS function block gets the status of a scan.
Example
(* Get the scan status. *)
VAR MY_TR_SCAN_STATUS : TR_SCAN_STATUS ; END_VAR
MY_TR_SCAN_STATUS() ;
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
Tricon (TR1LIB/TX1LIB)
TR_SHUTDOWN
Enables a Tricon system shutdown according to industry guidelines.
Syntax
MY_TR_SHUTDOWN( CI:=b1, IO_CO:=b2, IO_TMR:=b3, IO_GE_DUAL:=b4, IO_GE_SINGLE:=b5,
IO_NO_VOTER_FLTS:=b6, IO_ERROR:=n1, MAX_TIME_DUAL:=t1, MAX_TIME_SINGLE:=t2,
MAX_SCAN_TIME:=t3 ) ;
IO_TMR BOOL Three channels are operating without fatal faults detected.
IO_GE_DUAL BOOL Two channels are operating without fatal faults detected.
MAX_TIME_DUAL TIME The maximum time of continuous operation in dual mode (two
channels operating).
MAX_TIME_SINGLE TIME The maximum time of continuous operation in single mode (one
channel operating).
Description
The TR_SHUTDOWN function block enables a Tricon system shutdown according to industry
guidelines. For more information, see the Safety Considerations Guide for Tricon v9-v10 Systems.
Example
For shutdown examples, see this sample project:
• ExTUV.pt2 (For Tricon controllers)
Note See Sample Projects on page 7 for information about where to find this project on the PC where
you installed TriStation 1131.
Runtime Errors
If ERROR is non-zero Set alarm outputs to true, reset the other BOOL BADPARAM, ERROR
outputs to false, and reset TIME_LEFT to zero.
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
If a programming error or configuration error occurs, then CO is false and the error number is non-zero.
For error numbers, see the description of the ERROR output.
Application Notes
Can be used in Safety or Control applications.
Library
Tricon (TR1LIB/TX1LIB)
TR_SLOT_STATUS
Gets the status of a Tricon controller slot.
Syntax
MY_TR_SLOT_STATUS( CI:=b1, CHASSIS:=n1, SLOT:=n2 ) ;
PASS BOOL I/O module is installed in the slot and the pass indicator is on.
FAIL BOOL An I/O module is installed in the slot and the fail indicator is on.
ACTIVE BOOL An I/O module is installed in the slot and the active indicator is on.
LOADFUSE BOOL An I/O module is installed in the slot and the load/fuse indicator is on.
VOTER_FAULT BOOL An I/O module is installed in the slot and a point has a voter fault.
OVD_ENABLED BOOL An I/O module is installed in the slot and output voter diagnostics are
enabled.
NOGOOD BOOL The I/O module installed in the slot is operating in SINGLE mode for at
least one point. Please refer to the Safety Considerations Guide for Tricon v9-
v10 Systems for SINGLE mode SIL operation time guidelines.
Description
The TR_SLOT_STATUS function block gets the status of a Tricon controller slot.
Example
(* Get the status for chassis 1 slot 5. *)
VAR MY_TR_SLOT_STATUS : TR_SLOT_STATUS ; END_VAR
MY_TR_SLOT_STATUS( CI:=TRUE, CHASSIS:=1, SLOT:=5 ) ;
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
• Can be used in Safety or Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
Tricon (TR1LIB/TX1LIB)
TR_URCV_BOOL
Receives up to 20 data values from a matching TR_USEND_BOOL function block on another Triconex
controller.
Syntax
MY_TR_URCV_BOOL( CI:=b1, RECVID:=n1, SENDNODE:=n2, SENDID:=n3, N:=n4 ) ;
RECVID DINT The unique identifier for a TR_URCV_BOOL function block (1–99).
SENDNODE DINT Specifies which node sends data to a TR_URCV_BOOL function block (1–63).
SENDID DINT The unique identifier for a matching TR_USEND_BOOL function block in a
sending controller (1–99).
Description
The TR_URCV_BOOL function block receives up to 20 data values from a matching TR_USEND_BOOL
function block on another Triconex controller. For detailed descriptions of the input and output
parameters, see Appendix B, Peer-to-Peer Parameters.
For information about setting the number of send and receive functions and determining data transfer
time, see the TriStation 1131 Developer’s Guide.
Example
For Peer-to-Peer examples, see these sample projects:
• ExPeer.pt2 (For Tricon controllers)
• TdPeer.pt2 (For Trident or Tri-GP controllers)
Note See Sample Projects on page 7 for information about where to find these projects on the PC where
you installed TriStation 1131.
Runtime Errors
For error numbers, see the description for the STATUS output.
Application Notes
• Can be used in Safety or Control applications.
• Exactly Once: each instance should be executed exactly once per scan.
Library
Tricon (TR1LIB/TX1LIB)
TR_URCV_DINT
Receives up to 20 data values from a matching TR_USEND_DINT function block on another Triconex
controller.
Syntax
MY_TR_URCV_DINT( CI:=b1, RECVID:=n1, SENDNODE:=n2, SENDID:=n3, N:=n4 ) ;
RECVID DINT The unique identifier for a TR_URCV_DINT function block (1–99).
SENDNODE DINT Specifies which node sends data to a TR_URCV_DINT function block (1–63).
SENDID DINT The unique identifier for a matching TR_USEND_DINT function block in a
sending controller (1–99).
Description
The TR_URCV_DINT function block receives up to 20 data values from a matching TR_USEND_DINT
function block on another Triconex controller. For detailed descriptions of the input and output
parameters, see Appendix B, Peer-to-Peer Parameters.
For information about setting the number of send and receive functions and determining data transfer
time, see the TriStation 1131 Developer’s Guide.
Example
For Peer-to-Peer examples, see these sample projects:
• ExPeer.pt2 (For Tricon controllers)
• TdPeer.pt2 (For Trident or Tri-GP controllers)
Note See Sample Projects on page 7 for information about where to find these projects on the PC where
you installed TriStation 1131.
Runtime Errors
For error numbers, see the description for the STATUS output.
Application Notes
• Can be used in Safety or Control applications.
• Exactly Once: each instance should be executed exactly once per scan.
Library
Tricon (TR1LIB/TX1LIB)
TR_URCV_DINT_32
Receives up to 32 data values from a matching TR_USEND_DINT_32 function block on another Triconex
controller.
Syntax
MY_TR_URCV_DINT_32( CI:=b1, RECVID:=n1, SENDNODE:=n2, SENDID:=n3, N:=n4 ) ;
RECVID DINT The unique identifier for a TR_URCV_DINT_32 function block (1–99).
SENDNODE DINT Specifies which node sends data to a TR_URCV_DINT_32 function block (1–63).
SENDID DINT The unique identifier for a matching TR_USEND_DINT_32 function block in a
sending controller (1–99).
Description
The TR_URCV_DINT_32 function block receives up to 32 data values from a matching
TR_USEND_DINT_32 function block on another Triconex controller. For detailed descriptions of the
input and output parameters, see Appendix B, Peer-to-Peer Parameters.
For information about setting the number of send and receive functions and determining data transfer
time, see the TriStation 1131 Developer’s Guide.
Example
For Peer-to-Peer examples, see these sample projects:
• ExPeer.pt2 (For Tricon controllers)
• TdPeer.pt2 (For Trident or Tri-GP controllers)
Note See Sample Projects on page 7 for information about where to find these projects on the PC where
you installed TriStation 1131.
Runtime Errors
For error numbers, see the description for the STATUS output.
Application Notes
• Can be used in Safety or Control applications.
• Exactly Once: each instance should be executed exactly once per scan.
Library
Tricon (TR1LIB/TX1LIB)
TR_URCV_REAL
Receives up to 20 data values from a matching TR_USEND_REAL function block on another Triconex
controller.
Syntax
MY_TR_URCV_REAL( CI:=b1, RECVID:=n1, SENDNODE:=n2, SENDID:=n3, N:=n4 ) ;
RECVID DINT The unique identifier for a TR_URCV_REAL function block (1–99).
SENDNODE DINT Specifies which node sends data to a TR_URCV_REAL function block (1–63).
SENDID DINT The unique identifier for a matching TR_USEND_REAL function block in a
sending controller (1–99).
Description
The TR_URCV_REAL function block receives up to 20 data values from a matching TR_USEND_REAL
function block on another Triconex controller. For detailed descriptions of the input and output
parameters, see Appendix B, Peer-to-Peer Parameters.
For information about setting the number of send and receive functions and determining data transfer
time, see the TriStation 1131 Developer’s Guide.
Example
For Peer-to-Peer examples, see these sample projects:
• ExPeer.pt2 (For Tricon controllers)
• TdPeer.pt2 (For Trident or Tri-GP controllers)
Note See Sample Projects on page 7 for information about where to find these projects on the PC where
you installed TriStation 1131.
Runtime Errors
For error numbers, see the description for the STATUS output.
Application Notes
• Can be used in Safety or Control applications.
• Exactly Once: each instance should be executed exactly once per scan.
Library
Tricon (TR1LIB/TX1LIB)
TR_URCV_REAL_32
Receives up to 32 data values from a matching TR_USEND_REAL_32 function block on another Triconex
controller.
Syntax
MY_TR_URCV_REAL_32( CI:=b1, RECVID:=n1, SENDNODE:=n2, SENDID:=n3, N:=n4 ) ;
RECVID DINT The unique identifier for a TR_URCV_REAL_32 function block (1–99).
SENDNODE DINT Specifies which node sends data to a TR_URCV_REAL_32 function block (1–63).
SENDID DINT The unique identifier for a matching TR_USEND_REAL_32 function block in a
sending controller (1–99).
Description
The TR_URCV_REAL_32 function block receives up to 32 data values from a matching
TR_USEND_REAL_32 function block on another Triconex controller. For detailed descriptions of the
input and output parameters, see Appendix B, Peer-to-Peer Parameters.
For information about setting the number of send and receive functions and determining data transfer
time, see the TriStation 1131 Developer’s Guide.
Example
For Peer-to-Peer examples, see these sample projects:
• ExPeer.pt2 (For Tricon controllers)
• TdPeer.pt2 (For Trident or Tri-GP controllers)
Note See Sample Projects on page 7 for information about where to find these projects on the PC where
you installed TriStation 1131.
Runtime Errors
For error numbers, see the description for the STATUS output.
Application Notes
• Can be used in Safety or Control applications.
• Exactly Once: each instance should be executed exactly once per scan.
Library
Tricon (TR1LIB/TX1LIB)
TR_USEND_BOOL
Sends up to 20 data values to a matching TR_URCV_BOOL function block on another Triconex controller.
Syntax
MY_TR_USEND_BOOL( SENDFLG:=b1, SENDID:=n1, RECVNODE:=n2, RECVID:=n3, N:=n4, SD_01:=d1,
..., SD_20:=d20 ) ;
SENDID DINT The unique identifier for a TR_USEND_BOOL function block (1–99).
RECVNODE DINT Specifies which controller node receives data from a TR_USEND_BOOL
function block (1–63).
RECVID DINT The unique identifier for a matching TR_URCV_BOOL function block in a
receiving controller (1–99).
Description
The TR_USEND_BOOL function block sends up to 20 data values to a matching TR_URCV_BOOL
function block on another Triconex controller. For detailed descriptions of the input and output
parameters, see Appendix B, Peer-to-Peer Parameters.
For information about setting the number of send and receive functions and determining data transfer
time, see the TriStation 1131 Developer’s Guide.
Example
For Peer-to-Peer examples, see these sample projects:
• ExPeer.pt2 (For Tricon controllers)
• TdPeer.pt2 (For Trident or Tri-GP controllers)
Note See Sample Projects on page 7 for information about where to find these projects on the PC where
you installed TriStation 1131.
Runtime Errors
For error numbers, see the description for the STATUS output.
Application Notes
• Can be used in Safety or Control applications.
• Exactly Once: each instance should be executed exactly once per scan.
Library
Tricon (TR1LIB/TX1LIB)
TR_USEND_DINT
Sends up to 20 data values to a matching TR_URCV_DINT function block on another Triconex controller.
Syntax
MY_TR_USEND_DINT( SENDFLG:=b1, SENDID:=n1, RECVNODE:=n2, RECVID:=n3, N:=n4, SD_01:=d1,
..., SD_20:=d20 ) ;
SENDID DINT The unique identifier for a TR_USEND_DINT function block (1–99).
RECVNODE DINT Specifies which controller node receives data from a TR_USEND_DINT function
block (1–63).
RECVID DINT The unique identifier for a matching TR_URCV_DINT function block in a
receiving controller (1–99).
Description
The TR_USEND_DINT function block ends up to 20 data values to a matching TR_URCV_DINT function
block on another Triconex controller. For detailed descriptions of the input and output parameters, see
Appendix B, Peer-to-Peer Parameters.
For information about setting the number of send and receive functions and determining data transfer
time, see the TriStation 1131 Developer’s Guide.
Example
For Peer-to-Peer examples, see these sample projects:
• ExPeer.pt2 (For Tricon controllers)
• TdPeer.pt2 (For Trident or Tri-GP controllers)
Note See Sample Projects on page 7 for information about where to find these projects on the PC where
you installed TriStation 1131.
Runtime Errors
For error numbers, see the description for the STATUS output.
Application Notes
• Can be used in Safety or Control applications.
• Exactly Once: each instance should be executed exactly once per scan.
Library
Tricon (TR1LIB/TX1LIB)
TR_USEND_DINT_32
Sends up to 32 data values to a matching TR_URCV_DINT_32 function block on another Triconex
controller.
Syntax
MY_TR_USEND_DINT_32( SENDFLG:=b1, SENDID:=n1, RECVNODE:=n2, RECVID:=n3, N:=n4,
SD_01:=d1, ..., SD_32:=d32 ) ;
SENDID DINT The unique identifier for a TR_USEND_DINT_32 function block (1–99).
RECVNODE DINT Specifies which controller node receives data from a TR_USEND_DINT_32
function block (1–63).
RECVID DINT The unique identifier for a matching TR_URCV_DINT_32 function block in a
receiving controller (1–99).
Description
The TR_USEND_DINT_32 function block sends up to 32 data values to a matching TR_URCV_DINT_32
function block on another Triconex controller. For detailed descriptions of the input and output
parameters, see Appendix B, Peer-to-Peer Parameters.
For information about setting the number of send and receive functions and determining data transfer
time, see the TriStation 1131 Developer’s Guide.
Example
For Peer-to-Peer examples, see these sample projects:
• ExPeer.pt2 (For Tricon controllers)
• TdPeer.pt2 (For Trident or Tri-GP controllers)
Note See Sample Projects on page 7 for information about where to find these projects on the PC where
you installed TriStation 1131.
Runtime Errors
For error numbers, see the description for the STATUS output.
Application Notes
• Can be used in Safety or Control applications.
• Exactly Once: each instance should be executed exactly once per scan.
Library
Tricon (TR1LIB/TX1LIB)
TR_USEND_REAL
Sends up to 20 data values to a matching TR_URCV_REAL function block on another Triconex controller.
Syntax
MY_TR_USEND_REAL( SENDFLG:=b1, SENDID:=n1, RECVNODE:=n2, RECVID:=n3, N:=n4, SD_01:=d1,
..., SD_20:=d20 ) ;
SENDID DINT The unique identifier for a TR_USEND_REAL function block (1–99).
RECVNODE DINT Specifies which controller node receives data from a TR_USEND_REAL function
block (1–63).
RECVID DINT The unique identifier for a matching TR_URCV_REAL function block in a
receiving controller (1–99).
Description
The TR_USEND_REAL function block sends up to 20 data values to a matching TR_URCV_REAL
function block on another Triconex controller. For detailed descriptions of the input and output
parameters, see Appendix B, Peer-to-Peer Parameters.
For information about setting the number of send and receive functions and determining data transfer
time, see the TriStation 1131 Developer’s Guide.
Example
For Peer-to-Peer examples, see these sample projects:
• ExPeer.pt2 (For Tricon controllers)
• TdPeer.pt2 (For Trident or Tri-GP controllers)
Note See Sample Projects on page 7 for information about where to find these projects on the PC where
you installed TriStation 1131.
Runtime Errors
For error numbers, see the description for the STATUS output.
Application Notes
• Can be used in Safety or Control applications.
• Exactly Once: each instance should be executed exactly once per scan.
Library
Tricon (TR1LIB/TX1LIB)
TR_USEND_REAL_32
Sends up to 32 data values to a matching TR_URCV_REAL_32 function block on another Triconex
controller.
Syntax
MY_TR_USEND_REAL_32( SENDFLG:=b1, SENDID:=n1, RECVNODE:=n2, RECVID:=n3, N:=n4,
SD_01:=d1, ..., SD_32:=d32 ) ;
SENDID DINT The unique identifier for a TR_USEND_REAL_32 function block (1-99).
RECVNODE DINT Specifies which controller node receives data from a TR_USEND_REAL_32
function block (1–63).
RECVID DINT The unique identifier for a matching TR_URCV_REAL_32 function block in a
receiving controller (1–99).
Description
The TR_USEND_REAL_32 function block sends up to 32 data values to a matching TR_URCV_REAL_32
function block on another Triconex controller. For detailed descriptions of the input and output
parameters, see Appendix B, Peer-to-Peer Parameters.
For information about setting the number of send and receive functions and determining data transfer
time, see the TriStation 1131 Developer’s Guide.
Example
For Peer-to-Peer examples, see these sample projects:
• ExPeer.pt2 (For Tricon controllers)
• TdPeer.pt2 (For Trident or Tri-GP controllers)
Note See Sample Projects on page 7 for information about where to find these projects on the PC where
you installed TriStation 1131.
Runtime Errors
For error numbers, see the description for the STATUS output.
Application Notes
• Can be used in Safety or Control applications.
• Exactly Once: each instance should be executed exactly once per scan.
Library
Tricon (TR1LIB/TX1LIB)
TR_VOTE_MODE
Converts redundancy status.
Syntax
MY_TR_VOTE_MODE( CI:=b1, IN_TMR:=b2, GE_DUAL:=b3, GE_SINGLE:=b4 ) ;
Description
The TR_VOTE_MODE function block converts redundancy status, as shown in this truth table.
T T T T F F F
F T T F T F F
F F T F F T F
F F F F F F T
Othera F F F F
a. If an error in the inputs occurs, then CO is false, the mode outputs are
false, and the function block reports a bad parameter error
(BADPARAM).
Example
For shutdown examples, see this sample project:
• ExTUV.pt2 (For Tricon controllers)
Note See Sample Projects on page 7 for information about where to find this project on the PC where
you installed TriStation 1131.
Runtime Errors
If the inputs do not match one of the first four Reset all BOOL outputs to false BADPARAM, ERROR
rows of the truth table
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
• Can be used in Safety or Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
Tricon (TR1LIB/TX1LIB)
TRUNC_LREAL_TO_DINT
Truncates a 64-bit long real number to a 32-bit integer.
Syntax
k := TRUNC_LREAL_TO_DINT(x);
Description
The TRUNC_LREAL_TO_DINT function converts a 64-bit long real number to a 32-bit integer with
truncation instead of rounding, which means the fraction is dropped.
Note IEC 1131-3 requires strict data type checking. It does not permit assigning the value of a variable
directly to a variable of a different data type. When it is necessary to use variables of different
data types, an explicit conversion must be made using a data type conversion function.
Example
VAR k : DINT; x : LREAL; END_VAR;
x := -123.6;
k := TRUNC_LREAL_TO_DINT( x ); (* result is -123 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the error flags
to true, and resets ENO to false. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
TRUNC_LREAL_TO_INT
Truncates a 64-bit long real number to a 16-bit integer.
Syntax
k := TRUNC_LREAL_TO_INT(x);
Description
The TRUNC_LREAL_TO_INT function converts a 64-bit long real number to a 16-bit integer with
truncation instead of rounding, which means the fraction is dropped.
Note IEC 1131-3 requires strict data type checking. It does not permit assigning the value of a variable
directly to a variable of a different data type. When it is necessary to use variables of different
data types, an explicit conversion must be made using a data type conversion function.
Example
VAR k : INT; x : LREAL; END_VAR;
x := -123.6;
k := TRUNC_LREAL_TO_INT( x ); (* result is -123 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the error flags
to true, and resets ENO to false. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
TRUNC_REAL_TO_DINT
Truncates a 32-bit real number to a 32-bit integer.
Syntax
k := TRUNC_REAL_TO_DINT(x);
Description
The TRUNC_REAL_TO_DINT function converts a 32-bit real number to a 32-bit integer with truncation
instead of rounding which means the fraction is dropped.
Note IEC 1131-3 requires strict data type checking. It does not permit assigning the value of a variable
directly to a variable of a different data type. When it is necessary to use variables of different
data types, an explicit conversion must be made using a data type conversion function.
Example
VAR k : DINT; x : REAL; END_VAR;
x := -123.6;
k := TRUNC_REAL_TO_DINT( x ); (* result is -123 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the error flags
to true, and resets ENO to false. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
TRUNC_REAL_TO_INT
Truncates a 32-bit real number to a 16-bit integer.
Syntax
k := TRUNC_REAL_TO_INT(x);
Description
The TRUNC_REAL_TO_INT function converts a 32-bit real number to a 16-bit integer with truncation
instead of rounding, which means the fraction is dropped.
Note IEC 1131-3 requires strict data type checking. It does not permit assigning the value of a variable
directly to a variable of a different data type. When it is necessary to use variables of different
data types, an explicit conversion must be made using a data type conversion function.
Example
VAR k : INT; x : REAL; END_VAR;
x := -123.6;
k := TRUNC_REAL_TO_INT( x ); (* result is -123 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the error flags
to true, and resets ENO to false. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
TSCHED
Schedules periodic execution.
Syntax
MY_TSCHED( CI:=b1, PERIOD:=t1, OFFSET:=t2 ) ;
OFFSET TIME Time offset before the first setting of output Q (0.0 OFFSET < PERIOD).
Description
The TCSCHED function block schedules execution with a specified time period. (The CSCHED function
block schedules execution after a specified number of scans.)
Output Q is true when the specified period of time has passed, holding true for one scan. Otherwise
output Q is false. By testing the output Q, you can cause sections of the control program to be executed
periodically.
Example
(*
* Increment N every 90 seconds.
*)
VAR MY_TSCHED : TSCHED ; END_VAR
VAR N : DINT ; END_VAR
MY_TSCHED( CI:=TRUE, PERIOD:=T#90s ) ;
if MY_TSCHED.Q then
N := N + 1 ;
end_if ;
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Exactly Once: each instance should be executed exactly once per scan.
Library
Triconex (TCXLIB)
TSCHED_I
Schedules periodic execution.
Syntax
MY_TSCHED_I( CI:=b1, PERIOD:=n1, OFFSET:=n2 ) ;
PERIOD DINT The desired time period, in milliseconds, between settings of output Q.
OFFSET DINT Time offset, in milliseconds, before the first setting of output Q (0.0 is less than or
equal to OFFSET).
Description
The TCSCHED_I function block schedules periodic execution with the time period given in integer
milliseconds.
The output Q is true when the specified period of time has passed, holding true for one scan. Otherwise
Q is false. By testing the output Q, you can cause sections of the control program to be executed in a
periodic manner.
Note If PERIOD is within one scan period of 2147483647 milliseconds (25 days), then the time
accumulator can overflow to a negative value.
Example
(*
* Increment N every 90 seconds.
*)
VAR MY_TSCHED_I : TSCHED_I ; END_VAR
VAR N : DINT ; END_VAR
MY_TSCHED_I( CI:=TRUE, PERIOD:=90000 ) ;
if MY_TSCHED_I.Q then
N := N + 1 ;
end_if ;
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Exactly Once: each instance should be executed exactly once per scan.
Library
Triconex (TCXLIB)
TSCHED_R
Schedules periodic execution.
Syntax
MY_TSCHED_R( CI:=b1, PERIOD:=x1, OFFSET:=x2 ) ;
PERIOD REAL The desired time period, in seconds, between settings of output Q.
OFFSET REAL Time offset, in seconds, before the first setting of output Q
(0.0 is less than or equal to OFFSET).
ACTUAL REAL The measured time, in seconds, since last setting of output Q.
Description
The TCSCHED_R function block schedules periodic execution with the time period given in real seconds.
The output Q is true when the specified period of time has passed, holding true for one scan. Otherwise
Q is false. By testing the output Q, you can cause sections of the control program to be executed in a
periodic manner.
Note The rounding error in the time accumulator increases with time until the accumulator eventually
stops. The rounding error in seconds is less than ACC ACC (50,000,000 T), where ACC is
the accumulated time in seconds and T is the scan period in seconds. The accumulator stops after
ACC > 16,000,000 T. For example, if the scan period is 20 milliseconds, then after one hour, the
rounding error is less than 13 seconds.
Example
(*
* Increment N every 90 seconds.
*)
VAR MY_TSCHED_R : TSCHED_R ; END_VAR
VAR N : DINT ; END_VAR
MY_TSCHED_R( CI:=TRUE, PERIOD:=90.0 ) ;
if MY_TSCHED_R.Q then
N := N + 1 ;
end_if ;
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Exactly Once: each instance should be executed exactly once per scan.
Library
Triconex (TCXLIB)
UNPACK16
Unpacks a DWORD into 16 separate Boolean outputs.
Syntax
MY_UNPACK16( CI:=b1, INPUT:=w1 ) ;
Description
The UNPACK16 function block unpacks the low-order 16 bits of INPUT, a 32-bit word, into 16 separate
Boolean outputs (Q01 through Q16). Q01 is the least significant bit and Q16 is the most significant.
The INPUT data type is DWORD. Output NZ is true if any bits are true, and false if all 16 bits are false.
The UNPACK16 function block is useful for unpacking 16 bits that have been transmitted using a
Modbus alias.
Example
VAR MY_UNPACK16 : UNPACK16 ; END_VAR
MY_UNPACK16( CI:=TRUE, INPUT:=16#0000001F ) ;
(*
* Result on Q outputs of MY_UNPACK16:
* Q16 Q01
* 0000000000011111
*)
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
Triconex (TCXLIB)
UNPACK32
Unpacks a DWORD into 32 separate Boolean outputs.
Syntax
MY_UNPACK32( CI:=b1, INPUT:=w1 ) ;
Description
The UNPACK32 function block unpacks the 32 bits of INPUT, a 32-bit word, into 32 separate Boolean
outputs (Q01 through Q32). Q01 is the least significant bit and Q32 is the most significant.
The INPUT data type is DWORD. Output NZ is true if any of the bits are true, and false if all 32 bits are
false. The UNPACK32 function is useful for unpacking 32 bits that have been transmitted using
peer-to-peer communications.
Example
VAR MY_UNPACK32 : UNPACK32 ; END_VAR
MY_UNPACK32( CI:=TRUE, INPUT:=16#0000001F ) ;
(*
* Result on Q outputs of MY_UNPACK32:
* Q32 Q01
* 00000000000000000000000000011111
*)
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Space Saver: a single instance can be executed more than once per scan to reduce memory usage
and increase performance. For directions, see Using a Space Saver Function Block on page 6.
Library
Triconex (TCXLIB)
X_OF_N
Determines whether at least X of the last N measurements exceeds a specified limit.
Syntax
MY_X_OF_N( CI:=b1, RESET:=b2, VALUE:=x1, LMT:=x2, X:=n1, N:=n2 ) ;
CI BOOL Enables X of N.
X DINT The minimum number of N measurements that must exceed the limit to turn output Q
on, where X is less than N.
N DINT The number of measurements entailed, where N is less than or equal to 32.
Description
The X_OF_N function block determines whether at least X of the last N measurements exceeds a specified
limit. The result is output Q. RESET clears the internal state to start without measurements. RESET clears
the state even if CI is false. If CI and RESET are both false, no operation occurs.
Example
VAR X3oo4 : X_OF_N ; END_VAR
X3oo4( CI:=FALSE, RESET:=TRUE, LMT:=0.5, X:=3, N:=4 ) ;
X3oo4( VALUE:=0.7, CI:=TRUE, RESET:=FALSE ) ;
X3oo4( VALUE:=0.8 ) ;
X3oo4( VALUE:=0.4 ) ;
X3oo4( VALUE:=0.9 ) ;
(*
* result : X3oo4.Q is true because 3 out of 4 values
* are greater than or equal to 0.5.
*)
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and sets the
error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
• Can be used in Safety or Control applications.
• Internal State: a single instance can be executed more than once per scan. However, you should
be aware of the internal states that are used from one scan to the next.
Library
Triconex (TCXLIB)
XOR
Performs a logical exclusive OR of two or more Boolean operands or a bitwise exclusive OR of two or
more bit-strings.
Syntax
b := b1 XOR b2 XOR ... XOR bn ;
Description
In graphical languages, the XOR function returns the logical XOR of Boolean operands or the bitwise XOR
of bit-strings. In Structured Text, the XOR operator is used instead of the XOR function.
The maximum number of function inputs is 50.
All operands must be the same type as the return value either all BOOL or all DWORD.
If the operand type is BOOL, then the result is true if the number of true operands is odd. The result is
false if the number of true operands is even.
b1 b2 b1 XOR b2
If the operand type is DWORD, then the result is the bitwise exclusive OR of all the operands. In other
words, the value in each bit position of the result is the exclusive OR of all the values in the same bit
position.
w1 w2 w1 XOR w2
Example
Note that on the Controller Panel, you will see the example values in hex. The hex values of the operands
are w1=16#00000001, w2=16#00000003, w3=16#00000007, and the hex values of the results are
16#00000005 and 16#00000002.
Runtime Errors
None.
Application Notes
• Can be used in Safety or Control applications.
• Can be used in CEM Cause cells.
Library
Standard (STDLIB)
Overview 456
Message Response Time 457
Modbus Messages 459
Modbus Functions 465
Transmission Errors and Exception Conditions 476
Overview
This sppendix provides detailed information about Modbus protocol, which is a communication protocol
used with serial ports to transmit data between a Modbus master and slave. Modbus protocol includes
functions which define the message format for the query and response.
Query-Response Sessions
Modbus communication is a query-response session, in which the Modbus master initiates a query and
a Modbus slave responds. In Modbus communication, a serial link transmits data in both directions, but
in only one direction at a time.
A query-response session consists of these actions:
• The master sends a query to a slave.
• The master starts a fail-safe timer while it waits for the slave response. Typical slave response
time is in hundreds of milliseconds.
• The slave returns a response to the master.
• The master waits until it has received the response from the slave before sending another query.
• If there is a slave response timeout, the master will retry the query. The number of retries and
the timeout interval is configured by the MBCTRL function block (see page 178).
For information on configuring Modbus communication, see the Communication Guide for your controller.
Prepare Query (master) Varies depending on the specific Modbus function (message) and any other
program processing
Transmit Query (master) (1000 Baud Rate) x Bits per Characters x Number of Characters
Transmit Response (slave) (1000 Baud Rate) x Bits per Characters x Number of Characters
(in milliseconds)
Time-Out and Retry Values Varies depending on settings for the MBCTRL function block, which determines
the time-out and retry values which can increase the message time (see MBCTRL
on page 178).
Message Response Time = the sum of all the results
Modbus Messages
This section describes the Modbus messages (query and response functions) supported by Triconex
communication modules. The serial ports on Triconex communication modules support several Modbus
message formats and functions (queries and responses).
Topics include:
• Communication Modes on page 459
• Function Names and Aliases on page 460
• Modbus Message Formats on page 461
• Sample Query and Response Messages on page 463
• Modbus Message Lengths on page 464
Communication Modes
A Modbus serial link must use either the Remote Terminal Unit (RTU) or ASCII mode of communication.
If both modes are available, you should choose RTU because it is more efficient and robust than ASCII.
Each serial port can use a different communication mode, assuming that each port is connected to a
separate Modbus master or slave device. If you configure a port for combination Modbus master and
slave operation, you must use RTU mode.
RTU Mode
In RTU mode, data is sent in 8-bit binary characters. Gaps between characters cannot exceed three
character times (the time it takes to send a character). RTU mode uses a 16-bit cyclic redundancy check
(CRC) to detect transmission errors.
ASCII Mode
In ASCII mode, data is transmitted in pairs of ASCII characters. The first character is the ASCII
representation of the most significant 4 bits of the corresponding RTU character. The second character is
the ASCII representation of the least significant 4 bits of the corresponding RTU character. For example,
the RTU character 010011112 (4F16) is sent as the two ASCII characters 4 and F (3416 and 4616). Each ASCII
message has a colon at the beginning and a carriage return and line feed at the end. Gaps between
characters in an ASCII message are not significant.
Data Fields
The Data fields contain information that is specific to the query or response. The length of the data varies,
depending on the function code.
The CRC is computed across the station address, the function code, and the data and appended to the end
of the message.
Address 0x30
0x32
Header None :
Trailer None CR LF
Header None :
Trailer None CR LF
Modbus Functions
This section includes details on Modbus functions.
Functions include:
• Read Coil Status Function (Function Code 01) on page 466
• Read Input Status (Function Code 02) on page 467
• Read Holding Registers (Function Code 03) on page 468
• Read Input Registers (Function Code 04) on page 469
• Force Single Coil (Function Code 05) on page 470
• Preset Single Register (Function Code 06) on page 471
• Read Exception Status (Function Code 07) on page 472
• Loop-Back Diagnostic Test (Function Code 08) on page 473
• Force Multiple Coils (Function Code 15) on page 474
• Preset Multiple Registers (Function Code 16) on page 475
Query Format
Response Format
The Read Coil Status response data is packed with one bit for each coil, where 1=On, and 0=Off. The low-
order bit of the first RTU character contains the status of the first coil. For coil quantities that are not even
multiples of eight, the last RTU character is zero-filled at the high-order end.
Query Format
Response Format
Query Format
Response Format
The Read Holding Registers response data consists of two bytes for each register queried, with the binary
content right-justified. The leftmost character includes the high-order bits, and the rightmost character
includes the low-order bits.
Query Format
Response Format
Query Format
Response Format
Query Format
Response Format
Query Format
Response Format
Query Format
Response Format
Query Format
ò ò
ò ò
Response Format
Query Format
Response Format
Transmission Errors
The most frequent cause of transmission errors is noise. Noise sources include improperly installed or
broken connectors, damaged cables, electrical equipment such as generators and elevators, and lightning.
Transmission errors can be detected through the use of character framing, parity checking, and
redundancy checking.
When a slave detects a transmission error, it does not act on or respond to the message. The master
assumes a communication error has occurred if there is no response within a specified time, usually 3
seconds.
Parity checking helps detect single-bit transmission errors. However, if there are two errors within a
single character, parity checking cannot detect a change. For example, if 1100 0100 is distorted to 1111
0100, the number of 1 bits in the data is still odd.
Modbus protocol provides several levels of error checking to ensure the accuracy of data transmission.
To detect multiple bit errors, the system uses cyclic redundancy check (CRC) for RTU mode, or
longitudinal redundancy check (LRC) for ASCII mode.
Exception Conditions
If a master detects an exception in a response to a query or does not receive a response, it takes
appropriate actions which usually include re-transmitting the query. This table lists exception conditions
that are returned by the slave if a programming or operation error causes a master to send an incorrect
query.
Query Message CRC or LRC The slave does not respond, because the error could be in the station address.
Error The master uses its response fail-safe timer to recover.
Query Function Code Error The slave sends an Illegal Function (01) response code when it detects an error
in the function code field.
Query Address Error The slave sends an Illegal Data Address (02) response code when it detects an
error in the starting address field.
Query Data Error The slave sends an Illegal Data Value (03) response code when it detects an
error in the data field.
Main Processors Not This exception applies only to serial ports which are configured as slaves.
Communicating If the slave port receives a query requiring a data exchange and it cannot
communicate with the Main Processors, it sends a Busy, Reject Message (06)
response code and turns off the Active indicator on the communication
module.
Remote Write Disabled The slave port sends a Busy, Reject Message (06) response code if a master
sends one of these queries and the slave port is not enabled for remote
(external) writes:
• Force Single Coil (Function Code 05)
• Preset Single Register (Function Code 06)
• Force Multiple Coils (Function Code 15)
• Preset Multiple Registers (Function Code 16)
Exception Responses
When a slave detects an exception condition, it sends a response message to the master consisting of the
slave’s station address, function code, error code, and error-check fields. To indicate that the message is
an exception response, the slave sets the high-order bit of the function code to 1. This example shows an
exception response to a Preset Multiple Registers (Function Code 16) query.
Sample Query
02 Illegal Data Address The alias in the query does not exist in the slave.
03 Illegal Data Value The value is not in the range allowed for the alias.
04 Failure in Associated The slave failed to respond to a message or an error that occurred in
Device the controller. When a master receives this response code, it must issue
a supervisory alert.
05 Acknowledge A slave port does not send this exception response code.
06 Busy, Rejected Message The query was received without error, but the slave cannot comply.
07 Negative Acknowledge A slave port does not send this exception response code.
08 Memory Parity Error A slave port does not send this exception response code.
Overview 482
Parameters of Send Function Blocks 483
Parameters of Receive Function Blocks 486
Peer-to-Peer Runtime Errors 488
Overview
This appendix describes the input and output parameters for Peer-to-Peer function blocks, and runtime
errors.
Topics include:
• Parameters of Send Function Blocks on page 483
• Parameters of Receive Function Blocks on page 486
• Peer-to-Peer Runtime Errors on page 488
SENDFLG
The SENDFLG input parameter specifies whether a send is initiated. If the value is true, a send is initiated.
If the value is false, a send is not initiated even if the Send function block is executed. In other words, no
data transfer takes place unless the SENDFLG parameter is set to true.
When a Send function block is executed by the TriStation 1131 application for the first time with
SENDFLG set to false, the sending controller attempts to establish communication with the receiving
controller and sets the STATUS parameter to 100.
The sending controller sets the STATUS parameter of the Send function block to 0 if:
• Communication is established with the receiving controller
• A receiving controller has a matching Send function block with a matching Receive identifier,
Send node number, and Send identifier
If the STATUS parameter of a Send function block (with SENDFLG set to 0) is greater than or equal to 100,
there is a problem in the network. The STATUS parameter indicates the type of problem and the action
you should to take to resolve it. For more information on codes, see STATUS on page 486.
A TriStation 1131 application must execute a Send function block unconditionally, exactly once per scan.
The SENDFLG parameter should be zero for the first scan. If the value of SENDFLG is zero, no send
operation takes place even though the function block is executed. When another application has new data
to send, it should first check the result of the Send function block execution (in other words, the STATUS
output). If the STATUS is zero, then set SENDFLG to true to initiate the send operation so that data can
be transferred.
SENDID
The SENDID input parameter specifies a unique identifier for a Send function block. The legal range for
identifiers is from 1 to the value specified for Maximum Number of Peer-to-Peer Send.
Each Send function block in a TriStation 1131 application must have a unique SENDID. If more than one
Send function block has the same SENDID, the first Send function block in the application will work
properly. Other Send function blocks with the same SENDID will generate an error status of 105.
RECVNODE
The RECVNODE input parameter specifies which controller will receive data from this Send function
block. It should be set to the node number of the receiving Triconex controller. The range is 1 to 63. (Note:
Nodes 32 to 63 are valid for Trident or Tri-GP controllers only.) If RECVNODE is out of range, calls to the
function block set the STATUS output to 102.
RECVID
The RECVID input parameter specifies the unique Receive function block that receives data from this
Send function block. A receive call with a matching RECVID must be defined in the receiving controller.
The legal range for RECVID identifiers is from 1 to the value specified for Maximum Number of Peer-to-
Peer Receive. If RECVID is out of range, calls to the function block set the STATUS output to 102.
N
The N input parameter specifies the number of data values to send (1 to 20 for TR_USEND function
blocks and 1 to 32 for TR_USEND_32 function blocks). The receiving function block must specify the
same value for the N output parameter.
SD_01...SD_nn
The SD_ input parameters send data values to the receiving controller. A TR_USEND function block can
send up to 20 values and a TR_USEND_32 function block can send up to 32 values. These values can be
BOOL, DINT, or REAL data types. There must be matching RD_ parameters in the Receive function block
of the receiving controller.
SENT
The SENT output parameter of type BOOL indicates that a send was initiated and the STATUS parameter
is set to 1 or 4. Instead of testing the STATUS output, you can use the SENT output to change the send
data if you want to send it again, or reset the SENDFLG if you do not want to send the data again.
ACK
The ACK output parameter indicates that the receiving controller has acknowledged the send. In other
words, the last send operation was completed successfully and the STATUS parameter is equal to 3 or 4.
ERROR
The ERROR output parameter indicates that an error has occurred and the STATUS parameter is greater
than or equal to 100.
STATUS
The STATUS output parameter indicates the current state of communication with the receiving
controller. The STATUS values described in the following table allow the TriStation 1131 application to
perform an appropriate action when a problem occurs.
0 Communication is established with the receive node. When you execute a Send function block with
SENDFLG = false, you should receive STATUS = 0 to indicate that communication is established
with the receiving controller and that the receiving TriStation 1131 application has an exactly
matching Receive function block. You can initiate a send operation by setting SENDFLG to true.
1 A send was initiated by a Send function block call with SENDFLG set to true. Set SENDFLG to false
to coordinate the acknowledgment from the receiving node of the last send. If you do not set
SENDFLG to false, the controller will initiate another send as soon as it completes the current send
(in other words, as soon as it receives an acknowledgment from the receiving controller).
2 The Send identifier is currently busy sending data to the receiving controller. STATUS is set to 2 on
the scan that immediately follows a scan during which a send was initiated. STATUS remains 2 until
an acknowledgment is received from the receiving controller or a 5-second time-out expires. If an
acknowledgment is received, STATUS changes to 3 and then to 0 (if SENDFLG = false) or 4 (if
SENDFLG = true). If the 5-second time-out expires, STATUS changes to 100 (described below).
Table 489 Send Function Block STATUS Output Parameter Values (continued)
Status Meaning and Action
3 The last send operation was completed successfully and the receiving controller sent an
acknowledgment. STATUS = 3 only if SENDFLG was set to false after STATUS was equal to 1.
The sending controller gets an acknowledgment from the receiving controller for each successfully
completed send (STATUS = 3). As soon as the acknowledgment is received, the sending controller
initiates another send because SENDFLG is set to true. If SENDFLG is set to true all the time, the
STATUS value oscillates between 2 and 4 unless a communication problem causes another type of
error.
4 The last send was completed successfully and a new send was initiated. The receiving controller
acknowledged that its TriStation 1131 application received the data.
STATUS = 3 only if SENDFLG was set to false after STATUS was equal to 1.
The sending controller gets an acknowledgment from the receiving node for each successfully
completed send (STATUS = 3). However, as soon as the acknowledgment is received, the sending
controller initiates another send because SENDFLG is set to true. If SENDFLG is set to true all the
time, the STATUS value oscillates between 2 and 4 unless a communication problem causes another
type of error.
100 The controller is trying to recover or establish communication with the receiving controller. This can
happen if there is no receiving controller connected to the network, or if there is no matching
Receive function block in the TriStation 1131 application of the receiving controller. The sending
controller will retry every 2 seconds to establish communication.
Make sure that the receiving controller is connected to the network. If the receiving controller is
connected and running, verify that the TriStation 1131 application includes a Receive function block
with parameters that exactly match those of the Send function block. If STATUS = 100, the
application should inform the operator of communication loss with the receiving controller.
101 The last send operation that was initiated has failed. There is a communication problem or other
problem in the receiving controller. The sending controller will retry every 2 seconds to establish
communication with the receiving controller. If the retry fails, STATUS is set to 100, and the
TriStation 1131 application should inform the operator of communication loss with the receiving
controller.
102 Bad identifier. SENDID, RECVNODE, or RECVID is out of range, or the SENDID is greater than the
Maximum Number of Peer-to-Peer Sends specified in the configuration.
103 The types or number of variables in the Send and Receive function block pair are mismatched. In
other words, the parameters defined for the Send and Receive function block pair do not match
exactly. This is a programming error—in one or both of the TriStation 1131 applications—that must
be corrected.
104 Number of values (N parameter) is out of range. The allowable range is 1 to 20 for TR_USEND
function blocks and 1 to 32 for TR_USEND_32 function blocks.
105 More than one Send function block has the same SENDID, or the same Send function block has been
called twice. This is a programming error. Each Send function block in the TriStation 1131
application must have a unique SENDID. If there is more than one Send function block with the
same SENDID, the first Send function block in the application will work properly. Other Send
function blocks with the same SENDID will result in error status 105.
Send function blocks must be evaluated exactly once per scan. Error status 105 results if the
application executes the same Send function block twice per scan. If the application does not execute
the Send function block during every scan, results are unpredictable.
RECVID
The RECVID input parameter specifies the identifier for this Receive function block. The legal range is
from 1 to the value specified for the Maximum Number of Receive. There must be a Send function block
in the sending controller with the same RECVID.
Each Receive function block in the application must have a unique RECVID. If there is more than one
Receive function block with the same RECVID, then the first Receive function block in the application will
work properly. Other function blocks with the same RECVID will result in an error status of 105.
SENDNODE
The SENDNODE input parameter specifies which controller will send data to this Receive function block.
The Receive function block will accept data only from the specified SENDNODE. It should be set to the
node number of the sending Triconex controller. The range is 1 to 63. (Note: Nodes 32 to 63 are valid for
Trident or Tri-GP controllers only.) If SENDNODE is out of range, calling the function block sets the
STATUS output to 102.
SENDID
The SENDID input parameter specifies which Send function block in the sending controller will send data
to this Receive block. There must be a Send function block call in the sending controller with the same
SENDID. The legal range is from 1 the value specified for the Maximum Number of Send. If SENDID is
out of range, calling the function block sets the STATUS output to 102.
N
The N input parameter specifies the number of values to be received (1 to 20 for TR_URCV function
blocks and 1 to 32 for TR_URCV_32 function blocks). The sending function block must specify the same
value for its N input parameter.
NDR
The NDR (New Data Received) output parameter indicates that new data has been received and is
available in the RD_01...RD_nn output parameters until new data is received again. NDR is true when the
STATUS parameter has a value of 1.
ERROR
The ERROR output parameter indicates that an error has occurred. ERROR is true when the STATUS
parameter is greater than or equal to 100.
STATUS
The STATUS output parameter allows the application to determine the status of communication with the
sending controller. This table describes the STATUS values.
1 New data has been received from the sending controller and is available in outputs RD_01...RD_nn
until new data is received again.
102 Bad identifier. RECVID, SENDNODE, or SENDID is out of range, or the RECVID is greater than the
value specified for Maximum Number of Receive.
103 Data was received from the sending controller but the number or type of variables received did not
exactly match the number or type of variables defined for the Receive function block. Data outputs
RD_01...RD_nn do not change. In other words, the parameters defined for the Send and Receive
function blocks do not match. This is a programming error in one or both applications, which should
ask the operator to make a correction.
105 The program called the same Receive function block twice, or there is more than one Receive function
block with the same RECVID. This is a programming error. Each Receive function block in the
application must have a unique RECVID. If there is more than one Receive function block with the
same RECVID, then the first Receive function block in the application will work properly, but other
function blocks with the same RECVID will result in error status 105.
RD_01...RD_nn
The RD_ input parameters receive data values from the sending controller. A TR_URCV function block
can receive up to 20 values and a TR_URCV_32 function block can receive up to 32 values. These
parameters must match the number and type of the parameters specified in the corresponding Send
function block.
COMM_OK is false on No communication path Diagnostics on the CM After initial start-up, the
TR_PEER_STATUS between the sending and send a message to each TriStation 1131
function block receiving controllers. node. If no response is application can use this
One of the controllers is received within 1 second, output to set an alarm.
disconnected from the the CM sets the output
network, the CM has false.
failed, or the Ethernet The CM reports the
cable or field termination status to the MPs every
is bad. 30 seconds.
COMM_REDUNDANT is No redundant The MPs set the output This might or might not
false on communication path based on the status be an error, depending
TR_PEER_STATUS between the sending and received from each of on system configuration.
function block receiving controllers. two CMs. If redundancy is used,
One of the controllers has The CMs report their after initial start-up the
only one CM or has a status to the MPs every TriStation 1131
failed CM, or the 30 seconds. application can use the
Ethernet cable or field STATUS output to set an
termination is bad. alarm.
STATUS is 100 on a Send • There is no receiving The STATUS output is After initial start-up, the
function block controller on the updated whenever the TriStation 1131
network. Send function block is application can use the
• There is no matching executed. If the STATUS output to set an
Receive function acknowledgment for the alarm.
block in the last Send is not received
receiving controller. in 1 second, the sending
controller tries to send
• The receiving
the message again. If the
controller is trying
retry fails, then a
to recover from a
STATUS of 100 is
communication
returned.
error.
STATUS is greater than or There is a programming The MPs detect After initial start-up,
equal to 102 on a Send error in the sending or programming errors. programming errors
function block receiving controller. should not occur. If they
do, then the TriStation
1131 application should
use the STATUS output
to set an alarm.
STATUS is 100 on a The receiving controller The STATUS output is After initial start-up, the
Receive function block is trying to establish updated whenever the TriStation 1131
communication with the Receive function block is application can use the
sending controller. executed. STATUS output to set an
alarm.
STATUS is greater than or There is a programming The MPs detect After initial start-up,
equal to 101 on a Receive error in the sending or programming errors. programming errors
function block receiving controller. should not occur. If they
do, then the TriStation
1131 application should
use the STATUS output
to set an alarm.
G LE function 152
gas detector 120 lead-lag compensation 154, 156
GASDETR function block 120 LEADLAG function block 154
GATDIS function block 123 LEADLAG_R function block 156
gate disable 123 less than or equal to operator 152, 174
gate enable 124 LEVEL_ALARM_DINT function 29
GATENB function block 124 LEVEL_ALARM_REAL function 33
GE function 126 LF field 462
GetDelta_DINT function 128 LIMIT function 158
GetDelta_REAL function 130 line monitor 160
GetDeltaT function 132 LINEMNTR function block 160
GetTimer function 134 LN function 162
gradual underflow LOG function 163
effect on absolute and relative error 167, 255 logarithm
for LREAL data types 166 base ten 163
for REAL data types 254 natural 162
GT function 136 logical AND 48
logical NOT 217
H logical OR 221
high-resolution analog input 19 logical XOR 453
long reals, precision when approaching zero 167
I longitudinal redundancy check. See LRC checksum.
i.LREAL numbers, precision when approaching loop detector 164
zero 167
Loop-Back Diagnostic Test function 473
I/O modules, status 392
LOOPDETR function block 164
IEC-559 Standard Floating-Point format 254
LRC checksum, calculation 462
inclusive OR 221
LREAL data type 166
-INF 205, 206
LREAL_TO_DINT function 168
INFINITY_LREAL function 138
LREAL_TO_INT function 170
INFINITY_REAL function 139
LREAL_TO_REAL function 172
INT data type 140
LT function 174
INT_TO_DINT function 141
INT_TO_LREAL function 142
M
INT_TO_REAL function 143
MAX function 176
integration 144, 146
MBCTRL function block 178
INTERNALERR error flag 76
MBREAD_BOOL function block 180
INTGTOR function block 144
MBREAD_DINT function block 182
INTGTOR_R function block 146
MBREAD_REAL function block 184
IsFinite_LREAL function 148
MBREAD_REAL_TRD function block 188
IsFinite_REAL function 149
MBWRITE_BOOL function block 191
IsNan_LREAL function 150
MBWRITE_DINT function block 193
IsNan_REAL function 151
MBWRITE_REAL function block 195
MBWRITE_REAL_TRD function block 198
L
median 201
latch 264, 281
U
underflow
gradual for LREAL data types 166
gradual for REAL data types 254
UNDERFLOW error flag 76
UNPACK16 function block 447
UNPACK32 function block 449
up counter 91
up-down counter 93
W
write access 123
X
X_OF_N function block 451
XOR function 453
XOR operator 453