Beruflich Dokumente
Kultur Dokumente
Libraries Reference
Information in this document is subject to change without notice. Companies, names and data used in
examples herein are fictitious unless otherwise noted. No part of this document may be reproduced or
transmitted in any form or by any means, electronic or mechanical, for any purpose, without the express
written permission of Invensys Systems, Inc.
20032010 by Invensys Systems, Inc. All rights reserved.
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.
Contents
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
Chapter 2
ABS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
ACOS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
ADD. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
AIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
AIN_BP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
AIN_BP12 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
AIN_HR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
ALARM_DEVIATION_DINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
ALARM_DEVIATION_REAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
ALARM_LEVEL_DINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
ALARM_LEVEL_REAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
ALARM_ROC_DINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
ALARM_ROC_REAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
ALARM_TRIP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
AND. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
AOUT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
AOUT_BP12 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
ARRAY32_BOOL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
ARRAY32_DINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
ARRAY32_REAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
ASIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
ATAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
BLINK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
BLINK_I . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
BLINK_R . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
BOOL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
iv
Contents
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
Contents
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
vi
Contents
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
Contents
vii
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
viii
Contents
XOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453
455
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 456
Message Response Time. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 457
Determining Message Response Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 457
Modbus Functions and Scan Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 458
Modbus Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459
Communication Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459
Function Names and Aliases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 460
Modbus Message Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 461
Sample Query and Response Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463
Modbus Message Lengths . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 464
Modbus Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 465
Read Coil Status Function (Function Code 01) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 466
Read Input Status (Function Code 02) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467
Read Holding Registers (Function Code 03) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 468
Read Input Registers (Function Code 04) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469
Force Single Coil (Function Code 05) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 470
Preset Single Register (Function Code 06) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471
Read Exception Status (Function Code 07) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 472
Loop-Back Diagnostic Test (Function Code 08) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473
Force Multiple Coils (Function Code 15) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474
Preset Multiple Registers (Function Code 16) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475
Transmission Errors and Exception Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 476
Transmission Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 476
Exception Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 477
Exception Responses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 478
Exception Response Codes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 479
481
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 482
Parameters of Send Function Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483
Parameters of Receive Function Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 486
Peer-to-Peer Runtime Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 488
Index
491
Preface
The Triconex libraries include IEC-compliant functions and function blocks which are part of the
TriStation 1131 Developers 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, IntroductionExplains how the functions and function blocks are described.
Chapter 2, Functions and Data TypesDescribes the parameters, return values, runtime error
flags, and usage constraints for each function and function block.
Related Documents
Preface
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.
Requests from participants with a support agreement and customers with purchase
order or charge card authorization are given next priority
If you require emergency or immediate response and do not have a support agreement, you
may incur a charge. Please have a purchase order or credit card available for billing.
Telephone
Toll-free number
Toll number
866-746-6477, or
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
Preface
xi
A brief description of the content you are referring to (for example, step-by-step
instructions that are incorrect, information that requires clarification or more details,
missing information that you would find helpful)
Your name, company name, job title, phone number, and e-mail address
xii
Preface
1
Introduction
Sample Projects
Chapter 1
Introduction
Syntax on page 2
Library on page 6
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:
Table 1
Input Parameters
Name
Data Type
Description
BOOL
Output Parameters
A table of output parameters shows the name, data type, and description of each function block output.
This is an example:
Table 2
Output Parameters
Name
Data Type
Description
CO
BOOL
Return Value
A table shows the data type and description of the value returned by the function. This is an example:
Table 3
Return Value
Data Type
Description
DWORD
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
Condition
Return Value
Error Flags
32768
BADCONV, ERROR
+32767
BADCONV, ERROR
Chapter 1
Introduction
Application Notes
The Application Notes section indicates how the function, function block, or data type can be used. These
properties are indicated:
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 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.
Application Type
Used in a Safety
Element
Safety element
OK
OK
WF0050 or WF0051
OK
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.
Chapter 1
Introduction
Declare only one instance of the function block and use that same instance throughout your
program. On a function block diagram, just use the same instance name repeatedly.
To prevent mistakes, connect a value to every function block input. If you forget to connect an
input, then you must search for a previous execution of the function block to see the input value
because the function block remembers the input value from one execution to the next if the input
is not connected.
Do not use the function block instance more than once in a networkthe result is a WG0014
warning because the diagram could be ambiguous.
Note
If a function block is not a space saver, then using the same function block instance more than
once on a function block diagram results in a WF0031 warningwhereas there is no such
warning for a space saver.
CEM Enabled
A CEM Enabled function or function block can be used in the CEM matrix as indicated by one of these
statements:
Library
The Library section identifies the libraries that the function or function block is included in. TriStation
1131 includes these libraries:
Standard Sheet Library (STDSHEET) for all Triconex controllers (used only for selecting a sheet
template in a new function block diagram)
Alarms Library (ALARMS) for all Triconex controllers (first released with TriStation 4.7.0)
Sample Projects
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):
Note
Older versions of TriStation 1131 (v4.6 or earlier) may have installed the sample projects in a
different location. If you cannot locate the sample projects in the above directories, simply search
your hard drive for the name of the sample project you are looking for.
Chapter 1
Introduction
2
Functions and Data Types
This section describes the functions, function blocks, and data types included in TriStation 1131 Libraries.
10
Chapter 2
ABS
Calculates the absolute value of a number.
Syntax
k := ABS(m)
Table 4
Input Parameters
Name
Data Type
Description
ANY_NUM
A number.
Table 5
Return Value
Data Type
Description
ANY_NUM
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 );
k := ABS( 1234 );
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
(* result is 1234 *)
(* result is 1234 *)
ACOS
11
ACOS
Calculates the principal arc cosine of a real number.
Syntax
y := ACOS( x )
Table 6
Input Parameters
Name
Data Type
Description
ANY_REAL
Table 7
Return Value
Data Type
Description
ANY_REAL
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 );
y := ACOS( 1.0 );
(* result is 0.0
*)
(* result is 3.14159 *)
Runtime Errors
Condition
Return Value
Error Flags
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)
12
Chapter 2
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.
Parameter
Data Type
Result Data
Type
Return Value
ANY_NUM
ANY_NUM
TIME
TIME
DT + TIME
DT
TOD + TIME
TOD
Operation
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.
Parameter
Data Type
Return Value
Data Type
Return Value
ANY_NUM
ANY_NUM
TIME
TIME
DT + TIME
DT
TOD + TIME
TOD
Operation
ADD
13
Example
Calculate the Sum of Numeric Values
VAR m : DINT; END_VAR
m := 10 + 1564;
m := 10 + 1564 + 32761 + 512;
(* result is 1574 *)
(* result is 33823 *)
(* result is T#12d1h43m *)
(* result is DT#2002-01-27-11:30:45 *)
(* result is TOD#11:30:45 *)
Runtime Errors
Condition
Return Value
Error Flags
INF
OVERFLOW, ERROR
NAN
OVERFLOW, ERROR
Invalid date
BADPARAM, ERROR
Invalid time
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)
14
Chapter 2
AIN
Converts an analog input to a real number.
Syntax
y := AIN( MX,
Table 8
IN,
MN )
Input Parameters
Name
Data Type
Description
MX
REAL
IN
DINT
MN
REAL
Table 9
Return Value
Data Type
Description
REAL
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 :=
y :=
y :=
y : REAL; END_VAR
AIN( 100.0, 4095, 0.0 );
AIN( 100.0, 2457, 0.0 );
AIN( 100.0, 819,
0.0 );
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Triconex (TCXLIB)
(* result is 100.0 *)
(* result is 50.0 *)
(* result is
0.0 *)
AIN_BP
15
AIN_BP
Converts a differential bipolar analog input to a real number.
Syntax
y := AIN_BP( MX,
Table 10
IN,
MN )
Input Parameters
Name
Data Type
Description
MX
REAL
IN
DINT
MN
REAL
Table 11
Return Value
Data Type
Description
REAL
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 :=
y :=
y :=
y : REAL; END_VAR
AIN_BP( 100.0, 16383, 0.0 );
AIN_BP( 100.0, 0, 0.0 );
AIN_BP( 100.0, -16383,
0.0 );
(* result is 100.0 *)
(* result is 50.0 *)
(* result is
0.0 *)
Runtime Errors
None.
16
Chapter 2
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
17
AIN_BP12
Converts a 12-bit differential bipolar analog input to a real number.
Syntax
y := AIN_BP12( MX,
Table 12
IN,
MN )
Input Parameters
Name
Data Type
Description
MX
REAL
IN
DINT
MN
REAL
Table 13
Return Value
Data Type
Description
REAL
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
MX
-4095
+4095
Machine
Count
MN
18
Chapter 2
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:
-4095
-10.0
0.0
+4095
+10.0
END_VAR
-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
19
AIN_HR
Converts a high-resolution analog input to a real number.
Syntax
y := AIN_HR( MX,
Table 14
IN,
MN )
Input Parameters
Name
Data Type
Description
MX
REAL
IN
DINT
MN
REAL
Table 15
Return Value
Data Type
Description
REAL
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 :=
y :=
y :=
y : REAL; END_VAR
AIN_HR( 100.0, 16383, 0.0 );
AIN_HR( 100.0, 9829, 0.0 );
AIN_HR( 100.0, 3276,
0.0 );
(* result is 100.0 *)
(* result is 50.0 *)
(* result is
0.0 *)
Runtime Errors
None.
20
Chapter 2
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
21
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);
Table 16
Input Parameters
Name
Data Type
Description
SOURCE
DINT
SETPOINT
DINT
BYPASS
BOOL
ACK_REQUEST
BOOL
DISABLE_REQUEST
BOOL
AUTOMATIC_RESET
BOOL
MANUAL_RESET_REQUEST
BOOL
DEADBAND
DINT
Specifies the difference between the alarm limit and the input
value before an alarm goes inactive.
TIME_DELAY
TIME
RINGBACK
BOOL
22
Chapter 2
Table 16
Name
Data Type
Description
HIGH_HIGH_LIMIT
DINT
HIGH_HIGH_SEVERITY
DINT
HIGH_LIMIT
DINT
HIGH_SEVERITY
DINT
LOW_LIMIT
DINT
LOW_SEVERITY
DINT
LOW_LOW_LIMIT
DINT
LOW_LOW_SEVERITY
DINT
SOURCE_ID
DINT
Table 17
Output Parameters
Name
Data Type
Description
ACTIVE
BOOL
HIGH_HIGH_ACTIVE
BOOL
HIGH_ACTIVE
BOOL
LOW_ACTIVE
BOOL
LOW_LOW_ACTIVE
BOOL
ACKNOWLEDGED
BOOL
ACK_TIME
DT
ACTIVE_TIME
DT
INACTIVE_TIME
DT
ALARM_DEVIATION_DINT
Table 17
23
Name
Data Type
Description
ALARM_STATE
DINT
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 values 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.
24
Chapter 2
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
My_Deviation_Alarm (SOURCE:=My_Tagname, BYPASS:=Tagname2,
SETPOINT:=55, ACK_REQUEST:=Tagname3, DISABLE_REQUEST:=Tagname4,
AUTOMATIC_RESET:=Tagname5, MANUAL_RESET_REQUEST:=Tagname6, DEADBAND:=2,
TIME_DELAY:=T#5ms, RINGBACK:=TRUE, HIGH_HIGH_LIMIT:=10, HIGH_HIGH_SEVERITY:=4,
HIGH_LIMIT:=5, HIGH_SEVERITY:=3, LOW_LIMIT:=5, LOW_SEVERITY:=2, LOW_LOW_LIMIT:=
10, LOW_LOW_SEVERITY:=1
);
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
25
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);
Table 18
Input Parameters
Name
Data Type
Description
SOURCE
DINT
SETPOINT
DINT
BYPASS
BOOL
ACK_REQUEST
BOOL
DISABLE_REQUEST
BOOL
AUTOMATIC_RESET
BOOL
MANUAL_RESET_REQUEST
BOOL
DEADBAND
DINT
Specifies the difference between the alarm limit and the input
value before an alarm goes inactive.
TIME_DELAY
TIME
RINGBACK
BOOL
26
Chapter 2
Table 18
Name
Data Type
Description
HIGH_HIGH_LIMIT
DINT
HIGH_HIGH_SEVERITY
DINT
HIGH_LIMIT
DINT
HIGH_SEVERITY
DINT
LOW_LIMIT
DINT
LOW_SEVERITY
DINT
LOW_LOW_LIMIT
DINT
LOW_LOW_SEVERITY
DINT
SOURCE_ID
DINT
Table 19
Output Parameters
Name
Data Type
Description
ACTIVE
BOOL
HIGH_HIGH_ACTIVE
BOOL
HIGH_ACTIVE
BOOL
LOW_ACTIVE
BOOL
LOW_LOW_ACTIVE
BOOL
ACKNOWLEDGED
BOOL
ACK_TIME
DT
ACTIVE_TIME
DT
INACTIVE_TIME
DT
ALARM_DEVIATION_REAL
Table 19
27
Name
Data Type
Description
ALARM_STATE
DINT
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 values 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.
28
Chapter 2
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
My_Deviation_Alarm (SOURCE:=My_Tagname, BYPASS:=Tagname2,
SETPOINT:=55, ACK_REQUEST:=Tagname3, DISABLE_REQUEST:=Tagname4,
AUTOMATIC_RESET:=Tagname5, MANUAL_RESET_REQUEST:=Tagname6, DEADBAND:=2,
TIME_DELAY:=T#5ms, RINGBACK:=TRUE, HIGH_HIGH_LIMIT:=10, HIGH_HIGH_SEVERITY:=4,
HIGH_LIMIT:=5, HIGH_SEVERITY:=3, LOW_LIMIT:=5, LOW_SEVERITY:=2, LOW_LOW_LIMIT:=
10, LOW_LOW_SEVERITY:=1
);
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
29
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);
Table 20
Input Parameters
Name
Data Type
Description
SOURCE
DINT
BYPASS
BOOL
ACK_REQUEST
BOOL
DISABLE_REQUEST
BOOL
AUTOMATIC_RESET
BOOL
MANUAL_RESET_REQUEST
BOOL
DEADBAND
DINT
Specifies the difference between the alarm limit and the input
value before an alarm goes inactive.
TIME_DELAY
TIME
RINGBACK
BOOL
HIGH_HIGH_LIMIT
DINT
HIGH_HIGH_SEVERITY
DINT
30
Chapter 2
Table 20
Name
Data Type
Description
HIGH_LIMIT
DINT
HIGH_SEVERITY
DINT
LOW_LIMIT
DINT
LOW_SEVERITY
DINT
LOW_LOW_LIMIT
DINT
LOW_LOW_SEVERITY
DINT
SOURCE_ID
DINT
Table 21
Output Parameters
Name
Data Type
Description
ACTIVE
BOOL
HIGH_HIGH_ACTIVE
BOOL
HIGH_ACTIVE
BOOL
LOW_ACTIVE
BOOL
LOW_LOW_ACTIVE
BOOL
ACKNOWLEDGED
BOOL
ACK_TIME
DT
ACTIVE_TIME
DT
INACTIVE_TIME
DT
ALARM_LEVEL_DINT
Table 21
31
Name
Data Type
Description
ALARM_STATE
DINT
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
My_Level_Alarm (SOURCE:=My_Tagname, BYPASS:=Tagname2, ACK_REQUEST:=Tagname3,
DISABLE_REQUEST:=Tagname4, AUTOMATIC_RESET:=Tagname5, MANUAL_RESET_REQUEST:=Tagname6,
DEADBAND:=2, TIME_DELAY:=T#5ms, RINGBACK:=TRUE, HIGH_HIGH_LIMIT:=100,
HIGH_HIGH_SEVERITY:=4, HIGH_LIMIT:=80, HIGH_SEVERITY:=3, LOW_LIMIT:=20,
LOW_SEVERITY:=2, LOW_LOW_LIMIT:=10, LOW_LOW_SEVERITY:=1
32
Chapter 2
);
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
33
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);
Table 22
Input Parameters
Name
Data Type
Description
SOURCE
DINT
BYPASS
BOOL
ACK_REQUEST
BOOL
DISABLE_REQUEST
BOOL
AUTOMATIC_RESET
BOOL
MANUAL_RESET_REQUEST
BOOL
DEADBAND
DINT
Specifies the difference between the alarm limit and the input
value before an alarm goes inactive.
TIME_DELAY
TIME
RINGBACK
BOOL
HIGH_HIGH_LIMIT
DINT
HIGH_HIGH_SEVERITY
DINT
34
Chapter 2
Table 22
Name
Data Type
HIGH_LIMIT
DINT
Description
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.
HIGH_SEVERITY
DINT
LOW_LIMIT
DINT
LOW_SEVERITY
DINT
LOW_LOW_LIMIT
DINT
LOW_LOW_SEVERITY
DINT
SOURCE_ID
DINT
Table 23
Output Parameters
Name
Data Type
Description
ACTIVE
BOOL
HIGH_HIGH_ACTIVE
BOOL
HIGH_ACTIVE
BOOL
LOW_ACTIVE
BOOL
LOW_LOW_ACTIVE
BOOL
ACKNOWLEDGED
BOOL
ACK_TIME
DT
ACTIVE_TIME
DT
INACTIVE_TIME
DT
ALARM_LEVEL_REAL
Table 23
35
Name
Data Type
Description
ALARM_STATE
DINT
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
My_Level_Alarm (SOURCE:=My_Tagname, BYPASS:=Tagname2, ACK_REQUEST:=Tagname3,
DISABLE_REQUEST:=Tagname4, AUTOMATIC_RESET:=Tagname5, MANUAL_RESET_REQUEST:=Tagname6,
DEADBAND:=2, TIME_DELAY:=T#5ms, RINGBACK:=TRUE, HIGH_HIGH_LIMIT:=100,
HIGH_HIGH_SEVERITY:=4, HIGH_LIMIT:=80, HIGH_SEVERITY:=3, LOW_LIMIT:=20,
LOW_SEVERITY:=2, LOW_LOW_LIMIT:=10, LOW_LOW_SEVERITY:=1
36
Chapter 2
);
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
37
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);
Table 24
Input Parameters
Name
Data Type
Description
SOURCE
DINT
RATEOFCHANGE
DINT
BYPASS
BOOL
ACK_REQUEST
BOOL
DISABLE_REQUEST
BOOL
AUTOMATIC_RESET
BOOL
MANUAL_RESET_REQUEST
BOOL
DEADBAND
DINT
Specifies the difference between the alarm limit and the input
value before an alarm goes inactive.
TIME_DELAY
TIME
RINGBACK
BOOL
HIGH_HIGH_LIMIT
DINT
38
Chapter 2
Table 24
Name
Data Type
Description
HIGH_HIGH_SEVERITY
DINT
HIGH_LIMIT
DINT
HIGH_SEVERITY
DINT
LOW_LIMIT
DINT
LOW_SEVERITY
DINT
LOW_LOW_LIMIT
DINT
LOW_LOW_SEVERITY
DINT
SOURCE_ID
DINT
Table 25
Output Parameters
Name
Data Type
Description
ACTIVE
BOOL
HIGH_HIGH_ACTIVE
BOOL
HIGH_ACTIVE
BOOL
LOW_ACTIVE
BOOL
LOW_LOW_ACTIVE
BOOL
ACKNOWLEDGED
BOOL
ACK_TIME
DT
ACTIVE_TIME
DT
INACTIVE_TIME
DT
ALARM_ROC_DINT
Table 25
39
Name
Data Type
Description
ALARM_STATE
DINT
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
VAR_EXTERNAL My_Tagname: DINT; Tagname2:BOOL; Tagname3:BOOL; Tagname4:BOOL;
Tagname5:BOOL; Tagname6:BOOL;
END_VAR
40
Chapter 2
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
41
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);
Table 26
Input Parameters
Name
Data Type
Description
SOURCE
DINT
RATEOFCHANGE
DINT
BYPASS
BOOL
ACK_REQUEST
BOOL
DISABLE_REQUEST
BOOL
AUTOMATIC_RESET
BOOL
MANUAL_RESET_REQUE
ST
BOOL
DEADBAND
DINT
Specifies the difference between the alarm limit and the input
value before an alarm goes inactive.
TIME_DELAY
TIME
RINGBACK
BOOL
42
Chapter 2
Table 26
Name
Data Type
HIGH_HIGH_LIMIT
DINT
Description
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
HIGH_LIMIT
DINT
HIGH_SEVERITY
DINT
LOW_LIMIT
DINT
LOW_SEVERITY
DINT
LOW_LOW_LIMIT
DINT
LOW_LOW_SEVERITY
DINT
SOURCE_ID
DINT
Table 27
Output Parameters
Name
Data Type
Description
ACTIVE
BOOL
HIGH_HIGH_ACTIVE
BOOL
HIGH_ACTIVE
BOOL
LOW_ACTIVE
BOOL
LOW_LOW_ACTIVE
BOOL
ACKNOWLEDGED
BOOL
ACK_TIME
DT
ACTIVE_TIME
DT
INACTIVE_TIME
DT
ALARM_ROC_REAL
Table 27
43
Name
Data Type
Description
ALARM_STATE
DINT
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
VAR_EXTERNAL My_Tagname:REAL; Tagname2:BOOL; Tagname3:BOOL; Tagname4:BOOL;
Tagname5:BOOL; Tagname6:BOOL;
END_VAR
44
Chapter 2
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
45
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);
Table 28
Input Parameters
Name
Data Type
Description
SOURCE
DINT
BYPASS
BOOL
NORMAL_STATE
BOOL
ACK_REQUEST
BOOL
DISABLE_REQUEST
BOOL
AUTOMATIC_RESET
BOOL
MANUAL_RESET_REQUEST
BOOL
RINGBACK
BOOL
TIME_DELAY
TIME
SEVERITY
DINT
SOURCE_ID
DINT
46
Chapter 2
Table 29
Output Parameters
Name
Data Type
Description
ACTIVE
BOOL
ACKNOWLEDGED
BOOL
ACK_TIME
DT
ACTIVE_TIME
DT
INACTIVE_TIME
DT
ALARM_STATE
DINT
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.
ALARM_TRIP
47
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.
48
Chapter 2
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 ;
Table 30
Input Parameters
Name
Data Type
Description
b1...bn
ANY_BIT
Operands
Table 31
Return Value
Data Type
Description
ANY_BIT
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.
Table 32
Logical AND
b1
b2
b1 OR b2
FALSE
FALSE
FALSE
FALSE
TRUE
FALSE
TRUE
FALSE
FALSE
TRUE
TRUE
TRUE
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.
Table 33
Bitwise AND
w1
w2
w1 AND w2
2#0011
2#0101
2#0001
AND
49
Example
Using Boolean Operands
VAR b, b1:=TRUE, b2:=FALSE, b3:=TRUE : BOOL; END_VAR
b := b1 AND b2 AND b3;
(* result is FALSE *)
b := b1 AND b3;
(* result is TRUE *)
;
;
;
*)
*)
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
Library
Standard (STDLIB)
50
Chapter 2
AOUT
Converts a real number to an analog output.
Syntax
k := AOUT( MX,
Table 34
IN,
MN )
Input Parameters
Name
Data Type
Description
MX
REAL
IN
REAL
MN
REAL
Table 35
Return Value
Data Type
Description
DINT
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 :=
k :=
k :=
k : DINT; END_VAR
AOUT( 100.0, 100.0, 0.0 );
AOUT( 100.0, 50.0, 0.0 );
AOUT( 100.0,
0.0, 0.0 );
(* result is 4095 *)
(* result is 2457 *)
(* result is 819 *)
Runtime Errors
Condition
Return Value
Error Flags
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
Triconex (TCXLIB)
AOUT_BP12
51
AOUT_BP12
Converts a real number to a 12-bit differential bipolar analog output.
Syntax
y := AOUT_BP12( MX,
Table 36
IN,
MN )
Input Parameters
Name
Data Type
Description
MX
REAL
IN
REAL
MN
REAL
The engineering unit value for the minimum machine count of 4095.
Table 37
Return Value
Data Type
Description
DINT
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
+4095
MN
MX
Engineering
Units
-4095
52
Chapter 2
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:
-60.0
-4095
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
53
ARRAY32_BOOL
Stores an array of 32 Boolean values.
Syntax
ARRAY32_BOOL(READ:=b1, WRITE:=b2, INDEX:=k, IN:=b3)
Table 38
Input Parameters
Name
Data Type
Description
READ
BOOL
WRITE
BOOL
INDEX
DINT
IN
BOOL
Table 39
Output Parameters
Name
Data Type
Description
CO
BOOL
OUT
BOOL
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.
READ
WRITE
INDEX
CO
OUT
Notes
True
False
In-range
True
False
True
In-range
True
False
True
True
In-range
True
True
Out-of-range
False
False
True
Out-of-range
False
False
False
False
False
False
No operation.
54
Chapter 2
Example
Write a value to array element 23
VAR MY_ARRAY : ARRAY32_BOOL; END_VAR;
MY_ARRAY(READ:=FALSE, WRITE:=TRUE, INDEX:=23, IN:=TRUE);
(* Result: MY_ARRAY.CO is TRUE; MY_ARRAY.OUT is FALSE *)
Runtime Errors
Condition
Return Value
Error Flags
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
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
55
ARRAY32_DINT
Stores an array of 32 integers.
Syntax
ARRAY32_DINT(READ:=b1, WRITE:=b2, INDEX:=k, IN:=b3)
Table 40
Input Parameters
Name
Data Type
Description
READ
BOOL
WRITE
BOOL
INDEX
DINT
IN
DINT
Table 41
Output Parameters
Name
Data Type
Description
CO
BOOL
OUT
DINT
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.
READ
WRITE
INDEX
CO
OUT
Notes
True
False
In-range
True
False
True
In-range
True
True
True
In-range
True
True
Out-of-range
False
True
Out-of-range
False
False
False
False
No operation.
56
Chapter 2
Example
Write a value to array element 23
VAR MY_ARRAY : ARRAY32_DINT; END_VAR;
MY_ARRAY(READ:=FALSE, WRITE:=TRUE, INDEX:=23, IN:=1234);
(* Result: MY_ARRAY.CO is TRUE; MY_ARRAY.OUT is 0 *)
Runtime Errors
Condition
Return Value
Error Flags
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
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
57
ARRAY32_REAL
Stores an array of 32 real numbers.
Syntax
ARRAY32_REAL(READ:=b1, WRITE:=b2, INDEX:=k, IN:=b3)
Table 42
Input Parameters
Name
Data Type
Description
READ
BOOL
WRITE
BOOL
INDEX
DINT
IN
REAL
Table 43
Output Parameters
Name
Data Type
Description
CO
BOOL
OUT
REAL
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.
READ
WRITE
INDEX
CO
OUT
Notes
True
False
In-range
True
False
True
In-range
True
True
True
In-range
True
True
Out-of-range
False
True
Out-of-range
False
False
False
False
No operation.
58
Chapter 2
Example
Write a value to array element 23
VAR MY_ARRAY : ARRAY32_DINT; END_VAR;
MY_ARRAY(READ:=FALSE, WRITE:=TRUE, INDEX:=23, IN:=1234);
(* Result: MY_ARRAY.CO is TRUE; MY_ARRAY.OUT is 0 *)
Runtime Errors
Condition
Return Value
Error Flag
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
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
59
ASIN
Calculates the principal arc sine of a real number.
Syntax
Y := ASIN( x )
Table 44
Input Parameters
Name
Data Type
Description
ANY_REAL
The real number between 1.0 and 1.0 whose arc sine is to be calculated.
Table 45
Return Value
Data Type
Description
ANY_REAL
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 );
y := ASIN( 1.0 );
(* result is +1.5708 *)
(* result is 1.5708 *)
Runtime Errors
Condition
Return Values
Error Flags
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)
60
Chapter 2
ATAN
Calculates the principal arc tangent of a real number.
Syntax
Y := ATAN( x )
Table 46
Input Parameters
Name
Data Type
Description
ANY_REAL
Table 47
Return Value
Data Type
Description
ANY_REAL
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 :=
y :=
y :=
y :=
y : REAL; END_VAR
ATAN(
1.0 );
ATAN( 1.0 );
ATAN( 10.0 );
ATAN( 10.0 );
(*
(*
(*
(*
result
result
result
result
is
is
is
is
+0.785398
0.785398
+1.47113
1.47113
*)
*)
*)
*)
Runtime Errors
Condition
Return Value
Error Flags
If X is not a number.
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)
BLINK
61
BLINK
Generates a pulse output.
Syntax
BLINK(IN:=b1, RESET:=b2, T_ON:=t1, T_OFF:=t2)
Table 48
Input Parameters
Name
Data Type
Description
IN
BOOL
Enables blinking.
RESET
BOOL
T_ON
TIME
T_OFF
TIME
Table 49
Output Parameters
Name
Data Type
Description
BOOL
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 ;
62
Chapter 2
Runtime Errors
None.
Application Notes
Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
Library
Triconex (TCXLIB)
BLINK_I
63
BLINK_I
Generates a pulse output.
Syntax
BLINK_I(IN:=b1, RESET:=b2, T_ON:=t1, T_OFF:=t2)
Table 50
Input Parameters
Name
Data Type
Description
IN
BOOL
Enables blinking.
RESET
BOOL
T_ON
DINT
T_OFF
DINT
Table 51
Output Parameters
Name
Data Type
Description
BOOL
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 ;
64
Chapter 2
Runtime Errors
None.
Application Notes
Exactly Once: each instance should be executed exactly once per scan.
Library
Triconex (TCXLIB)
BLINK_R
65
BLINK_R
Generates a pulse output.
Syntax
BLINK_R(IN:=b1, RESET:=b2, T_ON:=t1, T_OFF:=t2)
Table 52
Input Parameters
Name
Data Type
Description
IN
BOOL
Enables blinking.
RESET
BOOL
T_ON
REAL
T_OFF
REAL
Table 53
Output Parameters
Name
Data Type
Description
BOOL
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 pulseoff 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 ;
66
Chapter 2
Runtime Errors
None.
Application Notes
Exactly Once: each instance should be executed exactly once per scan.
Library
Triconex (TCXLIB)
BOOL
67
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
Default value
False (0)
Lower limit
False (0)
Upper limit
True (1)
N/A
Application Notes
68
Chapter 2
BOOL_TO_DWORD
Converts a Boolean (BOOL) value to a DWORD value.
Syntax
w := BOOL_TO_DWORD(b);
Table 54
Input Parameters
Name
Data Type
Description
BOOL
Table 55
Return Value
Name
Data Type
Description
DWORD
DWORD
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 :=
w :=
b :=
w :=
b : BOOL;
w : DWORD;
TRUE;
BOOL_TO_DWORD( b );
FALSE;
BOOL_TO_DWORD( b );
END_VAR;
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
(* result is 16#0001 *)
(* result is 16#0000 *)
BYPASS_BOOL
69
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);
Table 56
Input Parameters
Name
Data Type
Description
BYPASS_REQ
BOOL
BYPASS_VALUE
BOOL
TAG_VALUE
BOOL
Table 57
Output Parameters
Name
Data Type
Description
VALUE
BOOL
BYPASSED
BOOL
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 blocks BYPASS input to true will not bypass the alarm. You
must use BYPASS_BOOL to bypass the value, while the BOOL alarm function blocks 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);
My_Trip_Alarm (SOURCE:=My_BYPASS_BOOL.value, BYPASS:=My_BypassTagname,
ACK_REQUEST:=False, DISABLE_REQUEST:=False, AUTOMATIC_RESET:=False,
MANUAL_RESET_REQUEST:=True, TIME_DELAY:=T#10ms, RINGBACK:=FALSE, SEVERITY:=200,
NORMAL_STATE:=True);
70
Chapter 2
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
71
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);
Table 58
Input Parameters
Name
Data Type
Description
BYPASS_REQ
BOOL
BYPASS_VALUE
DINT
TAG_VALUE
DINT
Table 59
Output Parameters
Name
Data Type
Description
VALUE
DINT
BYPASSED
BOOL
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 blocks BYPASS input to true will not bypass the alarm. You must
use BYPASS_DINT to bypass the value, while the DINT alarm function blocks 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
My_BYPASS_DINT(TAG_VALUE:=My_Tagname, BYPASS_VALUE:=55, BYPASS_REQ:=Tagname4);
My_Deviation_Alarm (SOURCE:=My_BYPASS_DINT.value, BYPASS:=Tagname4,
SETPOINT:=55, ACK_REQUEST:=Tagname3, DISABLE_REQUEST:=Tagname4,
72
Chapter 2
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
73
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);
Table 60
Input Parameters
Name
Data Type
Description
BYPASS_REQ
BOOL
BYPASS_VALUE
REAL
TAG_VALUE
REAL
Table 61
Output Parameters
Name
Data Type
Description
VALUE
REAL
BYPASSED
BOOL
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 blocks BYPASS input to true will not bypass the alarm. You
must use BYPASS_REAL to bypass the value, while the REAL alarm function blocks 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
My_BYPASS_REAL(TAG_VALUE:=My_Tagname, BYPASS_VALUE:=55, BYPASS_REQ:=Tagname4);
My_Deviation_Alarm (SOURCE:=My_BYPASS_REAL.value, BYPASS:=Tagname4,
SETPOINT:=55, ACK_REQUEST:=Tagname3, DISABLE_REQUEST:=Tagname4,
74
Chapter 2
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
75
CEIL
Returns the next higher integer.
Syntax
y := CEIL( x )
Table 62
Input Parameters
Name
Data Type
Description
ANY_REAL
The operand.
Table 63
Return Value
Data Type
Description
ANY_REAL
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
Condition
Return Value
Error Flags
If x is not a number.
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)
76
Chapter 2
CHK_ERR
Checks for runtime errors.
Syntax
CHK_ERR( CI:=TRUE )
Table 64
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables CHK_ERR.
Table 65
Output Parameters
Name
Data Type
Description
CO
BOOL
ERROR
BOOL
DIVBYZERO
BOOL
Divide by zero.
OVERFLOW
BOOL
Floating-point overflow.
UNDERFLOW
BOOL
Floating-point underflow.
BADPARAM
BOOL
Bad parameter.
BADCONV
BOOL
STRLEN
BOOL
RANGE
BOOL
ARRAYERR
BOOL
INTERNALERR
BOOL
Internal error.
OTHER
BOOL
Other error.
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.
CHK_ERR
77
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.
Condition
Reset ENO
Divide by zero
ERROR, DIVBYZERO
Yes
ERROR, OVERFLOW
Yes
UNDERFLOW
No
Bad parameter
ERROR, BADPARAM
Yes
ERROR, BADCONV
Yes
ERROR, STRLEN
Yes
ERROR, RANGE
Yes
ERROR, ARRAYERR
Yes
Internal error
ERROR, INTERNALERR
Yes
Other error
ERROR, OTHER
Yes
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.
78
Chapter 2
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-boundsthe 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:
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() ;
CHK_ERR
79
Runtime Errors
NoneCHK_ERR reads, but does not change, the runtime error flags.
Application Notes
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)
80
Chapter 2
CLR_ERR
Clears the runtime errors read by the CHK_ERR function block.
Syntax
CLR_ERR( CI:=TRUE )
Table 66
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables CHK_ERR.
Table 67
Output Parameters
Name
Data Type
Description
CO
BOOL
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
(*
:
CHECK_ERRORS( CI := TRUE );
IF (CHECK_ERRORS.ERROR = TRUE ) THEN ERRORS_A
CLEAR_ERRORS( CI := TRUE );
:
(* More
:
IF (CHECK_ERRORS.ERROR = TRUE ) THEN ERRORS_B
CLEAR_ERRORS( CI := TRUE );
END_PROGRAM
Runtime Errors
None.
Program code *)
:= TRUE; END_IF;
program code *)
:= TRUE; END_IF;
CLR_ERR
81
Application Notes
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)
82
Chapter 2
CONCAT_DT
Concatenates date and time-of-day values.
Syntax
datetime := CONCAT_DT( d, t )
Table 68
Input Parameters
Name
Data Type
Description
DATE
The date.
TOD
Table 69
Return Value
Data Type
Description
DT
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
Conditions
Return Values
Error Flags
If d or t is out of range.
d+t
BADPARAM, ERROR
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)
COS
83
COS
Calculates the cosine of an angle.
Syntax
y := COS( x ) ;
Table 70
Input Parameters
Name
Data Type
Description
ANY_REAL
Table 71
Return Value
Data Type
Description
ANY_REAL
The cosine of 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
Condition
Return Value
Error Flags
If x is not a number.
NAN
BADPARAM, ERROR
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)
84
Chapter 2
CSCHED
Schedules the execution of selected program logic after a specified number of scans.
Syntax
CSCHED( CI:=b1, NSCANS:=m1, NOFFSET:=m2 )
Table 72
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables CSCHED.
NSCANS
DINT
NOFFSET
DINT
The number of scans before the Q output is set to true for the first
time.
Table 73
Output Parameters
Name
Data Type
Description
CO
BOOL
BOOL
True if the specified number of scans occur. Q holds true for one
scan, then returns to false.
ACTUAL
TIME
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.
CSCHED
85
Application Notes
Exactly Once: each instance should be executed exactly once per scan.
Library
Triconex (TCXLIB)
86
Chapter 2
CSCHED_I
Schedules the execution of selected program logic after a specified number of scans.
Syntax
CSCHED_I( CI:=b1, NSCANS:=m1, NOFFSET:=m2 )
Table 74
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables CSCHED_I.
NSCANS
DINT
NOFFSET
DINT
The number of scans before the Q output is set to true for the first time.
Table 75
Output Parameters
Name
Data Type
Description
CO
BOOL
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.
CSCHED_I
87
Application Notes
Exactly Once: each instance should be executed exactly once per scan.
Library
Triconex (TCXLIB)
88
Chapter 2
CSCHED_R
Schedules the execution of selected program logic after a specified number of scans.
Table 76
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables CSCHED_R.
NSCANS
DINT
NOFFSET
DINT
The number of scans before the Q output is set to true for the first time.
Table 77
Output Parameters
Name
Data Type
Description
CO
BOOL
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
Exactly Once: each instance should be executed exactly once per scan.
Library
Triconex (TCXLIB)
TriStation 1131 Libraries Reference
CTD
89
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 )
Table 78
Input Parameters
Name
Data Type
Description
CD
BOOL
LD
BOOL
PV
INT
Table 79
Output Parameters
Name
Data Type
Description
BOOL
CV
INT
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.
90
Chapter 2
Application Notes
Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
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 risingedge trigger. The countdown progresses as long as the CD input remains true.
Library
Standard (STDLIB)
CTU
91
CTU
Up counter. Signals when a count reaches a preset value (PV).
Syntax
CTU( CU:=b1, R:=b2, PV:=m )
Table 80
Input Parameters
Name
Data Type
Description
CU
BOOL
BOOL
PV
INT
Table 81
Output Parameters
Name
Data Type
Description
BOOL
CV
INT
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.
92
Chapter 2
Application Notes
Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
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
93
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 )
Table 82
Input Parameters
Name
Data Type
Description
CU
BOOL
CD
BOOL
BOOL
LD
BOOL
PV
INT
Table 83
Output Parameters
Name
Data Type
Description
QU
BOOL
QD
BOOL
CV
INT
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.
94
Chapter 2
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
Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
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
95
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
Default value
D#1970-01-01
Lower limit
D#1970-01-01
Upper limit
D#2029-12-31
Invalid date
Invalid date
Application Notes
96
Chapter 2
DINT
A DINT data type is a double integer, 32 bits in length.
Attribute
Description
Keyword/type
DINT
Description
Double integer
Size
32 bits
Default value
Lower limit
2**31
Upper limit
2**311
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
DINT_TO_DWORD
97
DINT_TO_DWORD
Converts a 32-bit integer to a DWORD value.
Syntax
w := DINT_TO_DWORD(k);
Table 84
Input Parameters
Name
Data Type
Description
DINT
Table 85
Return Value
Data Type
Description
DWORD
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)
98
Chapter 2
DINT_TO_INT
Converts a 32-bit integer to a 16-bit integer.
Syntax
m := DINT_TO_INT(k);
Table 86
Input Parameters
Name
Data Type
Description
DINT
Table 87
Return Value
Data Type
Description
INT
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;
k := 1234;
m := DINT_TO_INT( k );
END_VAR;
(* result is 1234 *)
Runtime Errors
Condition
Return Value
Error Flags
32768
BADCONV, ERROR
+32767
BADCONV, 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)
DINT_TO_LREAL
99
DINT_TO_LREAL
Converts a 32-bit integer to a 64-bit long real number.
Syntax
x := DINT_TO_LREAL(k);
Table 88
Input Parameters
Name
Data Type
Description
DINT
Table 89
Return Value
Data Type
Description
LREAL
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;
k := 1234;
x := DINT_TO_LREAL( k );
END_VAR;
(* result is 1234.0 *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
100
Chapter 2
DINT_TO_REAL
Converts a 32-bit integer to a 32-bit real number.
Syntax
x := DINT_TO_REAL( k );
Table 90
Input Parameters
Name
Data Type
Description
DINT
Table 91
Return Value
Data Type
Description
REAL
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;
k := 1234;
x := DINT_TO_REAL( k );
END_VAR;
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
(* result is 1234.0 *)
DIV 101
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.
Table 92
DIV Operations
Operation
Numerator
Data Type
Denominator
Data Type
Result
Data Type
ANY_NUMa
ANY_NUM1
ANY_NUM
TIME
ANY_NUM
TIME
a. The numerator, denominator and quotient must the same numerical data type.
Example
Divide Two Numbers
VAR x : DINT;
VAR
x = 100 / 10;
END_VAR
(* result is 10 *)
(* result is T#1d1h1m0s0.0ms *)
102
Chapter 2
Runtime Errors
Conditions
Return Values
Error Flags
NAN
BADPARAM, ERROR
INF
DIVBYZERO, ERROR
NAN
DIVBYZERO, ERROR
+INF
DIVBYZERO, ERROR
DIVBYZERO, 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)
DT
103
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.
A DT data type cannot be used as a program input or output.
Attribute
Description
Keyword/type
DT
Description
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
Default value
DT#1970-01-01-00:00:00
Lower limit
DT#1970-01-01-00:00:00
Upper limit
DT#2029-12-31-23:59:59.999
Invalid date
Invalid date
Application Notes
104
Chapter 2
DT_TO_DATE
Extracts the date from a date and time value.
Syntax
d := DT_TO_DATE(dtm);
Table 93
Input Parameters
Name
Data Type
Description
dtm
DT
Table 94
Return Value
Name
Data Type
Description
OUT
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
Condition
Return Value
Error Flags
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)
DT_TO_TOD
105
DT_TO_TOD
Extracts the time of day from a date and time value.
Syntax
t := DT_TO_TOD(dtm);
Table 95
Input Parameters
Name
Data Type
Description
dtm
DT
The date and time from which to extract the time of day.
Table 96
Return Value
Data Type
Description
TOD
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
Condition
Return Value
Error Flags
Invalid time
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)
106
Chapter 2
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.
A DWORD data type cannot be used as a program input or output.
Attribute
Description
Keyword/type
DWORD
Description
Double word
Size
32 bits
Default value
Lower limit
Upper limit
16#FFFFFFFF
N/A
V and 16#FFFFFFFF
Application Notes
DWORD_TO_BOOL
107
DWORD_TO_BOOL
Converts a DWORD value to a Boolean (BOOL) value.
Syntax
b := DWORD_TO_BOOL(w)
Table 97
Input Parameters
Name
Data Type
Description
IN
DWORD
Table 98
Return Value
Name
Data Type
Description
OUT
BOOL
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);
b := DWORD_TO_BOOL(16#00000002);
*)
*)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
108
Chapter 2
DWORD_TO_DINT
Converts a DWORD value to a DINT value (32-bit signed integer).
Syntax
k := DWORD_TO_DINT(w)
Table 99
Parameter
Name
Data Type
Description
DWORD
Table 100
Return Value
Data Type
Description
DINT
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 );
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
(* result is 255 *)
EQ
109
EQ
Compares two operands for equality.
Syntax
b :=
x = y;
Table 101
Input Parameters
Name
Data Type
Description
ANY
First operand.
ANY
Second operand.
Table 102
Return Value
Data Type
Description
BOOL
True if x is equal to 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;
b := 11 = 11;
b := 'abcd' = 'abcd';
(* result is FALSE *)
(* result is TRUE *)
(* result is TRUE *)
Runtime Errors
None.
110
Chapter 2
Application Notes
Library
Standard (STDLIB)
EXP
111
EXP
Calculates the natural exponential for a real number.
Syntax
x := EXP(y)
Table 103
Input Parameters
Name
Data Type
Description
ANY_REAL
The operand.
Table 104
Return Value
Data Type
Description
ANY_REAL
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 :=
x :=
x :=
x : REAL; END_VAR
EXP(1.0);
EXP(2.0);
EXP(3.0);
(* result is 2.71828 *)
(* result is 7.38906 *)
(* result is 20.0855 *)
Runtime Errors
Conditions
Return Values
Error Flags
If y is not a number.
NAN
BADPARAM, ERROR
+INF
BADPARAM, ERROR
0.0
UNDERFLOW
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.
112
Chapter 2
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
EXPFLTR
113
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;
Table 105
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables smoothing.
RESET
BOOL
INPUT
REAL
FACTOR
REAL
The smoothing factor is greater than or equal to 0.0 and less than or equal to1.0.
IOUTPUT
REAL
Table 106
Output Parameters
Name
Data Type
Description
CO
BOOL
OUTPUT
REAL
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;
114
Chapter 2
Runtime Errors
Conditions
Return Values
Error Flag
CO=false,
BADPARAM, ERROR
OUTPUT=No change
If FACTOR is greater then 1.0.
CO=false,
BADPARAM, ERROR
OUTPUT=INPUT
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
Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
Library
Standard (STDLIB)
EXPT
115
EXPT
Raises a value to a specified power.
Syntax
z := x ** y;
Table 107
Input Parameters
Name
Data Type
Description
ANY_REAL
ANY_NUM
The exponent.
Table 108
Return Value
Data Type
Description
ANY_REAL
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 *)
116
Chapter 2
Runtime Errors
Conditions
Return Values
Error Flag
If x or y is not a number.
NAN
BADPARAM, ERROR
NAN
BADPARAM, ERROR
NAN
BADPARAM, ERROR
If y = 1.#INF and x is less than or equal to 1.0 and less than 0.0.
NAN
BADPARAM, ERROR
NAN
BADPARAM, ERROR
NAN
BADPARAM, ERROR
INF
None
+INF
None
+INF
None
+INF
None
+INF
None
+INF
None
0.0
None
0.0
None
0.0
None
0.0
None
0.0
None
0.0
UNDERFLOW
1.0
None
1.0
None
1.0
None
1.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
117
F_TRIG
Triggers on the falling edge of the CLK input.
Syntax
F_TRIG(CLK:=b)
Table 109
Input Parameters
Name
Data Type
Description
CLK
BOOL
Table 110
Output Parameters
Data Type
Description
BOOL
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.
118
Chapter 2
Application Notes
Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
Library
Standard (STDLIB)
FLOOR 119
FLOOR
Truncates a real number to an integer.
Syntax
y := FLOOR( x );
Table 111
Input Parameters
Name
Data Type
Description
ANY_REAL
The operand.
Table 112
Return Value
Data Type
Description
ANY_REAL
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
Condition
Return Value
Error Flags
If x is not a number.
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)
120
Chapter 2
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;
Table 113
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables GASDETR.
INPUT
DINT
INHIBIT
BOOL
RESET
BOOL
OPFLIM
DINT
SHFLIM
DINT
CALBLIM
DINT
OVRFLIM
DINT
GDMAXAV
DINT
GDMINAV
DINT
GDMAXEU
REAL
GDMINEU
REAL
GHIALIM
REAL
GLOALIM
REAL
Table 114
Output Parameters
Name
Data Type
Description
CO
BOOL
GDVALUE
REAL
HIALARM
BOOL
LOALARM
BOOL
OPALARM
BOOL
SHALARM
BOOL
CLALARM
BOOL
ORALARM
BOOL
HISTAT
BOOL
GASDETR
Table 114
121
Name
Data Type
Description
LOSTAT
BOOL
OPSTAT
BOOL
SHSTAT
BOOL
CLSTAT
BOOL
ORSTAT
BOOL
OUTPUT
DWORD
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
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.
122
Chapter 2
Application Notes
Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
Library
Standard (STDLIB)
GATDIS 123
GATDIS
Disables remote writes to aliased variables in a Tricon controller.
Syntax
GATDIS(CI:=b)
Table 115
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables GATDIS.
Table 116
Output Parameters
Name
Data Type
Description
CO
BOOL
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
Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
Library
Tricon (TX1LIB)
124
Chapter 2
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
Table 117
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables GATENB.
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
RRWLAST
DINT
Table 118
Output Parameters
Name
Data Type
Description
CO
BOOL
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 externalhost 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).
GATENB
125
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
Condition
Return Value
Error Flags
CO=false
None
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
Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
Library
Tricon (TX1LIB)
126
Chapter 2
GE
Determines if one operand is greater than or equal to another operand.
Syntax
b :=
x >= y ;
Table 119
Input Parameters
Name
Data Type
Description
ANY_ NOTE1
First operand.
ANY_NOTE1
Second operand.
Table 120
Return Value
Data Type
Description
BOOL
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.
GE
127
Examples
Structured Text
VAR b : BOOL; END_VAR
b := 10 >= 11;
b := 11 >= 11;
b := 11 >= 10;
b := 'abce' >= 'abcd';
(*
(*
(*
(*
result
result
result
result
is
is
is
is
FALSE
TRUE
TRUE
TRUE
*)
*)
*)
*)
Runtime Errors
None.
Application Notes
Library
Standard (STDLIB)
128
Chapter 2
GetDelta_DINT
Returns the scan period for the previous scan in milliseconds.
Syntax
t := GetDelta_DINT()
Table 121
Input Parameters
Name
Data Type
Description
None
None
None.
Table 122
Return Value
Data Type
Description
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.
GetDelta_DINT
129
Application Notes
Can be used in Safety or Control applications.
Library
Triconex (TCXLIB)
130
Chapter 2
GetDelta_REAL
Returns the scan period for the previous scan in seconds.
Syntax
t := GetDelta_REAL()
Table 123
Input Parameters
Name
Data Type
Description
None
None
None.
Table 124
Return Value
Data Type
Description
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.
GetDelta_REAL
131
Application Notes
Can be used in Safety or Control applications.
Library
Triconex (TCXLIB)
132
Chapter 2
GetDeltaT
Returns the scan period for the previous scan.
Syntax
t := GetDeltaT()
Table 125
Input Parameters
Name
Data Type
Description
None
None
None.
Table 126
Return Value
Data Type
Description
DINT
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.
GetDeltaT
133
Application Notes
Can be used in Safety or Control applications.
Library
Triconex (TCXLIB)
134
Chapter 2
GetTimer
Returns a date and time value that can be used to calculate the elapsed time between two events.
Syntax
dt := GetTimer()
Table 127
Input Parameters
Name
Data Type
Description
None
None
None.
Table 128
Return Value
Data Type
Description
DT
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
T1, T2
ElapsedTime
END_VAR
: BOOL;
: DT;
: TIME;
IF Event1 then
T1 := GetTimer();
END_IF;
IF Event2 then
T2 := GetTimer();
ElapsedTime := T2 - T1;
END_IF;
Runtime Errors
None.
GetTimer
135
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
136
Chapter 2
GT
Determines if two operands have a greater-than-or-equal-to relationship.
Syntax
b :=
x > y;
Table 129
Input Parameters
Name
Data Type
Description
ANY_ NOTE1
First operand.
ANY_ NOTE1
Second operand.
Table 130
Return Value
Data Type
Description
BOOL
Description
The GT function is used in graphical languages to determine if two operands have a greater-than-orequal-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.
GT
137
Example
Structured Text
VAR b : BOOL; END_VAR
b := 10 >= 11;
b := 11 >= 10;
b := 'abce' >= 'abcd';
(* result is FALSE *)
(* result is TRUE *)
(* result is TRUE *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
138
Chapter 2
INFINITY_LREAL
Returns plus infinity.
Syntax
y := INFINITY_LREAL();
Table 131
Input Parameters
Name
Data Type
Description
NA
NA
No inputs.
Table 132
Return Value
Data Type
Description
LREAL
Plus infinity.
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
139
INFINITY_REAL
Returns plus infinity.
Syntax
y := INFINITY_REAL();
Table 133
Input Parameters
Name
Data Type
Description
NA
NA
No inputs.
Table 134
Return Value
Data Type
Description
REAL
Plus infinity.
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)
140
Chapter 2
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
Lower limit
2**15
Upper limit
2**151
InvINT
InvINT
Application Notes
INT_TO_DINT
141
INT_TO_DINT
Converts a 16-bit integer to a 32-bit integer.
Syntax
m := INT_TO_DINT(k);
Table 135
Input Parameters
Name
Data Type
Description
INT
Table 136
Return Value
Data Type
Description
DINT
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;
k := 1234;
m := INT_TO_DINT( k );
END_VAR;
(* result is 1234 *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
142
Chapter 2
INT_TO_LREAL
Converts a 16-bit integer to a 64-bit long real number.
Syntax
x := INT_TO_LREAL(k);
Table 137
Input Parameters
Name
Data Type
Description
INT
Table 138
Return Value
Data Type
Description
LREAL
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;
k := 1234;
x := INT_TO_LREAL( k );
END_VAR;
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
(* result is 1234.0 *)
INT_TO_REAL
143
INT_TO_REAL
Converts a 16-bit integer to a 32-bit real number.
Syntax
x := INT_TO_REAL(k);
Table 139
Input Parameters
Name
Data Type
Description
INT
Table 140
Return Value
Data Type
Description
REAL
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;
k := 1234;
x := INT_TO_REAL( k );
END_VAR;
(* result is 1234.0 *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
144
Chapter 2
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 ;
Table 141
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables INTGTOR.
RESET
BOOL
INPUT
REAL
MINLVL
REAL
GAIN
REAL
DELTAT
TIME
IOUTPUT
REAL
Table 142
Output Parameters
Name
Data Type
Description
CO
BOOL
OUTPUT
REAL
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.
INTGTOR
145
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
Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
Library
Triconex (TCXLIB)
146
Chapter 2
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 ;
Table 143
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables INTGTOR_R.
RESET
BOOL
INPUT
REAL
MINLVL
REAL
GAIN
REAL
IOUTPUT
REAL
Table 144
Output Parameters
Name
Data Type
Description
CO
BOOL
OUTPUT
REAL
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.
INTGTOR_R 147
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
Exactly Once: each instance should be executed exactly once per scan.
Library
Triconex (TCXLIB)
148
Chapter 2
IsFinite_LREAL
Returns true if a number is finite.
Syntax
b := IsFinite_LREAL( x );
Table 145
Input Parameters
Name
Data Type
Description
LREAL
A number
Table 146
Return Value
Data Type
Description
BOOL
True if x is finite.
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 :=
b :=
x :=
b :=
x : LREAL ; b : BOOL ;
0.0 ;
IsFinite_LREAL( x );
1.0 / x ;
IsFinite_LREAL( x );
END_VAR;
(* result is true *)
(* result is false *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
IsFinite_REAL
149
IsFinite_REAL
Returns true if a number is finite.
Syntax
b := IsFinite_REAL( x );
Table 147
Input Parameters
Name
Data Type
Description
REAL
A number
Table 148
Return Value
Data Type
Description
BOOL
True if x is finite.
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 :=
b :=
x :=
b :=
x : REAL ; b : BOOL ;
0.0 ;
IsFinite_REAL( x );
1.0 / x ;
IsFinite_REAL( x );
END_VAR;
(* result is true *)
(* result is false *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
150
Chapter 2
IsNan_LREAL
Returns true if the operand is not a number (NAN).
Syntax
b := IsNan_LREAL( x );
Table 149
Input Parameters
Name
Data Type
Description
LREAL
The operand
Table 150
Return Value
Data Type
Description
BOOL
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 :=
b :=
x :=
b :=
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
IsNan_REAL
151
IsNan_REAL
Returns true if the operand is not a number (NAN).
Syntax
b := IsNan_REAL( x );
Table 151
Input Parameters
Name
Data Type
Description
REAL
The operand
Table 152
Return Value
Data Type
Description
BOOL
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 :=
b :=
x :=
b :=
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
152
Chapter 2
LE
Determines if one operand is less than or equal to another operand.
Syntax
b :=
x <= y ;
Table 153
Input Parameters
Name
Data Type
Description
ANY_ NOTE1
First operand.
ANY_ NOTE1
Second operand.
Table 154
Return Value
Data Type
Description
BOOL
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.
LE
153
Example
Structured Text
VAR b : BOOL; END_VAR
b := 10 <= 11;
b := 11 <= 11;
b := 11 <= 10;
b := 'abce' <= 'abcd';
(*
(*
(*
(*
result
result
result
result
is
is
is
is
TRUE *)
TRUE *)
FALSE *)
FALSE *)
Runtime Errors
None.
Application Notes
Library
Standard (STDLIB)
154
Chapter 2
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 ;
Table 155
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables LEADLAG.
IN
REAL
GAIN
REAL
TAU1
REAL
TAU2
REAL
AUTO_MAN
BOOL
DELTAT
TIME
Table 156
Output Parameters
Name
Data Type
Description
CO
BOOL
OUT
REAL
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.
LEADLAG
155
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
Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
Library
Triconex (TCXLIB)
156
Chapter 2
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 ;
Table 157
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables LEADLAG_R.
IN
REAL
GAIN
REAL
TAU1
REAL
TAU2
REAL
AUTO_MAN
BOOL
Table 158
Output Parameters
Name
Data Type
Description
CO
BOOL
OUT
REAL
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.
LEADLAG_R
157
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
Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
Library
Triconex (TCXLIB)
158
Chapter 2
LIMIT
Returns a value between a minimum limit and a maximum limit.
Syntax
y := LIMIT( low, x, high ) ;
Table 159
Input Parameters
Name
Data Type
Description
MN
ANY_ NOTE1
IN
ANY_NOTE1
MX
ANY_NOTE1
Table 160
Return Value
Data Type
Description
ANY_NOTE1
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
LIMIT
159
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)
160
Chapter 2
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 ;
Table 161
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables LINEMNTR.
INPUT
DINT
LNOPLIM
DINT
LNSHLIM
DINT
LMONLIM
DINT
Table 162
Output Parameters
Name
Data Type
Description
CO
BOOL
Control out.
OUTPUT
BOOL
LNSHORT
BOOL
LNOPEN
BOOL
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 shortcircuit 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.
TriStation 1131 Libraries Reference
LINEMNTR
161
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
MY_LINEMNTR
(
LNOPLIM:=819,
LMONLIM:=2000,
LNSHLIM:=4000,
INPUT:=4010
);
IS_OPEN := MY_LINEMNTR.LNOPEN;
(*
IS_SHORTED := MY_LINEMNTR.LNSHORT; (*
IS_ON := MY_LINEMNTR.LNSHORT;
(*
; END_VAR
result is false *)
result is true *)
result is false *)
Runtime Errors
None.
Application Notes
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)
162
Chapter 2
LN
Calculates the natural logarithm of a real number.
Syntax
y := LN( x );
Table 163
Input Parameters
Name
Data Type
Description
ANY_REAL
A real number.
Table 164
Return Value
Data Type
Description
ANY_REAL
Description
The LN function calculates the natural logarithm of a real number.
Example
VAR y : REAL; END_VAR
y := LN( 1.0 );
y := LN( 2.718282 );
(* result is 0.0 *)
(* result is 1.0 *)
Runtime Errors
Conditions
Return Values
Error Flags
If x is not a number.
NAN
BADPARAM, ERROR
If x is negative or zero.
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)
LOG
163
LOG
Calculates the common (base-ten) logarithm of a real number.
Syntax
y := LOG( x );
Table 165
Input Parameters
Name
Data Type
Description
ANY_REAL
A real number.
Table 166
Return Value
Data Type
Description
ANY_REAL
Description
The LOG function calculates the common (base-ten) logarithm of a real number.
Example
VAR
y :=
y :=
y :=
y : REAL;
LOG(
1.0
LOG( 10.0
LOG( 100.0
END_VAR
);
);
);
(* result is 0.0 *)
(* result is 1.0 *)
(* result is 2.0 *)
Runtime Errors
Conditions
Return Values
Error Flags
If x is not a number.
NAN
BADPARAM, ERROR
If x is negative or zero.
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)
164
Chapter 2
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);
Table 167
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables LOOPDETR.
INPUT
DINT
INHIBIT
BOOL
RSTIN
BOOL
OPFLIM
DINT
SHFLIM
DINT
TRALIM
DINT
HITRIP
BOOL
RSTTIME
TIME
DELTAT
TIME
Table 168
Output Parameters
Name
Data Type
Description
CO
BOOL
TRALARM
BOOL
OPALARM
BOOL
SHALARM
BOOL
RSTOUT
BOOL
TRSTAT
BOOL
OPSTAT
BOOL
SHSTAT
BOOL
RSTCNTR
TIME
OUTPUT
BOOL
LOOPDETR 165
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
Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
Library
Triconex (TCXLIB)
166
Chapter 2
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.
An LREAL data type cannot be used as a program input or output.
Attribute
Description
Keyword/type
LREAL
Description
Long-real number
Size
64 bits
Default value
0.0
1.7976931348623158 e +308
4.9406564584124654 e 324
4.9406564584124654 e 324
1.7976931348623158 e +308
Infinity or HUGE
+Infinity or HUGE
21022 = 2.2250738585072014E308.
21074 = 4.9406564584124654E324.
LREAL
167
This table shows how the precision changes as LREAL numbers approach zero.
If |x| Is Greater Than:
5.0E308
17 digits
5.0E309
16 digits
5.0E310
15 digits
5.0E322
3 digits
5.0E323
2 digits
5.0E324
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.
Range
Maximum Absolute
Error
Maximum Relative
Error
|x|
21075
21075 / |x|
253 * |x|
253
Application Notes
168
Chapter 2
LREAL_TO_DINT
Converts a 64-bit long real number to a 32-bit integer.
Syntax
k := LREAL_TO_DINT(x);
Table 169
Input Parameters
Name
Data Type
Description
LREAL
Table 170
Return Value
Data Type
Description
DINT
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;
x := -123.6;
k := LREAL_TO_DINT( x );
END_VAR;
(* result is -124 *)
Runtime Errors
Conditions
Return Values
Error Flags
If x is not a number.
2147483648
BADPARAM, ERROR
2147483648
BADCONV, ERROR
+2147483647
BADCONV, 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.
LREAL_TO_DINT 169
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
170
Chapter 2
LREAL_TO_INT
Converts a 64-bit long real number to a 16-bit integer.
Syntax
k := LREAL_TO_INT(x);
Table 171
Input Parameters
Name
Data Type
Description
LREAL
Table 172
Return Value
Data Type
Description
INT
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;
x := -123.6;
k := LREAL_TO_INT( x );
END_VAR;
(* result is -124 *)
Runtime Errors
Conditions
Return Values
Error Flags
If x is not a number.
32768
BADPARAM, ERROR
32768
BADCONV, ERROR
+32767
BADCONV, 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.
LREAL_TO_INT
171
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
172
Chapter 2
LREAL_TO_REAL
Converts a 64-bit long real number to a 32-bit real number.
Syntax
y := LREAL_TO_REAL(x);
Table 173
Input Parameters
Name
Data Type
Description
LREAL
Table 174
Return Value
Data Type
Description
REAL
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
Conditions
Return Values
Error Flags
If x is not a number.
NAN
BADPARAM, ERROR
INF
BADCONV, ERROR
+INF
BADCONV, 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.
LREAL_TO_REAL
173
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
174
Chapter 2
LT
Determines if one operand is less than another operand.
Syntax
b :=
x < y ;
Table 175
Input Parameters
Name
Data Type
Description
ANY_ NOTE1
First operand
ANY_ NOTE1
Second operand
Table 176
Return Value
Data Type
Description
BOOL
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.
LT
175
Example
Structured Text
VAR b : BOOL; END_VAR
b := 10 < 11;
b := 11 < 11;
b := 11 < 10;
b := 'abce' < 'abcd';
(*
(*
(*
(*
result
result
result
result
is
is
is
is
TRUE *)
FALSE *)
FALSE *)
FALSE *)
Runtime Errors
None.
Application Notes
Library
Standard (STDLIB)
176
Chapter 2
MAX
Finds the maximum of the input values.
Syntax
M := MAX( I1, I2, ..., In ) ;
Table 177
Input Parameters
Name
Data Type
Description
I1
ANY_ NOTE1
Input value 1.
In
ANY_ NOTE1
Input value n.
Table 178
Return Value
Data Type
Description
ANY_NOTE1
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
MAX
177
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)
178
Chapter 2
MBCTRL
Sets time-out and retry values for a Modbus master port.
Syntax
MY_MBCTRL(CI:=b1, PORT:=n1, TIME_OUT:=n2, RETRIES:=n3 );
Table 179
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables MBCTRL.
PORT
DINT
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
Table 180
DINT
Output Parameters
Name
Data Type
Description
CO
BOOL
STATUS
DINT
Status:
0=
Idle, no operation.
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:
Note
See Sample Projects on page 7 for information about where to find these projects on the PC where
you installed TriStation 1131.
MBCTRL
179
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
Condition
Return Value
Error Flag
CO=false
None
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
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)
180
Chapter 2
MBREAD_BOOL
Reads Boolean values from a Modbus slave.
Syntax
MY_MBREAD_BOOL(ACTIVE:=b1, ALIAS:=n1, N:=n2, PORT:=n3, STATION:=n4 );
Table 181
Input Parameters
Name
Data Type
Description
ACTIVE
BOOL
ALIAS
DINT
DINT
PORT
DINT
STATION
DINT
Table 182
Output Parameters
Name
Data Type
Description
IDLE
BOOL
BOOL
NDR
BOOL
ERROR
BOOL
STATUS
DINT
Status:
0=
Idle, no operation.
1=
Read initiated.
2=
3=
4=
Response received and new data received and next read initiated.
MBREAD_BOOL
Table 182
Name
181
Description
214 = Modbus slaves response has an LRC error.
216 = Modbus slaves response has a length error.
217 = Modbus slaves response function code does not match.
219 = Response not received in specified time-out period.
D01
BOOL
D32
BOOL
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
Example
For examples of using the MBREAD_BOOL function block, see these sample projects:
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
Condition
Return Value
Error Flag
ERROR=true
None
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
Exactly Once: each instance should be executed exactly once per scan.
Library
Tricon (TR1LIB/TX1LIB)
Trident/Tri-GP (TRDLIB)
182
Chapter 2
MBREAD_DINT
Reads integers from a Modbus slave.
Syntax
MY_MBREAD_DINT(ACTIVE:=b1, ALIAS:=n1, N:=n2, PORT:=n3, STATION:=n4 );
Table 183
Input Parameters
Name
Data Type
Description
ACTIVE
BOOL
ALIAS
DINT
DINT
PORT
DINT
STATION
DINT
Table 184
Output Parameters
Name
Data Type
Description
IDLE
BOOL
BOOL
NDR
BOOL
ERROR
BOOL
STATUS
DINT
Status:
0=
Idle, no operation.
1=
Read initiated.
3=
4=
Response received and new data received and next read initiated.
MBREAD_DINT
Table 184
183
Name
Data Type
Description
D01
DINT
D32
DINT
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
Example
For examples of using the MBREAD_DINT function block, see these sample projects:
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
Condition
Return Value
Error Flag
ERROR=true
None
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
Exactly Once: each instance should be executed exactly once per scan.
Library
Tricon (TR1LIB/TX1LIB)
Trident/Tri-GP (TRDLIB)
184
Chapter 2
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 );
Table 185
Input Parameters
Name
Data Type
Description
ACTIVE
BOOL
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:
3200132120 = Input real, read only.
3300134000 = Memory real, read only.
4100142000 = 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:
3400134240 = Input real, read only.
4400144240 = Input real, read only.
3500137000 = Memory real, read only.
4500147000 = Memory real, read only.
4200144000 = Memory real, read/write.
DINT
PORT
DINT
STATION
DINT
SPECIAL
BOOL
True if special aliases are used. For more information, see Description on page 185.
Table 186
Output Parameters
Name
Data Type
Description
IDLE
BOOL
BOOL
NDR
BOOL
ERROR
BOOL
MBREAD_REAL
Table 186
185
Name
Data Type
STATUS
DINT
Description
Status:
0=
Idle, no operation.
1=
Read initiated.
2=
3=
4=
Response received and new data received and next read initiated.
REAL
D25
REAL
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
186
Chapter 2
Special Alias
Description
32001
3400134002 or 4400144002
32001
3400334004 or 4400344004
32120
3423934240 or 4423944240
33001
3500135002 or 4500145002
33002
3500335004 or 4500345004
34000
3699937000 or 4699947000
41001
4200142002
41002
4200342004
4399944000
.
.
.
.
.
.
42000
Example
For examples of using the MBREAD_REAL function block, see these sample projects:
Note
See Sample Projects on page 7 for information about where to find these projects on the PC where
you installed TriStation 1131.
MBREAD_REAL
187
Runtime Errors
Condition
Return Value
Error Flag
ERROR=true
None
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
Exactly Once: each instance should be executed exactly once per scan.
Library
Tricon (TR1LIB/TX1LIB)
Trident/Tri-GP (TRDLIB)
188
Chapter 2
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 );
Table 187
Input Parameters
Name
Data Type
Description
ACTIVE
BOOL
ALIAS
DINT
DINT
PORT
DINT
STATION
DINT
Table 188
Output Parameters
Name
Data Type
Description
IDLE
BOOL
BOOL
NDR
BOOL
ERROR
BOOL
STATUS
DINT
Status:
0=
Idle, no operation.
1=
Read initiated.
2=
3=
4=
Response received and new data received and next read initiated.
MBREAD_REAL_TRD
Table 188
Name
189
Description
213 = Modbus slaves response has a CRC error.
214 = Modbus slaves response has an LRC error.
216 = Modbus slaves response has a length error.
217 = Modbus slaves response function code does not match.
219 = Response not received in specified time-out period.
D01
REAL
D25
REAL
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
Example
For examples of using Modbus Read function blocks, see these sample projects:
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
Condition
Return Value
Error Flag
ERROR=true
None
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.
190
Chapter 2
Application Notes
Can be used in Safety or Control applications.
Library
Tricon (TR1LIB/TX1LIB)
Trident/Tri-GP (TRDLIB)
MBWRITE_BOOL
191
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 );
Table 189
Input Parameters
Name
Data Type
Description
ACTIVE
BOOL
ALIAS
DINT
DINT
PORT
DINT
STATION
DINT
D01
BOOL
D32
BOOL
Table 190
Output Parameters
Name
Data Type
Description
IDLE
BOOL
BOOL
ACK
BOOL
ERROR
BOOL
STATUS
DINT
Status:
0=
Idle, no operation.
1=
Write initiated.
2=
3=
Response received.
4=
192
Chapter 2
Table 190
Name
Description
203 = Modbus slave returned an Illegal Data Value response code
204 = Modbus slave returned a Failure in Associated Device response code.
206 = Modbus slave returned a Busy, Rejected Message code.
213 = Modbus slaves response has a CRC error.
214 = Modbus slaves response has an LRC error.
216 = Modbus slaves response has a length error.
217 = Modbus slaves response function code does not match.
219 = Response not received in specified time-out period.
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
Example
For examples of using the MBWRITE_BOOL function block, see these sample projects:
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
Condition
Return Value
Error Flag
ERROR=true
None
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
Exactly Once: each instance should be executed exactly once per scan.
Library
Tricon (TR1LIB/TX1LIB)
Trident/Tri-GP (TRDLIB)
MBWRITE_DINT
193
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 );
Table 191
Input Parameters
Name
Data Type
Description
ACTIVE
BOOL
ALIAS
DINT
DINT
PORT
DINT
STATION
DINT
D01
DINT
D32
DINT
Table 192
Output Parameters
Name
Data Type
Description
IDLE
BOOL
BOOL
ACK
BOOL
ERROR
BOOL
STATUS
DINT
Status:
0=
Idle, no operation.
1=
Write initiated.
2=
3=
Response received.
4=
194
Chapter 2
Table 192
Name
Description
203 = Modbus slave returned an Illegal Data Value response code.
204 = Modbus slave returned a Failure in Associated Device response code
206 = Modbus slave returned a Busy, Rejected Message code
213 = Modbus slaves response has a CRC error.
214 = Modbus slaves response has an LRC error.
216 = Modbus slaves response has a length error.
217 = Modbus slaves response function code does not match.
219 = Response not received in specified time-out period.
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
Example
For examples of using the MBWRITE_DINT function block, see these sample projects:
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
Condition
Return Value
Error Flag
ERROR=true
None
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
Exactly Once: each instance should be executed exactly once per scan.
Library
Tricon (TR1LIB/TX1LIB)
Trident/Tri-GP (TRDLIB)
MBWRITE_REAL
195
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 );
Table 193
Input Parameters
Name
Data Type
Description
ACTIVE
BOOL
ALIAS
DINT
DINT
PORT
DINT
STATION
DINT
SPECIAL
BOOL
True if special aliases are used. For more information, see Special Alias Mapping in
Tricon Controller on page 197.
D01
REAL
D25
REAL
Table 194
Output Parameters
Name
Data Type
Description
IDLE
BOOL
BOOL
ACK
BOOL
ERROR
BOOL
196
Chapter 2
Table 194
Name
Data Type
STATUS
DINT
Description
Status:
0=
Idle, no operation.
1=
Write initiated.
2=
3=
Response received.
4=
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
MBWRITE_REAL
197
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.
Special Alias
Description
41001
4200142002
41002
4200342004
42000
439994400
Example
For examples of using the MBWRITE_REAL function block, see these sample projects:
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
Condition
Return Value
Error Flag
ERROR=true
None
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
Exactly Once: each instance should be executed exactly once per scan.
Library
Tricon (TR1LIB/TX1LIB)
Trident/Tri-GP (TRDLIB)
198
Chapter 2
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 );
Table 195
Input Parameters
Name
Data Type
Description
ACTIVE
BOOL
ALIAS
DINT
DINT
PORT
DINT
STATION
DINT
D01
REAL
D25
REAL
Table 196
Output Parameters
Name
Data Type
Description
IDLE
BOOL
BOOL
ACK
BOOL
ERROR
BOOL
MBWRITE_REAL_TRD
Table 196
199
Name
Data Type
STATUS
DINT
Description
Status:
0=
Idle, no operation.
1=
Write initiated.
2=
3=
Response received.
4=
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 16bit 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
Example
For examples of using Modbus Write function blocks, see these sample projects:
Note
See Sample Projects on page 7 for information about where to find these projects on the PC where
you installed TriStation 1131.
200
Chapter 2
Runtime Errors
Condition
Return Value
Error Flag
ERROR=true
None
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 201
MEDSEL
Returns the median of the input numbers.
Syntax
y := MEDSEL( x1, x2, ..., xn ) ;
Table 197
Input Parameters
Name
Data Type
Description
x1
ANY_REAL
Input value 1.
xn
ANY_REAL
Input value n.
Table 198
Return Value
Data Type
Description
ANY_REAL
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
(* result is 15.0 *)
(* result is 17.5 *)
Runtime Errors
Table 199
Runtime Errors
Condition
Return Value
Error Flags
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.
202
Chapter 2
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
MIN
203
MIN
Find the minimum of the input values.
Syntax
M := MIN( I1, I2, ..., In ) ;
Table 200
Input Parameters
Name
Data Type
Description
I1
ANY_ NOTE1
Input value 1.
In
ANY_ NOTE1
Input value n.
Table 201
Return Value
Data Type
Description
ANY_NOTE1
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
Example
VAR m : DINT ; END_VAR
m := MIN( 3, 1, 2 );
(* Result is 1 *)
204
Chapter 2
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
MINUS_INFINITY_LREAL
205
MINUS_INFINITY_LREAL
Returns minus infinity.
Syntax
y := MINUS_INFINITY_LREAL();
Table 202
Input Parameters
Name
Data Type
Description
NA
NA
No inputs.
Table 203
Return Value
Data Type
Description
LREAL
Minus infinity.
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)
206
Chapter 2
MINUS_INFINITY_REAL
Returns minus infinity.
Syntax
y := MINUS_INFINITY_REAL();
Table 204
Input Parameters
Name
Data Type
Description
NA
NA
No inputs.
Table 205
Return Value
Data Type
Description
REAL
Minus infinity.
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
207
MOD
Divides two integers and returns the remainder.
Syntax
i := j MOD k ;
Table 206
Input Parameters
Name
Data Type
Description
ANY_INT
First operand.
ANY_INT
Second operand.
Table 207
Return Value
Data Type
Description
ANY_INT
The remainder.
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
Condition
Return Value
Error Flags
DIVBYZERO, 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)
208
Chapter 2
MOVE
Assigns an input value to an output value.
Syntax
OUT := IN ;
Table 208
Input Parameters
Name
Data Type
Description
IN
ANY
Table 209
Return Value
Data Type
Description
ANY
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 ;
Runtime Errors
None.
Application Notes
Library
Standard (STDLIB)
MUL
209
MUL
Multiplies two or more numbers, or multiplies a time by a number.
Syntax
P := I1 * I2 * ... * In ;
T2 := T1 * N ;
Input Parameters
Name
Data Type
Description
I1
ANY_NUM
First operand.
In
ANY_NUM
Last operand.
Table 211
Return Value
Data Type
Description
ANY_NUM
The product.
Input Parameters
Name
Type
Description
T1
TIME
The time.
ANY_NUM
A number.
Table 213
Return Value
Data Type
Description
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.
210
Chapter 2
Example
Calculate the product of three numbers
VAR p : DINT; END_VAR
p := 2 * 3 * 4 ;
(* result is 24 *)
END_VAR
(* result is T#2s *)
Runtime Errors
Condition
Return Value
Error Flags
INF
OVERFLOW, ERROR
NAN
OVERFLOW, ERROR
Invalid time
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)
MUX
211
MUX
Selects a value from multiple inputs.
Syntax
v := MUX( K, I0, I1, ..., In-1 ) ;
Table 214
Input Parameters
Name
Data Type
Description
ANY_INT
The selector.
I0
ANY
Data value 0.
..
In-1
ANY
Table 215
Return Value
Data Type
Description
ANY
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
Conditions
Return Values
Error Flags
Input I0
BADPARAM, ERROR
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.
212
Chapter 2
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
NAN_LREAL
213
NAN_LREAL
Returns not a number (NAN).
Syntax
y := NAN_LREAL();
Table 216
Input Parameters
Name
Data Type
Description
NA
NA
No inputs.
Table 217
Return Value
Data Type
Description
LREAL
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)
214
Chapter 2
NAN_REAL
Returns not a number (NAN).
Syntax
y := NAN_REAL();
Table 218
Input Parameters
Name
Data Type
Description
NA
NA
No inputs.
Table 219
Return Value
Data Type
Description
REAL
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
215
NE
Compares two operands for inequality.
Syntax
b :=
x <> y;
Table 220
Input Parameters
Name
Data Type
Description
ANY
First operand
ANY
Second operand
Table 221
Return Value
Data Type
Description
BOOL
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;
b := 11 <> 11;
b := 'abcd' <> 'abcd';
(* result is TRUE *)
(* result is FALSE *)
(* result is FALSE *)
Runtime Errors
None.
216
Chapter 2
Application Notes
Library
Standard (STDLIB)
NOT
217
NOT
Performs a logical negation of a Boolean operand or a bitwise complement of a bit-string.
Syntax
v := not b ;
Table 222
Input Parameters
Name
Data Type
Description
ANY_BIT
Operand
Table 223
Return Value
Data Type
Description
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.
Table 224
logical NOT
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.
Table 225
bitwise complement
Bit
Complement
The operand and the return value are the same data type, that is, they are both BOOL or both DWORD.
218
Chapter 2
Example
Using Boolean Operands
VAR b, b1:=TRUE, b2:=FALSE : BOOL; END_VAR
b := NOT b1;
(* result is FALSE *)
b := NOT b2;
(* result is TRUE *)
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
Library
Standard (STDLIB)
NUMBITS
219
NUMBITS
Counts the number of Boolean parameters with value true.
Syntax
n := NUMBITS(b1, b2, ... , bn) ;
Table 226
Input Parameters
Name
Data Type
Description
b1...bn
BOOL
Boolean parameters
Table 227
Return Value
Data Type
Description
DINT
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)
220
Chapter 2
NUMBITS_DWORD
Counts the number of 1-bits in a DWORD.
Syntax
n := NUMBITS_DWORD( w ) ;
Table 228
Input Parameters
Name
Data Type
Description
DWORD
A bit-string
Table 229
Return Value
Data Type
Description
DINT
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 221
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 ;
Table 230
Input Parameters
Name
Data Type
Description
b1...bn
ANY_BIT
Operands
Table 231
Return Value
Data Type
Description
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.
Table 232
logical OR
b1
b2
b1 OR b2
FALSE
FALSE
FALSE
FALSE
TRUE
TRUE
TRUE
FALSE
TRUE
TRUE
TRUE
TRUE
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.
Table 233
bitwise OR
w1
w2
w1 OR w2
2#0011
2#0101
2#0111
222
Chapter 2
Example
Using Boolean Operands
VAR b, b1:=FALSE, b2:=FALSE, b3:=TRUE : BOOL; END_VAR
b := b1 OR b2 OR b3;
(* result is TRUE *)
b := b1 OR b2;
(* result is FALSE *)
;
;
;
*)
*)
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
Library
Standard (STDLIB)
OVDDISABLE
223
OVDDISABLE
Disables output voter diagnostics (OVD) for a selected Digital Output (DO) Module.
Syntax
MY_OVDDISABLE( CI:=b1, CHASSIS:=n1, SLOT:=n2 ) ;
Table 234
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables OVDDISABLE.
CHASSIS
DINT
SLOT
DINT
Table 235
Output Parameters
Name
Data Type
Description
CO
BOOL
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
Condition
Return Value
Error Flags
CO=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
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)
224
Chapter 2
OVDENABLE
Enables output voter diagnostics (OVD) for a selected Digital Output (DO) Module.
Syntax
MY_OVDENABLE( CI:=b1, CHASSIS:=n1, SLOT:=n2 ) ;
Table 236
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables OVDENABLE.
CHASSIS
DINT
SLOT
DINT
Table 237
Output Parameters
Name
Data Type
Description
CO
BOOL
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
Condition
Return Value
Error Flags
CO=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
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
225
PACK16
Packs 16 bits into a DWORD.
Syntax
w := PACK16(IN01, IN02, ... , IN16) ;
Table 238
Input Parameters
Name
Data Type
Description
IN01
BOOL
IN02
BOOL
IN03
BOOL
IN04
BOOL
INnn
BOOL
IN16
BOOL
Table 239
Return Value
Data Type
Description
DWORD
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)
226
Chapter 2
PACK32
Packs 32 bits into a DWORD.
Syntax
w := PACK32(IN01, IN02, ... , IN32) ;
Table 240
Input Parameters
Name
Data Type
Description
IN01
BOOL
IN02
BOOL
IN03
BOOL
IN04
BOOL
INnn
BOOL
IN32
BOOL
Table 241
Return Value
Data Type
Description
DWORD
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 227
PAGE_EJECT
Ejects paper (feeds the form) to the top of the next page.
Syntax
MY_PAGE_EJECT( CI:=b1, PRINTER:=n1 ) ;
Table 242
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables PAGE_EJECT.
PRINTER
DINT
Printer number.
Table 243
Output Parameters
Name
Data Type
Description
CO
BOOL
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 validhowever, 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
Condition
Return Value
Error Flags
If PRINTER is invalid.
CO=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.
If the PRINTER parameter is invalid, then the function block aborts the print operation.
228
Chapter 2
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
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
229
PERDEV
Computes percent deviation.
Syntax
b := PERDEV( NAME1, NAME2, SPAN, FRACTION );
Table 244
Input Parameters
Name
Data Type
Description
NAME1
REAL
NAME2
REAL
SPAN
REAL
FRACTION
REAL
Table 245
Return Value
Data Type
Description
BOOL
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 ) ;
b := PERDEV( 10.0, 80.0, 100.0, 0.5 ) ;
(* result is TRUE *)
(* result is FALSE *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Triconex (TCXLIB)
230
Chapter 2
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 ) ;
Table 246
VAR_IN_OUT Parameters
Name
Data Type
Description
SP
REAL
CV
REAL
Table 247
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables PID.
PV
REAL
AUTO_MAN
BOOL
RATE
REAL
RESET
REAL
KPB
REAL
MAXCV
REAL
MINCV
REAL
MAXRATE
REAL
DELTAT
TIME
Table 248
Output Parameters
Name
Data Type
Description
CO
BOOL
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).
PID
231
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
Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
Library
Triconex (TCXLIB)
232
Chapter 2
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 ;
Table 249
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables PID_R.
SPIN
REAL
CVIN
REAL
PV
REAL
AUTO_MAN
BOOL
RATE
REAL
RESET
REAL
KPB
REAL
MAXCV
REAL
MINCV
REAL
MAXRATE
REAL
DLT
REAL
Table 250
Output Parameters
Name
Data Type
Description
CO
BOOL
SPOUT
REAL
CVOUT
REAL
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
PID_R
233
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
Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
Library
Triconex (TCXLIB)
234
Chapter 2
POLY4
Returns the value of a polynomial with four coefficients.
Syntax
y := POLY4( X, C0, C1, C2, C3 ) ;
Table 251
Input Parameters
Name
Data Type
Description
LREAL
C0
LREAL
Coefficient 0.
C1
LREAL
Coefficient 1.
C2
LREAL
Coefficient 2.
C3
LREAL
Coefficient 3.
Table 252
Return Value
Data Type
Description
LREAL
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
235
POLY5
Returns the value of a polynomial with five coefficients.
Syntax
y := POLY4( X, C0, C1, C2, C3, C4 ) ;
Table 253
Input Parameters
Name
Data Type
Description
LREAL
C0
LREAL
Coefficient 0.
C1
LREAL
Coefficient 1.
C2
LREAL
Coefficient 2.
C3
LREAL
Coefficient 3.
C4
LREAL
Coefficient 4.
Table 254
Return Value
Data Type
Description
LREAL
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)
236
Chapter 2
PRINT_BOOL
Prints a three-character field containing either Off or On.
Syntax
MY_PRINT_BOOL( CI:=b1, PRINTER:=n1, IN:=b2 ) ;
Table 255
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables PRINT_BOOL.
PRINTER
DINT
Printer number.
IN
BOOL
Table 256
Output Parameters
Name
Data Type
Description
CO
BOOL
Description
The PRINT_BOOL function block prints a three-character field containing either Off or On. (On is leftjustified 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 ) ;
PRINT_BOOL
237
Runtime Errors
Condition
Return Value
Error Flags
If PRINTER is invalid.
CO=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.
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
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)
238
Chapter 2
PRINT_CDT
Prints the current date and time of day.
Syntax
MY_PRINT_CDT( CI:=b1, PRINTER:=n1 ) ;
Table 257
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables PRINT_CDT.
PRINTER
DINT
Printer number.
Table 258
Output Parameters
Name
Data Type
Description
CO
BOOL
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 ) ;
PRINT_CDT
239
Runtime Errors
Condition
Return Value
Error FlagS
If PRINTER is invalid.
CO=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.
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
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)
240
Chapter 2
PRINT_CRLF
Prints a new line (a carriage return and line feed).
Syntax
MY_PRINT_CRLF( CI:=b1, PRINTER:=n1 ) ;
Table 259
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables PRINT_CRLF.
PRINTER
DINT
Printer number.
Table 260
Output Parameters
Name
Data Type
Description
CO
BOOL
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 ) ;
PRINT_CRLF
241
Runtime Errors
Condition
Return Value
Error Flags
If PRINTER is invalid.
CO=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.
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
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)
242
Chapter 2
PRINT_CTOD
Prints the current time of day.
Syntax
MY_PRINT_CTOD( CI:=b1, PRINTER:=n1 ) ;
Table 261
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables PRINT_CTOD.
PRINTER
DINT
Printer number.
Table 262
Output Parameters
Name
Data Type
Description
CO
BOOL
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 ) ;
PRINT_CTOD 243
Runtime Errors
Condition
Return Value
Error Flag
If PRINTER is invalid.
CO=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.
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
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)
244
Chapter 2
PRINT_DINT
Prints a double integer right-justified in an eight-character field.
Syntax
MY_PRINT_DINT( CI:=b1, PRINTER:=n1, IN:=n2 ) ;
Table 263
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables PRINT_DINT.
PRINTER
DINT
Printer number.
IN
DINT
Table 264
Output Parameters
Name
Data Type
Description
CO
BOOL
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.
PRINT_DINT
245
Example
VAR MY_PRINT_DINT : PRINT_DINT ; END_VAR
(* Print "
999" on printer 5. *)
MY_PRINT_DINT( PRINTER:=5, IN:=999 ) ;
Runtime Errors
Condition
Return Value
Error Flags
If PRINTER is invalid.
CO=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.
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
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)
246
Chapter 2
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 ) ;
Table 265
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables PRINT_REAL.
PRINTER
DINT
Printer number.
IN
REAL
PRECISION
DINT
Table 266
Output Parameters
Name
Data Type
Description
CO
BOOL
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.
PRINT_REAL
247
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
Condition
Return Value
Error Flags
If PRINTER is invalid.
CO=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.
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
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)
248
Chapter 2
PRINT_STRING
Prints a string of text (not including quotation marks).
Syntax
MY_PRINT_STRING( CI:=b1, PRINTER:=n1, IN:=s1 ) ;
Table 267
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables PRINT_STRING.
PRINTER
DINT
Printer number.
IN
STRING
Table 268
Output Parameters
Name
Data Type
Description
CO
BOOL
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.
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. ) ;
PRINT_STRING
249
Runtime Errors
Condition
Return Value
Error Flags
If PRINTER is invalid.
CO=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.
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
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)
250
Chapter 2
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 ) ;
Table 269
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables PRNTR_FLUSH.
PRINTER
DINT
Printer number.
Table 270
Output Parameters
Name
Data Type
Description
CO
BOOL
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 ) ;
PRNTR_FLUSH
251
Runtime Errors
Condition
Return Value
Error Flags
If PRINTER is invalid.
CO=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.
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
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)
252
Chapter 2
R_TRIG
Detects a rising edge.
Syntax
MY_R_TRIG( CLK:=b1 ) ;
b2 := MY_R_TRIG.Q ;
Table 271
Input Parameters
Name
Data Type
Description
CLK
BOOL
Clock.
Table 272
Output Parameters
Name
Data Type
Description
BOOL
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 ;
CHECK_FOR_RISING_EDGE(
b := 1 ;
CHECK_FOR_RISING_EDGE(
b := 1 ;
CHECK_FOR_RISING_EDGE(
b := 0 ;
CHECK_FOR_RISING_EDGE(
CLK:=b );
CLK:=b );
CLK:=b );
CLK:=b );
(* no rising edge *)
(* Q is FALSE *)
(*
(*
(*
(*
(*
(*
rising edge, 0 to 1 *)
Q is TRUE *)
no rising edge *)
Q is FALSE *)
no rising edge *)
Q is FALSE *)
R_TRIG
253
Runtime Errors
None.
Application Notes
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.
Library
Standard (STDLIB)
254
Chapter 2
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
Description
Real number
Size
32 bits
Default value
0.0
3.402823466 e +38
1.401298464 e 45
1.401298464 e 45
3.402823466 e +38
Infinity or HUGE
+Infinity or HUGE
With Underflow
2126 = 1.175494351E-38.
The precision changes abruptly from 7 digits to 0
digits when the value changes from a number greater
than 2127 to a number less than 2127.
2149 = 1.401298464E45.
The precision changes gradually from 7 digits to 1 digit
as the value changes from 2127 to 2149.
The maximum relative error changes gradually from 2
to 1 as the value changes from 2127 to
149
2 .
24
REAL
255
This table shows how the precision changes as numbers approach zero.
If |x| Is Greater Than:
1.5E39
7 digits
1.5E40
6 digits
1.5E41
5 digits
1.5E42
4 digits
1.5E43
3 digits
1.5E44
2 digits
1.5E45
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.
Range
Maximum Absolute
Error
Maximum Relative
Error
|x|
2150
2150 / |x|
224 * |x|
224
Application Notes
256
Chapter 2
REAL_TO_DINT
Converts a 32-bit real number to a 32-bit integer.
Syntax
k := REAL_TO_DINT( x );
Table 273
Input Parameters
Name
Data Type
Description
REAL
Table 274
Return Value
Data Type
Description
DINT
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;
x := -123.6;
k := REAL_TO_DINT( x );
END_VAR;
(* result is -124 *)
Runtime Errors
Conditions
Return Values
Error Flags
If x is not a number.
2147483648
BADPARAM, ERROR
2147483648
BADCONV, ERROR
+2147483647
BADCONV, 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.
REAL_TO_DINT
257
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
258
Chapter 2
REAL_TO_INT
Converts a 32-bit real number to a 16-bit integer.
Syntax
k := REAL_TO_INT( x );
Table 275
Input Parameters
Name
Data Type
Description
REAL
Table 276
Return Value
Data Type
Description
INT
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;
x := -123.6;
k := REAL_TO_INT( x );
END_VAR;
(* result is -124 *)
Runtime Errors
Conditions
Return Values
Error Flags
If x is not a number.
32768
BADPARAM, ERROR
32768
BADCONV, ERROR
+32767
BADCONV, 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.
REAL_TO_INT
259
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
260
Chapter 2
REAL_TO_LREAL
Converts a 32-bit real number to a 64-bit long real number.
Syntax
y := REAL_TO_LREAL( x );
Table 277
Input Parameters
Name
Data Type
Description
REAL
Table 278
Return Value
Data Type
Description
LREAL
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
Condition
Return Value
Error Flags
If x is not a number
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)
ReportBadParam
261
ReportBadParam
Reports a bad parameter error.
Syntax
b1 := ReportBadParam(I1) ;
Table 279
Input Parameters
Name
Data Type
Description
I1
INT
Not used.
Table 280
Return Value
Data Type
Description
BOOL
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)
262
Chapter 2
ROL
Rotates left N bits, where N is the shift count.
Syntax
w := ROL( IN, N ) ;
Table 281
Input Parameters
Name
Data Type
Description
IN
ANY_BIT
Operand
ANY_INT
Shift count.
Table 282
Return Value
Data Type
Description
ANY_BIT
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
263
ROR
Rotates right N bits, where N is the shift count.
Syntax
w := ROR( IN, N ) ;
Table 283
Input Parameters
Name
Data Type
Description
IN
ANY_BIT
Operand.
ANY_INT
Shift count.
Table 284
Return Value
Data Type
Description
ANY_BIT
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)
264
Chapter 2
RS
RS is a bistable function block (reset dominant).
Syntax
RS( S:=b1, R1:=b2 ) ;
b3 := SR.Q1
Table 285
Input Parameters
Name
Data Type
Description
BOOL
Set.
R1
BOOL
Reset.
Table 286
Output Parameters
Name
Data Type
Description
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.
Table 287
Truth Table
R1
Q1
false
false
no change
false
true
false
true
false
true
true
true
false
Example
VAR MY_RS : RS ; END_VAR
MY_RS( S:=FALSE, R1:=TRUE
MY_RS( S:=FALSE, R1:=FALSE
MY_RS( S:=TRUE,
R1:=TRUE
MY_RS( S:=TRUE,
R1:=FALSE
MY_RS( S:=FALSE, R1:=FALSE
Runtime Errors
None.
);
);
);
);
);
(*
(*
(*
(*
(*
Q1
Q1
Q1
Q1
Q1
is
is
is
is
is
FALSE
FALSE
FALSE
TRUE
TRUE
*)
*)
*)
*)
*)
RS
265
Application Notes
Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
Library
Standard (STDLIB)
266
Chapter 2
RTC
Provides a real-time clock.
Syntax
MY_RTC( IN:=b1, PDT:=dt1 ) ;
Table 288
Input Parameters
Name
Data Type
Description
IN
BOOL
Enables RTC.
PDT
DT
Table 289
Output Parameters
Name
Data Type
Description
BOOL
Copy of IN.
CDT
DT
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).
Example
VAR MY_RTC : RTC ; END_VAR
MY_RTC() ;
(* Output CDT is the current date and time. *)
Runtime Errors
None.
Application Notes
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
267
SCALE
Scales a value from one engineering unit to another.
Syntax
y := SCALE( INPUT, MAX1, MIN1, MAX2, MIN2 )
Table 290
Input Parameters
Name
Data Type
Description
INPUT
REAL
MAX1
REAL
MIN1
REAL
MAX2
REAL
MIN2
REAL
Table 291
Return Value
Data Type
Description
REAL
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)
268
Chapter 2
SEL
Selects one of two data values.
Syntax
v := SEL( G, IN0, IN1 ) ;
Table 292
Input Parameters
Name
Data Type
Description
BOOL
IN0
ANY
IN1
ANY
Table 293
Return Value
Data Type
Description
ANY
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
269
SHL
Shifts left N bits, where N is the shift count.
Syntax
w := SHL( IN, N ) ;
Table 294
Input Parameters
Name
Data Type
Description
IN
ANY_BIT
Operand
ANY_INT
Shift count.
Table 295
Return Value
Data Type
Description
ANY_BIT
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)
270
Chapter 2
SHR
Shifts right N bits, where N is the shift count.
Syntax
w := SHR( IN, N ) ;
Table 296
Input Parameters
Name
Data Type
Description
IN
ANY_BIT
Operand
ANY_INT
Shift count
Table 297
Return Value
Data Type
Description
ANY_BIT
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
271
SIN
Calculates the sine of an angle.
Syntax
y := SIN( x ) ;
Table 298
Input Parameters
Name
Data Type
Description
ANY_REAL
Table 299
Return Value
Data Type
Description
ANY_REAL
The sine of 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
Conditions
Return Values
Error Flags
If x is not a number.
NAN
BADPARAM, ERROR
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)
272
Chapter 2
SOECLR
Clears a sequence of events (SOE) block.
Syntax
MY_SOECLR( CI:=b1, BLOCK:=n1 ) ;
Table 300
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables SOECLR.
BLOCK
DINT
Table 301
Output Parameters
Name
Data Type
Description
CO
BOOL
STAT
DINT
Status:
0 = The block is not started or not configured with data type and size.
1 = The block is collecting data.
2 = The block is stopped or cleared.
3 = The block is full.
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:
Note
See Sample Projects on page 7 for information about where to find these projects on the PC where
you installed TriStation 1131.
SOECLR 273
Runtime Errors
Condition
Return Value
Error Flags
CO=false,
BADPARAM, ERROR
STAT=0
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
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)
274
Chapter 2
SOESTAT
Returns status for a sequence of events (SOE) block.
Syntax
MY_SOESTAT( CI:=b1, BLOCK:=n1 ) ;
Table 302
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables SOESTAT.
BLOCK
DINT
Table 303
Output Parameters
Name
Data Type
Description
CO
BOOL
STAT
DINT
Status:
0 = The block is not started or not configured with data type and size.
1 = The block is collecting data.
2 = The block is stopped or cleared.
3 = The block is full.
FREE
DINT
USED
DINT
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:
Note
See Sample Projects on page 7 for information about where to find these projects on the PC where
you installed TriStation 1131.
SOESTAT
275
Runtime Errors
Condition
Return Value
Error Flags
CO=false,
BADPARAM, ERROR
STAT=0,
FREE=0,
USED=0
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
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)
276
Chapter 2
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 ) ;
Table 304
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables SOESTOP.
BLOCK
DINT
Table 305
Output Parameters
Name
Data Type
Description
CO
BOOL
STAT
DINT
Status:
0 = The block is not started or not configured with data type and size.
1 = The block is collecting data.
2 = The block is stopped or cleared.
3 = The block is full.
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:
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
Condition
Return Value
Error Flags
CO=false,
BADPARAM, ERROR
STAT=0
SOESTOP
277
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
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)
278
Chapter 2
SOESTRT
Starts sequence of events (SOE) collection for an SOE block.
Syntax
MY_SOESTRT( CI:=b1, BLOCK:=n1 ) ;
Table 306
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables SOESTRT.
BLOCK
DINT
Table 307
Output Parameters
Name
Data Type
Description
CO
BOOL
STAT
DINT
Status:
0 = The block is not started or not configured with data type and size.
1 = The block is collecting data.
2 = The block is stopped or cleared.
3 = The block is full.
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:
Note
See Sample Projects on page 7 for information about where to find these projects on the PC where
you installed TriStation 1131.
SOESTRT
279
Runtime Errors
Condition
Return Value
Error Flags
CO=false,
BADPARAM, ERROR
STAT=0
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
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)
280
Chapter 2
SQRT
Calculates the square root of a number.
Syntax
y := SQRT( x ) ;
Table 308
Input Parameters
Name
Data Type
Description
ANY_REAL
A real number.
Table 309
Return Value
Data Type
Description
ANY_REAL
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
Conditions
Return Values
Error Flags
If x is not a number.
NAN
BADPARAM, ERROR
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)
SR
281
SR
SR is a bistable function block (set dominant).
Syntax
SR( S1:=b1, R:=b2 ) ;
b3 := SR.Q1
Table 310
Input Parameters
Name
Data Type
Description
S1
BOOL
Set
BOOL
Reset
Table 311
Output Parameters
Name
Data Type
Description
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.
Table 312
Truth Table
S1
Q1
false
false
no change
false
true
false
true
false
true
true
true
true
Example
VAR MY_SR : SR ; END_VAR
MY_SR( S1:=FALSE, R:=TRUE
MY_SR( S1:=FALSE, R:=FALSE
MY_SR( S1:=TRUE,
R:=TRUE
MY_SR( S1:=TRUE,
R:=FALSE
MY_SR( S1:=FALSE, R:=FALSE
);
);
);
);
);
(*
(*
(*
(*
(*
Q1
Q1
Q1
Q1
Q1
is
is
is
is
is
FALSE
FALSE
TRUE
TRUE
TRUE
*)
*)
*)
*)
*)
Runtime Errors
None.
282
Chapter 2
Application Notes
Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
Library
Standard (STDLIB)
STRING
283
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.
A STRING data type cannot be used as a program input or output.
Attribute
Description
Keyword/type
STRING
Description
Character string
Size
136 bytes
Default Value
Lower limit
0 characters
Upper limit
132 characters
Truncated string
N/A
Application Notes
284
Chapter 2
SUB
Calculates the difference between two operands.
Table 313
Input Parameters
Name
Data Type
Description
ANY_NUM
Minuend
ANY_NUM
Subtrahend
Table 314
Return Value
Data Type
Description
ANY_NUM
The difference x - y
Table 315
Input Parameters
Name
Data Type
Description
d1
DT
Minuend
TIME
Subtrahend
Table 316
Return Value
Data Type
Description
DT
The difference d1 - t
Table 317
Input Parameters
Name
Data Type
Description
t1
TIME
Minuend
t2
TIME
Subtrahend
Table 318
Return Value
Data Type
Description
TIME
The difference t1 - t2
SUB
285
Table 319
Input Parameters
Name
Data Type
Description
tod1
TIME OF DAY
Minuend
TIME
Subtrahend
Table 320
Return Value
Data Type
Description
TOD
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:
Example
Subtract two numbers:
VAR m : DINT; END_VAR
m := 1564 - 10;
(* result is 1554 *)
(* result is DT#2002-01-27-05:29:15 *)
(* result is T#11d19h23m *)
286
Chapter 2
Runtime Errors
Condition
Return Value
Error Flags
INF
OVERFLOW, ERROR
NAN
OVERFLOW, ERROR
Invalid date
BADPARAM, ERROR
Invalid time
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
287
SYS_AI32_STATUS
Gets the status of an Analog Input Module in a Trident or Tri-GP controller.
Syntax
MY_SYS_AI32_STATUS( CI:=b1, IOP:=n1, SLOT:=n2 ) ;
Table 321
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables SYS_AI32_STATUS.
IOP
DINT
SLOT
DINT
Table 322
Output Parameters
Name
Data Type
Description
CO
BOOL
TMR
BOOL
GE_DUAL
BOOL
GE_SINGLE
BOOL
NO_FLTS
BOOL
NO_ACTIVE_FLTS
BOOL
LOGIC_PWR1_OK
BOOL
LOGIC_PWR2_OK
BOOL
PASS_LEFT
BOOL
ACTIVE_LEFT
BOOL
INSTALLED_LEFT
BOOL
LOCKED_LEFT
BOOL
PASS_RIGHT
BOOL
ACTIVE_RIGHT
BOOL
INSTALLED_RIGHT
BOOL
LOCKED_RIGHT
BOOL
NO_FLD_ALARM_LEFT
BOOL
NO_FLD_ALARM_RIGHT
BOOL
FLD_PWR1_OK
BOOL
FLD_PWR2_OK
BOOL
NO_FLD_FLTS
BOOL
288
Chapter 2
Table 322
Name
Data Type
Description
NO_VOTER_FLTS
BOOL
ERROR_NUM
DINT
Error Number:
0 =No error.
1 =The IOP is invalid.
2 =The slot is not valid.
3 =The module is not configured.
4 =The module is the wrong type.
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
Condition
Return Value
Error Flags
If ERROR_NUM is non-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
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
289
SYS_AO04_STATUS
Gets the status of an Analog Output Module.
Syntax
MY_SYS_AO04_STATUS( CI:=b1, IOP:=n1, SLOT:=n2 ) ;
Table 323
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables SYS_AO04_STATUS.
IOP
DINT
SLOT
DINT
Table 324
Output Parameters
Name
Data Type
Description
CO
BOOL
TMR
BOOL
GE_DUAL
BOOL
GE_SINGLE
BOOL
NO_FLTS
BOOL
NO_ACTIVE_FLTS
BOOL
LOGIC_PWR1_OK
BOOL
LOGIC_PWR2_OK
BOOL
PASS_LEFT
BOOL
ACTIVE_LEFT
BOOL
INSTALLED_LEFT
BOOL
LOCKED_LEFT
BOOL
PASS_RIGHT
BOOL
ACTIVE_RIGHT
BOOL
INSTALLED_RIGHT
BOOL
LOCKED_RIGHT
BOOL
NO_FLD_ALARM_LEFT
BOOL
NO_FLD_ALARM_RIGHT
BOOL
FLD_PWR1_OK
BOOL
FLD_PWR2_OK
BOOL
NO_FLD_FLTS
BOOL
NO_VOTER_FLTS
BOOL
290
Chapter 2
Table 324
Name
Data Type
Description
FLD_OK01
BOOL
FLD_OK02
BOOL
FLD_OK03
BOOL
FLD_OK04
BOOL
ERROR_NUM
DINT
Error Number:
0 =No error.
1 =The IOP is invalid.
2 =The slot is not valid.
3 =The module is not configured.
4 =The module is the wrong type.
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
Condition
Return Value
Error Flags
If ERROR_NUM is non-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
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
291
SYS_APP_HALT
Halts the application.
Syntax
n1 := SYS_APP_HALT( b1 ) ;
Table 325
Input Parameters
Name
Data Type
Description
APP_HALT
BOOL
Table 326
Return Value
Data Type
Description
DINT
Error Number:
0 =No error.
1 =The IOP is invalid.
2 =The slot is not valid.
3 =The module is not configured.
4 =The module is the wrong type.
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
Condition
Return Value
Error Flags
Error number
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.
292
Chapter 2
Application Notes
Can be used in Safety or Control applications.
Library
Trident/Tri-GP (TRDLIB)
SYS_CLEAR_FLTS 293
SYS_CLEAR_FLTS
Clear all faults in the system.
Syntax
n1 := SYS_CLEAR_FLTS( b1 ) ;
Table 327
Input Parameters
Name
Data Type
Description
CLEAR_FLTS
BOOL
Table 328
Return Value
Data Type
Description
DINT
Error Number:
0 =No error.
1 =The IOP is invalid.
2 =The slot is not valid.
3 =The module is not configured.
4 =The module is the wrong type.
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
Condition
Return Value
Error Flags
Error number
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.
294
Chapter 2
Application Notes
Can be used in Safety or Control applications.
Library
Trident/Tri-GP (TRDLIB)
SYS_CM_STATUS
295
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 ) ;
Table 329
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables SYS_CM_STATUS.
IOP
DINT
SLOT
DINT
Table 330
Output Parameters
Name
Data Type
Description
CO
BOOL
NO_FLTS
BOOL
No faults on CM detected.
LOGIC_PWR1_OK
BOOL
LOGIC_PWR2_OK
BOOL
PASS
BOOL
ACTIVE
BOOL
The CM is active.
INSTALLED
BOOL
The CM is installed.
LOCKED
BOOL
The CM is locked.
NET1_OK
BOOL
NET2_OK
BOOL
PRNTR_READY
BOOL
PRNTR_NO_OVRFLW
BOOL
STATS_RESET_SERIAL_1
BOOL
STATS_RESET_SERIAL_2
BOOL
STATS_RESET_SERIAL_3
BOOL
CM_TEMP
DINT
MSGS_SERIAL_1
DINT
BRDCSTS_SERIAL_1
DINT
RSPNS_SERIAL_1
DINT
BAD_MSGS_SERIAL_1
DINT
ELAPSED_SERIAL_1
DINT
MSGS_SERIAL_2
DINT
296
Chapter 2
Table 330
Name
Data Type
Description
BRDCSTS_SERIAL_2
DINT
RSPNS_SERIAL_2
DINT
BAD_MSGS_SERIAL_2
DINT
ELAPSED_SERIAL_2
DINT
MSGS_SERIAL_3
DINT
BRDCSTS_SERIAL_3
DINT
RSPNS_SERIAL_3
DINT
BAD_MSGS_SERIAL_3
DINT
ELAPSED_SERIAL_3
DINT
PRNTR_BYTES_FREE
DINT
PRNTR_BYTES_USED
DINT
ERROR_NUM
DINT
Error Number:
0 =No error.
1 =The IOP is invalid.
2 =The slot is not valid.
3 =The module is not configured.
4 =The module is the wrong type.
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
Condition
Return Value
Error Flags
If ERROR_NUM is non-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.
SYS_CM_STATUS
297
Application Notes
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)
298
Chapter 2
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 ) ;
Table 331
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables SYS_CRITICAL_IO.
RESET
BOOL
Resets.
IOP
DINT
SLOT
DINT
APP
DINT
RELAY_OK
BOOL
Table 332
Output Parameters
Name
Data Type
Description
CO
BOOL
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.
NO_VOTER_FLTS
BOOL
ERROR_NUM
DINT
Error Number:
0 =No error.
1 =The IOP is invalid.
2 =The slot is not valid.
3 =The module is not configured.
4 =The module is the wrong type.
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.
RESET := FALSE
CI := TRUE
SYS_CRITICAL_IO
APP := DE_ENERGIZED
RELAY_OK := false
299
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 );
CO
TMR
GE_DUAL
GE_SINGLE
Example
For shutdown examples, see this sample project:
Note
Runtime Errors
Condition
Return Value
Error Flags
If ERROR_NUM is non-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.
Library
Trident/Tri-GP (TRDLIB)
300
Chapter 2
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 ) ;
Table 333
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables SYS_DI16_A16_STATUS.
IOP
DINT
SLOT
DINT
Table 334
Output Parameters
Name
Data Type
Description
CO
BOOL
TMR
BOOL
GE_DUAL
BOOL
GE_SINGLE
BOOL
NO_FLTS
BOOL
NO_ACTIVE_FLTS
BOOL
LOGIC_PWR1_OK
BOOL
LOGIC_PWR2_OK
BOOL
PASS_LEFT
BOOL
ACTIVE_LEFT
BOOL
INSTALLED_LEFT
BOOL
LOCKED_LEFT
BOOL
PASS_RIGHT
BOOL
ACTIVE_RIGHT
BOOL
INSTALLED_RIGHT
BOOL
LOCKED_RIGHT
BOOL
NO_FLD_ALARM_LEFT
BOOL
NO_FLD_ALARM_RIGHT
BOOL
FLD_PWR1_OK
BOOL
FLD_PWR2_OK
BOOL
SYS_DI16_AI16_STATUS
Table 334
301
Name
Data Type
Description
NO_FLD_FLTS
BOOL
NO_VOTER_FLTS
BOOL
ERROR_NUM
DINT
Error Number:
0 =No error.
1 =The IOP is invalid.
2 =The slot is not valid.
3 =The module is not configured.
4 =The module is the wrong type.
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
VAR AIDI_ACTIVE : BOOL ; END_VAR
MY_AIDI( CI:=TRUE, IOP:=1, SLOT:=5
AIDI_ACTIVE := MY_AIDI.LEFT_ACTIVE
(*
* Result : AIDI_ACTIVE is TRUE if
* an active AI/DI combo module in
*)
; END_VAR
) ;
OR MY_AIDI.RIGHT_ACTIVE ;
there is
slot 5.
Runtime Errors
Condition
Return Value
Error Flags
If ERROR_NUM is non-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
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.
302
Chapter 2
SYS_DI32_STATUS
Gets the status of a discrete input module.
Syntax
MY_SYS_DI32_STATUS( CI:=b1, IOP:=n1, SLOT:=n2 ) ;
Table 335
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables SYS_DI32_STATUS.
IOP
DINT
SLOT
DINT
Table 336
Output Parameters
Name
Data Type
Description
CO
BOOL
TMR
BOOL
GE_DUAL
BOOL
GE_SINGLE
BOOL
NO_FLTS
BOOL
NO_ACTIVE_FLTS
BOOL
LOGIC_PWR1_OK
BOOL
LOGIC_PWR2_OK
BOOL
PASS_LEFT
BOOL
ACTIVE_LEFT
BOOL
INSTALLED_LEFT
BOOL
LOCKED_LEFT
BOOL
PASS_RIGHT
BOOL
ACTIVE_RIGHT
BOOL
INSTALLED_RIGHT
BOOL
LOCKED_RIGHT
BOOL
NO_FLD_ALARM_LEFT
BOOL
NO_FLD_ALARM_RIGHT
BOOL
FLD_PWR1_OK
BOOL
FLD_PWR2_OK
BOOL
SYS_DI32_STATUS
Table 336
303
Name
Data Type
Description
NO_FLD_FLTS
BOOL
NO_VOTER_FLTS
BOOL
ERROR_NUM
DINT
Error Number:
0 =No error.
1 =The IOP is invalid.
2 =The slot is not valid.
3 =The module is not configured.
4 =The module is the wrong type.
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
Condition
Return Value
Error Flags
If ERROR_NUM is non-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
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)
304
Chapter 2
SYS_DO16_STATUS
Gets the status of a discrete output module.
Syntax
MY_SYS_DO16_STATUS( CI:=b1, IOP:=n1, SLOT:=n2 ) ;
Table 337
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables SYS_DO16_STATUS.
IOP
DINT
SLOT
DINT
Table 338
Output Parameters
Name
Data Type
Description
CO
BOOL
TMR
BOOL
GE_DUAL
BOOL
GE_SINGLE
BOOL
NO_FLTS
BOOL
NO_ACTIVE_FLTS
BOOL
LOGIC_PWR1_OK
BOOL
LOGIC_PWR2_OK
BOOL
PASS_LEFT
BOOL
ACTIVE_LEFT
BOOL
INSTALLED_LEFT
BOOL
LOCKED_LEFT
BOOL
PASS_RIGHT
BOOL
ACTIVE_RIGHT
BOOL
INSTALLED_RIGHT
BOOL
LOCKED_RIGHT
BOOL
NO_FLD_ALARM_LEFT
BOOL
NO_FLD_ALARM_RIGHT
BOOL
FLD_PWR1_OK
BOOL
FLD_PWR2_OK
BOOL
NO_FLD_FLTS
BOOL
NO_VOTER_FLTS
BOOL
SYS_DO16_STATUS
Table 338
305
Name
Data Type
Description
OVD_RUNNING_01_16
DWORD
FLD_OK_01_16
DWORD
ERROR_NUM
DINT
Error Number:
0 =No error.
1 =The IOP is invalid.
2 =The slot is not valid.
3 =The module is not configured.
4 =The module is the wrong type.
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
Condition
Return Value
Error Flags
If ERROR_NUM is non-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
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)
306
Chapter 2
SYS_HRDI32_STATUS
Gets the status of a high resolution discrete input module.
Syntax
MY_SYS_HRDI32_STATUS( CI:=b1, IOP:=n1, SLOT:=n2 ) ;
Table 339
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables SYS_HRDI32_STATUS.
IOP
DINT
SLOT
DINT
Table 340
Output Parameters
Name
Data Type
Description
CO
BOOL
TMR
BOOL
GE_DUAL
BOOL
GE_SINGLE
BOOL
NO_FLTS
BOOL
NO_ACTIVE_FLTS
BOOL
LOGIC_PWR1_OK
BOOL
LOGIC_PWR2_OK
BOOL
PASS_LEFT
BOOL
ACTIVE_LEFT
BOOL
INSTALLED_LEFT
BOOL
LOCKED_LEFT
BOOL
PASS_RIGHT
BOOL
ACTIVE_RIGHT
BOOL
INSTALLED_RIGHT
BOOL
LOCKED_RIGHT
BOOL
NO_FLD_ALARM_LEFT
BOOL
NO_FLD_ALARM_RIGHT
BOOL
FLD_PWR1_OK
BOOL
FLD_PWR2_OK
BOOL
SYS_HRDI32_STATUS
Table 340
307
Name
Data Type
Description
NO_FLD_FLTS
BOOL
NO_VOTER_FLTS
BOOL
ERROR_NUM
DINT
Error Number:
0 =No error.
1 =The IOP is invalid.
2 =The slot is not valid.
3 =The module is not configured.
4 =The module is the wrong type.
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
Condition
Return Value
Error Flags
If ERROR_NUM is non-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.
308
Chapter 2
Application Notes
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
309
SYS_IO_STATUS
Gets the status of an I/O module.
Syntax
MY_SYS_IO_STATUS( CI:=b1, IOP:=n1, SLOT:=n2 ) ;
Table 341
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables SYS_IO_STATUS.
IOP
DINT
SLOT
DINT
Table 342
Output Parameters
Name
Data Type
Description
CO
BOOL
TMR
BOOL
GE_DUAL
BOOL
GE_SINGLE
BOOL
NO_FLTS
BOOL
NO_ACTIVE_FLTS
BOOL
LOGIC_PWR1_OK
BOOL
LOGIC_PWR2_OK
BOOL
PASS_LEFT
BOOL
ACTIVE_LEFT
BOOL
INSTALLED_LEFT
BOOL
LOCKED_LEFT
BOOL
PASS_RIGHT
BOOL
ACTIVE_RIGHT
BOOL
INSTALLED_RIGHT
BOOL
LOCKED_RIGHT
BOOL
NO_FLD_ALARM_LEFT
BOOL
NO_FLD_ALARM_RIGHT
BOOL
FLD_PWR1_OK
BOOL
FLD_PWR2_OK
BOOL
NO_FLD_FLTS
BOOL
NO_VOTER_FLTS
BOOL
310
Chapter 2
Table 342
Name
Data Type
Description
ERROR_NUM
DINT
Error Number:
0 =No error.
1 =The IOP is invalid.
2 =The slot is not valid.
3 =The module is not configured.
4 =The module is the wrong type.
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
Condition
Return Value
Error Flags
If ERROR_NUM is non-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
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
311
SYS_IOP_STATUS
Gets the status of a Trident or Tri-GP I/O Processor.
Syntax
MY_SYS_IOP_STATUS( CI:=b1, IOP:=n1 ) ;
Table 343
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables SYS_IOP_STATUS.
IOP
DINT
Table 344
Output Parameters
Name
Data Type
Description
CO
BOOL
TMR
BOOL
GE_DUAL
BOOL
GE_SINGLE
BOOL
NO_FLTS
BOOL
LOGIC_PWR1_OK
BOOL
LOGIC_PWR2_OK
BOOL
PASS_LEFT
BOOL
ACTIVE_LEFT
BOOL
INSTALLED_LEFT
BOOL
LOCKED_LEFT
BOOL
PASS_MID
BOOL
ACTIVE_MID
BOOL
INSTALLED_MID
BOOL
LOCKED_MID
BOOL
PASS_RIGHT
BOOL
ACTIVE_RIGHT
BOOL
INSTALLED_RIGHT
BOOL
LOCKED_RIGHT
BOOL
IO_TMR
BOOL
IO_GE_Dual
BOOL
312
Chapter 2
Table 344
Name
Data Type
Description
IO_GE_Single
BOOL
IO_NO_FLTS
BOOL
IO_NO_ACTIVE_FLTS
BOOL
IO_NO_VOTER_FLTS
BOOL
IO_NO_FLD_FLTS
BOOL
IO_LOGIC_PWR1_OK
BOOL
IO_LOGIC_PWR2_OK
BOOL
IO_FLD_PWR1_OK
BOOL
IO_FLD_PWR2_OK
BOOL
DISCRETE_POLL_TIME
DINT
ANALOG_POLL_TIME
DINT
REAL_POLL_TIME
DINT
STRUCTURE_POLL_TIME
DINT
ERROR_NUM
DINT
Error Number:
0 =No error.
1 =The IOP is invalid.
2 =The slot is not valid.
3 =The module is not configured.
4 =The module is the wrong type.
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
Condition
Return Value
Error Flags
If ERROR_NUM is non-zero
BADPARAM, ERROR
SYS_IOP_STATUS
313
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
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)
314
Chapter 2
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 ) ;
Table 345
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables SYS_MP_STATUS.
Table 346
Output Parameters
Name
Data Type
Description
CO
BOOL
REQUESTED_SCAN_TIME
DINT
ACTUAL_SCAN_TIME
DINT
SURPLUS_SCAN_TIME
DINT
SCAN_OVERRUNS
DINT
TEMP_LEFT
DINT
TEMP_MID
DINT
TEMP_RIGHT
DINT
POINTS_DISABLED
DINT
APP_STATE
DINT
Application states:
0 =Running
1 =Halted
2 =Paused
3 =Trapped
MSGS_PORT_LEFT
DINT
BRDCSTS_PORT_LEFT
DINT
RSPNS_PORT_LEFT
DINT
BAD_MSGS_PORT_LEFT
DINT
ELAPSED_PORT_LEFT
DINT
MSGS_PORT_MID
DINT
BRDCSTS_PORT_MID
DINT
RSPNS_PORT_MID
DINT
BAD_MSGS_PORT_MID
DINT
ELAPSED_PORT_MID
DINT
SYS_MP_EXT_STATUS
Table 346
315
Name
Data Type
Description
MSGS_PORT_RIGHT
DINT
BRDCSTS_PORT_RIGHT
DINT
RSPNS_PORT_RIGHT
DINT
BAD_MSGS_PORT_RIGHT
DINT
ELAPSED_PORT_RIGHT
DINT
ERROR_NUM
DINT
Error Number:
0 =No error.
1 =The IOP is invalid.
2 =The slot is not valid.
3 =The module is not configured.
4 =The module is the wrong type.
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
Condition
Return Value
Error Flags
If ERROR_NUM is non-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.
316
Chapter 2
Application Notes
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 317
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 ) ;
Table 347
Input Parameters
Name
Data Type
Description
RESET_PORT_LEFT
BOOL
RESET_PORT_MID
BOOL
RESET_PORT_RIGHT
BOOL
Table 348
Return Value
Data Type
Description
DINT
Error Number:
0 =No error.
1 =The IOP is invalid.
2 =The slot is not valid.
3 =The module is not configured.
4 =The module is the wrong type.
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
Condition
Return Value
Error Flags
Error number
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.
318
Chapter 2
Application Notes
Can be used in Safety or Control applications.
Library
Trident/Tri-GP (TRDLIB)
SYS_MP_STATUS
319
SYS_MP_STATUS
Gets the status of the Trident or Tri-GP Main Processor Modules.
Syntax
MY_SYS_MP_STATUS( CI:=b1 ) ;
Table 349
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables SYS_MP_STATUS.
Table 350
Output Parameters
Name
Data Type
Description
CO
BOOL
TMR
BOOL
GE_DUAL
BOOL
NO_FLTS
BOOL
LOGIC_PWR1_OK
BOOL
LOGIC_PWR2_OK
BOOL
PASS_LEFT
BOOL
ACTIVE_LEFT
BOOL
INSTALLED_LEFT
BOOL
LOCKED_LEFT
BOOL
BATT_OK_LEFT
BOOL
NET_OK_LEFT
BOOL
PASS_MID
BOOL
ACTIVE_MID
BOOL
INSTALLED_MID
BOOL
LOCKED_MID
BOOL
BATT_OK_MID
BOOL
NET_OK_MID
BOOL
PASS_RIGHT
BOOL
ACTIVE_RIGHT
BOOL
INSTALLED_RIGHT
BOOL
LOCKED_RIGHT
BOOL
BATT_OK_RIGHT
BOOL
320
Chapter 2
Table 350
Name
Data Type
Description
NET_OK_RIGHT
BOOL
APP_LOCKED
BOOL
APP_RUNNING
BOOL
TEMP_OK
BOOL
MP temperature is OK.
SYSTEM_OK
BOOL
LOGIC_PWR_OK
BOOL
FLD_PWR_OK
BOOL
PROG_ALARM_ON
BOOL
REMOTE_WRT_ENABLE
BOOL
ERROR_NUM
DINT
Error Number:
0 =No error.
1 =The IOP is invalid.
2 =The slot is not valid.
3 =The module is not configured.
4 =The module is the wrong type.
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
Condition
Return Value
Error Flags
If ERROR_NUM is non-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
SYS_MP_STATUS
321
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)
322
Chapter 2
SYS_OVD_INHIBIT
Inhibits output voter diagnostics.
Syntax
n1 := SYS_OVD_INHIBIT( IOP, SLOT, IOVD_01_16 ) ;
Table 351
Input Parameters
Name
Data Type
Description
IOP
DINT
SLOT
DINT
IOVD_01_16
DWORD
Table 352
Return Value
Data Type
Description
DINT
Error Number:
0 =No error.
1 =The IOP is invalid.
2 =The slot is not valid.
3 =The module is not configured.
4 =The module is the wrong type.
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.
WARNING
Points on the Trident or Tri-GP SDO module are configured for supervision in
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 Developers Guide for more information about configuring
the Trident or Tri-GP SDO module.
SYS_OVD_INHIBIT
323
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
Condition
Return Value
Error Flags
Error number
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
Trident/Tri-GP (TRDLIB)
324
Chapter 2
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 ) ;
Table 353
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables SYS_PI06_STATUS.
IOP
DINT
SLOT
DINT
Table 354
Output Parameters
Name
Data Type
Description
CO
BOOL
TMR
BOOL
GE_DUAL
BOOL
GE_SINGLE
BOOL
NO_FLTS
BOOL
NO_ACTIVE_FLTS
BOOL
LOGIC_PWR1_OK
BOOL
LOGIC_PWR2_OK
BOOL
PASS_LEFT
BOOL
ACTIVE_LEFT
BOOL
INSTALLED_LEFT
BOOL
LOCKED_LEFT
BOOL
PASS_RIGHT
BOOL
ACTIVE_RIGHT
BOOL
INPUT_STABLE_1
BOOL
INPUT_STABLE_2
BOOL
INPUT_STABLE_3
BOOL
INPUT_STABLE_4
BOOL
INPUT_STABLE_5
BOOL
SYS_PI06_STATUS
Table 354
325
Name
Data Type
Description
INPUT_STABLE_6
BOOL
INSTALLED_RIGHT
BOOL
LOCKED_RIGHT
BOOL
NO_FLD_ALARM_LEFT
BOOL
NO_FLD_ALARM_RIGHT
BOOL
FLD_PWR1_OK
BOOL
FLD_PWR2_OK
BOOL
NO_FLD_FLTS
BOOL
NO_VOTER_FLTS
BOOL
SIGNAL_PRESENT_1
BOOL
SIGNAL_PRESENT_2
BOOL
SIGNAL_PRESENT_3
BOOL
SIGNAL_PRESENT_4
BOOL
SIGNAL_PRESENT_5
BOOL
SIGNAL_PRESENT_6
BOOL
ERROR_NUM
DINT
Error Number:
0 =No error.
1 =The IOP is invalid.
2 =The slot is not valid.
3 =The module is not configured.
4 =The module is the wrong type.
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.
*)
326
Chapter 2
Runtime Errors
Condition
Return Value
Error Flags
If ERROR_NUM is non-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
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
327
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 ) ;
Table 355
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables SYS_RO32_STATUS.
IOP
DINT
SLOT
DINT
Table 356
Output Parameters
Name
Data Type
Description
CO
BOOL
TMR
BOOL
GE_DUAL
BOOL
GE_SINGLE
BOOL
NO_FLTS
BOOL
NO_ACTIVE_FLTS
BOOL
LOGIC_PWR1_OK
BOOL
LOGIC_PWR2_OK
BOOL
PASS_LEFT
BOOL
ACTIVE_LEFT
BOOL
INSTALLED_LEFT
BOOL
LOCKED_LEFT
BOOL
PASS_RIGHT
BOOL
ACTIVE_RIGHT
BOOL
INSTALLED_RIGHT
BOOL
LOCKED_RIGHT
BOOL
NO_FLD_ALARM_LEFT
BOOL
NO_FLD_ALARM_RIGHT
BOOL
FLD_PWR1_OK
BOOL
FLD_PWR2_OK
BOOL
NO_FLD_FLTS
BOOL
NO_VOTER_FLTS
BOOL
328
Chapter 2
Table 356
Name
Data Type
Description
ERROR_NUM
DINT
Error Number:
0 =No error.
1 =The IOP is invalid.
2 =The slot is not valid.
3 =The module is not configured.
4 =The module is the wrong type.
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
Condition
Return Value
Error Flags
If ERROR_NUM is non-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
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
329
SYS_SDO16_STATUS
Gets the status of a supervised discrete output module.
Syntax
MY_SYS_SDO16_STATUS( CI:=b1, IOP:=n1, SLOT:=n2 ) ;
Table 357
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables SYS_SDO16_STATUS.
IOP
DINT
SLOT
DINT
Table 358
Output Parameters
Name
Data Type
Description
CO
BOOL
TMR
BOOL
GE_DUAL
BOOL
GE_SINGLE
BOOL
NO_FLTS
BOOL
NO_ACTIVE_FLTS
BOOL
LOGIC_PWR1_OK
BOOL
LOGIC_PWR2_OK
BOOL
PASS_LEFT
BOOL
ACTIVE_LEFT
BOOL
INSTALLED_LEFT
BOOL
LOCKED_LEFT
BOOL
PASS_RIGHT
BOOL
ACTIVE_RIGHT
BOOL
INSTALLED_RIGHT
BOOL
LOCKED_RIGHT
BOOL
NO_FLD_ALARM_LEFT
BOOL
NO_FLD_ALARM_RIGHT
BOOL
FLD_PWR1_OK
BOOL
FLD_PWR2_OK
BOOL
NO_FLD_FLTS
BOOL
NO_VOTER_FLTS
BOOL
330
Chapter 2
Table 358
Name
Data Type
Description
OVD_RUNNING_01_16
DWORD
FLD_OK_01_16
DWORD
SPRVSD_ON_01_16
DWORD
ERROR_NUM
DINT
Error Number:
0 =No error.
1 =The IOP is invalid.
2 =The slot is not valid.
3 =The module is not configured.
4 =The module is the wrong type.
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
Condition
Return Value
Error Flags
If ERROR_NUM is non-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.
SYS_SDO16_STATUS
331
Application Notes
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.
332
Chapter 2
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 ) ;
Table 359
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables SYS_SERIAL_PORT.
IOP
DINT
SLOT
DINT
RESET_STATS_SERIAL_1
BOOL
RESET_STATS_SERIAL_2
BOOL
RESET_STATS_SERIAL_3
BOOL
Table 360
Output Parameters
Name
Data Type
Description
CO
BOOL
STATS_RESET_SERIAL_1
BOOL
STATS_RESET_SERIAL_2
BOOL
STATS_RESET_SERIAL_3
BOOL
ERROR_NUM
DINT
Error Number:
0 =No error.
1 =The IOP is invalid.
2 =The slot is not valid.
3 =The module is not configured.
4 =The module is the wrong type.
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.
SYS_SERIAL_PORT
333
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
Condition
Return Value
Error Flags
If ERROR_NUM is non-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
Exactly Once: each instance should be executed exactly once per scan.
Library
Trident/Tri-GP (TRDLIB)
334
Chapter 2
SYS_SET_APP_LOCK
Turns the application lock on or off.
Syntax
n1 := SYS_SET_APP_LOCK( b1 ) ;
Table 361
Input Parameters
Name
Data Type
Description
VALUE
BOOL
Table 362
Return Value
Data Type
Description
DINT
Error Number:
0 =No error.
1 =The IOP is invalid.
2 =The slot is not valid.
3 =The module is not configured.
4 =The module is the wrong type.
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.
CAUTION
Example
(* Lock the application. *)
SYS_SET_APP_LOCK
VAR
n : DINT;
END_VAR
n := SYS_SET_APP_LOCK( TRUE );
335
{* result is 0 *)
Runtime Errors
Condition
Return Value
Error Flags
Error number
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
Trident/Tri-GP (TRDLIB)
336
Chapter 2
SYS_SET_PROG_ALARM
Turns the programmable alarm on or off.
Syntax
n1 := SYS_SET_PROG_ALARM( b1 ) ;
Table 363
Input Parameters
Name
Data Type
Description
VALUE
BOOL
Table 364
Return Value
Data Type
Description
DINT
Error Number:
0 =No error.
1 =The IOP is invalid.
2 =The slot is not valid.
3 =The module is not configured.
4 =The module is the wrong type.
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
Condition
Return Value
Error Flags
Error number
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.
SYS_SET_PROG_ALARM
337
Application Notes
Can be used in Safety or Control applications.
Library
Trident/Tri-GP (TRDLIB)
338
Chapter 2
SYS_SET_REMOTE_WRT_ENBL
Turns remote write enable on or off.
Syntax
n1 := SYS_SET_REMOTE_WRT_ENBL( b1 ) ;
Table 365
Input Parameters
Name
Data Type
Description
VALUE
BOOL
Table 366
Return Value
Data Type
Description
DINT
Error Number:
0 =No error.
1 =The IOP is invalid.
2 =The slot is not valid.
3 =The module is not configured.
4 =The module is the wrong type.
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
Condition
Return Value
Error Flags
Error number
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.
SYS_SET_REMOTE_WRT_ENBL
339
Application Notes
Can be used in Safety or Control applications.
Library
Trident/Tri-GP (TRDLIB)
340
Chapter 2
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 ) ;
Table 367
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables SYS_SHUTDOWN.
IO_CO
BOOL
IO_TMR
BOOL
IO_GE_DUAL
BOOL
IO_GE_SINGLE
BOOL
IO_NO_VOTER_FLTS
BOOL
IO_ERROR
DINT
MAX_TIME_DUAL
TIME
MAX_TIME_SINGLE
TIME
MAX_SCAN_TIME
TIME
Table 368
Output Parameters
Name
Data Type
Description
CO
BOOL
OPERATING
BOOL
TMR
BOOL
DUAL
BOOL
SINGL
BOOL
ZERO
BOOL
TIMER_RUNNING
BOOL
TIME_LEFT
TIME
ALARM_PROGRAMMING_PE
RMITTED
BOOL
ALARM_REMOTE_ACCESS
BOOL
SYS_SHUTDOWN
Table 368
341
Name
Data Type
Description
ALARM_RESPONSE_TIME
BOOL
ALARM_DISABLED_POINTS
BOOL
ERROR
DINT
Error Number:
0 =No error.
1 =Error in maximum time.
2 =IO function block error - IO_ERROR is non-zero.
3 =System status or MP status function block error.
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:
Note
Runtime Errors
Condition
Return Value
Error Flags
If ERROR is non-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.
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)
342
Chapter 2
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 ) ;
Table 369
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables SYS_SYSTEM_STATUS.
Table 370
Output Parameters
Name
Data Type
Description
CO
BOOL
TMR
BOOL
GE_DUAL
BOOL
GE_SINGLE
BOOL
NO_FLTS
BOOL
NO_ACTIVE_FLTS
BOOL
LOGIC_PWR1_OK
BOOL
LOGIC_PWR2_OK
BOOL
POWER_UP
BOOL
FIRST_SCAN
BOOL
COLD_START
BOOL
PT_DISABLING_OFF
BOOL
MASTER_CLK
BOOL
LOCAL_TIME
BOOL
DAYLIGHT_TIME
BOOL
DSBL_REMOTE_CHGS
BOOL
IO_TMR
BOOL
IO_GE_Dual
BOOL
IO_GE_Single
BOOL
IO_NO_FLTS
BOOL
IO_NO_ACTIVE_FLTS
BOOL
SYS_SYSTEM_STATUS 343
Table 370
Name
Data Type
Description
IO_NO_VOTER_FLTS
BOOL
IO_NO_FLD_FLTS
BOOL
FLD_PWR1_OK
BOOL
FLD_PWR2_OK
BOOL
NODE_OK_01_32
DWORD
NODE_OK_33_64
DWORD
NODE_REDUNDANT_01_32
DWORD
NODE_REDUNDANT_33_64
DWORD
YEAR
DINT
MONTH
DINT
DAY
DINT
HOUR
DINT
MINUTE
DINT
SECOND
DINT
MILLISECOND
DINT
MICROSECOND
DINT
RELATIVE_SECONDS
DINT
DAY_OF_WEEK
DINT
APP_MAJOR_VRSN
DINT
APP_MINOR_VRSN
DINT
APP_NAME
STRING
ERROR_NUM
DINT
Error Number:
0 =No error.
1 =The IOP is invalid.
2 =The slot is not valid.
3 =The module is not configured.
4 =The module is the wrong type.
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).
344
Chapter 2
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
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 Number
NODE_OK_33_64 or NODE_REDUNDANT_33_64
Layout
Digit
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
Node Number
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
Condition
Return Value
Error Flags
If ERROR_NUM is non-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
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
345
SYS_VOTE_MODE
Converts redundancy status.
Syntax
MY_SYS_VOTE_MODE( CI:=b1, IN_TMR:=b2, GE_DUAL:=b3, GE_SINGLE:=b4 ) ;
Table 371
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables SYS_VOTE_MODE.
IN_TMR
BOOL
GE_DUAL
BOOL
GE_SINGLE
BOOL
Table 372
Output Parameters
Name
Data Type
Description
CO
BOOL
TMR
BOOL
DUAL
BOOL
SINGLE
BOOL
ZERO
BOOL
No channel is operating.
Description
The SYS_VOTE_MODE function block converts redundancy status, as shown in this truth table.
Table 373
Truth Table
TMR
GE_DUAL
GE_SINGLE
TMR
DUAL
SINGL
ZERO
Othera
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).
Note
346
Chapter 2
Example
For shutdown examples, see this sample project:
Note
Runtime Errors
Condition
Return Value
Error Flags
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
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
347
TAN
Calculates the tangent of an angle.
Syntax
y := TAN( x ) ;
Table 374
Input Parameters
Name
Data Type
Description
ANY_REAL
Table 375
Return Value
Data Type
Description
ANY_REAL
The tangent of 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
Conditions
Return Values
Error Flags
If x is not a number.
NAN
BADPARAM, ERROR
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)
348
Chapter 2
TCJ_CONV
Converts a Type J thermocouple input into degrees Celsius and returns the result.
Syntax
y := TCJ_CONV( MC, CONVM, CONVB, COLDJNC ) ;
Table 376
Input Parameters
Name
Data Type
Description
MC
DINT
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).
COLDJNC
REAL
Table 377
Return Value
Data Type
Description
REAL
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.
WARNING
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.
TCJ_CONV
349
Application Notes
Can be used in Safety or Control applications.
Library
Triconex (TCXLIB)
350
Chapter 2
TCK_CONV
Converts a Type K thermocouple input into degrees Celsius and returns the result.
Syntax
y := TCJ_CONV( MC, CONVM, CONVB, COLDJNC ) ;
Table 378
Input Parameters
Name
Data Type
Description
MC
DINT
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).
COLDJNC
REAL
Table 379
Return Value
Data Type
Description
REAL
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 coldjunction compensation temperature must be in the range from 20 C to 500 C.
WARNING
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.
TCK_CONV
351
Application Notes
Can be used in Safety or Control applications.
Library
Triconex (TCXLIB)
352
Chapter 2
TDD_I
Provides a time delay to de-energize.
Syntax
MY_TDD_I( I1:=b1, TGT:=n1 ) ;
Table 380
Input Parameters
Name
Data Type
Description
I1
BOOL
TGT
DINT
Table 381
Output Parameters
Name
Data Type
Description
Q1
BOOL
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.
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
Exactly Once: each instance should be executed exactly once per scan.
Library
Standard (STDLIB)
TDD_R
353
TDD_R
Provides a time delay to de-energize.
Syntax
MY_TDD_R( I1:=b1, TGT:=x1 ) ;
Table 382
Input Parameters
Name
Data Type
Description
I1
BOOL
TGT
REAL
Table 383
Output Parameters
Name
Data Type
Description
Q1
BOOL
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.
354
Chapter 2
Application Notes
Exactly Once: each instance should be executed exactly once per scan.
Library
Standard (STDLIB)
TDE_I
355
TDE_I
Provides a time delay to energize.
Syntax
MY_TDE_I( I1:=b1, TGT:=n1 ) ;
Table 384
Input Parameters
Name
Data Type
Description
I1
BOOL
TGT
DINT
Table 385
Output Parameters
Name
Data Type
Description
Q1
BOOL
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.
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
Exactly Once: each instance should be executed exactly once per scan.
Library
Standard (STDLIB)
356
Chapter 2
TDE_R
Provides a time delay to energize.
Syntax
MY_TDE_R( I1:=b1, TGT:=x1 ) ;
Table 386
Input Parameters
Name
Data Type
Description
I1
BOOL
TGT
REAL
Table 387
Output Parameters
Name
Data Type
Description
Q1
BOOL
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.
TDE_R
357
Application Notes
Exactly Once: each instance should be executed exactly once per scan.
Library
Standard (STDLIB)
358
Chapter 2
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.
A TIME data type cannot be used as a program input or output.
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
Default value
TIME#0S
Lower limit
TIME#-3652134d
Upper limit
TIME#3652134d
Inv Time
Inv Time
Note
In TriStation 1131 v4.4 and later, the syntax of the TIME data type is not case-sensitive.
Application Notes
TIME_TO_SECS 359
TIME_TO_SECS
Converts time to number of seconds.
Syntax
y := TIME_TO_SECS( t ) ;
Table 388
Input Parameters
Name
Data Type
Description
TIME
The time.
Table 389
Return Value
Data Type
Description
LREAL
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
Condition
Return Value
Error Flags
If t is out of range.
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)
360
Chapter 2
TIME_TO_SECS_REAL
Converts time to number of seconds.
Syntax
y := TIME_TO_SECS_REAL( t ) ;
Table 390
Input Parameters
Name
Data Type
Description
TIME
The time.
Table 391
Return Value
Data Type
Description
REAL
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
Condition
Return Value
Error Flags
If t is out of range.
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)
TIMEADJ
361
TIMEADJ
Adjusts the calendar clock.
Syntax
MY_TIMEADJ( CI:=b1, MS:=n1 ) ;
Table 392
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables TIMEADJ.
MS
DINT
Table 393
Output Parameters
Name
Data Type
Description
CO
BOOL
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
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.
CAUTION
Triconex recommends using the TIMEADJ function block no more than once a
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
Condition
Return Value
Error Flags
CO=false
BADPARAM, ERROR
362
Chapter 2
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
Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
Library
Triconex (TCXLIB)
TIMESET
363
TIMESET
Sets the calendar clock.
Syntax
MY_TIMESET( CI:=b1, GMT:=n1, MS:=n2 ) ;
Table 394
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables TIMESET.
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
Table 395
Output Parameters
Name
Data Type
Description
CO
BOOL
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
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 detectedfor example, if MS is less than 0 or greater than 999.
As a general rule, do not set the time back to previous dates.
CAUTION
Triconex recommends using the TIMESET function no more than once a day.
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.
364
Chapter 2
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
Condition
Return Value
Error Flags
CO=false
BADPARAM, ERROR
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
Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
Library
Triconex (TCXLIB)
TMR
365
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 ) ;
Table 396
Input Parameters
Name
Data Type
Description
IN
BOOL
Enables TMR.
RESET
BOOL
Resets TMR.
PT
TIME
IT
TIME
Table 397
Output Parameters
Name
Data Type
Description
BOOL
ET
TIME
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.
366
Chapter 2
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
Exactly Once: each instance should be executed exactly once per scan.
Library
Triconex (TCXLIB)
TMR_I
367
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 ) ;
Table 398
Input Parameters
Name
Data Type
Description
IN
BOOL
Enables TMR_I.
RESET
BOOL
Resets TMR_I.
PT
DINT
Table 399
Output Parameters
Name
Data Type
Description
BOOL
ET
DINT
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.
368
Chapter 2
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
Exactly Once: each instance should be executed exactly once per scan.
Library
Triconex (TCXLIB)
TMR_R
369
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 ) ;
Table 400
Input Parameters
Name
Data Type
Description
IN
BOOL
Enables TMR_I.
RESET
BOOL
Resets TMR_I.
PT
REAL
Table 401
Output Parameters
Name
Data Type
Description
BOOL
ET
REAL
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.
370
Chapter 2
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
Exactly Once: each instance should be executed exactly once per scan.
Library
Triconex (TCXLIB)
TOD
371
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.
A TOD data type cannot be used as a program input or output.
Attribute
Description
Keyword/type
TOD
Description
Time of day
Size
64 bits
Syntax
TOD#HH:MM:SS
or
TOD#HH:MM:SS.FFF
or
TIME_OF_DAY#HH:MM:SS
Default value
TOD#00:00:00
Lower limit
TOD#00:00:00
Upper limit
TOD#23:59:59.999
V modulo 24 hours
V modulo 24 hours
Application Notes
372
Chapter 2
TOF
Delays the falling edge of a pulse.
Syntax
MY_TOF( IN:=b1, PT:=t1 ) ;
Table 402
Input Parameters
Name
Data Type
Description
IN
BOOL
PT
TIME
Table 403
Output Parameters
Name
Data Type
Description
BOOL
ET
TIME
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.
TOF
373
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.
374
Chapter 2
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
Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
Library
Standard (STDLIB)
TOGGLE
375
TOGGLE
Replaces the functionality of the TGL coil in TriStation MSW.
Syntax
MY_TOGGLE( IN:=b1, RESET:=b2 ) ;
Table 404
Input Parameters
Name
Data Type
Description
IN
BOOL
Enables TOGGLE.
RESET
BOOL
Resets TOGGLE.
Table 405
Output Parameters
Name
Data Type
Description
BOOL
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.
Table 406
Truth Table
IN
RESET
false
false
no change
false
true
false
true
false
not Q
true
true
false
Example
VAR MY_TOGGLE : TOGGLE ; END_VAR
MY_TOGGLE( IN:=FALSE, RESET:=TRUE
MY_TOGGLE( IN:=FALSE, RESET:=FALSE
MY_TOGGLE( IN:=TRUE,
RESET:=TRUE
MY_TOGGLE( IN:=TRUE,
RESET:=FALSE
MY_TOGGLE( IN:=FALSE, RESET:=FALSE
MY_TOGGLE( IN:=TRUE,
RESET:=FALSE
);
);
);
);
);
);
(*
(*
(*
(*
(*
(*
Q
Q
Q
Q
Q
Q
is
is
is
is
is
is
FALSE
FALSE
FALSE
TRUE
TRUE
FALSE
*)
*)
*)
*)
*)
*)
Runtime Errors
None.
376
Chapter 2
Application Notes
Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
Library
Triconex (TCXLIB)
TON
377
TON
Delays the rising edge of a pulse.
Syntax
MY_TON( IN:=b1, PT:=t1 ) ;
Table 407
Input Parameters
Name
Data Type
Description
IN
BOOL
PT
TIME
Table 408
Output Parameters
Name
Data Type
Description
BOOL
ET
TIME
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.
378
Chapter 2
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
Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
Library
Standard (STDLIB)
TP
379
TP
Generates a timed pulse.
Syntax
MY_TP( IN:=b1, PT:=t1 ) ;
Table 409
Input Parameters
Name
Data Type
Description
IN
BOOL
PT
TIME
Table 410
Output Parameters
Name
Data Type
Description
BOOL
ET
TIME
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.
380
Chapter 2
Application Notes
Only Once: each instance should be executed only once per scan, but does not need to be
executed every scan.
Library
Standard (STDLIB)
TP_I
381
TP_I
Generates a timed pulse.
Syntax
MY_TP_I( IN:=b1, PT:=n1 ) ;
Table 411
Input Parameters
Name
Data Type
Description
IN
BOOL
PT
DINT
Table 412
Output Parameters
Name
Data Type
Description
BOOL
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.
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.
382
Chapter 2
Application Notes
Exactly Once: each instance should be executed exactly once per scan.
Library
Standard (STDLIB)
TP_R
383
TP_R
Generates a timed pulse.
Syntax
MY_TP_R( IN:=b1, PT:=x1 ) ;
Table 413
Input Parameters
Name
Data Type
Description
IN
BOOL
PT
REAL
Table 414
Output Parameters
Name
Data Type
Description
BOOL
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.
384
Chapter 2
Application Notes
Exactly Once: each instance should be executed exactly once per scan.
Library
Standard (STDLIB)
TR_64_POINT_STATUS
385
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 ) ;
Table 415
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables TR_64_POINT_STATUS.
CHASSIS
DINT
SLOT
DINT
Table 416
Output Parameters
Name
Data Type
Description
CO
BOOL
FUSE_01_32
DWORD
FUSE_33_64
DWORD
FAULT_01_32
DWORD
FAULT_33_64
DWORD
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.
386
Chapter 2
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
Condition
Return Value
Error Flags
CO=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
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
387
TR_CALENDAR
Gets calendar values from a Tricon controller.
Syntax
MY_TR_CALENDAR( CI:= b1 ) ;
Table 417
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables TR_CALENDAR.
Table 418
Output Parameters
Name
Data Type
Description
CO
BOOL
YEAR
DINT
MONTH
DINT
DAY
DINT
HOUR
DINT
MINUTE
DINT
SECOND
DINT
MILLISEC
DINT
WEEKDAY
DINT
RELSEC
DINT
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.
388
Chapter 2
Application Notes
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
389
TR_CHASSIS_STATUS
Gets the chassis status from a Tricon controller.
Syntax
MY_TR_CHASSIS_STATUS( CI:=b1, CHASSIS:=n1 ) ;
Table 419
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables TR_CHASSIS_STATUS.
CHASSIS
DINT
Table 420
Output Parameters
Name
Data Type
Description
CO
BOOL
MAINTENANCE
BOOL
UPPERPOWER
BOOL
LOWERPOWER
BOOL
IOFAULT
BOOL
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
Condition
Return Value
Error Flags
CO=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.
390
Chapter 2
Application Notes
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
391
TR_CLEAR_FLTS
Clears all faults in the system.
Syntax
ERROR_NUMBER := TR_CLEAR_FLTS( CLEAR_FLTS := TRUE );
Table 421
Input Parameters
Name
Data Type
Description
CLEAR_FLTS
BOOL
Table 422
Return Value
Data Type
Description
DINT
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
Condition
Return Value
Error Flags
If the system is not Tricon v10 or later, the function is not supported.
-1
BADPARAM
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.
392
Chapter 2
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 ) ;
Table 423
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables TR_CRITICAL_IO.
INIT
BOOL
Initializes TR_CRITICAL_IO.
CHASSIS
DINT
SLOT
DINT
APP
DINT
RELAY_OK
BOOL
Table 424
Output Parameters
Name
Data Type
Description
CO
BOOL
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
NO_VOTER_FLTS
BOOL
ERROR
DINT
Error Number:
0 =No error.
1 The slot is not odd or not numbered 115.
2 =Invalid chassis or slot.
3 =The module is not configured.
5 =An invalid application number is used.
6 =Not initialized.
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.
TR_CRITICAL_IO
393
INIT := FALSE
CI := TRUE
APP := DE_ENERGIZED
RELAY_OK := FALSE
To get the status of all safety-critical I/O modules, invoke each module by specifying these input
values:
CHASSIS
SLOT
APP
RELAY_OK
If CHASSIS 1 SLOT 1 is a critical DI module, and CHASSIS 1 SLOT 2 is a critical DO module with
a relay, then this example applies. SCIO is the function block instance name:
SCIO(CHASSIS:=1,SLOT:=1,APP:=DE-ENERGIZED,RELAY_OK:=FALSE);
SCIO(CHASSIS:=1,SLOT:=2,APP:=RELAY,RELAY_OK:=RELAY1_OK);
CO
TMR
GE_DUAL
GE_SINGLE
NO_VOTER_FAULTS
The output values are an accumulation of the status of all critical I/O modules. For example, the
output called TMR is true if all of the critical modules in the system are in TMR mode.
Example
For shutdown examples, see this sample project:
Note
Runtime Errors
Condition
Return Value
Error Flags
If ERROR is non-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.
394
Chapter 2
Application Notes
Can be used in Safety or Control applications.
Library
Tricon (TR1LIB/TX1LIB)
TR_MP_STATUS
395
TR_MP_STATUS
Gets the status of the Main Processor.
Syntax
MY_TR_MP_STATUS( CI:=b1 ) ;
Table 425
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables TR_MP_STATUS.
Table 426
Output Parameters
Name
Data Type
Description
CO
BOOL
MPMAIN
BOOL
MPBAD
BOOL
Two MPs are out-of-sync or have failed, or the controller is running in simplex
mode.
IOMAIN
BOOL
IOBAD
BOOL
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.
396
Chapter 2
Application Notes
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 397
TR_PEER_STATUS
Gets the Peer-to-Peer status of a node.
Syntax
MY_TR_PEER_STATUS( CI:=b1, NODE:=n1 ) ;
Table 427
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables TR_PEER_STATUS.
NODE
DINT
Table 428
Output Parameters
Name
Data Type
Description
CO
BOOL
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:
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
Condition
Return Value
Error Flags
CO=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.
398
Chapter 2
Application Notes
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 399
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 ) ;
Table 429
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables TR_POINT_STATUS.
CHASSIS
DINT
SLOT
DINT
POINT
DINT
Table 430
Output Parameters
Name
Data Type
Description
CO
BOOL
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
Condition
Return Value
Error Flags
CO=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.
400
Chapter 2
Application Notes
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
401
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 ) ;
Table 431
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables TR_PORT_STATUS.
Table 432
Output Parameters
Name
Data Type
Description
CO
BOOL
ICM_P5_OVFL
BOOL
ICM_P10_OVFL
BOOL
ICM_P5_RDY
BOOL
ICM_P10_RDY
BOOL
NCM_NET1L_OK
BOOL
NCM_NET2L_OK
BOOL
NCM_NET1R_OK
BOOL
NCM_NET2R_OK
BOOL
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.
402
Chapter 2
Application Notes
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
403
TR_PROGRAM_STATUS
Gets the status of a Tricon program.
Syntax
MY_TR_PROGRAM_STATUS( CI:=b1 ) ;
Table 433
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables TR_PROGRAM_STATUS.
Table 434
Output Parameters
Name
Data Type
Description
CO
BOOL
MAJOR_VERSION
DINT
MINOR_VERSION
DINT
WRITE_ENABLED
BOOL
DISABLE_NOT_ALLOWED
BOOL
POINTS_DISABLED
DINT
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.
404
Chapter 2
Application Notes
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
405
TR_SCAN_STATUS
Gets the status of a scan.
Syntax
MY_TR_SCAN_STATUS( CI:=b1 ) ;
Table 435
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables TR_SCAN_STATUS.
Table 436
Output Parameters
Name
Data Type
Description
CO
BOOL
POWERUP
BOOL
FIRSTSCAN
BOOL
SCANREQUEST
DINT
SCANSURPLUS
DINT
SCANDELTA
DINT
DELTAT
TIME
SCANOVERRUN
DINT
The average number of scan overruns for the last 100 scans.
KEYSWITCH
DINT
Setting:
0 =STOP
1 =PROGRAM
2 =RUN
3 =REMOTE
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.
406
Chapter 2
Application Notes
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
407
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 ) ;
Table 437
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables TR_SHUTDOWN.
IO_CO
BOOL
IO_TMR
BOOL
IO_GE_DUAL
BOOL
IO_GE_SINGLE
BOOL
IO_NO_VOTER_FLTS
BOOL
IO_ERROR
DINT
Zero = no error.
Non-zero = programming or configuration error.
MAX_TIME_DUAL
TIME
MAX_TIME_SINGLE
TIME
MAX_SCAN_TIME
TIME
Table 438
Output Parameters
Name
Data Type
Description
CO
BOOL
OPERATING
BOOL
TMR
BOOL
DUAL
BOOL
SINGL
BOOL
ZERO
BOOL
TIMER_RUNNING
BOOL
TIME_LEFT
TIME
ALARM_PROGRAMMING_
PERMITTED
BOOL
ALARM_REMOTE_ACCESS
BOOL
ALARM_RESPONSE_TIME
BOOL
408
Chapter 2
Table 438
Name
Data Type
Description
ALARM_DISABLED_POINT
S
BOOL
ERROR
DINT
Error Number:
0 No error.
1 =Error in maximum time.
2 =Error in I/O function block (IO_ERROR input is
non-zero).
3 =Error in status function block.
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:
Note
Runtime Errors
Condition
Return Value
Error Flags
If ERROR is non-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.
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
409
TR_SLOT_STATUS
Gets the status of a Tricon controller slot.
Syntax
MY_TR_SLOT_STATUS( CI:=b1, CHASSIS:=n1, SLOT:=n2 ) ;
Table 439
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables TR_SLOT_STATUS.
CHASSIS
DINT
SLOT
DINT
Table 440
Output Parameters
Name
Data Type
Description
CO
BOOL
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.
INSTALLED
BOOL
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 v9v10 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 ) ;
410
Chapter 2
Runtime Errors
Condition
Return Value
Error Flags
CO=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
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
411
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 ) ;
Table 441
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables TR_URCV_BOOL.
RECVID
DINT
SENDNODE
DINT
SENDID
DINT
DINT
Table 442
Output Parameters
Name
Data Type
Description
NDR
BOOL
ERROR
BOOL
STATUS
DINT
0=
1=
BOOL
RD_20
BOOL
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 Developers Guide.
412
Chapter 2
Example
For Peer-to-Peer examples, see these sample projects:
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
Condition
Return Value
Error Flags
ERROR=true
None
For error numbers, see the description for the STATUS output.
Application Notes
Exactly Once: each instance should be executed exactly once per scan.
Library
Tricon (TR1LIB/TX1LIB)
TR_URCV_DINT
413
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 ) ;
Table 443
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables TR_URCV_DINT.
RECVID
DINT
SENDNODE
DINT
SENDID
DINT
DINT
Table 444
Output Parameters
Name
Data Type
Description
NDR
BOOL
ERROR
BOOL
STATUS
DINT
0=
1=
DINT
RD_20
DINT
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 Developers Guide.
414
Chapter 2
Example
For Peer-to-Peer examples, see these sample projects:
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
Condition
Return Value
Error Flags
ERROR=true
None
For error numbers, see the description for the STATUS output.
Application Notes
Exactly Once: each instance should be executed exactly once per scan.
Library
Tricon (TR1LIB/TX1LIB)
TR_URCV_DINT_32
415
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 ) ;
Table 445
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables TR_URCV_DINT_32.
RECVID
DINT
SENDNODE
DINT
SENDID
DINT
DINT
Table 446
Output Parameters
Name
Data Type
Description
NDR
BOOL
ERROR
BOOL
STATUS
DINT
0=
1=
DINT
RD_32
DINT
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 Developers Guide.
416
Chapter 2
Example
For Peer-to-Peer examples, see these sample projects:
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
Condition
Return Value
Error Flags
ERROR=true
None
For error numbers, see the description for the STATUS output.
Application Notes
Exactly Once: each instance should be executed exactly once per scan.
Library
Tricon (TR1LIB/TX1LIB)
TR_URCV_REAL
417
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 ) ;
Table 447
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables TR_URCV_REAL.
RECVID
DINT
SENDNODE
DINT
SENDID
DINT
DINT
Table 448
Output Parameters
Name
Data Type
Description
NDR
BOOL
ERROR
BOOL
STATUS
DINT
0=
1=
REAL
RD_20
REAL
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 Developers Guide.
418
Chapter 2
Example
For Peer-to-Peer examples, see these sample projects:
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
Condition
Return Value
Error Flags
ERROR=true
None
For error numbers, see the description for the STATUS output.
Application Notes
Exactly Once: each instance should be executed exactly once per scan.
Library
Tricon (TR1LIB/TX1LIB)
TR_URCV_REAL_32
419
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 ) ;
Table 449
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables TR_URCV_REAL_32.
RECVID
DINT
SENDNODE
DINT
SENDID
DINT
DINT
Table 450
Output Parameters
Name
Data Type
Description
NDR
BOOL
ERROR
BOOL
STATUS
DINT
0=
1=
REAL
RD_32
REAL
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 Developers Guide.
420
Chapter 2
Example
For Peer-to-Peer examples, see these sample projects:
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
Condition
Return Value
Error Flags
ERROR=true
None
For error numbers, see the description for the STATUS output.
Application Notes
Exactly Once: each instance should be executed exactly once per scan.
Library
Tricon (TR1LIB/TX1LIB)
TR_USEND_BOOL
421
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 ) ;
Table 451
Input Parameters
Name
Data Type
Description
SENDFLG
BOOL
Enables TR_USEND_BOOL.
SENDID
DINT
RECVNODE
DINT
RECVID
DINT
DINT
SD_01
BOOL
SD_20
BOOL
Table 452
Output Parameters
Name
Data Type
Description
SENT
BOOL
ACK
BOOL
ERROR
BOOL
STATUS
DINT
0=
1=
2=
3=
4=
422
Chapter 2
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 Developers Guide.
Example
For Peer-to-Peer examples, see these sample projects:
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
Condition
Return Value
Error Flags
ERROR=true
None
For error numbers, see the description for the STATUS output.
Application Notes
Exactly Once: each instance should be executed exactly once per scan.
Library
Tricon (TR1LIB/TX1LIB)
TR_USEND_DINT
423
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 ) ;
Table 453
Input Parameters
Name
Data Type
Description
SENDFLG
BOOL
Enables TR_USEND_DINT.
SENDID
DINT
RECVNODE
DINT
RECVID
DINT
DINT
SD_01
DINT
SD_20
DINT
Table 454
Output Parameters
Name
Data Type
Description
SENT
BOOL
ACK
BOOL
ERROR
BOOL
STATUS
DINT
0=
1=
2=
3=
4=
424
Chapter 2
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 Developers Guide.
Example
For Peer-to-Peer examples, see these sample projects:
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
Condition
Return Value
Error Flags
ERROR=true
None
For error numbers, see the description for the STATUS output.
Application Notes
Exactly Once: each instance should be executed exactly once per scan.
Library
Tricon (TR1LIB/TX1LIB)
TR_USEND_DINT_32
425
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 ) ;
Table 455
Input Parameters
Name
Data Type
Description
SENDFLG
BOOL
Enables TR_USEND_DINT_32.
SENDID
DINT
RECVNODE
DINT
RECVID
DINT
DINT
SD_01
DINT
SD_32
DINT
Table 456
Output Parameters
Name
Data Type
Description
SENT
BOOL
ACK
BOOL
ERROR
BOOL
STATUS
DINT
0=
1=
2=
3=
4=
426
Chapter 2
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 Developers Guide.
Example
For Peer-to-Peer examples, see these sample projects:
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
Condition
Return Value
Error Flags
ERROR=true
None
For error numbers, see the description for the STATUS output.
Application Notes
Exactly Once: each instance should be executed exactly once per scan.
Library
Tricon (TR1LIB/TX1LIB)
TR_USEND_REAL
427
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 ) ;
Table 457
Input Parameters
Name
Data Type
Description
SENDFLG
BOOL
Enables TR_USEND_REAL.
SENDID
DINT
RECVNODE
DINT
RECVID
DINT
DINT
SD_01
REAL
SD_20
REAL
Table 458
Output Parameters
Name
Data Type
Description
SENT
BOOL
ACK
BOOL
ERROR
BOOL
STATUS
DINT
0=
1=
2=
3=
4=
428
Chapter 2
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 Developers Guide.
Example
For Peer-to-Peer examples, see these sample projects:
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
Condition
Return Value
Error Flags
ERROR=true
None
For error numbers, see the description for the STATUS output.
Application Notes
Exactly Once: each instance should be executed exactly once per scan.
Library
Tricon (TR1LIB/TX1LIB)
TR_USEND_REAL_32
429
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 ) ;
Table 459
Input Parameters
Name
Data Type
Description
SENDFLG
BOOL
Enables TR_USEND_REAL_32.
SENDID
DINT
RECVNODE
DINT
RECVID
DINT
DINT
SD_01
REAL
SD_32
REAL
Table 460
Output Parameters
Name
Data Type
Description
SENT
BOOL
ACK
BOOL
ERROR
BOOL
STATUS
DINT
0=
1=
2=
3=
4=
430
Chapter 2
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 Developers Guide.
Example
For Peer-to-Peer examples, see these sample projects:
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
Condition
Return Value
Error Flags
ERROR=true
None
For error numbers, see the description for the STATUS output.
Application Notes
Exactly Once: each instance should be executed exactly once per scan.
Library
Tricon (TR1LIB/TX1LIB)
TR_VOTE_MODE 431
TR_VOTE_MODE
Converts redundancy status.
Syntax
MY_TR_VOTE_MODE( CI:=b1, IN_TMR:=b2, GE_DUAL:=b3, GE_SINGLE:=b4 ) ;
Table 461
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables TR_VOTE_MODE.
IN_TMR
BOOL
GE_DUAL
BOOL
GE_SINGLE
BOOL
Table 462
Output Parameters
Name
Data Type
Description
CO
BOOL
TMR
BOOL
DUAL
BOOL
SINGL
BOOL
ZERO
BOOL
Description
The TR_VOTE_MODE function block converts redundancy status, as shown in this truth table.
Table 463
Truth Table
TMR
GE_DUAL
GE_SINGLE
TMR
DUAL
SINGL
ZERO
Othera
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).
Note
432
Chapter 2
Example
For shutdown examples, see this sample project:
Note
Runtime Errors
Condition
Return Value
Error Flags
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
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
433
TRUNC_LREAL_TO_DINT
Truncates a 64-bit long real number to a 32-bit integer.
Syntax
k := TRUNC_LREAL_TO_DINT(x);
Table 464
Input Parameters
Name
Data Type
Description
LREAL
Table 465
Return Value
Data Type
Description
DINT
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
Conditions
Return Values
Error Flags
If x is not a number
2147483648
BADPARAM, ERROR
If x is minus infinity
2147483648
BADPARAM, ERROR
If x is plus infinity
+2147483647
BADPARAM, ERROR
If x <= -2147483649.0
2147483648
BADCONV, ERROR
If x >= +2147483648.0
+2147483647
BADCONV, 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.
434
Chapter 2
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
TRUNC_LREAL_TO_INT
435
TRUNC_LREAL_TO_INT
Truncates a 64-bit long real number to a 16-bit integer.
Syntax
k := TRUNC_LREAL_TO_INT(x);
Table 466
Input Parameters
Name
Data Type
Description
LREAL
Table 467
Return Value
Data Type
Description
INT
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
Conditions
Return Values
Error Flags
If x is not a number
32768
BADPARAM, ERROR
If x is minus infinity
32768
BADPARAM, ERROR
If x is plus infinity
+32767
BADPARAM, ERROR
If x <= -32769.0
32768
BADCONV, ERROR
If x >= +32768.0
+32767
BADCONV, 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.
436
Chapter 2
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
TRUNC_REAL_TO_DINT
437
TRUNC_REAL_TO_DINT
Truncates a 32-bit real number to a 32-bit integer.
Syntax
k := TRUNC_REAL_TO_DINT(x);
Table 468
Input Parameters
Name
Data Type
Description
REAL
Table 469
Return Value
Data Type
Description
DINT
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
Conditions
Return Values
Error Flags
If x is not a number
2147483648
BADPARAM, ERROR
If x is minus infinity
2147483648
BADPARAM, ERROR
If x is plus infinity
+2147483647
BADPARAM, ERROR
If x <= -2147483649.0
2147483648
BADCONV, ERROR
If x >= +2147483648.0
+2147483647
BADCONV, 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.
438
Chapter 2
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
TRUNC_REAL_TO_INT
439
TRUNC_REAL_TO_INT
Truncates a 32-bit real number to a 16-bit integer.
Syntax
k := TRUNC_REAL_TO_INT(x);
Table 470
Input Parameters
Name
Data Type
Description
REAL
Table 471
Return Value
Data Type
Description
INT
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
Conditions
Return Values
Error Flags
If x is not a number
32768
BADPARAM, ERROR
If x is minus infinity
32768
BADPARAM, ERROR
If x is plus infinity
+32767
BADPARAM, ERROR
If x <= -32769.0
32768
BADCONV, ERROR
If x >= +32768.0
+32767
BADCONV, 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.
440
Chapter 2
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
TSCHED 441
TSCHED
Schedules periodic execution.
Syntax
MY_TSCHED( CI:=b1, PERIOD:=t1, OFFSET:=t2 ) ;
Table 472
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables TCSCHED.
PERIOD
TIME
OFFSET
TIME
Time offset before the first setting of output Q (0.0 OFFSET < PERIOD).
Table 473
Output Parameters
Name
Data Type
Description
CO
BOOL
BOOL
ACTUAL
TIME
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.
442
Chapter 2
Application Notes
Exactly Once: each instance should be executed exactly once per scan.
Library
Triconex (TCXLIB)
TSCHED_I
443
TSCHED_I
Schedules periodic execution.
Syntax
MY_TSCHED_I( CI:=b1, PERIOD:=n1, OFFSET:=n2 ) ;
Table 474
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables TCSCHED_I.
PERIOD
DINT
OFFSET
DINT
Time offset, in milliseconds, before the first setting of output Q (0.0 is less than or
equal to OFFSET).
Table 475
Output Parameters
Name
Data Type
Description
CO
BOOL
BOOL
ACTUAL
DINT
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.
444
Chapter 2
Application Notes
Exactly Once: each instance should be executed exactly once per scan.
Library
Triconex (TCXLIB)
TSCHED_R
445
TSCHED_R
Schedules periodic execution.
Syntax
MY_TSCHED_R( CI:=b1, PERIOD:=x1, OFFSET:=x2 ) ;
Table 476
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables TCSCHED_R
PERIOD
REAL
OFFSET
REAL
Table 477
Output Parameters
Name
Data Type
Description
CO
BOOL
BOOL
ACTUAL
REAL
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.
446
Chapter 2
Application Notes
Exactly Once: each instance should be executed exactly once per scan.
Library
Triconex (TCXLIB)
UNPACK16
447
UNPACK16
Unpacks a DWORD into 16 separate Boolean outputs.
Syntax
MY_UNPACK16( CI:=b1, INPUT:=w1 ) ;
Table 478
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables UNPACK16.
INPUT
DWORD
Table 479
Output Parameters
Name
Data Type
Description
CO
BOOL
NZ
BOOL
Not zero.
Q01
BOOL
Q02
BOOL
Q03
BOOL
Qnn
BOOL
Q16
BOOL
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.
448
Chapter 2
Application Notes
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
449
UNPACK32
Unpacks a DWORD into 32 separate Boolean outputs.
Syntax
MY_UNPACK32( CI:=b1, INPUT:=w1 ) ;
Table 480
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables UNPACK32.
INPUT
DWORD
Table 481
Output Parameters
Name
Data Type
Description
CO
BOOL
NZ
BOOL
Not zero.
Q01
BOOL
Q02
BOOL
Q03
BOOL
Qnn
BOOL
Q32
BOOL
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.
450
Chapter 2
Application Notes
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
451
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 ) ;
Table 482
Input Parameters
Name
Data Type
Description
CI
BOOL
Enables X of N.
RESET
BOOL
VALUE
REAL
LMT
REAL
DINT
The minimum number of N measurements that must exceed the limit to turn output Q
on, where X is less than N.
DINT
Table 483
Output Parameters
Name
Data Type
Description
CO
BOOL
BOOL
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
Conditions
Return Values
Error Flags
CO=false, Q=false
BADPARAM, ERROR
452
Chapter 2
Conditions
Return Values
Error Flags
CO=false, Q=false
BADPARAM, ERROR
CO=false, Q=false
BADPARAM, ERROR
CO=false, Q=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
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
453
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 ;
Table 484
Input Parameters
Name
Data Type
Description
b1..bn
ANY_BIT
Operands
Table 485
Output Parameters
Data Type
Description
ANY_BIT
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.
Table 486
Logical XOR
b1
b2
b1 XOR b2
FALSE
FALSE
FALSE
FALSE
TRUE
TRUE
TRUE
FALSE
TRUE
TRUE
TRUE
FALSE
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.
Table 487
Bitwise XOR
w1
w2
w1 XOR w2
2#0011
2#0101
2#0110
454
Chapter 2
Example
Using Boolean Operands
VAR b, b1:=TRUE, b2:=TRUE, b3:=TRUE : BOOL; END_VAR
b := b1 XOR b2 XOR b3;
(* result is TRUE *)
b := b1 XOR b2;
(* result is FALSE *)
;
;
;
*)
*)
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
Library
Standard (STDLIB)
A
Modbus Protocol
Overview 456
Message Response Time 457
Modbus Messages 459
Modbus Functions 465
Transmission Errors and Exception Conditions 476
456
Appendix A
Modbus Protocol
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 starts a fail-safe timer while it waits for the slave response. Typical slave response
time is in hundreds of milliseconds.
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.
457
Equation or Constraints
Varies depending on the specific Modbus function (message) and any other
program processing
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
458
Appendix A
Modbus Protocol
Modbus Messages
459
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
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.
460
Appendix A
Modbus Protocol
Code
Coil or Register
Constant
01
Coil
02
Coil
10001
03
Register
40001
04
Register
30001
05
Coil
06
Register
40001
07
Coil
n/a
08
Register
n/a
15
Coil
16
Register
40001
Modbus Messages
461
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.
462
Appendix A
Modbus Protocol
The CRC is computed across the station address, the function code, and the data and appended to the end
of the message.
Add the hex characters for the message content. (In the example, this includes the address,
function code, starting address, and number of points fields.) The colon, carriage return, and
line feed are ignored.
This table shows how to calculate the LRC for a sample message.
Table 488
Message Field
Message Content
Address
0x30
0x32
Function Code
0x30
0x31
0x30
0x30
0x31
0x33
0x30
0x30
0x32
0x35
0x4E
0xB2
0x42 (B)
0x32 (2)
Modbus Messages
463
RTU
ASCII
Header
None
Station Address
0000 0010
02
Function Code
0000 0001
01
0000 0000
00
0001 0011
13
0000 0000
00
0010 0101
25
Error Check
0000 1100
C5
0010 0111
Trailer
None
CR LF
Response Message
RTU
ASCII
Header
None
Station Address
0000 0010
02
Function Code
0000 0001
01
Byte Count
0000 0101
05
Data Byte 1
1100a 1101b
CD
Data Byte 2
0110 1011
6B
Data Byte 3
1011 0010
B2
Data Byte 4
0000 1110
0E
Data Byte 5
0001 1011
1B
Error Check
0000 0100
E5
1111 1111
Trailer
None
CR LF
464
Appendix A
Modbus Protocol
Query
Number of RTU
Characters
Number of ASCII
Characters
01
17
02
17
03
17
04
17
05
17
06
17
15
9 + (1 per 8 coils)
19 + (2 per 8 coils)
16
9 + (2 per register)
19 + (4 per register)
Response
Number of RTU
Characters
Number of ASCII
Characters
01
5 + (1 per 8 coils)
11 + (2 per 8 coils)
02
5 + (1 per 8 coils)
11 + (2 per 8 coils)
03
5 + (2 per register)
11 + (4 per register)
04
5 + (2 per register)
11 + (4 per register)
05
17
06
17
15
17
16
17
Function
Code
Modbus Functions
465
Modbus Functions
This section includes details on Modbus functions.
Functions include:
466
Appendix A
Modbus Protocol
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 loworder 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.
Modbus Functions
467
Query Format
Response Format
468
Appendix A
Modbus Protocol
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.
Modbus Functions
469
Query Format
Response Format
470
Appendix A
Modbus Protocol
Query Format
Response Format
Modbus Functions
471
Query Format
Response Format
472
Appendix A
Modbus Protocol
Note
A serial port configured as a Modbus master cannot use the Read Exception Status function.
Query Format
Response Format
Modbus Functions
473
Note
A serial port configured as a Modbus Master cannot use the Loop-Back Diagnostic Test function.
Query Format
Response Format
474
Appendix A
Modbus Protocol
Query Format
Response Format
Modbus Functions
475
Query Format
Response Format
476
Appendix A
Modbus Protocol
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.
477
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.
Exception Condition
Description
The slave does not respond, because the error could be in the station address.
The master uses its response fail-safe timer to recover.
The slave sends an Illegal Function (01) response code when it detects an error
in the function code field.
The slave sends an Illegal Data Address (02) response code when it detects an
error in the starting address field.
The slave sends an Illegal Data Value (03) response code when it detects an
error in the data field.
This exception applies only to serial ports which are configured as slaves.
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:
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.
478
Appendix A
Modbus Protocol
Exception Responses
When a slave detects an exception condition, it sends a response message to the master consisting of the
slaves 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
479
Name
Description
01
Illegal Function
02
03
04
Failure in Associated
Device
05
Acknowledge
06
The query was received without error, but the slave cannot comply.
07
Negative Acknowledge
08
480
Appendix A
Modbus Protocol
B
Peer-to-Peer Parameters
Overview 482
Parameters of Send Function Blocks 483
Parameters of Receive Function Blocks 486
Peer-to-Peer Runtime Errors 488
482
Appendix B
Peer-to-Peer Parameters
Overview
This appendix describes the input and output parameters for Peer-to-Peer function blocks, and runtime
errors.
Topics include:
483
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:
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-toPeer Receive. If RECVID is out of range, calls to the function block set the STATUS output to 102.
484
Appendix B
Peer-to-Peer Parameters
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.
Table 489
Status
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.
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).
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
485
Status
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.
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 errorin one or both of the TriStation 1131 applicationsthat 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.
486
Appendix B
Peer-to-Peer Parameters
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.
Table 490
487
Status
New data has been received from the sending controller and is available in outputs RD_01...RD_nn
until new data is received again.
100
101
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.
104
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.
488
Appendix B
Peer-to-Peer Parameters
TR_PEER_STATUS
It takes 2 to 30 seconds to detect and report time-out and communication errors. A TriStation 1131
application that receives and acts on safety-critical data must verify that new data is received within the
specified process tolerance time. If the data is not received in time, the application must take appropriate
actions.
Table 491
Error
Description
Detection
Suggested Action
COMM_OK is false on
TR_PEER_STATUS
function block
No communication path
between the sending and
receiving controllers.
Diagnostics on the CM
send a message to each
node. If no response is
received within 1 second,
the CM sets the output
false.
No redundant
communication path
between the sending and
receiving controllers.
There is no receiving
controller on the
network.
There is no matching
Receive function
block in the
receiving controller.
The receiving
controller is trying
to recover from a
communication
error.
There is a programming
error in the sending or
receiving controller.
Table 491
489
Error
Description
Detection
Suggested Action
STATUS is 100 on a
Receive function block
There is a programming
error in the sending or
receiving controller.
490
Appendix B
Peer-to-Peer Parameters
Index
Symbols
arc cosine 11
* operator 209
arc sine 59
** operator 115
arc tangent 60
/ operator 101
+ operator 12
= operator 109
Numerics
ASCII mode
characters in station address 461
defined 459
A
ABS function 10
absolute value 10
ACK output parameter 484
ACOS function 11
ADD function 12
AIN function 14
AIN_BP function 15
AIN_BP12 function 17
AIN_HR function 19
alarm functions
BYPASS_BOOL 69
BYPASS_DINT 71
BYPASS_REAL 73
DEVIATION_ALARM_DINT 21
DEVIATION_ALARM_REAL 25
LEVEL_ALARM_DINT 29
LEVEL_ALARM_REAL 33
ROC_ALARM_DINT 37
ROC_ALARM_REAL 41
TRIP_ALARM 45
analog input 14, 15, 17, 19
ASIN function 59
ATAN function 60
B
BADCONV error flag 76
BADPARAM error flag 76
BADPARAM status flag 261
base ten logarithm 163
bistable 264, 281
bitwise AND 48
bitwise complement 217
bitwise NOT 217
bitwise OR 221
bitwise XOR 453
BLINK function block 61
BLINK_I function block 63
BLINK_R function block 65
BOOL data type 67
BOOL_TO_DWORD function 68
BYPASS_BOOL function 69
BYPASS_DINT function 71
BYPASS_REAL function 73
AND function 48
AND operator 48
AOUT function 50
AOUT_BP12 function 51
calendar clock
adjusting 361
setting 363
492
Index
CEIL function 75
ceiling 75
down counter 89
CONCAT_DT function 82
concatenate 82
COS function 83
cosine 83
count down 89
count up 91
count up-down 93
CR field 462
CRC error check 461
CSCHED function block 84
CSCHED_I function block 86
CSCHED_R function block 88
CTD function block 89
CTU function block 91
EQ function 109
error flags 76
ERROR output parameter 484, 486
errors 76
errors, Modbus data transmission 476
event collection 272, 274, 276, 278
exclusive OR 453
data types
BOOL 67
DATE 95
DINT 96
DT 103
DWORD 106
INT 140
LREAL 166
REAL 254
STRING 283
TIME 358
TOD 371
F
F_TRIG function block 117
flags 76
deviation 229
DEVIATION_ALARM_DINT function 21
floating-point underflow
for LREAL data types 166
for REAL data types 254
DEVIATION_ALARM_REAL function 25
differential bipolar analog input 15, 17
DINT data type 96
DINT_TO_DWORD function 97
DINT_TO_INT function 98
DINT_TO_LREAL function 99
Index
LE function 152
LEVEL_ALARM_DINT function 29
LEVEL_ALARM_REAL function 33
GE function 126
LF field 462
LN function 162
gradual underflow
effect on absolute and relative error 167, 255
for LREAL data types 166
for REAL data types 254
GT function 136
logical AND 48
H
high-resolution analog input 19
I
i.LREAL numbers, precision when approaching
zero 167
I/O modules, status 392
IEC-559 Standard Floating-Point format 254
inclusive OR 221
-INF 205, 206
INFINITY_LREAL function 138
INFINITY_REAL function 139
INT data type 140
INT_TO_DINT function 141
INT_TO_LREAL function 142
INT_TO_REAL function 143
integration 144, 146
INTERNALERR error flag 76
INTGTOR function block 144
INTGTOR_R function block 146
IsFinite_LREAL function 148
IsFinite_REAL function 149
IsNan_LREAL function 150
IsNan_REAL function 151
L
latch 264, 281
493
logarithm
base ten 163
natural 162
logical NOT 217
logical OR 221
logical XOR 453
long reals, precision when approaching zero 167
longitudinal redundancy check. See LRC checksum.
loop detector 164
Loop-Back Diagnostic Test function 473
LOOPDETR function block 164
LRC checksum, calculation 462
LREAL data type 166
LREAL_TO_DINT function 168
LREAL_TO_INT function 170
LREAL_TO_REAL function 172
LT function 174
M
MAX function 176
MBCTRL function block 178
MBREAD_BOOL function block 180
MBREAD_DINT function block 182
MBREAD_REAL function block 184
MBREAD_REAL_TRD function block 188
MBWRITE_BOOL function block 191
MBWRITE_DINT function block 193
MBWRITE_REAL function block 195
MBWRITE_REAL_TRD function block 198
median 201
494
Index
OR function 221
OR operator 221
Modbus functions
list of names and codes 459
supported by serial ports 459
Modbus master
reading values from a slave 180, 182, 184, 188
setting timeout and retry values 178
writing values to a slave 191, 193, 195, 198
Modbus protocol
checksum field 461
exception conditions 477
exception responses 478, 479
function code field, described 461
message format 461
message header 461
message lengths 464
overview 456
performance considerations 458
query and response 463
station address field 461
modulo 207
monitoring analog current loops 160
MOVE function 208
MUL function 209
MUX function 211
N
N input parameter 484, 486
NAN 150, 151, 213, 214
NAN_LREAL function 213
NAN_REAL function 214
natural exponential 111
natural logarithm 162
NDR output parameter 486
NE function 215
noise sources, Modbus communication 476
not a number (NAN) 150, 151, 213, 214
NOT function 217
NOT operator 217
R
R_TRIG function block 252
Index
495
RD_nn 487
sine 271
remainder 207
status
critical I/O modules 392
safety-critical I/O modules 298
Tricon 64 point 385
Tricon chassis 389
Tricon main processor 395
Tricon Peer-to-Peer 397
Tricon points 399
Tricon port 401
Tricon program 403
Tricon scan 405
Tricon slot 409
Trident analog input module 287
Trident analog output module 289
Trident combo AI/DI input module 300
Trident communication module 295
Trident discrete input module 302
Trident discrete output module 304
Trident high resolution discrete input module 306
Trident I/O module 309
Trident I/O processor 311
Trident main processor 314, 319
Trident pulse input module 324
Trident relay output module 327
Trident supervised discrete output module 329
Trident system 342
Tri-GP analog input module 287
Tri-GP analog output module 289
Tri-GP combo AI/DI input module 300
Tri-GP communication module 295
Tri-GP discrete input module 302
Tri-GP discrete output module 304
Tri-GP high resolution discrete input module 306
S
SCALE function 267
scan time, effect on Modbus performance 458
scheduling execution 84, 86, 88, 441, 443, 445
SD_nn input parameters 484
SEL function 268
select 268
SENDFLG input parameter 483
SENDID input parameter 483, 486
SENDNODE input parameter 486
SENT output parameter 484
sequence of events 272, 274, 276, 278
496
Index
status (continued)
Tri-GP I/O module 309
Tri-GP I/O processor 311
Tri-GP main processor 314, 319
Tri-GP pulse input module 324
Tri-GP relay output module 327
Tri-GP supervised discrete output module 329
Tri-GP system 342
status flags 76
STATUS output parameter 484
STATUS output values 486
STRING data type 283
STRLEN error flag 76
SUB function 284
subtraction operator 284
SYS_AI32_STATUS function block 287
SYS_AO04_STATUS function block 289
SYS_APP_HALT function 291
SYS_CLEAR_FLTS function 293
SYS_CM_STATUS function block 295
SYS_CRITICAL_IO function block 298
SYS_DI16_AI16_STATUS function block 300
SYS_DI32_STATUS function block 302
SYS_DO16_STATUS function block 304
SYS_HRDI32_STATUS function block 306
SYS_IO_STATUS function block 309
SYS_IOP_STATUS function block 311
SYS_MP_EXT_STATUS function block 314
SYS_MP_RESET_PORTS function 317
SYS_MP_STATUS function block 319
SYS_OVD_INHIBIT function 322
SYS_PI06_STATUS function block 324
SYS_RO32_STATUS function block 327
SYS_SDO16_STATUS function block 329
SYS_SERIAL_PORT function block 332
SYS_SET_APP_LOCK function 334
SYS_SET_PROG_ALARM function 336
SYS_SET_REMOTE_WRT_ENBL function 338
SYS_SHUTDOWN function block 340
SYS_SYSTEM_STATUS function block 342
SYS_VOTE_MODE function block 345
T
TAN function 347
tangent 347
Index
497
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
498
Index