Sunteți pe pagina 1din 456

Libraries Reference

TriStation 1131
Assembly No. 9700098-008
June 2009
TriStation 1131 Developers Workbench
Versions 4.0 and Later
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.
20032009 by Invensys Systems, Inc. All rights reserved.
Triconex, Tricon, Trident, TriStation 1131, TriStation MSW, and CEMPLE are trademarks of Invensys plc,
its subsidiaries and affiliates. All other brands may be trademarks of their respective owners.
Document No. 9720098-008
Printed in the United States of America.
TriStation 1131 Libraries Reference
Contents
Preface xi
Summary of Sections. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
Related Documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
Product and Training Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xii
Technical Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xii
We Welcome Your Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii
Chapter 1 Introduction 1
How to Use This Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Name and Brief Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Parameters and Return Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Description and Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Runtime Errors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Application Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Application Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Function Block Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
CEM Enabled . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Library. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Chapter 2 Functions and Data Types 7
ABS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
ACOS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
ADD. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
AIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
AIN_BP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
AIN_BP12 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
AIN_HR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
AND. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
AOUT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
AOUT_BP12 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
ARRAY32_BOOL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
ARRAY32_DINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
ARRAY32_REAL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
ASIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
ATAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
BLINK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
iv Contents
TriStation 1131 Libraries Reference
BLINK_I . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
BLINK_R. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
BOOL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
BOOL_TO_DWORD. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
CEIL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
CHK_ERR. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
CLR_ERR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
CONCAT_DT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
COS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
CSCHED. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
CSCHED_I . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
CSCHED_R. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
CTD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
CTU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
CTUD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
DATE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
DINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
DINT_TO_DWORD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
DINT_TO_INT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
DINT_TO_LREAL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
DINT_TO_REAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
DIV. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
DT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
DT_TO_DATE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
DT_TO_TOD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
DWORD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
DWORD_TO_BOOL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
DWORD_TO_DINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
EQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
EXP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
EXPFLTR. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
EXPT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
F_TRIG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
FLOOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
GASDETR. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
GATDIS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
GATENB. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
GE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
GetDelta_DINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
GetDelta_REAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
GetDeltaT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
GetTimer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
GT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
INFINITY_LREAL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
Contents v
TriStation 1131 Libraries Reference
INFINITY_REAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
INT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
INT_TO_DINT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
INT_TO_LREAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
INT_TO_REAL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
INTGTOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
INTGTOR_R. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
IsFinite_LREAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
IsFinite_REAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
IsNan_LREAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
IsNan_REAL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
LE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
LEADLAG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
LEADLAG_R . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
LIMIT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
LINEMNTR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
LN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
LOG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
LOOPDETR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
LREAL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
LREAL_TO_DINT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
LREAL_TO_INT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
LREAL_TO_REAL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
LT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
MAX. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
MBCTRL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
MBREAD_BOOL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
MBREAD_DINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
MBREAD_REAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
MBREAD_REAL_TRD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
MBWRITE_BOOL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
MBWRITE_DINT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
MBWRITE_REAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
MBWRITE_REAL_TRD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
MEDSEL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
MIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
MINUS_INFINITY_LREAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
MINUS_INFINITY_REAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
MOD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
MOVE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
MUL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
MUX. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
NAN_LREAL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
NAN_REAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
vi Contents
TriStation 1131 Libraries Reference
NE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
NOT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
NUMBITS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
NUMBITS_DWORD. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
OR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
OVDDISABLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
OVDENABLE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
PACK16. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
PACK32. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
PAGE_EJECT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
PERDEV . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
PID. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
PID_R . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
POLY4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
POLY5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
PRINT_BOOL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
PRINT_CDT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
PRINT_CRLF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
PRINT_CTOD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
PRINT_DINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198
PRINT_REAL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
PRINT_STRING. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202
PRNTR_FLUSH. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
R_TRIG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
REAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
REAL_TO_DINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
REAL_TO_INT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
REAL_TO_LREAL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
ReportBadParam. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
ROL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
ROR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
RS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
RTC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
SCALE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
SEL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220
SHL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
SHR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
SIN. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
SOECLR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
SOESTAT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
SOESTOP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
SOESTRT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230
SQRT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
SR. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
Contents vii
TriStation 1131 Libraries Reference
STRING. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
SUB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
SYS_AI32_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
SYS_AO04_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241
SYS_APP_HALT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
SYS_CLEAR_FLTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244
SYS_CM_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246
SYS_CRITICAL_IO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
SYS_DI16_AI16_STATUS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
SYS_DI32_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
SYS_DO16_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
SYS_HRDI32_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
SYS_IO_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260
SYS_IOP_STATUS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
SYS_MP_EXT_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265
SYS_MP_RESET_PORTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
SYS_MP_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270
SYS_OVD_INHIBIT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
SYS_PI06_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
SYS_RO32_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278
SYS_SDO16_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280
SYS_SERIAL_PORT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
SYS_SET_APP_LOCK. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
SYS_SET_PROG_ALARM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
SYS_SET_REMOTE_WRT_ENBL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288
SYS_SHUTDOWN. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
SYS_SYSTEM_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
SYS_VOTE_MODE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294
TAN. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296
TCJ_CONV. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
TCK_CONV . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
TDD_I . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
TDD_R. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302
TDE_I. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303
TDE_R . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304
TIME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305
TIME_TO_SECS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306
TIME_TO_SECS_REAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
TIMEADJ. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308
TIMESET. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310
TMR. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312
TMR_I . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
TMR_R . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316
TOD. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318
viii Contents
TriStation 1131 Libraries Reference
TOF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319
TOGGLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322
TON. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324
TP. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326
TP_I . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328
TP_R . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330
TR_64_POINT_STATUS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332
TR_CALENDAR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334
TR_CHASSIS_STATUS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336
TR_CLEAR_FLTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338
TR_CRITICAL_IO. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339
TR_MP_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342
TR_PEER_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344
TR_POINT_STATUS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345
TR_PORT_STATUS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347
TR_PROGRAM_STATUS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
TR_SCAN_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351
TR_SHUTDOWN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353
TR_SLOT_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355
TR_URCV_BOOL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357
TR_URCV_DINT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359
TR_URCV_DINT_32. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361
TR_URCV_REAL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363
TR_URCV_REAL_32. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365
TR_USEND_BOOL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367
TR_USEND_DINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369
TR_USEND_DINT_32 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371
TR_USEND_REAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373
TR_USEND_REAL_32 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375
TR_VOTE_MODE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377
TRUNC_LREAL_TO_DINT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379
TRUNC_LREAL_TO_INT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381
TRUNC_REAL_TO_DINT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383
TRUNC_REAL_TO_INT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385
TSCHED . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387
TSCHED_I . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389
TSCHED_R. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391
UNPACK16 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393
UNPACK32 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395
X_OF_N. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397
XOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399
Contents ix
TriStation 1131 Libraries Reference
Appendix A Modbus Protocol 401
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402
Message Response Time. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403
Determining Message Response Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403
Modbus Functions and Scan Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404
Modbus Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405
Communication Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405
Function Names and Aliases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406
Modbus Message Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407
Sample Query and Response Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409
Modbus Message Lengths . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410
Modbus Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411
Read Coil Status Function (Function Code 01) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412
Read Input Status (Function Code 02) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413
Read Holding Registers (Function Code 03) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414
Read Input Registers (Function Code 04) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415
Force Single Coil (Function Code 05) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 416
Preset Single Register (Function Code 06) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417
Read Exception Status (Function Code 07) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 418
Loop-Back Diagnostic Test (Function Code 08) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419
Force Multiple Coils (Function Code 15) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 420
Preset Multiple Registers (Function Code 16) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 421
Transmission Errors and Exception Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 422
Transmission Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 422
Exception Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423
Exception Responses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424
Exception Response Codes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425
Appendix B Peer-to-Peer Parameters 427
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 428
Parameters of Send Function Blocks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 428
Parameters of Receive Function Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 432
Peer-to-Peer Runtime Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434
Index 437
x Contents
TriStation 1131 Libraries Reference
TriStation 1131 Libraries Reference
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 versions 4.0 and later.
Note For detailed information about the libraries released with each version of TriStation,
refer to the Product Release Notice for TriStation 1131, available on the IPS Global
Customer Support 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.
Appendix A, Modbus ProtocolProvides information about Modbus protocol
including Modbus message formats and error codes.
Appendix B, Peer-to-Peer ParametersProvides detailed information about the Peer-
to-Peer input and output parameters, and runtime errors.
Related Documents
TriStation 1131 Developers Guide
SOE Recorder Users Guide
Safety Considerations Guides for Tricon and Trident Systems
Product Release Notices for TriStation 1131
xii Preface
TriStation 1131 Libraries Reference
Product and Training Information
To obtain information about Triconex products and in-house and on-site training, see the
Triconex Web site or contact your regional customer center.
Web Site
http://www.ips.invensys.com/en/triconex
Technical Support
Customers in the U.S. and Canada can obtain technical support from the IPS Global Client
Support (GCS) center at the numbers below. International customers should contact their
regional support center.
Requests for support are prioritized as follows:
Emergency requests are given the highest priority
Requests from participants in the System Watch Agreement (SWA) and customers with
purchase order or charge card authorization are given next priority
All other requests are handled on a time-available basis
If you require emergency or immediate response and are not an SWA participant, you may
incur a charge. Please have a purchase order or credit card available for billing.
Telephone
Toll-free number 866-746-6477, or
Toll number 508-549-2424 (outside U.S.)
Fax
Toll number 508-549-4999
Web Site
http://support.ips.invensys.com/ (registration required)
E-mail
support@ips.invensys.com
Preface xiii
TriStation 1131 Libraries Reference
We Welcome Your Comments
To help us improve future versions of Triconex documentation, we want to know about any
corrections, clarifications, or further information you would find useful. When you contact us,
please include the following information:
The title and version of the guide you are referring to
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 suggestions for correcting or improving the documentation
The version of the Triconex hardware or software you are using
Your name, company name, job title, phone number, and e-mail address
Send e-mail to us at:
triconextechpubs@ips.invensys.com
Please keep in mind that this e-mail address is only for documentation feedback. If you have a
technical problem or question, please contact the Customer Satisfaction Center. See Technical
Support (page xii) for contact information.
Or, you can write to us at:
Attn: Technical Publications
Triconex
15345 Barranca Parkway
Irvine, CA 92618
Thank you for your feedback.
xiv Preface
TriStation 1131 Libraries Reference
TriStation 1131 Libraries Reference
1
Introduction
How to Use This Book 2
2 Chapter 1 Introduction
TriStation 1131 Libraries Reference
How to Use This Book
This section explains how the library elements (functions, function blocks, and data types) are
described in this book. For more information on programming with IEC functions and function
blocks, see Programming Industrial Control Systems Using IEC 1131-3, by R.W. Lewis, London:
Short Run Press Ltd., 1998.
Topics include:
Name and Brief Description on page 2
Syntax on page 2
Parameters and Return Values on page 2
Description and Example on page 3
Runtime Errors on page 3
Application Notes on page 4
Name and Brief Description
The name and a brief description introduces each function and function block. This is an
example:
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);
Parameters and Return Values
This section describes parameters and return values.
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
b BOOL The Boolean value to be converted.
Description and Example 3
TriStation 1131 Libraries Reference
Output Parameters
A table of output parameters shows the name, data type, and description of each function block
output. This is an example:
Return Value
A table shows the data type and description of the value returned by the function. This is an
example:
Description and Example
The description and example include a detailed description and short example of how to use the
function or function block. This is an example:
Description
The CEIL function returns the next higher integer greater than or equal to x.
Example
VAR x : REAL END_VAR;
x := ceil(6.04 ); (* result is 7.0 *)
Runtime Errors
The Runtime Errors section includes the conditions, return values, and error flags returned if a
runtime error occurs. This is an example:
Runtime Errors
Table 2 Output Parameters
Name Data Type Description
CO BOOL True if CLR_ERR executes successfully.
Table 3 Return Value
Data Type Description
DWORD The value of b converted to a DWORD value.
Condition Return Value Error Flags
If k is less than -32768 32768 BADCONV, ERROR
If k is greater than 32767 +32767 BADCONV, ERROR
4 Chapter 1 Introduction
TriStation 1131 Libraries Reference
Application Notes
The Application Notes section indicates how the function, function block, or data type can be
used. These properties are indicated:
Application Type on page 4
Function Block Usage on page 5
CEM Enabled on page 6
Application Type
The Application Type indicates whether a function, function block, or data type can be used in
a safety program or control program. The purpose of this designation is to reduce the interaction
between safety programs and control programs running on the same controller.
Each element (program, function, function block, or data type) is specified as a safety element
or a control (non-safety) element:
A safety element can be used in a safety element or a control (non-safety) element.
A control (non-safety) element can only be used in a control (non-safety) element.
A safety element must be made up entirely of other safety elements. A control (non-safety)
element can use a safety element or a control element.
Attempting to use a non-safety element in a safety element results in one of these errors:
WF0050: Element is not a safety element (indicated by Red X).
WF0051: Safety element uses non-safety element.
Application Type
Used in a Safety
Element
Used in a Control
(Non-Safety) Element
Safety element OK OK
Control (non-safety) element WF0050 or WF0051 OK
Application Notes 5
TriStation 1131 Libraries Reference
Function Block Usage
The Usage section includes information about how a function block should be used in a
TriStation 1131 application. To display the properties, right-click a function block, click
Properties, then click the Usage tab.
Usage includes these options:
Using a Space Saver Function Block
1 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.
2 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.
Option Description
Exactly Once Each function block instance should be executed exactly once per scan.
Only Once Each function block instance should be executed only once per scan, but does not
need to be executed every scan.
Space Saver Each function block instance can be executed more than once per scan to reduce
memory usage and increase performance. See Using a Space Saver Function
Block on page 5.
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.
6 Chapter 1 Introduction
TriStation 1131 Libraries Reference
3 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:
Can be used in CEM Cause cells.
Can be used in CEM Cause and Effect cells.
Can be used in CEM Cause, Effect, and Intersection cells.
Can be used in CEM Effect cells.
Can be used in CEM Cause and Intersection cells.
Can be used in CEM Intersection cells.
Library
The Library section identifies the libraries that the function or function block is included in.
TriStation 1131 includes these libraries:
Standard Library (STDLIB) complies with the IEC 61131-3 standard
Triconex Library (TCXLIB) for all Triconex controllers
Tricon Library () for Tricon controllers
Trident Library (TRDLIB) for Trident controllers
TriStation 1131 Libraries Reference
2
Functions and Data Types
This section describes the functions, function blocks, and data types included in TriStation 1131
Libraries.
8 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
ABS
Calculates the absolute value of a number.
Syntax
k := ABS(m)
Description
The ABS function returns the absolute value of a number. The absolute value is the magnitude
that is, the value with the sign removed.
Example
VAR k : DINT; END_VAR
k := ABS( 1234 ); (* result is 1234 *)
k := ABS( 1234 ); (* result is 1234 *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
Table 4 Input Parameters
Name Data Type Description
m ANY_NUM A number.
Table 5 Return Value
Data Type Description
ANY_NUM The absolute value of m.
ACOS 9
TriStation 1131 Libraries Reference
ACOS
Calculates the principal arc cosine of a real number.
Syntax
y := ACOS( x )
Description
The ACOS function calculates the principal arc cosine of a real number. The result is in radians
from 0.0 to 3.14159.
Example
VAR y : REAL; END_VAR
y := ACOS( 1.0 ); (* result is 0.0 *)
y := ACOS( 1.0 ); (* result is 3.14159 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the
error flags to true, and resets ENO to false. For more information about error flags and runtime
errors, see the CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
Table 6 Input Parameters
Name Data Type Description
x ANY_REAL A real number between 1.0 and 1.0 whose arc cosine is to be calculated.
Table 7 Return Value
Data Type Description
ANY_REAL The arc cosine of x in radians from 0.0 to 3.14159.
Condition Return Value Error Flags
If x is not a number or the absolute value of x is greater
than 1.0.
NAN BADPARAM, ERROR
10 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
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.
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.
Operation
Parameter
Data Type
Result Data
Type
Return Value
Calculates the sum of two
numeric values.
ANY_NUM ANY_NUM The sum of the operands.
Calculates the sum of two time
periods.
TIME TIME The sum of the operands.
Adds a time operand to a date
and time operand.
DT + TIME DT The date and time operand plus the
time operand.
Adds a time operand to a time
of day operand.
TOD + TIME TOD The time-of-day operand plus the
time operand.
Operation
Parameter
Data Type
Return Value
Data Type
Return Value
Calculates the sum of from 1 to 50
numeric inputs.
ANY_NUM ANY_NUM The sum of the inputs.
Calculates the sum of two time
inputs.
TIME TIME The sum of the inputs.
Adds a time input to a date and
time input.
DT + TIME DT The date and time input plus
the time input.
Adds a time input to a time of day
input.
TOD + TIME TOD The time-of-day input plus
the time input.
ADD 11
TriStation 1131 Libraries Reference
Example
Calculate the Sum of Numeric Values
VAR m : DINT; END_VAR
m := 10 + 1564; (* result is 1574 *)
m := 10 + 1564 + 32761 + 512; (* result is 33823 *)
Calculate the Sum of Two Times
VAR t : TIME; END_VAR
t := T#11d22h33m + T#3h10m; (* result is T#12d1h43m *)
Add a Time to a Date and Time
VAR d : DT; END_VAR
d := DT#2002-01-27-08:00:00 + T#3h30m45s;
(* result is DT#2002-01-27-11:30:45 *)
Add a Time to a Time of Day
VAR t : TOD; END_VAR
t := TOD#08:00:00 + T#3h30m45s; (* result is TOD#11:30:45 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the
error flags to true, and resets ENO to false. For more information about error flags and runtime
errors, see the CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
Condition Return Value Error Flags
If the result is infinite INF OVERFLOW, ERROR
If an operand is not a number (NAN) NAN OVERFLOW, ERROR
If the date and time is out of range Invalid date BADPARAM, ERROR
If the time is out of range Invalid time BADPARAM, ERROR
12 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
AIN
Converts an analog input to a real number.
Syntax
y := AIN( MX, IN, MN )
Description
The AIN function converts an analog input to a real number. The range of IN is 819 to 4095,
which corresponds to 4 to 20 milliamps or 1 to 5 volts. The return value is a real number (in
engineering units) scaled to the range from MN to MX. MN is the value returned when the input
corresponds to 4 milliamps or 1 volt, or is less than 819. MX is the value returned when the input
corresponds to 20 milliamps or 5 volts, or is greater than or equal to 4095.
Example
VAR y : REAL; END_VAR
y := AIN( 100.0, 4095, 0.0 ); (* result is 100.0 *)
y := AIN( 100.0, 2457, 0.0 ); (* result is 50.0 *)
y := AIN( 100.0, 819, 0.0 ); (* result is 0.0 *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Triconex (TCXLIB)
Table 8 Input Parameters
Name Data Type Description
MX REAL The upper limit of the return value.
IN DINT The value to be converted to engineering units.
MN REAL The lower limit of the return value.
Table 9 Return Value
Data Type Description
REAL The value of IN converted to engineering units.
AIN_BP 13
TriStation 1131 Libraries Reference
AIN_BP
Converts a differential bipolar analog input to a real number.
Syntax
y := AIN_BP( MX, IN, MN )
Description
The AIN_BP function converts a differential bipolar analog input to a real number. The range
of IN is -16383 to 16383, which corresponds to -20 to 20 milliamps or -5 to 5 volts. The return
value is a real number (in engineering units) scaled to the range from MN to MX. MN is the
value returned when the input corresponds to -20 milliamps or -5 volts, or is less than -16383.
MX is the value returned when the input corresponds to 20 milliamps or 5 volts, or is greater
than or equal to 16383. The scaling equation implemented in this function is equal to
where HI= 16383 and LO= -16383.
Example
VAR y : REAL; END_VAR
y := AIN_BP( 100.0, 16383, 0.0 ); (* result is 100.0 *)
y := AIN_BP( 100.0, 0, 0.0 ); (* result is 50.0 *)
y := AIN_BP( 100.0, -16383, 0.0 ); (* result is 0.0 *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Triconex (TCXLIB)
1
Table 10 Input Parameters
Name Data Type Description
MX REAL The upper limit of the return value.
IN DINT The value to be converted to engineering units.
MN REAL The lower limit of the return value.
Table 11 Return Value
Data Type Description
REAL The value of IN converted to engineering units.
1. This function was added to the library in v1.31 of TCXLIB, first released with TriStation 1131 v4.1.419.
IN LO
HI LO
--------------------- MX MN ( ) MN +
14 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
AIN_BP12
Converts a 12-bit differential bipolar analog input to a real number.
Syntax
y := AIN_BP12( MX, IN, MN )
Description
The AIN_BP12 function converts a 12-bit differential bipolar analog input to a real number. The
typical range of IN is -4095 to 4095. The return value is a real number (in engineering units) scaled
to the range from MN to MX. MN is the value returned when the input is -4095. MX is the value
returned when the input is +4095. AIN_BP12 clamps the analog input to the range of -4095 to
+4095. The scaling equation implemented in this function is approximately equivalent to
where HI= 4095 and LO= -4095.
Table 12 Input Parameters
Name Data Type Description
MX REAL The upper limit of the return value.
IN DINT The value to be converted to engineering units.
MN REAL The lower limit of the return value.
Table 13 Return Value
Data Type Description
REAL The value of IN converted to engineering units.
IN LO
HI LO
--------------------- MX MN ( ) MN +
MN
MX
+4095
-4095
Machine
Count
Engineering
Units
AIN_BP12 15
TriStation 1131 Libraries Reference
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:
VAR y : REAL; in : DINT; END_VAR
y := AIN_BP12( +10.0, in, -10.0 );
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Triconex (TCXLIB)
2

in y
-4095 -10.0
0 0.0
+4095 +10.0
2. This function was added to the library in v1.32 of TCXLIB, first released with TriStation 1131 v4.3.
16 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
AIN_HR
Converts a high-resolution analog input to a real number.
Syntax
y := AIN_HR( MX, IN, MN )
Description
The AIN_HR function converts a high-resolution analog input to a real number. The range of
IN is 3276 to 16383, which corresponds to 4 to 20 milliamps or 1 to 5 volts. The return value is a
real number (in engineering units) scaled to the range from MN to MX. MN is the value returned
when the input corresponds to 4 milliamps or 1 volt, or is less than 3276. MX is the value
returned when the input corresponds to 20 milliamps or 5 volts, or is greater than or equal to
16383. The scaling equation implemented in this function is equal to
where HI= 16383 and LO= 3276.
Example
VAR y : REAL; END_VAR
y := AIN_HR( 100.0, 16383, 0.0 ); (* result is 100.0 *)
y := AIN_HR( 100.0, 9829, 0.0 ); (* result is 50.0 *)
y := AIN_HR( 100.0, 3276, 0.0 ); (* result is 0.0 *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Triconex (TCXLIB)
3
Table 14 Input Parameters
Name Data Type Description
MX REAL The upper limit of the return value.
IN DINT The value to be converted to engineering units.
MN REAL The lower limit of the return value.
Table 15 Return Value
Data Type Description
REAL The value of IN converted to engineering units.
3. This function was added to the library in v1.31 of TCXLIB, first released with TriStation 1131 v4.1.419.
IN LO
HI LO
--------------------- MX MN ( ) MN +
AND 17
TriStation 1131 Libraries Reference
AND
Performs a logical AND of two or more Boolean operands or a bitwise AND of two or more bit-
strings.
Syntax
b := b1 AND b2 AND ... AND bn ;
Description
In graphical languages, the AND function returns the logical AND of Boolean operands or the
bitwise AND of bit-strings. In Structured Text, the AND operator is used instead of the AND
function.
The maximum number of function inputs is 50.
All operands must be the same type as the return value, either all BOOL or all DWORD.
If the operand type is BOOL, then the result is true if all operands are true. The result is false if
any operand is false.
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 16 Input Parameters
Name Data Type Description
b1bn ANY_BIT Operands
Table 17 Return Value
Data Type Description
ANY_BIT b1 AND b2 AND ... AND bn
Table 18 Logical AND
b1 b2 b1 OR b2
FALSE FALSE FALSE
FALSE TRUE FALSE
TRUE FALSE FALSE
TRUE TRUE TRUE
Table 19 Bitwise AND
w1 w2 w1 AND w2
2#0011 2#0101 2#0001
18 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
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 *)
Using Bit-String Parameters
VAR w, w1, w2, w3 : DWORD; END_VAR
w1 := 2#00000000000000000000000000000111 ;
w2 := 2#00000000000000000000000000000011 ;
w3 := 2#00000000000000000000000000000101 ;
w := w1 AND w2 AND w3; (* 2#00000000000000000000000000000001 *)
w := w1 AND w3; (* 2#00000000000000000000000000000101 *)
Note that on the Controller Panel, you will see the example values in hex. The hex values of the
operands are w1=16#00000007, w2=16#00000003, w3=16#00000005, and the hex values of the
results are 16#00000001 and 16#00000005.
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Can be used in CEM Cause cells.
Library
Standard (STDLIB)
AOUT 19
TriStation 1131 Libraries Reference
AOUT
Converts a real number to an analog output.
Syntax
k := AOUT( MX, IN, MN )
Description
The AOUT function converts a real number to an analog output (in machine counts) that is
typically in the range of 819 to 4095. MN is the input value required to drive 4 milliamps or
1 volt in the field. MX is the input value required to drive 20 milliamps or 5 volts in the field.
AOUT does not clamp the analog output to the range of 819 to 4095.
Example
VAR k : DINT; END_VAR
k := AOUT( 100.0, 100.0, 0.0 ); (* result is 4095 *)
k := AOUT( 100.0, 50.0, 0.0 ); (* result is 2457 *)
k := AOUT( 100.0, 0.0, 0.0 ); (* result is 819 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the
error flags to true, and resets ENO to false. For more information about error flags and runtime
errors, see the CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Triconex (TCXLIB)
Table 20 Input Parameters
Name Data Type Description
MX REAL The value of IN required to drive 20 mA or 5 V in the field.
IN REAL The value to be converted to an analog output.
MN REAL The value of IN required to drive 4 mA or 1 V in the field.
Table 21 Return Value
Data Type Description
DINT The value of IN converted to machine counts.
Condition Return Value Error Flags
If MX is less than or equal to MN. 0 BADPARAM, ERROR
20 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
AOUT_BP12
Converts a real number to a 12-bit differential bipolar analog output.
Syntax
y := AOUT_BP12( MX, IN, MN )
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
where HI= 4095 and LO= -4095.
Table 22 Input Parameters
Name Data Type Description
MX REAL The engineering unit value for the maximum machine count
of +4095.
IN REAL The value to be converted to an analog output.
MN REAL The engineering unit value for the minimum machine count
of -4095.
Table 23 Return Value
Data Type Description
DINT The value of IN converted to machine counts.
IN MN
MX MN
-------------------------- HI LO ( ) LO +
MN
MX
+4095
-4095
Machine
Count
Engineering
Units
AOUT_BP12 21
TriStation 1131 Libraries Reference
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:
VAR y : DINT; in : REAL; END_VAR
y := AOUT_BP12( +60.0, in, -60.0 );
Runtime Errors
None
Application Notes
Can be used in Safety or Control applications.
Library
Triconex (TCXLIB)
4

in y
-60.0 -4095
0.0 0
+60.0 +4095
4. This function was added to the library in v1.32 of TCXLIB, first released with TriStation 1131 v4.3.
22 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
ARRAY32_BOOL
Stores an array of 32 Boolean values.
Syntax
ARRAY32_BOOL(READ:=b1, WRITE:=b2, INDEX:=k, IN:=b3)
Description
The ARRAY32_BOOL function block stores an array of 32 Boolean values. The INDEX input
selects one of the 32 array elements. If WRITE is true, then the data input value IN is copied to
the selected array element. If READ is true, then the value in the selected array element is copied
to OUT.
This table shows the outputs for a combination of inputs.
Table 24 Input Parameters
Name Data Type Description
READ BOOL Enables reading from the selected array element.
WRITE BOOL Enables writing to the selected array element.
INDEX DINT Selects an array element from 1 to 32.
IN BOOL Specifies the value to be used.
Table 25 Output Parameters
Name Data Type Description
CO BOOL The control output.
OUT BOOL The data output.
READ WRITE INDEX CO OUT Notes
True False In-range True Value in the selected
array element
False True In-range True False Writes IN to selected array
element.
True True In-range True Value in the selected
array element
Writes IN to selected array
element.
True
a
a. This symbol ( ) means the true or false value is ignored.
Out-of-range False False Sets BADPARAM, clears ENO.
True Out-of-range False False Sets BADPARAM, clears ENO.
False False False False No operation.
ARRAY32_BOOL 23
TriStation 1131 Libraries Reference
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 *)
Read a value from array element 23
VAR MY_ARRAY : ARRAY32_BOOL; END_VAR;
MY_ARRAY(READ:=TRUE, WRITE:=FALSE, INDEX:=23, IN:=FALSE);
(* Result: MY_ARRAY.CO is TRUE; MY_ARRAY.OUT is TRUE *)
Write then read a value from array element 23
VAR MY_ARRAY : ARRAY32_BOOL; END_VAR;
MY_ARRAY(READ:=TRUE, WRITE:=TRUE, INDEX:=23, IN:=FALSE);
(* Result: MY_ARRAY.CO is TRUE; MY_ARRAY.OUT is FALSE *)
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Internal State: a single instance can be executed more than once per scan. However, you
should be aware of the internal states that are used from one scan to the next.
Library
Triconex (TCXLIB)
Condition Return Value Error Flags
If INDEX is out-of-range (less than 1 or greater than 32). OUT is false BADPARAM, ERROR
24 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
ARRAY32_DINT
Stores an array of 32 integers.
Syntax
ARRAY32_DINT(READ:=b1, WRITE:=b2, INDEX:=k, IN:=b3)
Description
The ARRAY32_DINT function block stores an array of 32 integers. The INDEX input selects one
of the 32 array elements. If WRITE is true, then the data input value IN is copied to the selected
array element. If READ is true, then the value in the selected array element is copied to OUT.
This table shows the outputs for a combination of inputs.
Table 26 Input Parameters
Name Data Type Description
READ BOOL Enables reading from the selected array element.
WRITE BOOL Enables writing to the selected array element.
INDEX DINT Selects an array element from 1 to 32.
IN DINT Specifies the value to be used.
Table 27 Output Parameters
Name Data Type Description
CO BOOL The control output.
OUT DINT The data output.
READ WRITE INDEX CO OUT Notes
True False In-range True Value in the selected
array element
False True In-range True 0 Writes IN to selected array
element.
True True In-range True Value in the selected
array element
Writes IN to selected array
element.
True
a
a. This symbol ( ) means the true or false state is ignored.
Out-of-range False 0 Sets BADPARAM, clears ENO.
True Out-of-range False 0 Sets BADPARAM, clears ENO.
False False False 0 No operation.
ARRAY32_DINT 25
TriStation 1131 Libraries Reference
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 *)
Read a value from array element 23
VAR MY_ARRAY : ARRAY32_DINT; END_VAR;
MY_ARRAY(READ:=TRUE, WRITE:=FALSE, INDEX:=23, IN:=0);
(* Result: MY_ARRAY.CO is TRUE; MY_ARRAY.OUT is 1234 *)
Write then read a value from array element 23
VAR MY_ARRAY : ARRAY32_DINT; END_VAR;
MY_ARRAY(READ:=TRUE, WRITE:=TRUE, INDEX:=23, IN:=5678);
(* Result: MY_ARRAY.CO is TRUE; MY_ARRAY.OUT is 5678 *)
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Internal State: a single instance can be executed more than once per scan. However, you
should be aware of the internal states that are used from one scan to the next.
Library
Triconex (TCXLIB)
Condition Return Value Error Flags
If INDEX is out-of-range (less than 1 or greater than 32). OUT is 0 BADPARAM, ERROR
26 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
ARRAY32_REAL
Stores an array of 32 real numbers.
Syntax
ARRAY32_REAL(READ:=b1, WRITE:=b2, INDEX:=k, IN:=b3)
Description
The ARRAY32_REAL function block stores an array of 32 real numbers. The INDEX input
selects one of the 32 array elements. If WRITE is true, then the data input value IN is copied to
the selected array element. If READ is true, then the value in the selected array element is copied
to OUT.
This table shows the outputs for a combination of inputs.
Table 28 Input Parameters
Name Data Type Description
READ BOOL Enables reading from the selected array element.
WRITE BOOL Enables writing to the selected array element.
INDEX DINT Selects an array element from 1 to 32.
IN REAL Specifies the value to be used.
Table 29 Output Parameters
Name Data Type Description
CO BOOL The control output.
OUT REAL The data output.
READ WRITE INDEX CO OUT Notes
True False In-range True Value in the selected
array element
False True In-range True 0 Writes IN to selected array
element.
True True In-range True Value in the selected
array element
Writes IN to selected array
element.
True
a
a. This symbol ( ) means the true or false state is ignored.
Out-of-range False 0 Sets BADPARAM, clears ENO.
True Out-of-range False 0 Sets BADPARAM, clears ENO.
False False False 0 No operation.
ARRAY32_REAL 27
TriStation 1131 Libraries Reference
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 *)
Read a value from array element 23
VAR MY_ARRAY : ARRAY32_DINT; END_VAR;
MY_ARRAY(READ:=TRUE, WRITE:=FALSE, INDEX:=23, IN:=0);
(* Result: MY_ARRAY.CO is TRUE; MY_ARRAY.OUT is 1234 *)
Write then read a value from array element 23
VAR MY_ARRAY : ARRAY32_DINT; END_VAR;
MY_ARRAY(READ:=TRUE, WRITE:=TRUE, INDEX:=23, IN:=5678);
(* Result: MY_ARRAY.CO is TRUE; MY_ARRAY.OUT is 5678 *)
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Internal State: a single instance can be executed more than once per scan. However, you
should be aware of the internal states that are used from one scan to the next.
Library
Triconex (TCXLIB)
Condition Return Value Error Flag
If INDEX is out-of-range (less than 1 or greater than 32). OUT is 0 BADPARAM, ERROR
28 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
ASIN
Calculates the principal arc sine of a real number.
Syntax
Y := ASIN( x )
Description
The ASIN function calculates the principal arc sine of a real number. The result is in radians
from 1.5708 to +1.5708.
Example
VAR y : REAL; ND VAR
y := ASIN( 1.0 ); (* result is +1.5708 *)
y := ASIN( 1.0 ); (* result is 1.5708 *)
Runtime Errors
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)
Table 30 Input Parameters
Name Data Type Description
x ANY_REAL The real number between 1.0 and 1.0 whose arc sine is to be calculated.
Table 31 Return Value
Data Type Description
ANY_REAL The arc sine of x in radians from 1.5708 to +1.5708.
Condition Return Values Error Flags
If X is not a number or the absolute value of x is greater
than 1.0.
NAN BADPARAM, ERROR
ATAN 29
TriStation 1131 Libraries Reference
ATAN
Calculates the principal arc tangent of a real number.
Syntax
Y := ATAN( x )
Description
The ATAN function calculates the principal arc tangent of a real number. The result is in radians
from 1.5708 to +1.5708.
Example
VAR y : REAL; END_VAR
y := ATAN( 1.0 ); (* result is +0.785398 *)
y := ATAN( 1.0 ); (* result is 0.785398 *)
y := ATAN( 10.0 ); (* result is +1.47113 *)
y := ATAN( 10.0 ); (* result is 1.47113 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the
error flags to true, and resets ENO to false. For more information about error flags and runtime
errors, see the CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
Table 32 Input Parameters
Name Data Type Description
x ANY_REAL Any real number.
Table 33 Return Value
Data Type Description
ANY_REAL The arc tangent of x in radians from 1.5708 to +1.5708.
Condition Return Value Error Flags
If X is not a number. NAN BADPARAM, ERROR
30 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
BLINK
Generates a pulse output.
Syntax
BLINK(IN:=b1, RESET:=b2, T_ON:=t1, T_OFF:=t2)
Description
The BLINK function block generates a pulse output intended to repeatedly turn an indicator on
and off. The IN input enables blinking. The RESET input resets the Q output to false and initiates
the pulse-off period. T_ON specifies how long the pulse is on; T_OFF specifies how long the
pulse is off.
Example
This example blinks an alarm indicator at a rate of 1 second on and 500 milliseconds off.
VAR_OUTPUT INDICATOR : BOOL; END_VAR
VAR BLINK_ALARM : BLINK; END_VAR
BLINK_ALARM(IN:=TRUE,RESET:=FALSE,T_ON:=t#1s,T_OFF:=t#500ms);
INDICATOR := BLINK_ALARM.Q ;
Table 34 Input Parameters
Name Data Type Description
IN BOOL Enables blinking.
RESET BOOL Resets the output Q to false.
T_ON TIME Generates a pulse output on-time in microseconds.
T_OFF TIME Generates a pulse output off-time in microseconds.
Table 35 Output Parameters
Name Data Type Description
Q BOOL The output pulse.
BLINK 31
TriStation 1131 Libraries Reference
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Only Once: each instance should be executed only once per scan, but does not need to
be executed every scan.
Can be used in CEM Cause, Effect, and Intersection cells.
Library
Triconex (TCXLIB)
32 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
BLINK_I
Generates a pulse output.
Syntax
BLINK_I(IN:=b1, RESET:=b2, T_ON:=t1, T_OFF:=t2)
Description
The BLINK_I function block generates a pulse output intended to repeatedly turn an indicator
on and off. The IN input enables blinking. The RESET input resets the Q output to false and
initiates the pulse-off period. T_ON specifies how long the pulse is on; T_OFF specifies how
long the pulse is off.
Example
This example blinks an alarm indicator at a rate of one second on and one-half second off.
VAR_OUTPUT INDICATOR : BOOL; END_VAR
VAR BLINK_ALARM : BLINK_I; END_VAR
BLINK_ALARM(IN:=TRUE,RESET:=FALSE,T_ON:=t#1s,T_OFF:=t#500ms);
INDICATOR := BLINK_ALARM.Q ;
Table 36 Input Parameters
Name Data Type Description
IN BOOL Enables blinking.
RESET BOOL Resets the output Q to false.
T_ON DINT Generates a pulse output on-time in milliseconds.
T_OFF DINT Generates a pulse output off-time in milliseconds.
Table 37 Output Parameters
Name Data Type Description
Q BOOL The output pulse.
BLINK_I 33
TriStation 1131 Libraries Reference
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Exactly Once: each instance should be executed exactly once per scan.
Can be used in CEM Cause, Effect, and Intersection cells.
Library
Triconex (TCXLIB)
34 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
BLINK_R
Generates a pulse output.
Syntax
BLINK_R(IN:=b1, RESET:=b2, T_ON:=t1, T_OFF:=t2)
Description
The BLINK_R function block generates a pulse output intended to repeatedly turn an indicator
on and off. The IN input enables blinking. The RESET input resets the Q output to false and
initiates the pulse-off period. T_ON specifies how long the pulse is on; T_OFF specifies how
long the pulse is off.
Example
This example blinks an alarm indicator at a rate of one second on and one-half second off.
VAR_OUTPUT INDICATOR : BOOL; END_VAR
VAR BLINK_ALARM : BLINK_I; END_VAR
BLINK_ALARM(IN:=TRUE,RESET:=FALSE,T_ON:=t#1s,T_OFF:=t#500ms);
INDICATOR := BLINK_ALARM.Q ;
Table 38 Input Parameters
Name Data Type Description
IN BOOL Enables blinking.
RESET BOOL Resets the output Q to false.
T_ON REAL Generates a pulse output on-time in seconds.
T_OFF REAL Generates a pulse output off-time in seconds.
Table 39 Output Parameters
Name Data Type Description
Q BOOL The output pulse.
BLINK_R 35
TriStation 1131 Libraries Reference
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Exactly Once: each instance should be executed exactly once per scan.
Can be used in CEM Cause, Effect, and Intersection cells.
Library
Triconex (TCXLIB)
36 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
BOOL
A BOOL data type is one bit in length and has two possible values: false (0) or true (1).
Application Notes
Can be used in Safety or Control applications.
Can be used in CEM Cause, Effect, and Intersection cells.
Attribute Description
Keyword/type BOOL
Description Boolean
Size 1 bit
Default value False (0)
Lower limit False (0)
Upper limit True (1)
Result if intermediate value is less than lower limit N/A
Result if upper limit is less than intermediate value Intermediate Value MOD 2
BOOL_TO_DWORD 37
TriStation 1131 Libraries Reference
BOOL_TO_DWORD
Converts a Boolean (BOOL) value to a DWORD value.
Syntax
w := BOOL_TO_DWORD(b);
Description
The BOOL_TO_DWORD function converts a Boolean (BOOL) value to a DWORD value.
Note IEC 1131-3 requires strict data type checking. It does not permit assigning the value of a
variable directly to a variable of a different data type. When it is necessary to use
variables of different data types, an explicit conversion must be made using a data type
conversion function.
Example
VAR b : BOOL; w : DWORD; END_VAR;
b := TRUE;
w := BOOL_TO_DWORD( b ); (* result is 16#0001 *)
b := FALSE;
w := BOOL_TO_DWORD( b ); (* result is 16#0000 *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
Table 40 Input Parameters
Name Data Type Description
b BOOL The Boolean value to be converted.
Table 41 Return Value
Name Data Type Description
DWORD DWORD The value of b converted to a DWORD value.
38 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
CEIL
Returns the next higher integer.
Syntax
y := CEIL( x )
Description
The CEIL function returns the next higher integer greater than or equal to x.
Example
VAR x : REAL END_VAR;
x := ceil(6.04 ); (* result is 7.0 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the
error flags to true, and resets ENO to false. For more information about error flags and runtime
errors, see the CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
Table 42 Input Parameters
Name Data Type Description
x ANY_REAL The operand.
Table 43 Return Value
Data Type Description
ANY_REAL The next higher integer greater than or equal to x.
Condition Return Value Error Flags
If x is not a number. NAN BADPARAM, ERROR
CHK_ERR 39
TriStation 1131 Libraries Reference
CHK_ERR
Checks for runtime errors.
Syntax
CHK_ERR( CI:=TRUE )
Description
The CHK_ERR function block reads the runtime error flags.
When an error is detected while building or compiling a program, the error is considered a build
error or a compile error. When an error is detected while the program is running in an emulator
or controller, the error is considered a runtime error.
There are four mechanisms for detection, reporting, and handling of runtime errors.
1 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.
2 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.
Table 44 Input Parameters
Name Data Type Description
CI BOOL Enables CHK_ERR.
Table 45 Output Parameters
Name Data Type Description
CO BOOL True if CHK_ERR executes successfully.
ERROR BOOL True if any of the following outputs (except UNDERFLOW) are true.
DIVBYZERO BOOL Divide by zero.
OVERFLOW BOOL Floating-point overflow.
UNDERFLOW BOOL Floating-point underflow.
BADPARAM BOOL Bad parameter.
BADCONV BOOL Type conversion error.
STRLEN BOOL String length error.
RANGE BOOL Subrange bound error.
ARRAYERR BOOL Array index error.
INTERNALERR BOOL Internal error.
OTHER BOOL Other error.
40 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
3 A function or operator can reset ENO to false, indicating a runtime error. ENO is the
variable specified by IEC1131-3 for handling errors. In typical usage, a caller sets ENO
to true before calling the function. If the function detects a runtime error, the function
resets ENO to false. After calling the function, the caller tests ENO. For example, the
caller can continue normal operation if ENO is true, or handle the error if ENO is false.
Note that the value of ENO is undefined after calling a function block. See the Runtime
Errors section for a function to determine when the function resets ENO.
4 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
CLR_ERR function block to reset the runtime error flags to false. The runtime error flags
are automatically reset to false at the start of each scan. See the Runtime Errors section
for a function to see which runtime error flags can be set by the function.
This table shows the runtime error flags and the effect on ENO for each runtime error condition.
Note When the ERROR flag is true, it indicates a design flaw in the application that should be
corrected. For example, you should never have a divide by zero error because the
program should check the divisor before doing the division. To find such errors, a good
practice is to add a CHK_ERR function block at the end of the last program and set an
alarm if the ERROR output is true.
Divide by zero is detected by the divide operator / , the MOD operator, the DIV function, and
the MOD function when the divisor is zero.
Floating point overflow is detected by floating point arithmetic when the result is infinity, that
is, when the result is out of range.
Floating point underflow is detected by the exponential operator ** , the EXP function, and the
EXPT 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.
Condition
Runtime error flags,
CHK_ERR outputs
Reset ENO
Divide by zero ERROR, DIVBYZERO Yes
Floating point overflow ERROR, OVERFLOW Yes
Floating point underflow UNDERFLOW No
Bad parameter ERROR, BADPARAM Yes
Type conversion error ERROR, BADCONV Yes
String length error ERROR, STRLEN Yes
Subrange bound error ERROR, RANGE Yes
Array index error ERROR, ARRAYERR Yes
Internal error ERROR, INTERNALERR Yes
Other error ERROR, OTHER Yes
CHK_ERR 41
TriStation 1131 Libraries Reference
A type conversion error is detected by a conversion function ( like REAL_TO_DINT ) when the
converted result is out-of-range.
A string length error is detected when a string is too long, that is, too many characters.
A subrange bound error is detected when a result is out-of-range, that is, not in the specified
subrange. If the subrange data type feature is not implemented, then the RANGE flag is always
false (reserved for future use).
An array index error is detected when an array index is out-of-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 CLR_ERR 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 projects:
(For Tricon) My Documents\Triconex\TriStation 1131 4.x\Projects\Exmodbus.pt2
(For Trident) My Documents\Triconex\TriStation 1131 4.x\Projects\Tdmodbus.pt2
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 ;
42 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
END_IF ;
END_FUNCTION
PROGRAM MY_PROGRAM
VAR
FLAGS : CHK_ERR ;
n : DINT ;
END_VAR
FLAGS() ;
(* FLAGS.ERROR is false and FLAGS.BADPARAM is false. *)
ENO := true ;
IF ENO THEN
n := MY_FUNCTION( 1 ) ;
(* ENO is still true because the parameter was OK. *)
END_IF ;
IF ENO THEN
n := MY_FUNCTION( -1 ) ;
(* ENO is now false because MY_FUNCTION detected a runtime error. *)
END_IF ;
IF ENO THEN
(* The following statement is not executed because ENO is false. *)
n := n + 1 ;
END_IF ;
FLAGS() ;
(* FLAGS.ERROR is true and FLAGS.BADPARAM is true. *)
END_PROGRAM
Runtime Errors
NoneCHK_ERR reads, but does not change, the runtime error flags.
Application Notes
Can be used in Safety or Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, see Using a Space Saver
Function Block on page 5.
Library
Triconex (TCXLIB)
CLR_ERR 43
TriStation 1131 Libraries Reference
CLR_ERR
Clears the runtime errors read by the CHK_ERR function block.
Syntax
CLR_ERR( CI:=TRUE )
Description
The CLR_ERR function block clears the runtime errors read by the CHK_ERR function block.
Example
In this example, the program checks for runtime errors in the middle and end of the program.
CLR_ERR clears the errors after each error check.
PROGRAM CLR_ERR_EXAMPLE
VAR
CHECK_ERRORS : CHK_ERR;
CLEAR_ERRORS : CLR_ERR;
ERRORS_A, ERRORS_B : BOOL;
END_VAR
(* Program code *)
:
CHECK_ERRORS( CI := TRUE );
IF (CHECK_ERRORS.ERROR = TRUE ) THEN ERRORS_A := TRUE; END_IF;
CLEAR_ERRORS( CI := TRUE );
:
(* More program code *)
:
IF (CHECK_ERRORS.ERROR = TRUE ) THEN ERRORS_B := TRUE; END_IF;
CLEAR_ERRORS( CI := TRUE );
END_PROGRAM
Runtime Errors
None.
Table 46 Input Parameters
Name Data Type Description
CI BOOL Enables CHK_ERR.
Table 47 Output Parameters
Name Data Type Description
CO BOOL True if CLR_ERR executes successfully.
44 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Application Notes
Can be used in Safety or Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, see Using a Space Saver
Function Block on page 5.
Library
Triconex (TCXLIB)
CONCAT_DT 45
TriStation 1131 Libraries Reference
CONCAT_DT
Concatenates date and time-of-day values.
Syntax
datetime := CONCAT_DT( d, t )
Description
The CONCAT_DT function concatenates a date with a time of day and returns a date-and-time
value.
Example
VAR d : DATE; t : TOD; datetime : DT; END_VAR
d := D#2002-01-01;
t := TOD#10:32:12;
datetime := CONCAT_DT( d, t ); (*result is DT#2002-01-01-10:32:12*)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the
error flags to true, and resets ENO to false. For more information about error flags and runtime
errors, see the CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
Table 48 Input Parameters
Name Data Type Description
d DATE The date.
t TOD The time of day.
Table 49 Return Value
Data Type Description
DT The concatenation of d and t represented as date and time values.
Conditions Return Values Error Flags
If d or t is out of range. d + t BADPARAM, ERROR
If the result is out of range. Invalid date BADPARAM, ERROR
46 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
COS
Calculates the cosine of an angle.
Syntax
y := COS( x ) ;
Description
The COS function returns the cosine of an angle given in radians. The result is in the range 1 to
1.
Example
VAR y : REAL; END_VAR
y := COS( 3.14159 ); {* result is -1.0 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the
error flags to true, and resets ENO to false. For more information about error flags and runtime
errors, see the CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
Table 50 Input Parameters
Name Data Type Description
x ANY_REAL The angle in radians.
Table 51 Return Value
Data Type Description
ANY_REAL The cosine of x.
Condition Return Value Error Flags
If x is not a number. NAN BADPARAM, ERROR
If the absolute value of x is greater than 2**63 NAN BADPARAM, ERROR
CSCHED 47
TriStation 1131 Libraries Reference
CSCHED
Schedules the execution of selected program logic after a specified number of scans.
Syntax
CSCHED( CI:=b1, NSCANS:=m1, NOFFSET:=m2 )
Description
The CSCHED function block is used to schedule the execution of selected program logic after a
specified number of scans occur. Output Q is true after the specified number of scans occur and
holds true for one scan. By testing the output Q, sections of the control program can execute
periodically. This function block must be invoked exactly once per scan. Otherwise, the scan
count is incorrect.
Example
This example causes selected statements to be executed every 100 scans after the first 500 scans.
VAR EXEC_LOGIC : CSCHED; END_VAR
EXEC_LOGIC(CI := TRUE, NSCANS := 100, NOFFSET := 500 );
IF ( EXEC_LOGIC.Q = TRUE ) THEN
(* execute these statements *)
END_IF
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Exactly Once: each instance should be executed exactly once per scan.
Library
Triconex (TCXLIB)
Table 52 Input Parameters
Name Data Type Description
CI BOOL Enables CSCHED.
NSCANS DINT The number of scans between settings of the Q output.
NOFFSET DINT The number of scans before the Q output is set to true for the first time.
Table 53 Output Parameters
Name Data Type Description
CO BOOL True if CSCHED executes successfully.
Q BOOL True if the specified number of scans occur. Q holds true for one scan, then
returns to false.
ACTUAL TIME The elapsed time from the last setting of the Q output.
48 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
CSCHED_I
Schedules the execution of selected program logic after a specified number of scans.
Syntax
CSCHED_I( CI:=b1, NSCANS:=m1, NOFFSET:=m2 )
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.
Table 54 Input Parameters
Name Data Type Description
CI BOOL Enables CSCHED_I.
NSCANS DINT The number of scans between settings of the Q output.
NOFFSET DINT The number of scans before the Q output is set to true for the first time.
Table 55 Output Parameters
Name Data Type Description
CO BOOL True if CSCHED_I executes successfully.
Q BOOL True if the specified number of scans have occurred. Q holds true for one
scan, then returns to false.
ACTUAL DINT The elapsed time in milliseconds from the last setting of the Q output.
CSCHED_I 49
TriStation 1131 Libraries Reference
Application Notes
Can be used in Safety or Control applications.
Exactly Once: each instance should be executed exactly once per scan.
Library
Triconex (TCXLIB)
50 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
CSCHED_R
Schedules the execution of selected program logic after a specified number of scans.
Description
The CSCHED_R function block is used to schedule the execution of selected program logic after
a specified number of scans occur. Output Q is true after the specified number of scans occur
and holds true for one scan. By testing the output Q, sections of the control program can execute
periodically. This function block must be invoked exactly once per scan. Otherwise, the scan
count is incorrect.
Note CSCHED_R differs from CSCHED in that the ACTUAL elapsed time is represented in
seconds and is a REAL data type.
Example
This example causes selected statements to be executed every 100 scans after the first 500 scans.
VAR EXEC_LOGIC : CSCHED_R; END_VAR
EXEC_LOGIC(CI := TRUE, NSCANS := 100, NOFFSET := 500 );
IF ( EXEC_LOGIC.Q = TRUE ) THEN
(* execute these statements *)
END_IF
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Exactly Once: each instance should be executed exactly once per scan.
Library
Triconex (TCXLIB)
Table 56 Input Parameters
Name Data Type Description
CI BOOL Enables CSCHED_R.
NSCANS DINT The number of scans between settings of the Q output.
NOFFSET DINT The number of scans before the Q output is set to true for the first time.
Table 57 Output Parameters
Name Data Type Description
CO BOOL True if CSCHED_R executes successfully.
Q BOOL True if the specified number of scans occur. Q holds true for one scan, then
returns to false.
ACTUAL REAL The elapsed time in seconds from the last setting of the Q output.
CTD 51
TriStation 1131 Libraries Reference
CTD
Down counter. Signals when a value reaches zero while counting down from a preset value
(PV).
Syntax
CTD( CD:=b1, LD:=b2, PV:=m )
Description
The CTD function block decrements a value and signals when it reaches zero or less. Setting the
LD input to true causes the counter's current value to be initialized by the PV. While the input
CD is true, the CV decrements by one each time CTD is executed. The countdown stops when
CV reaches 32768. Output Q is true when CV is less than or equal to zero.
Example
This example counts down from 500 to zero. When zero is reached, the counter is reset and the
countdown is repeated.
VAR
COUNTDOWN : CTD;
RESET : BOOL := TRUE;
END_VAR;
COUNTDOWN( CD := TRUE, LD := RESET, PV := 500 );
RESET := COUNTDOWN.Q;
Runtime Errors
None.
Table 58 Input Parameters
Name Data Type Description
CD BOOL Enables counting down.
LD BOOL Loads the PV.
PV INT Defines the threshold at which the
countdown begins.
Table 59 Output Parameters
Name Data Type Description
Q BOOL True when CV is less than or equal to zero.
CV INT The current value of the counter.
52 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Application Notes
Can be used in Safety or Control applications.
Only Once: each instance should be executed only once per scan, but does not need to
be executed every scan.
Can be used in CEM Cause and Effect cells.
IEC 1131-3 specifies that the CTD function block counts down the number of rising-
edge triggers detected at the CD input. In the Triconex implementation, the CD input is
not a rising-edge trigger. The countdown progresses as long as the CD input remains
true.
Library
Standard (STDLIB)
CTU 53
TriStation 1131 Libraries Reference
CTU
Up counter. Signals when a count reaches a preset value (PV).
Syntax
CTU( CU:=b1, R:=b2, PV:=m )
Description
The CTU function block increments a value and signals when it reaches the value specified by
the PV input. Setting the R input to true resets the CV to zero. While the input CU is true, the
CV increments by one each time CTU is executed. The count up stops when CV reaches 32,767.
Output Q is true when CV is greater than or equal to PV.
Example
This example counts up from zero to 500. When 500 is reached, the counter is reset and the
count-up from zero is repeated.
VAR
COUNTUP : CTU;
RESET : BOOL := TRUE;
END_VAR;
COUNTUP( CU := TRUE, R := RESET, PV := 500 );
RESET := COUNTUP.Q;
Runtime Errors
None.
Table 60 Input Parameters
Name Data Type Description
CU BOOL Enables counting up.
R BOOL Resets the current value (CV) to zero.
PV INT Defines the threshold at which
output Q changes to True. .
Table 61 Output Parameters
Name Data Type Description
Q BOOL True when CV is greater than or equal to PV.
CV INT The current value of the counter.
54 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Application Notes
Can be used in Safety or Control applications.
Only Once: each instance should be executed only once per scan, but does not need to
be executed every scan.
Can be used in CEM Cause and Effect cells.
IEC 1131-3 specifies that the CTU function block count up the number of rising-edge
triggers detected at the CU input. In the Triconex implementation, the CU input is not a
rising-edge trigger. The count-up progresses as long as the CU input remains true.
Library
Standard (STDLIB)
CTUD 55
TriStation 1131 Libraries Reference
CTUD
Up-down counter. Signals when a count reaches either zero or a preset value (PV).
Syntax
CTUD( CU:=b1, CD:=b2, R:=b3, LD:=b4, PV:=m )
Description
The CTUD function block increments and decrements a value, and signals when it counts down
to zero or counts up to the value specified by the PV input. Setting the R input to true resets the
CV to zero. Setting the LD input to true causes the counter's CV to be initialized by the PV. When
the input CU is true and CD is false, the CV increments by one each time CTU is executed. When
the input CD is true and CU is false, the CV decrements by one each time CTU is executed. The
count up stops when CV reaches 32767; the count down stops when CV reaches 32768. Output
QU is true when CV is greater than or equal to PV. Output QD is true when CV is less than or
equal to zero.
Example
This example counts up from zero to 500. When 500 is reached, the counter counts back down
to zero.
VAR
COUNT : CTUD;
COUNTUP, RESET : BOOL := TRUE;
COUNTDN, BOOL := FALSE;
END_VAR;
COUNT( CU:=COUNTUP, CD:= COUNTDN, R:=RESET, LD:=FALSE, PV:=500 );
RESET := FALSE;
IF ( COUNT.QU = TRUE ) THEN
Table 62 Input Parameters
Name Data Type Description
CU BOOL Enables counting up if CD is false.
CD BOOL Enables counting down if CU is false.
R BOOL Resets the current value (CV) to zero.
LD BOOL Is set to true to load the PV.
PV INT Defines the threshold at which output
QU changes to True. .
Table 63 Output Parameters
Name Data Type Description
QU BOOL True when CV is greater than or equal to PV.
QD BOOL True when CV is less than or equal to zero.
CV INT The current value of the counter.
56 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
COUNTUP := FALSE;
COUNTDN := TRUE;
ELSIF ( COUNT.QD = TRUE ) THEN
COUNTUP := TRUE;
COUNTDN := FALSE;
END_IF
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Only Once: each instance should be executed only once per scan, but does not need to
be executed every scan.
Can be used in CEM Cause and Effect cells.
IEC 1131-3 specifies that the CTUD function block count up the number of rising-edge
triggers detected at the CU input and count down the number of rising-edge triggers
detected at the CD input. In the Triconex implementation, these inputs are not rising-
edge triggers. The CU and CD inputs enable counting up and counting down.
Library
Standard (STDLIB)
DATE 57
TriStation 1131 Libraries Reference
DATE
A DATE data type refers to a specific date expressed as the year, month, and day.
Application Notes
Can be used in Safety or Control applications.
Can be used in CEM Cause, Effect, and Intersection cells.
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
Result if intermediate value is less than lower limit Invalid date
Result if upper limit is less than intermediate value Invalid date
58 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
DINT
A DINT data type is a double integer, 32 bits in length.
Application Notes
Can be used in Safety or Control applications.
Can be used in CEM Cause, Effect, and Intersection cells.
Attribute Description
Keyword/type DINT
Description Double integer
Size 32 bits
Default value 0
Lower limit 2**31
Upper limit 2**311
Result if intermediate value
a
is less than lower limit
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.
2**31 or V modulo 2**32
Result if upper limit is less than intermediate value
a
2**311 or V modulo 2**32
DINT_TO_DWORD 59
TriStation 1131 Libraries Reference
DINT_TO_DWORD
Converts a 32-bit integer to a DWORD value.
Syntax
w := DINT_TO_DWORD(k);
Description
The DINT_TO_DWORD function converts a 32-bit integer to a DWORD value.
Note IEC 1131-3 requires strict data type checking. It does not permit assigning the value of a
variable directly to a variable of a different data type. When it is necessary to use
variables of different data types, an explicit conversion must be made using a data type
conversion function.
Example
VAR k : DINT; w : DWORD; END_VAR;
k := 256;
w := DINT_TO_DWORD( k ); (* result is 16#0100 *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
Table 64 Input Parameters
Name Data Type Description
k DINT The 32-bit integer to be converted.
Table 65 Return Value
Data Type Description
DWORD The value of k converted to a DWORD value.
60 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
DINT_TO_INT
Converts a 32-bit integer to a 16-bit integer.
Syntax
m := DINT_TO_INT(k);
Description
The DINT_TO_INT function converts a 32-bit integer to a 16-bit integer.
Note IEC 1131-3 requires strict data type checking. It does not permit assigning the value of a
variable directly to a variable of a different data type. When it is necessary to use
variables of different data types, an explicit conversion must be made using a data type
conversion function.
Example
VAR k : DINT; m : INT; END_VAR;
k := 1234;
m := DINT_TO_INT( k ); (* result is 1234 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the
error flags to true, and resets ENO to false. For more information about error flags and runtime
errors, see the CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
Table 66 Input Parameters
Name Data Type Description
k DINT The 32-bit integer to be converted.
Table 67 Return Value
Data Type Description
INT The value of k converted to a 16-bit integer.
Condition Return Value Error Flags
If k is less than -32768 32768 BADCONV, ERROR
If k is greater than 32767 +32767 BADCONV, ERROR
DINT_TO_LREAL 61
TriStation 1131 Libraries Reference
DINT_TO_LREAL
Converts a 32-bit integer to a 64-bit long real number.
Syntax
x := DINT_TO_LREAL(k);
Description
The DINT_TO_LREAL function converts a 32-bit integer to a 64-bit long real number.
Note IEC 1131-3 requires strict data type checking. It does not permit assigning the value of a
variable directly to a variable of a different data type. When it is necessary to use
variables of different data types, an explicit conversion must be made using a data type
conversion function.
Example
VAR k : DINT; x : LREAL; END_VAR;
k := 1234;
x := DINT_TO_LREAL( k ); (* result is 1234.0 *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
Table 68 Input Parameters
Name Data Type Description
k DINT The 32-bit integer to be converted.
Table 69 Return Value
Data Type Description
LREAL The value of k converted to a 64-bit long real number.
62 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
DINT_TO_REAL
Converts a 32-bit integer to a 32-bit real number.
Syntax
x := DINT_TO_REAL( k );
Description
The DINT_TO_REAL function converts a 32-bit integer to a 32-bit real number.
Note IEC 1131-3 requires strict data type checking. It does not permit assigning the value of a
variable directly to a variable of a different data type. When it is necessary to use
variables of different data types, an explicit conversion must be made using a data type
conversion function.
Example
VAR k : DINT; x : REAL; END_VAR;
k := 1234;
x := DINT_TO_REAL( k ); (* result is 1234.0 *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
Table 70 Input Parameters
Name Data Type Description
k DINT The 32-bit integer to be converted.
Table 71 Return Value
Data Type Description
REAL The value of k converted to a 32-bit real number.
DIV 63
TriStation 1131 Libraries Reference
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.
Example
Divide Two Numbers
VAR x : DINT; END_VAR
VAR
x = 100 / 10; (* result is 10 *)
Divide a Time by a Number
VAR t : TIME; END_VAR
t : = T#12d12h12m / 12; (* result is T#1d1h1m0s0.0ms *)
Function Block Diagram
Table 72 DIV Operations
Operation
Numerator
Data Type
Denominator
Data Type
Result
Data Type
Divide a number by a number. ANY_NUM
a
a. The numerator, denominator and quotient must the same numerical data type.
ANY_NUM
1
ANY_NUM
Divide a time by a number. TIME ANY_NUM TIME
64 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the
error flags to true, and resets ENO to false. For more information about error flags and runtime
errors, see the CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
Conditions Return Values Error Flags
If the numerator or the denominator is not a number. NAN BADPARAM, ERROR
If the denominator is 0.0 and numerator is negative. INF DIVBYZERO, ERROR
If the denominator is 0.0 and numerator is zero. NAN DIVBYZERO, ERROR
If the denominator is 0.0 and numerator is positive. +INF DIVBYZERO, ERROR
If the integer denominator is zero. 0 DIVBYZERO, ERROR
DT 65
TriStation 1131 Libraries Reference
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.
Application Notes
Can be used in Safety or Control applications.
Can be used in CEM Cause, Effect, and Intersection cells.
Attribute Description
Keyword/type DT
Description Date and time of day
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
Result if intermediate value is less than lower
limit
Invalid date
Result if upper limit is less than intermediate
value
Invalid date
66 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
DT_TO_DATE
Extracts the date from a date and time value.
Syntax
d := DT_TO_DATE(dtm);
Description
The DT_TO_DATE function extracts the date from the date portion of a DT data type value.
Example
VAR d : DATE; END_VAR
d := DT_TO_DATE( DT#2002-02-06-06:28:15 );
(* result is DATE#2002-02-06 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the
error flags to true, and resets ENO to false. For more information about error flags and runtime
errors, see the CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
Table 73 Input Parameters
Name Data Type Description
dtm DT The date and time from which to extract the date.
Table 74 Return Value
Name Data Type Description
OUT DATE The date extracted from dtm.
Condition Return Value Error Flags
If dtm is out of range. Invalid date BADPARAM, ERROR
DT_TO_TOD 67
TriStation 1131 Libraries Reference
DT_TO_TOD
Extracts the time of day from a date and time value.
Syntax
t := DT_TO_TOD(dtm);
Description
The DT_TO_TOD function extracts the time of day portion of a TD data type value.
Example
VAR t: TOD; END_VAR
t := DT_TO_TOD( DT#2002-02-06-06:28:15 );
(* result is TOD#06:28:15 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the
error flags to true, and resets ENO to false. For more information about error flags and runtime
errors, see the CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
Table 75 Input Parameters
Name Data Type Description
dtm DT The date and time from which to extract the time of day.
Table 76 Return Value
Data Type Description
TOD The time of day extracted from dtm.
Condition Return Value Error Flags
If dtm is out of range. Invalid time BADPARAM, ERROR
68 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
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.
Application Notes
Can be used in Safety or Control applications.
Can be used in CEM Cause, Effect, and Intersection cells.
Attribute Description
Keyword/type DWORD
Description Double word
Size 32 bits
Default value 0
Lower limit 0
Upper limit 16#FFFFFFFF
Result if intermediate value is less than lower limit N/A
Result if upper limit is less than intermediate value V and 16#FFFFFFFF
DWORD_TO_BOOL 69
TriStation 1131 Libraries Reference
DWORD_TO_BOOL
Converts a DWORD value to a Boolean (BOOL) value.
Syntax
b := DWORD_TO_BOOL(w)
Description
The DWORD_TO_BOOL function converts a DWORD value to a Boolean (BOOL) value. The
return value equals the value of the least significant bit of the DWORD.
Example
VAR b : BOOL; END_VAR
b := DWORD_TO_BOOL(16#00000001); (* result is TRUE (1) *)
b := DWORD_TO_BOOL(16#00000002); (* result is FALSE (0) *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
Table 77 Input Parameters
Name Data Type Description
IN DWORD The DWORD value to be converted.
Table 78 Return Value
Name Data Type Description
OUT BOOL The value of IN converted to a Boolean value.
70 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
DWORD_TO_DINT
Converts a DWORD value to a DINT value (32-bit signed integer).
Syntax
k := DWORD_TO_DINT(w)
Description
The DWORD_TO_DINT function converts a DWORD value to a DINT value (32-bit signed
integer).
Example
VAR k : DINT; END_VAR
k := DWORD_TO_DINT( 16#000000FF ); (* result is 255 *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
Table 79 Parameter
Name Data Type Description
w DWORD The DWORD value to be converted.
Table 80 Return Value
Data Type Description
DINT The value of w converted to a 32-bit integer.
EQ 71
TriStation 1131 Libraries Reference
EQ
Compares two operands for equality.
Syntax
b := x = y;
Description
The EQ function is used in graphical languages to determine if two operands are equal. In
Structured Text, the = operator is used to determine equality. The result is true if the operands
are equal; otherwise the result is false.
The operands can be any data type, but both operands must be the same data type. For type
REAL or LREAL, if either operand is not a number (NAN), the result is undefined.
Example
Structured Text
VAR b : BOOL; END_VAR
b := 10 = 11; (* result is FALSE *)
b := 11 = 11; (* result is TRUE *)
b := 'abcd' = 'abcd'; (* result is TRUE *)
Function Block Diagram
Runtime Errors
None.
Table 81 Input Parameters
Name Data Type Description
x ANY First operand.
y ANY Second operand.
Table 82 Return Value
Data Type Description
BOOL True if x is equal to y.
72 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Application Notes
Can be used in Safety or Control applications.
Can be used in CEM Cause cells.
Library
Standard (STDLIB)
EXP 73
TriStation 1131 Libraries Reference
EXP
Calculates the natural exponential for a real number.
Syntax
x := EXP(y)
Description
The EXP function calculates the natural exponential for a real number. EXP returns e raised to
the power specified by the real number parameter. The constant e is 2.71828182845904, the base
for natural logarithms.
Example
VAR x : REAL; END_VAR
x := EXP(1.0); (* result is 2.71828 *)
x := EXP(2.0); (* result is 7.38906 *)
x := EXP(3.0); (* result is 20.0855 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the
error flags to true, and resets ENO to false. For more information about error flags and runtime
errors, see the CHK_ERR function block.
Underflow occurs when the result is very close to zero. Since underflow is not an error, an
underflow condition does not set the ERROR flag and does not reset ENO to false.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
Table 83 Input Parameters
Name Data Type Description
y ANY_REAL The operand.
Table 84 Return Value
Data Type Description
ANY_REAL The natural exponential e
y
.
Conditions Return Values Error Flags
If y is not a number. NAN BADPARAM, ERROR
If the result is too large. +INF BADPARAM, ERROR
If the result underflows. 0.0 UNDERFLOW
74 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
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;
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;
Table 85 Input Parameters
Name Data Type Description
CI BOOL Enables smoothing.
RESET BOOL Resets the output to the initial value supplied by IOUTPUT.
INPUT REAL The raw unfiltered input value.
FACTOR REAL The smoothing factor is greater than or equal to 0.0 and less than or equal
to 1.0.
IOUTPUT REAL The initial output value.
Table 86 Output Parameters
Name Data Type Description
CO BOOL True if EXPFLTR executes successfully.
OUTPUT REAL The smoothed output value.
EXPFLTR 75
TriStation 1131 Libraries Reference
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Only Once: each instance should be executed only once per scan, but does not need to
be executed every scan.
Library
Standard (STDLIB)
Conditions Return Values Error Flag
If FACTOR is less than 0.0. CO=false,
OUTPUT=No change
BADPARAM, ERROR
If FACTOR is greater then 1.0. CO=false,
OUTPUT=INPUT
BADPARAM, ERROR
76 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
EXPT
Raises a value to a specified power.
Syntax
z := x ** y;
Description
The EXPT function raises a value to a specified power. EXPT is used in graphical languages to
raise a real value to a power specified by an exponent. In Structured Text, the ** operator is used
for exponentiation.
Both the value to be raised and the return value must be the same data type (REAL or LREAL).
The exponent may be a REAL, LREAL, DINT, or INT data type.
Example
Structured Text
VAR z : REAL; END_VAR
z := 10.0 ** 2; (* result is 100.0 *)
Function Block Diagram
Runtime Errors
Table 87 Input Parameters
Name Data Type Description
x ANY_REAL The value of the variable whose power is to be raised.
y ANY_NUM The exponent.
Table 88 Return Value
Data Type Description
ANY_REAL x to the y power, x
y.
Conditions Return Values Error Flag
If x or y is not a number. NAN BADPARAM, ERROR
If x = 1.#INF and y is not an integer. NAN BADPARAM, ERROR
If x = 1.#INF and y = +1.#INF. NAN BADPARAM, ERROR
EXPT 77
TriStation 1131 Libraries Reference
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)
If y = 1.#INF and x is less than or equal to 1.0 and less
than 0.0.
NAN BADPARAM, ERROR
If y = +1.#INF and x is less than or equal to 1.0. NAN BADPARAM, ERROR
If x is less than 0.0 and y is not an integer. NAN BADPARAM, ERROR
If x = 1.#INF and y is greater than 0.0 and is an odd
integer.
INF None
If x = 1.#INF and y is greater than 0.0 and is an even
integer.
+INF None
If x = +1.#INF and y is greater than 0.0. +INF None
If y = -1.#INF and x is greater than or equal to 0.0 and less
than 1.0.
+INF None
If y = +1.#INF and x is greater than 1.0. +INF None
If x = 0.0 and y is less than 1.0. +INF None
If x = 1.#INF and y is not an integer. 0.0 None
If x = +1.#INF and y is less than 0.0. 0.0 None
If y = 1.#INF and x is less than -1.0. 0.0 None
If x = 1.#INF and x is greater than 1.0. 0.0 None
If y = +1.#INF and x is greater than 1.0 and is less than
1.0.
0.0 None
If the absolute value of x ** y is less than 2.2E-308 0.0 UNDERFLOW
If x = 1.#INF and y = 0.0. 1.0 None
If x = +1.#INF and y = 0.0. 1.0 None
If y = 1.#INF and x = 1.0. 1.0 None
If y = +1.#INF and x = 1.0. 1.0 None
Conditions Return Values Error Flag
78 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
F_TRIG
Triggers on the falling edge of the CLK input.
Syntax
F_TRIG(CLK:=b)
Description
The F_TRIG function block detects a change in state of the CLK input from true to false. When
the change is detected, the Q output is set to true for one function block execution.
Example
This examples maintains a count of the number of times unit power has been lost.
VAR POWER_OK, POWER_FAILED : BOOL; END_VAR
VAR POWER_FAIL_COUNT : DINT; END_VAR
VAR POWER_MONITOR : F_TRIG; END_VAR
POWER_MONITOR( CLK:=POWER_OK );
IF ( POWER_MONITOR.Q = TRUE ) THEN POWER_FAIL_COUNT := POWER_FAIL_COUNT + 1;
END_IF;
Runtime Errors
None.
Table 89 Input Parameters
Name Data Type Description
CLK BOOL The value being monitored.
Table 90 Output Parameters
Data Type Description
BOOL The detector output.
F_TRIG 79
TriStation 1131 Libraries Reference
Application Notes
Can be used in Safety or Control applications.
Only Once: each instance should be executed only once per scan, but does not need to
be executed every scan.
Can be used in CEM Cause, Effect, and Intersection cells.
Library
Standard (STDLIB)
80 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
FLOOR
Truncates a real number to an integer.
Syntax
y := FLOOR( x );
Description
The FLOOR function truncates a real number to the largest integer that is less than or equal to
x. In other words, the function drops the fraction from the number.
Example
VAR y : REAL; END_VAR
y := FLOOR( 23.45986 ); (* result is 23.0 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the
error flags to true, and resets ENO to false. For more information about error flags and runtime
errors, see the CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
Table 91 Input Parameters
Name Data Type Description
x ANY_REAL The operand.
Table 92 Return Value
Data Type Description
ANY_REAL The integer part of x.
Condition Return Value Error Flags
If x is not a number. NAN BADPARAM, ERROR
GASDETR 81
TriStation 1131 Libraries Reference
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 93 Input Parameters
Name Data Type Description
CI BOOL Enables GASDETR.
INPUT DINT The gas detector analog input value.
INHIBIT BOOL Inhibits setting of alarms.
RESET BOOL Resets all alarms.
OPFLIM DINT The gas detector open-circuit fault limit.
SHFLIM DINT The gas detector short-circuit fault limit.
CALBLIM DINT The gas detector calibration limit.
OVRFLIM DINT The gas detector over-range fault limit.
GDMAXAV DINT The gas detector maximum analog input value.
GDMINAV DINT The gas detector minimum analog input value.
GDMAXEU REAL The gas detector maximum engineering value
GDMINEU REAL The gas detector minimum engineering value.
GHIALIM REAL The gas detector high-gas alarm limit.
GLOALIM REAL The gas detector low-gas alarm limit.
Table 94 Output Parameters
Name Data Type Description
CO BOOL True if GASDETR executes successfully.
GDVALUE REAL The gas concentration.
HIALARM BOOL The gas detector high-gas alarm.
LOALARM BOOL The gas detector low-gas alarm.
OPALARM BOOL The gas detector open-circuit fault alarm.
SHALARM BOOL The gas detector short-circuit fault alarm.
CLALARM BOOL The gas detector calibration alarm.
ORALARM BOOL The gas detector over-range alarm.
HISTAT BOOL The gas detector high-gas status.
82 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Description
The GASDETR function block processes analog inputs from a gas detector and generates alarms
by computing the gas concentration GDVALUE in engineering units and the low-gas and high-
gas status of the detector.
GASDETR also monitors the analog inputs and sets these status indicators:
Short-circuit fault
Open-circuit fault
Over-range fault
Detector in calibration
GASDETR generates alarms from the status values. However, alarms can be inhibited by setting
the alarm INHIBIT input, while the status indicators are unaffected by the alarm INHIBIT input.
All alarm outputs are latched after they are set, until reset by the RESET input. The function
packs all the status, alarm, inhibit, and reset bits into the OUTPUT variable.
Parameters include the limits that are used to check for these faults and limits:
Open-circuit faults
Short-circuit faults
Over-range faults
Calibration status
Low-gas alarm limit
High-gas alarm limit
The minimum and maximum analog input and engineering values are also provided so that
GASDETR can convert an analog input into a gas concentration. RESET clears the alarms even
when CI is false. RESET clears the alarms before executing the other operations. If RESET and
CI are both false, no operation occurs.
Runtime Errors
None.
LOSTAT BOOL The gas detector low-gas status.
OPSTAT BOOL The gas detector open-circuit fault status.
SHSTAT BOOL The gas detector short-circuit fault status.
CLSTAT BOOL The gas detector calibration status.
ORSTAT BOOL The gas detector over range status.
OUTPUT DWORD The gas detector status word.
Table 94 Output Parameters (continued)
Name Data Type Description
GASDETR 83
TriStation 1131 Libraries Reference
Application Notes
Can be used in Safety or Control applications.
Only Once: each instance should be executed only once per scan, but does not need to
be executed every scan.
Library
Standard (STDLIB)
84 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
GATDIS
Disables remote writes to aliased variables in a Tricon controller.
Syntax
GATDIS(CI:=b)
Description
In a Tricon controller, the GATDIS function block disables remote writes for all ranges of
read/write aliased variables that were previously enabled by GATENB, thereby restricting
write operations by external hosts. GATDIS must be executed after the GATENB function. For
more information, see GATENB on page 85.
Example
VAR GATE_IS_DISABLED : BOOL ; END_VAR
VAR DISABLED_GATE : GATDIS ; END_VAR
DISABLE_GATE(TRUE);
GATE_IS_DISABLED = GATDIS.CO ;
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Only Once: each instance should be executed only once per scan, but does not need to
be executed every scan.
Library
Tricon (TX1LIB)
Table 95 Input Parameters
Name Data Type Description
CI BOOL Enables GATDIS.
Table 96 Output Parameters
Name Data Type Description
CO BOOL True if GATDIS execute successfully.
GATENB 85
TriStation 1131 Libraries Reference
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,KRW
LAST:=k6
Description
In a Tricon controller, the GATENB function block opens a gate for external-host read/writes to
a specified range of Modbus aliased variables when the controller is operating in RUN mode.
In a safety shutdown application, the keyswitch is typically set to RUN mode for normal
operation. However, this mode does not support Modbus writes from external hosts. To solve
this problem, TriStation 1131 provides gated-access function blocks to programmatically enable
and disable external-host writes to a Tricon controller.
GATENB allows you to specify a range of aliases for each of these data types:
Discrete Read/Write
Integer Read/Write
Real Read/Write
You should use only one GATENB function block in a program. If you do not want to specify
alias ranges for certain data types, leave their starting and ending values at zero (the default).
Table 97 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 The starting alias number for memory real read/write range.
RRWLAST DINT The ending alias number for memory real read/write range.
Table 98 Output Parameters
Name Data Type Description
CO BOOL True if GATENB executes successfully.
86 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
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
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Only Once: each instance should be executed only once per scan, but does not need to
be executed every scan.
Library
Tricon (TX1LIB)
Condition Return Value Error Flags
If a specified alias range is invalid CO=false None
If this is a second function block with the same specified alias range CO=false None
GE 87
TriStation 1131 Libraries Reference
GE
Determines if one operand is greater than or equal to another operand.
Syntax
b := x >= y ;
Description
The GE function is used in graphical languages to determine if one operand is greater than or
equal to another operand. In Structured Text, the >= operator is used. The result is true if one
operand is greater than or equal to another operand; otherwise the result is false.
The operands can be any of these data types:
BOOL
DATE
DINT
DT
DWORD
INT
LREAL
REAL
STRING
TIME
TOD
Both operands must be the same data type. For type REAL or LREAL data types, if either
operand is not a number (NAN), the result is undefined.
Table 99 Input Parameters
Name Data Type Description
x ANY_ NOTE1 First operand.
y ANY_NOTE1 Second operand.
Table 100 Return Value
Data Type Description
BOOL True if x is greater than or equal to y.
88 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Examples
Structured Text
VAR b : BOOL; END_VAR
b := 10 >= 11; (* result is FALSE *)
b := 11 >= 11; (* result is TRUE *)
b := 11 >= 10; (* result is TRUE *)
b := 'abce' >= 'abcd'; (* result is TRUE *)
Function Block Diagram
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Can be used in CEM Cause cells.
Library
Standard (STDLIB)
GetDelta_DINT 89
TriStation 1131 Libraries Reference
GetDelta_DINT
Returns the scan period for the previous scan in milliseconds.
Syntax
t := GetDelta_DINT()
Description
The GetDelta_DINT function returns the scan period for the previous scan in milliseconds. The
scan period is measured from the start of the previous scan to the start of the current scan.
GetDelta_DINT can only be used in Structured Text programs because it has no input
parameters, which are required in FBD, LD, and CEMPLE programs.
GetDelta_DINT does not comply with the statement in IEC 1131-3 that invocation of a
function with the same arguments (input parameters) shall always yield the same value
(output). GetDelta_DINT yields the same value for every invocation within one scan, but
yields different values for different scans.
Example
VAR t : DINT ; END_VAR
t := GetDelta_DINT();
(* Result is 100 if the measured scan period is 100 milliseconds. *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Triconex (TCXLIB)
Table 101 Input Parameters
Name Data Type Description
None None None.
Table 102 Return Value
Data Type Description
DINT The scan period for the previous scan in milliseconds.
90 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
GetDelta_REAL
Returns the scan period for the previous scan in seconds.
Syntax
t := GetDelta_REAL()
Description
The GetDelta_REAL function returns the scan period for the previous scan in seconds. The scan
period is measured from the start of the previous scan to the start of the current scan.
GetDelta_REAL can only be used in Structured Text programs because it has no input
parameters, which are required in FBD, LD, and CEMPLE programs.
GetDelta_REAL does not comply with the statement in IEC 1131-3 that invocation of a
function with the same arguments (input parameters) shall always yield the same value
(output). GetDelta_REAL yields the same value for every invocation within one scan, but
yields different values for different scans.
Example
VAR t : REAL ; END_VAR
t := GetDelta_REAL();
(* Result is 0.1 if the measured scan period is 100 milliseconds. *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Triconex (TCXLIB)
Table 103 Input Parameters
Name Data Type Description
None None None.
Table 104 Return Value
Data Type Description
REAL The scan period for the previous scan in seconds.
GetDeltaT 91
TriStation 1131 Libraries Reference
GetDeltaT
Returns the scan period for the previous scan.
Syntax
t := GetDeltaT()
Description
The GetDeltaT function returns the scan period for the previous scan. The scan period is
measured from the start of the previous scan to the start of the current scan. GetDeltaT can only
be used in Structured Text programs because it has no input parameters, which are required in
FBD, LD, and CEMPLE programs.
GetDeltaT does not comply with the statement in IEC 1131-3 that invocation of a function
with the same arguments (input parameters) shall always yield the same value (output).
GetDeltaT yields the same value for every invocation within one scan, but yields different
values for different scans.
Example
VAR t : TIME ; END_VAR
t := GetDeltaT();
(* Result is T#100ms if the measured scan period is 100 milliseconds. *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Triconex (TCXLIB)
Table 105 Input Parameters
Name Data Type Description
None None None.
Table 106 Return Value
Data Type Description
DINT The scan period for the previous scan.
92 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
GetTimer
Returns a date and time value that can be used to calculate the elapsed time between two events.
Syntax
dt := GetTimer()
Description
The GetTimer function returns a date and time value that can be used in conjunction with a
previously returned date and time value to calculate an elapsed time. GetTimer can only be
used in Structured Text programs because it has no input parameters, which are required in
FBD, LD, and CEM programs.
The GetTimer function does not comply with the statement in IEC 61131-3 that: invocation
of a function with the same arguments (input parameters) shall always yield the same value
(output). The GetTimer function yields the same value for every invocation within one scan,
but yields different values on different scans. The return value always increases from one scan
to the next.
Example
This example calculates the time between two events: Event1 and Event2.
VAR
Event1, Event2 : BOOL;
T1, T2 : DT;
ElapsedTime : TIME;
END_VAR
IF Event1 then
T1 := GetTimer();
END_IF;
IF Event2 then
T2 := GetTimer();
ElapsedTime := T2 - T1;
END_IF;
Runtime Errors
None.
Table 107 Input Parameters
Name Data Type Description
None None None.
Table 108 Return Value
Data Type Description
DT The date and time.
GetTimer 93
TriStation 1131 Libraries Reference
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
94 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
GT
Determines if two operands have a greater-than-or-equal-to relationship.
Syntax
b := x > y;
Description
The GT function is used in graphical languages to determine if two operands have a greater-
than-or-equal-to relationship. In Structured Text, the >= operator is used. The result is true if the
operands have a greater-than-or-equal-to relationship; otherwise the result is false.
The operands can be any of these data types:
BOOL
DATE
DINT
DT
DWORD
INT
LREAL
REAL
STRING
TIME
TOD
Both operands must be the same data type. For type REAL or LREAL data types, if either
operand is not a number (NAN), the result is undefined.
Table 109 Input Parameters
Name Data Type Description
x ANY_ NOTE1 First operand.
y ANY_ NOTE1 Second operand.
Table 110 Return Value
Data Type Description
BOOL True if x is greater than y.
GT 95
TriStation 1131 Libraries Reference
Example
Structured Text
VAR b : BOOL; END_VAR
b := 10 >= 11; (* result is FALSE *)
b := 11 >= 10; (* result is TRUE *)
b := 'abce' >= 'abcd'; (* result is TRUE *)
Function Block Diagram
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
96 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
INFINITY_LREAL
Returns plus infinity.
Syntax
y := INFINITY_LREAL();
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)
Table 111 Input Parameters
Name Data Type Description
NA NA No inputs.
Table 112 Return Value
Data Type Description
LREAL Plus infinity.
INFINITY_REAL 97
TriStation 1131 Libraries Reference
INFINITY_REAL
Returns plus infinity.
Syntax
y := INFINITY_REAL();
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)
Table 113 Input Parameters
Name Data Type Description
NA NA No inputs.
Table 114 Return Value
Data Type Description
REAL Plus infinity.
98 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
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.
Application Notes
Can be used in Safety or Control applications.
Can be used in CEM Cause, Effect, and Intersection cells.
Attribute Description
Keyword/type INT
Description Integer
Size 32 bits
Default value 0
Lower limit 2**15
Upper limit 2**151
Result if intermediate value is less than lower limit InvINT
Result if upper limit is less than intermediate value InvINT
INT_TO_DINT 99
TriStation 1131 Libraries Reference
INT_TO_DINT
Converts a 16-bit integer to a 32-bit integer.
Syntax
m := INT_TO_DINT(k);
Description
The INT_TO_DINT function converts a 16-bit integer to a 32-bit integer.
Note IEC 1131-3 requires strict data type checking. It does not permit assigning the value of a
variable directly to a variable of a different data type. When it is necessary to use
variables of different data types, an explicit conversion must be made using a data type
conversion function.
Example
VAR k : INT; m : DINT; END_VAR;
k := 1234;
m := INT_TO_DINT( k ); (* result is 1234 *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
Table 115 Input Parameters
Name Data Type Description
k INT The 16-bit integer to be converted.
Table 116 Return Value
Data Type Description
DINT The value of k converted to a 32-bit integer.
100 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
INT_TO_LREAL
Converts a 16-bit integer to a 64-bit long real number.
Syntax
x := INT_TO_LREAL(k);
Description
The INT_TO_LREAL function converts a 16-bit integer to a 64-bit long real number.
Note IEC 1131-3 requires strict data type checking. It does not permit assigning the value of a
variable directly to a variable of a different data type. When it is necessary to use
variables of different data types, an explicit conversion must be made using a data type
conversion function.
Example
VAR k : INT; x : LREAL; END_VAR;
k := 1234;
x := INT_TO_LREAL( k ); (* result is 1234.0 *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
Table 117 Input Parameters
Name Data Type Description
k INT The 16-bit integer to be converted.
Table 118 Return Value
Data Type Description
LREAL The value of k converted to a 64-bit long real number.
INT_TO_REAL 101
TriStation 1131 Libraries Reference
INT_TO_REAL
Converts a 16-bit integer to a 32-bit real number.
Syntax
x := INT_TO_REAL(k);
Description
The INT_TO_REAL function converts a 16-bit integer to a 32-bit real number.
Note IEC 1131-3 requires strict data type checking. It does not permit assigning the value of a
variable directly to a variable of a different data type. When it is necessary to use
variables of different data types, an explicit conversion must be made using a data type
conversion function.
Example
VAR k : INT; x : REAL; END_VAR;
k := 1234;
x := INT_TO_REAL( k ); (* result is 1234.0 *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
Table 119 Input Parameters
Name Data Type Description
k INT The 16-bit integer to be converted.
Table 120 Return Value
Data Type Description
REAL The value of k converted to a 32-bit real number.
102 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
INTGTOR
Integrates the INPUT parameter, ignoring noise-level values less than or equal to MINLVL.
Syntax
MY_INTGTOR(CI:=b1, RESET:=b2, INPUT:=x1, MINLVL:=x2, GAIN:=x3, DELTAT :=
GetDeltaT(), IOUTPUT:=x4 );
y := MY_INTGTOR.OUTPUT ;
Description
The INTGTOR function block integrates the INPUT parameter, ignoring noise-level values less
than or equal to MINLVL. The result is OUTPUT.
CI is the control input. CI enables evaluation. If CI is false, then the integration step is not
executed. See DELTAT herein for suggested scheduling alternatives. The default initial value of
CI is true.
RESET initializes OUTPUT to the value of argument IOUTPUT. The default initial value is 0.0.
If RESET and CI are both false, no operation occurs.
INPUT is the input value to be integrated.
MINLVL is a lower limit for the input value. If the input value is below this lower limit, then the
integration step is skipped and the result OUTPUT does not change. The default lower limit is
zero.
GAIN is a gain factor. The input value is multiplied by the gain factor.
DELTAT is the time between executions. To schedule execution using a CSCHED or TSCHED
function block, connect the DELTAT input to the ACTUAL output of the CSCHED or TSCHED
function block, and connect the CI input to the Q output of the CSCHED or TSCHED function
Table 121 Input Parameters
Name Data Type Description
CI BOOL Enables INTGTOR.
RESET BOOL Copies IOUTPUT to OUTPUT.
INPUT REAL The input value.
MINLVL REAL Excludes inputs below this level from integration.
GAIN REAL The gain factor.
DELTAT TIME The time between INTGTOR executions.
IOUTPUT REAL The initial output value.
Table 122 Output Parameters
Name Data Type Description
CO BOOL True if INTGTOR executes successfully.
OUTPUT REAL The integrated output value.
INTGTOR 103
TriStation 1131 Libraries Reference
block. To schedule execution every scan, connect the DELTAT input to the ouput of a GetDeltaT
function, and set CI=true.
IOUTPUT is an optional initial output value. If the RESET input is true, then the function block
copies IOUTPUT to OUTPUT. The default initial value is zero.
CO is the control ouput. CO follows CI. CO=true indicates that evaluation was enabled.
OUTPUT is the result, the integral of the input value. The result unit is the input unit multiplied
by seconds and multiplied by the gain factor. The equation for the integration step is:
OUTPUT := OUTPUT + GAIN * INPUT * TIME_TO_SECS_REAL(DELTAT) ;
Example
VAR MY_INTGTOR : INTGTOR ; END_VAR
VAR y : REAL ; END_VAR
MY_INTGTOR( INPUT:=1.0, GAIN:=1.0, DELTAT := GetDeltaT() ) ;
y := MY_INTGTOR.OUTPUT; (* if the scan period is always 0.16 seconds, then the
result for the first 3 scans is 0.16, 0.32, 0.48 *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Only Once: each instance should be executed only once per scan, but does not need to
be executed every scan.
Library
Triconex (TCXLIB)
104 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
INTGTOR_R
Integrates the INPUT parameter, ignoring noise-level values less than or equal to MINLVL.
Syntax
MY_INTGTOR(CI:=b1, RESET:=b2, INPUT:=x1, MINLVL:=x2, GAIN:=x3, IOUTPUT:=x4 );
y := MY_INTGTOR.OUTPUT ;
Description
The INTGTOR_R function block integrates the INPUT parameter, ignoring noise-level values
less than or equal to MINLVL. The result is OUTPUT.
INTGTOR_R is smaller and faster than INTGTOR, but does not provide the scheduling
alternatives of INTGTOR, which means INTGTOR_R must be executed and enabled every scan.
CI is the control input. CI enables evaluation. If CI is false, then the integration step is not
executed. The default initial value of CI is true.
RESET initializes OUTPUT to the value of argument IOUTPUT. The default initial value is 0.0.
If RESET and CI are both false, no operation occurs.
INPUT is the input value to be integrated.
MINLVL is a lower limit for the input value. If the input value is below this lower limit, then the
integration step is skipped and the result OUTPUT does not change. The default lower limit is
zero.
GAIN is a gain factor. The input value is multiplied by the gain factor.
IOUTPUT is an optional initial output value. If the RESET input is true, then the function block
copies IOUTPUT to OUTPUT. The default initial value is zero.
CO is the control ouput. CO follows CI. CO=true indicates that evaluation was enabled.
Table 123 Input Parameters
Name Data Type Description
CI BOOL Enables INTGTOR_R.
RESET BOOL Copies IOUTPUT to OUTPUT.
INPUT REAL The input value.
MINLVL REAL Excludes inputs below this level from integration.
GAIN REAL The gain factor.
IOUTPUT REAL The initial output value.
Table 124 Output Parameters
Name Data Type Description
CO BOOL True if INTGTOR_R executes successfully.
OUTPUT REAL Integrated output value.
INTGTOR_R 105
TriStation 1131 Libraries Reference
OUTPUT is the result, the integral of the input value. The result unit is the input unit multiplied
by seconds and multiplied by the gain factor. The equation for the integration step is:
OUTPUT := OUTPUT + GAIN * INPUT * GetDelta_REAL() ;
Example
VAR MY_INTGTOR : INTGTOR_R ; END_VAR
VAR y : REAL ; END_VAR
MY_INTGTOR( INPUT:=1.0, GAIN:=1.0 ) ;
y := MY_INTGTOR.OUTPUT; (* if the scan period is always 0.16 seconds, then the
result for the first 3 scans is 0.16, 0.32, 0.48 *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Exactly Once: each instance should be executed exactly once per scan.
Library
Triconex (TCXLIB)
106 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
IsFinite_LREAL
Returns true if a number is finite.
Syntax
b := IsFinite_LREAL( x );
Description
The IsFinite_LREAL function returns true if input x is a finite number; false if x is plus infinity,
minus infinity, or not a number (NAN).
Example
VAR x : LREAL ; b : BOOL ; END_VAR;
x := 0.0 ;
b := IsFinite_LREAL( x ); (* result is true *)
x := 1.0 / x ;
b := IsFinite_LREAL( x ); (* result is false *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
Table 125 Input Parameters
Name Data Type Description
x LREAL A number
Table 126 Return Value
Data Type Description
BOOL True if x is finite.
IsFinite_REAL 107
TriStation 1131 Libraries Reference
IsFinite_REAL
Returns true if a number is finite.
Syntax
b := IsFinite_REAL( x );
Description
The IsFinite_REAL function returns true if input x is a finite number; false if x is plus infinity,
minus infinity, or not a number (NAN).
Example
VAR x : REAL ; b : BOOL ; END_VAR;
x := 0.0 ;
b := IsFinite_REAL( x ); (* result is true *)
x := 1.0 / x ;
b := IsFinite_REAL( x ); (* result is false *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
Table 127 Input Parameters
Name Data Type Description
x REAL A number
Table 128 Return Value
Data Type Description
BOOL True if x is finite.
108 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
IsNan_LREAL
Returns true if the operand is not a number (NAN).
Syntax
b := IsNan_LREAL( x );
Description
The IsNan_LREAL function returns true if input x is a not a number (NAN); false if x is a finite
number, plus infinity, or minus infinity.
Example
VAR x : LREAL ; b : BOOL ; END_VAR;
x := 0.0 ;
b := IsNan_LREAL( x ); (* result is false *)
x := SQRT(-1.0) ;
b := IsNan_LREAL( x ); (* result is true *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
Table 129 Input Parameters
Name Data Type Description
x LREAL The operand
Table 130 Return Value
Data Type Description
BOOL True if x is not a number (NAN).
IsNan_REAL 109
TriStation 1131 Libraries Reference
IsNan_REAL
Returns true if the operand is not a number (NAN).
Syntax
b := IsNan_REAL( x );
Description
The IsNan_REAL function returns true if input x is a not a number (NAN); false if x is a finite
number, plus infinity, or minus infinity.
Example
VAR x : REAL ; b : BOOL ; END_VAR;
x := 0.0 ;
b := IsNan_REAL( x ); (* result is false *)
x := SQRT(-1.0) ;
b := IsNan_REAL( x ); (* result is true *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
Table 131 Input Parameters
Name Data Type Description
x REAL The operand
Table 132 Return Value
Data Type Description
BOOL True if x is not a number (NAN).
110 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
LE
Determines if one operand is less than or equal to another operand.
Syntax
b := x <= y ;
Description
The LE function is used in graphical languages to determine if one operand is greater than or
equal to another operand. In Structured Text, the <= operator is used. The result is true if one
operand is less than or equal to another operand; otherwise the result is false.
The operands can be any of these data types:
BOOL
DATE
DINT
DT
DWORD
INT
LREAL
REAL
STRING
TIME
TOD
Both operands must be the same data type. For type REAL or LREAL data types, if either
operand is not a number (NAN), the result is undefined.
Table 133 Input Parameters
Name Data Type Description
x ANY_ NOTE1 First operand.
y ANY_ NOTE1 Second operand.
Table 134 Return Value
Data Type Description
BOOL True if x is less than or equal to y.
LE 111
TriStation 1131 Libraries Reference
Example
Structured Text
VAR b : BOOL; END_VAR
b := 10 <= 11; (* result is TRUE *)
b := 11 <= 11; (* result is TRUE *)
b := 11 <= 10; (* result is FALSE *)
b := 'abce' <= 'abcd'; (* result is FALSE *)
Function Block Diagram
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Can be used in CEM Cause cells.
Library
Standard (STDLIB)
112 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
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 ;
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.
Table 135 Input Parameters
Name Data Type Description
CI BOOL Enables LEADLAG.
IN REAL The input value.
GAIN REAL The gain factor applied to input.
TAU1 REAL The lead time constant in seconds.
TAU2 REAL The lag time constant in seconds.
AUTO_MAN BOOL Controls auto/manual status of LEADLAG (auto =1, manual = 0).
DELTAT TIME The time between LEADLAG evaluations.
Table 136 Output Parameters
Name Data Type Description
CO BOOL True if LEADLAG executes successfully.
OUT REAL The output value.
LEADLAG 113
TriStation 1131 Libraries Reference
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 ;
If AUTO_MAN=1 then the equation for the output is:
OUT := (GAIN * (T1 * (IN - OLDX) + IN)
+ (T2 * OUT)) / (T2 + REAL#1.0) ;
where:
T1 is TAU1/DLT
T2 is TAU2/DLT
DLT is DELTAT converted to seconds
OLDX is the previous value of the input
Runtime Errors
None.
Application Notes
Can be used in Control applications.
Only Once: each instance should be executed only once per scan, but does not need to
be executed every scan.
Library
Triconex (TCXLIB)
114 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
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 ;
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
Table 137 Input Parameters
Name Data Type Description
CI BOOL Enables LEADLAG_R.
IN REAL The input value.
GAIN REAL The gain factor applied to input.
TAU1 REAL The lead time constant in seconds.
TAU2 REAL The lag time constant in seconds.
AUTO_MAN BOOL Controls auto/manual status of LEADLAG_R (auto =1, manual = 0).
Table 138 Output Parameters
Name Data Type Description
CO BOOL True if LEADLAG_R executes successfully.
OUT REAL The output value.
LEADLAG_R 115
TriStation 1131 Libraries Reference
of input value, previous input value, previous output value, gain, lead time constant, lag time
constant, and time between evaluations.
CO is the control ouput. CO follows CI. CO=true indicates that evaluation was enabled.
OUT is the result. The result unit is the input unit multiplied by the gain factor.
If AUTO_MAN=0 then the equation for the output is:
OUT := GAIN * IN ;
If AUTO_MAN=1 then the equation for the output is:
OUT := (GAIN * (T1 * (IN - OLDX) + IN)
+ (T2 * OUT)) / (T2 + REAL#1.0) ;
where:
T1 is TAU1/DLT
T2 is TAU2/DLT
DLT is DELTAT converted to seconds
OLDX is the previous value of the input
Runtime Errors
None.
Application Notes
Can be used in Control applications only.
Only Once: each instance should be executed only once per scan, but does not need to
be executed every scan.
Library
Triconex (TCXLIB)
116 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
LIMIT
Returns a value between a minimum limit and a maximum limit.
Syntax
y := LIMIT( low, x, high ) ;
Description
The LIMIT function returns a value between a minimum limit and a maximum limit.
If the input value is between the minimum limit and the maximum limit, then the return value
equals the input value. If the input value is less than or equal to the minimum limit, then the
return value equals the minimum limit. If the input value is greater than or equal to the
maximum limit, then the return value equals the maximum limit.
The LIMIT function can be used with these data types:
BOOL
DATE
DINT
DT
DWORD
INT
LREAL
REAL
TIME
TOD
All operands must be the same data type as the data type for the return value. For data type
REAL or LREAL, if any operand is not a number (NAN), the result is NAN.
Note STRING data types are not supported for this function.
Table 139 Input Parameters
Name Data Type Description
MN ANY_ NOTE1 The minimum limit.
IN ANY_NOTE1 The input value.
MX ANY_NOTE1 The maximum limit.
Table 140 Return Value
Data Type Description
ANY_NOTE1 The output value.
LIMIT 117
TriStation 1131 Libraries Reference
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)
118 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
LINEMNTR
Monitors an analog current loop.
Syntax
MY_LINEMNTR_R(CI:=b1, INPUT:=n1, LNOPLIM:=n2, LNSHLIM:=n3, LMONLIM:=n4 ) ;
IS_ON := MY_LINEMNTR_R.OUTPUT ;
IS_SHORTED := MY_LINEMNTR_R.LNSHORT ;
IS_OPEN := MY_LINEMNTR_R.LNOPEN ;
Description
The LINEMNTR function block monitors an input from an analog current loop.
First, the function block compares the analog input value with the open-circuit fault limit. If the
analog input value is less than or equal to the open-circuit fault limit, then there is not enough
current flowing in the current loop, which means there is an open circuit fault, and the function
block sets ouput LNOPEN=true.
If there is no open-circuit fault, then the function block compares the analog input value with
the short-circuit fault limit. If the analog input value is greater than or equal to the short-circuit
fault limit, then there is too much current flowing in the current loop, which means there is a
short circuit fault, and the function block sets output LNSHORT=true.
If there is neither an open-circuit fault nor a short-circuit fault, then the function block compares
the analog input value with the "contact input on" limit which is a current threshold that
distinguishes data 0 from data 1. If the analog input value is greater than or equal to the "contact
input on" limit, then the function block sets OUTPUT=1; otherwise, OUTPUT=0.
CI is the control input. CI enables evaluation. If CI is false, then there is no operation. The default
initial value of CI is true.
Table 141 Input Parameters
Name Data Type Description
CI BOOL Enables LINEMNTR.
INPUT DINT The analog input value.
LNOPLIM DINT The open-circuit fault limit.
LNSHLIM DINT The short-circuit fault limit.
LMONLIM DINT The contact input on limit.
Table 142 Output Parameters
Name Data Type Description
CO BOOL Control out.
OUTPUT BOOL The contact input status.
LNSHORT BOOL The short-circuit fault status.
LNOPEN BOOL The open-circuit fault status.
LINEMNTR 119
TriStation 1131 Libraries Reference
INPUT is an analog input value that represents (for example, is proportional to) the monitored
current.
LNOPLIM is the open-circuit fault limit. The circuit is open if INPUT is less than or equal to
LNOPLIM.
LNSHLIM is the short-circuit fault limit. The circuit is shorted if INPUT is greater than or equal
to LNSHLIM.
LMONLIM is a threshold. The circuit is On, that is, OUTPUT=1, if there are no faults and INPUT
is greater than or equal to LMONLIM.
CO is the control ouput. CO follows CI. CO=true indicates that evaluation was enabled.
OUTPUT indicates whether the circuit is On. If there is no open-circuit and no short-circuit and
INPUT is greater than or equal to the threshold LMONLIM, then OUTPUT=1, indicating that
the circuit is On. If INPUT is less than the threshold LMONLIM or if there is an open-circuit or
short-circuit, then OUPUT=0.
LNSHORT indicates a short-circuit fault. LNSHORT=true if INPUT is greater than or equal to
LNSHLIM and there is no open-circuit fault.
LNOPEN indicates an open-circuit fault. LNOPEN=true if INPUT is less than or equal to
LNOPLIM.
Example
VAR MY_LINEMNTR : LINEMNTR ; END_VAR
VAR IS_ON, IS_SHORTED, IS_OPEN : BOOL ; END_VAR
MY_LINEMNTR
(
LNOPLIM:=819,
LMONLIM:=2000,
LNSHLIM:=4000,
INPUT:=4010
);
IS_OPEN := MY_LINEMNTR.LNOPEN; (* result is false *)
IS_SHORTED := MY_LINEMNTR.LNSHORT; (* result is true *)
IS_ON := MY_LINEMNTR.LNSHORT; (* result is false *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, see Using a Space Saver
Function Block on page 5.
Library
Triconex (TCXLIB)
120 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
LN
Calculates the natural logarithm of a real number.
Syntax
y := LN( x );
Description
The LN function calculates the natural logarithm of a real number.
Example
VAR y : REAL; END_VAR
y := LN( 1.0 ); (* result is 0.0 *)
y := LN( 2.718282 ); (* result is 1.0 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the
error flags to true, and resets ENO to false. For more information about error flags and runtime
errors, see the CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
Table 143 Input Parameters
Name Data Type Description
x ANY_REAL A real number.
Table 144 Return Value
Data Type Description
ANY_REAL The natural logarithm of x.
Conditions Return Values Error Flags
If x is not a number. NAN BADPARAM, ERROR
If x is negative or zero. NAN BADPARAM, ERROR
LOG 121
TriStation 1131 Libraries Reference
LOG
Calculates the common (base-ten) logarithm of a real number.
Syntax
y := LOG( x );
Description
The LOG function calculates the common (base-ten) logarithm of a real number.
Example
VAR y : REAL; END_VAR
y := LOG( 1.0 ); (* result is 0.0 *)
y := LOG( 10.0 ); (* result is 1.0 *)
y := LOG( 100.0 ); (* result is 2.0 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the
error flags to true, and resets ENO to false. For more information about error flags and runtime
errors, see the CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
Table 145 Input Parameters
Name Data Type Description
x ANY_REAL A real number.
Table 146 Return Value
Data Type Description
ANY_REAL The common logarithm of x.
Conditions Return Values Error Flags
If x is not a number. NAN BADPARAM, ERROR
If x is negative or zero. NAN BADPARAM, ERROR
122 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
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 147 Input Parameters
Name Data Type Description
CI BOOL Enables LOOPDETR.
INPUT DINT The loop detector analog input value.
INHIBIT BOOL The inhibit loop detector alarms.
RSTIN BOOL The loop detector reset input.
OPFLIM DINT The loop detector open-circuit fault limit.
SHFLIM DINT The loop detector short-circuit fault limit.
TRALIM DINT The loop detector trip limit.
HITRIP BOOL The loop high trip alarm flag (high = 1, low = 0).
RSTTIME TIME The loop detector reset time.
DELTAT TIME The time between LOOPDETR evaluations.
Table 148 Output Parameters
Name Data Type Description
CO BOOL True if LOOPDETR executes successfully.
TRALARM BOOL The loop detector trip alarm.
OPALARM BOOL The loop detector open-circuit fault alarm.
SHALARM BOOL The loop detector short-circuit fault alarm.
RSTOUT BOOL The loop detector reset output.
TRSTAT BOOL The loop detector trip status
OPSTAT BOOL The loop detector open-circuit fault status
SHSTAT BOOL The loop detector short-circuit fault status.
RSTCNTR TIME The loop detector reset counter.
OUTPUT BOOL The loop detector status.
LOOPDETR 123
TriStation 1131 Libraries Reference
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 GetDeltaT()
function.
Note To schedule execution using a CSCHED or TSCHED function block, connect the
DELTAT input to the ACTUAL output of a CSCHED or TSCHED function block.
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Only Once: each instance should be executed only once per scan, but does not need to
be executed every scan.
Library
Triconex (TCXLIB)
124 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
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.
Gradual Underflow for LREAL Data Types
In PCs and controllers, the floating-point implementation includes a standard feature called
gradual underflow that extends the range for an LREAL number and gradually changes the
precision as values approach zero.
This table compares the values obtained when gradual underflow is not present, to the values
obtained when it is present.
Attribute Description
Keyword/type LREAL
Description Long-real number
Size 64 bits
Default value 0.0
Most positive number 1.7976931348623158 e +308
Least positive number 4.9406564584124654 e 324
Least negative number 4.9406564584124654 e 324
Most negative number 1.7976931348623158 e +308
Result if intermediate value is less than lower limit Infinity or HUGE
Result if upper limit is less than intermediate value +Infinity or HUGE
Without Gradual Underflow With Gradual Underflow
The smallest positive number that can be
stored in an LREAL variable is:
2
1022
= 2.2250738585072014E308.
The smallest positive number that can be stored in
an LREAL variable is:
2
1074
= 4.9406564584124654E324.
The precision changes abruptly from 17 digits
to 0 digits when the value changes from a
number greater than 2
1023
to a number less
than 2
1023
.
The precision changes gradually from 17 digits to 1
digit as the value changes from
2
1023
to 2
1074
.
The maximum relative error changes abruptly
from 2
53
to 1 when the value changes from a
number greater than 2
1023
to a number less
than 2
1023
.
The maximum relative error changes gradually from
2
53
to 1 as the value changes from 2
1023
to 2
1074
.
For values from 2
1075
to 2
1022
, the maximum
absolute error equals the value.
For values from 2
1075
to 2
1022
, the maximum
absolute error is a constant 2
1075
.
LREAL 125
TriStation 1131 Libraries Reference
This table shows how the precision changes as LREAL numbers approach zero.
Absolute error is the absolute value of x a, where x is the exact value and a is the actual value
stored.
Relative error is the absolute value of (x a)/x, where x is the exact value and a is the actual value
stored.
This table shows how gradual underflow affects absolute error and relative error as LREAL
numbers approach zero.
Application Notes
Can be used in Safety or Control applications.
Can be used in CEM Cause, Effect, and Intersection cells.
If |x| Is Greater Than: Then the Precision Is Greater Than:
5.0E308 17 digits
5.0E309 16 digits
5.0E310
.
.
.
5.0E322
15 digits
.
.
.
3 digits
5.0E323 2 digits
5.0E324 1 digits
0.0 0 digits
Range
Maximum
Absolute Error
Maximum Relative
Error
0 < |x| s 2
1075
|x| 1
2
1075
< |x| s 2
1022
2
1075
2
1075
/ |x|
2
1022
s |x| < 2
1024
2
972
2
53
* |x| 2
53

126 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
LREAL_TO_DINT
Converts a 64-bit long real number to a 32-bit integer.
Syntax
k := LREAL_TO_DINT(x);
Description
The LREAL_TO_DINT function converts a 64-bit long real number to a 32-bit integer. The result
is rounded to the nearest integer.
Note IEC 1131-3 requires strict data type checking. It does not permit assigning the value of a
variable directly to a variable of a different data type. When it is necessary to use
variables of different data types, an explicit conversion must be made using a data type
conversion function.
Example
VAR k : DINT; x : LREAL; END_VAR;
x := -123.6;
k := LREAL_TO_DINT( x ); (* result is -124 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the
error flags to true, and resets ENO to false. For more information about error flags and runtime
errors, see the CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
Table 149 Input Parameters
Name Data Type Description
x LREAL The 64-bit number to be converted.
Table 150 Return Value
Data Type Description
DINT The value of x converted to a 32-bit integer.
Conditions Return Values Error Flags
If x is not a number. 2147483648 BADPARAM, ERROR
If x is less than -2147483648.5 2147483648 BADCONV, ERROR
If x is greater than or equal to +2147483647.5 +2147483647 BADCONV, ERROR
LREAL_TO_INT 127
TriStation 1131 Libraries Reference
LREAL_TO_INT
Converts a 64-bit long real number to a 16-bit integer.
Syntax
k := LREAL_TO_INT(x);
Description
The LREAL_TO_INT function converts a 64-bit long real number to a 16-bit integer. The result
is rounded to the nearest integer.
Note IEC 1131-3 requires strict data type checking. It does not permit assigning the value of a
variable directly to a variable of a different data type. When it is necessary to use
variables of different data types, an explicit conversion must be made using a data type
conversion function.
Example
VAR k : DINT; x : LREAL; END_VAR;
x := -123.6;
k := LREAL_TO_INT( x ); (* result is -124 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the
error flags to true, and resets ENO to false. For more information about error flags and runtime
errors, see the CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
Table 151 Input Parameters
Name Data Type Description
x LREAL The 64-bit long real number to be converted.
Table 152 Return Value
Data Type Description
INT The value of x converted to a 16-bit integer.
Conditions Return Values Error Flags
If x is not a number. 32768 BADPARAM, ERROR
If x is less than -32768.5 32768 BADCONV, ERROR
If x is greater than or equal to +32757.5 +32767 BADCONV, ERROR
128 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
LREAL_TO_REAL
Converts a 64-bit long real number to a 32-bit real number.
Syntax
y := LREAL_TO_REAL(x);
Description
The LREAL_TO_REAL function converts a 64-bit long real number to a 32-bit real number.
Note IEC 1131-3 requires strict data type checking. It does not permit assigning the value of a
variable directly to a variable of a different data type. When it is necessary to use
variables of different data types, an explicit conversion must be made using a data type
conversion function.
Example
VAR x : LREAL END_VAR;
VAR y : REAL END_VAR;
x := 6.25;
y = LREAL_TO_REAL(x); (* result is 6.25 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the
error flags to true, and resets ENO to false. For more information about error flags and runtime
errors, see the CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
Table 153 Input Parameters
Name Data Type Description
x LREAL The 64-bit long real number to be converted.
Table 154 Return Value
Data Type Description
REAL The value of x converted to a 32-bit real number.
Conditions Return Values Error Flags
If x is not a number. NAN BADPARAM, ERROR
If the result is out of range and negative. INF BADCONV, ERROR
If the result is out of range and positive. +INF BADCONV, ERROR
LT 129
TriStation 1131 Libraries Reference
LT
Determines if one operand is less than another operand.
Syntax
b := x < y ;
Description
The LT function is used in graphical languages to determine if one operand is less than another
operand. In Structured Text, the < operator is used. The result is true if one operand is less than
another operand; otherwise the result is false.
The operands can be any of these data types:
BOOL
DATE
DINT
DT
DWORD
INT
LREAL
REAL
STRING
TIME
TOD
Both operands must be the same data type. For type REAL or LREAL data types, if either
operand is not a number (NAN), the result is undefined.
Table 155 Input Parameters
Name Data Type Description
x ANY_ NOTE1 First operand
y ANY_ NOTE1 Second operand
Table 156 Return Value
Data Type Description
BOOL True if x is less than y.
130 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Example
Structured Text
VAR b : BOOL; END_VAR
b := 10 < 11; (* result is TRUE *)
b := 11 < 11; (* result is FALSE *)
b := 11 < 10; (* result is FALSE *)
b := 'abce' < 'abcd'; (* result is FALSE *)
Function Block Diagram
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Can be used in CEM Cause cells.
Library
Standard (STDLIB)
MAX 131
TriStation 1131 Libraries Reference
MAX
Finds the maximum of the input values.
Syntax
M := MAX( I1, I2, ..., In ) ;
Description
The MAX function returns the maximum of input values I1 ... In.
The maximum number of function inputs is 50.
The function can be used with these data types:
BOOL
DATE
DINT
DT
DWORD
INT
LREAL
REAL
TIME
TOD
All operands must have the same data type as the return value. For data type REAL or LREAL,
if any operand is not a number (NAN), the result is NAN.
Note STRING data types are not supported for this function.
Table 157 Input Parameters
Name Data Type Description
I1
.
.
.
In
ANY_ NOTE1
.
.
.
ANY_ NOTE1
Input value 1.
.
.
.
Input value n.
Table 158 Return Value
Data Type Description
ANY_NOTE1 The largest value of I1In.
132 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Example
VAR y : REAL ; END_VAR
y := MAX( 10.0, 15.0, 20.0 ) ; (* result is 20.0 *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
MBCTRL 133
TriStation 1131 Libraries Reference
MBCTRL
Sets time-out and retry values for a Modbus master port.
Syntax
MY_MBCTRL(CI:=b1, PORT:=n1, TIME_OUT:=n2, RETRIES:=n3 );
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:
(Tricon) My Documents\Triconex\TriStation 1131 4.x\Projects\Exmodbus.pt2
(Trident) My Documents\Triconex\TriStation 1131 4.x\Projects\Tdmodbus.pt2
Table 159 Input Parameters
Name Data Type Description
CI BOOL Enables MBCTRL.
PORT DINT The Modbus master port number.
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 135 143) and
MBWRITE functions (pages 146 153) for error codes.
RETRIES DINT The number of retries for a failed inquiry. The default is zero.
Table 160 Output Parameters
Name Data Type Description
CO BOOL True if MBCTRL executes successfully.
STATUS DINT Status:
0 = Idle, no operation.
100 = Bad parameter if PORT is less than 0.
105 = Bad parameter if TIME_OUT is less than 0 or RETRIES is less than 0.
134 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Example
VAR MY_MBCTRL : MBCTRL ; END_VAR
VAR bInitialized : BOOL ; END_VAR
(*
* Increase the port 1 time-out to 4 seconds
* and the number of retries to 3.
*)
MY_MBCTRL( CI:=not bInitialized, PORT:=1, TIME_OUT:=4, RETRIES:=3 ) ;
bInitialized := true ;
Runtime Errors
See the description for the STATUS output for runtime error conditions and codes.
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Only Once: each instance should be executed only once per scan, but does not need to
be executed every scan.
Library
Tricon (TR1LIB/TX1LIB)
Trident (TRDLIB)
Condition Return Value Error Flag
If STATUS is greater than or equal to 100 CO=false None
MBREAD_BOOL 135
TriStation 1131 Libraries Reference
MBREAD_BOOL
Reads Boolean values from a Modbus slave.
Syntax
MY_MBREAD_BOOL(ACTIVE:=b1, ALIAS:=n1, N:=n2, PORT:=n3, STATION:=n4 );
Table 161 Input Parameters
Name Data Type Description
ACTIVE BOOL Requests a Modbus read operation when the internal status equals 0 or 3.
ALIAS DINT The starting alias of the slave (119999).
N DINT The number of values to read from slave (132).
PORT DINT The port number.
STATION DINT The slave station address (1247).
Table 162 Output Parameters
Name Data Type Description
IDLE BOOL Idle (STATUS = 0).
I BOOL Read initiated (STATUS = 1 or 4).
NDR BOOL New data received (STATUS = 3 or 4).
ERROR BOOL True if STATUS is greater than or equal to 100.
STATUS DINT Status:
0 = Idle, no operation.
1 = Read initiated.
2 = Busy (waiting for response to previous operation).
3 = Response received and new data received.
4 = Response received and new data received and next read initiated.
100 = PORT is not a Modbus port.
101 = ALIAS in function is not a valid alias.
102 = N is not valid.
103 = Port malfunctions or the port is not a Modbus master port.
106 = Sequence error (conditional execution of Modbus function block).
201 = Modbus slave returned an Illegal Function response code.
202 = Modbus slave returned an Illegal Data Address response code.
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.
136 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Description
The MBREAD_BOOL function block reads Boolean values from a Modbus slave.
On each scan, the sequence of Modbus function block calls must be the same, from the start of
the first program to the end of the last program. A change detected in the sequence of Modbus
function blocks causes error status 106.
Note The number of Modbus reads and writes per scan is limited.
Example
For examples of using the MBREAD_BOOL function block, see these sample projects:
(Tricon) My Documents\Triconex\TriStation 1131 4.x\Projects\Exmodbus.pt2
(Trident) My Documents\Triconex\TriStation 1131 4.x\Projects\Tdmodbus.pt2
Runtime Errors
See the description for the STATUS output for runtime error conditions and codes.
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Exactly Once: each instance should be executed exactly once per scan.
Library
Tricon (TR1LIB/TX1LIB)
Trident (TRDLIB)
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
.
.
.
D32
BOOL
.
.
.
BOOL
Receive data 01.
.
.
.
Receive data 32.
Condition Return Value Error Flag
If STATUS is greater than or equal to 100 ERROR=true None
Table 162 Output Parameters (continued)
Name Data Type Description
MBREAD_DINT 137
TriStation 1131 Libraries Reference
MBREAD_DINT
Reads integers from a Modbus slave.
Syntax
MY_MBREAD_DINT(ACTIVE:=b1, ALIAS:=n1, N:=n2, PORT:=n3, STATION:=n4 );
Table 163 Input Parameters
Name Data Type Description
ACTIVE BOOL Requests a Modbus read operation when the internal status equals 0 or 3.
ALIAS DINT The starting alias of the slave (30001499999).
N DINT The number of values to read from slave (132).
PORT DINT The port number.
STATION DINT The slave station address (1247).
Table 164 Output Parameters
Name Data Type Description
IDLE BOOL Idle (STATUS = 0).
I BOOL Read initiated (STATUS = 1 or 4).
NDR BOOL New data received (STATUS = 3 or 4).
ERROR BOOL True if STATUS is greater than or equal to 100.
STATUS DINT Status:
0 = Idle, no operation.
1 = Read initiated.
3 = Response received and new data received.
4 = Response received and new data received and next read initiated.
100 = PORT is not a Modbus port.
101 = ALIAS in function is not a valid alias.
102 = N is not valid.
103 = Port malfunctions or the port is not a odbus master port.
106 = Sequence error (conditional execution of Modbus function block).
201 = Modbus slave returned an Illegal Function response code.
202 = Modbus slave returned an Illegal Data Address response code.
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.
217 = Modbus slaves response function code does not match.
138 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Description
The MBREAD_DINT function block reads integers from a Modbus slave. The type of the data
output (D01..D32) is DINT, which is a 32-bit integer. However, the corresponding data from the
Modbus is only 16 bits. The 16-bit value from the Modbus slave is in the least significant 16 bits
of the DINT, with zero in the most significant 16 bits of the DINT.
On each scan, the sequence of Modbus function block calls must be the same, from the start of
the first program to the end of the last program. A change detected in the sequence of Modbus
function blocks causes error status 106.
Note The number of Modbus reads and writes per scan is limited.
Example
For examples of using the MBREAD_DINT function block, see these sample projects:
(Tricon) My Documents\Triconex\TriStation 1131 4.x\Projects\Exmodbus.pt2
(Trident) My Documents\Triconex\TriStation 1131 4.x\Projects\Tdmodbus.pt2
Runtime Errors
See the description for the STATUS output for runtime error conditions and codes.
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Exactly Once: each instance should be executed exactly once per scan.
Library
Tricon (TR1LIB/TX1LIB)
Trident (TRDLIB)
216 = Modbus slaves response has a length error.
219 = Response not received in specified time-out period.
D01
.
.
.
D32
DINT
.
.
.
DINT
Receive data 01.
.
.
.
Receive data 32.
Condition Return Value Error Flag
If STATUS is greater than or equal to 100 ERROR=true None
Table 164 Output Parameters (continued)
Name Data Type Description
MBREAD_REAL 139
TriStation 1131 Libraries Reference
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 controller or non-Triconex device.
Syntax
MY_MBREAD_REAL(ACTIVE:=b1, ALIAS:=n1, N:=n2, PORT:=n3, STATION:=n4,
SPECIAL:=b2 );
Table 165 Input Parameters
Name Data Type Description
ACTIVE BOOL Requests a Modbus read operation when the internal status equals 0 or 3.
ALIAS DINT The starting alias of the slave. If SPECIAL = false, then the starting alias is
the same as the configured alias in the slave (if the slave is a Tricon
controller).
ALIAS Ranges:
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.
N DINT The number of values to read from slave (125).
PORT DINT The port number.
STATION DINT The slave station address (1247).
SPECIAL BOOL True if special aliases are used. For more information, see Description on
page 140.
Table 166 Output Parameters
Name Data Type Description
IDLE BOOL Idle (STATUS = 0).
I BOOL Read initiated (STATUS = 1 or 4).
NDR BOOL New data received (STATUS = 3 or 4).
ERROR BOOL True if STATUS is greater than or equal to 100.
140 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Description
The MBREAD_REAL function block 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 controller or non-Triconex device.
On each scan, the sequence of Modbus function block calls must be the same, from the start of
the first program to the end of the last program. A change detected in the sequence of Modbus
function blocks causes error status 106.
Note The number of Modbus reads and writes per scan is limited.
STATUS DINT Status:
0 = Idle, no operation.
1 = Read initiated.
2 = Busy (waiting for response to previous operation).
3 = Response received and new data received.
4 = Response received and new data received and next read initiated.
100 = PORT is not a Modbus port.
101 = ALIAS in function is not a valid alias.
102 = N is not valid.
103 = Port malfunctions or the port is not a Modbus master port.
106 = Sequence error (conditional execution of Modbus function block).
201 = Modbus slave returned an Illegal Function response code.
202 = Modbus slave returned an Illegal Data Address response code.
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.
D01
.
.
.
D25
REAL
.
.
.
REAL
Receive data 01.
.
.
.
Receive data 25.
Table 166 Output Parameters (continued)
Name Data Type Description
MBREAD_REAL 141
TriStation 1131 Libraries Reference
Reading Real Values from a Tricon Controller
To read a real value from a Tricon controller, Triconex recommends setting SPECIAL=false (the
default value). The value of the ALIAS input is the same as the value configured in the slave
controller. For example, to read one real value from ALIAS 33002 in the slave, set ALIAS=33002
and N=1.
Reading Real Values from a Non-Triconex Device
You can use MBREAD_REAL to read a real value from a non-Triconex device if the alias you
want to read is a special alias. To read a real value from a non-Triconex device, set
SPECIAL=true. The MBREAD_REAL 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. The starting alias must be odd. For example, to read a real value from SPECIAL
ALIASES 35003 and 35004, set SPECIAL=true, ALIAS=35003, and N=1.
Special Alias Mapping in Tricon Controllers
The Tricon controller provides special aliases for real variables. Each real variable is mapped
into two aliases to produce a 32-bit value. This table shows the mapping of real-variable aliases
to the special aliases.
Example
For examples of using the MBREAD_REAL function block, see these sample projects:
(Tricon) My Documents\Triconex\TriStation 1131 4.x\Projects\Exmodbus.pt2
(Trident) My Documents\Triconex\TriStation 1131 4.x\Projects\Tdmodbus.pt2
Alias Special Alias Description
32001 3400134002 or 4400144002 Input real, read only.
32001
.
.
32120
3400334004 or 4400344004
3423934240 or 4423944240
Input real, read only.
Input real, read only.
33001 3500135002 or 4500145002 Memory real, read only.
33002
.
.
34000
3500335004 or 4500345004
3699937000 or 4699947000
Memory real, read only.
Memory real, read only.
41001 4200142002 Memory real, read/write.
41002
.
.
42000
4200342004
4399944000
Memory real, read/write.
Memory real, read/write.
142 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Runtime Errors
See the description for the STATUS output for runtime error conditions and codes.
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Exactly Once: each instance should be executed exactly once per scan.
Library
Tricon (TR1LIB/TX1LIB)
Trident (TRDLIB)
Condition Return Value Error Flag
If STATUS is greater than or equal to 100 ERROR=true None
MBREAD_REAL_TRD 143
TriStation 1131 Libraries Reference
MBREAD_REAL_TRD
Reads real numbers from a Modbus slave.
The Modbus slave should be a Trident controller or 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 167 Input Parameters
Name Data Type Description
ACTIVE BOOL Requests a Modbus read operation when the internal status equals 0 or 3.
ALIAS DINT The starting alias of the slave (3000149998).
N DINT The number of values to read from slave (125).
PORT DINT The port number.
STATION DINT The slave station address (1247).
Table 168 Output Parameters
Name Data Type Description
IDLE BOOL Idle (STATUS = 0).
I BOOL Read initiated (STATUS = 1 or 4).
NDR BOOL New data received (STATUS = 3 or 4).
ERROR BOOL True if STATUS is greater than or equal to 100.
STATUS DINT Status:
0 = Idle, no operation.
1 = Read initiated.
2 = Busy (waiting for response to previous operation).
3 = Response received and new data received.
4 = Response received and new data received and next read initiated.
100 = PORT is not a Modbus port.
101 = ALIAS in function is not a valid alias.
102 = N is not valid.
103 = Port malfunctions or the port is not a Modbus master port.
106 = Sequence error (conditional execution of Modbus function block).
201 = Modbus slave returned an Illegal Function response code.
202 = Modbus slave returned an Illegal Data Address response code.
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.
144 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Description
The MBREAD_REAL_TRD function block reads real numbers from a Modbus slave.
The Modbus slave should be a Trident controller or non-Triconex device. Use MBREAD_REAL
if the Modbus slave is a Tricon controller.
The function block reads two 16-bit values from two consecutive aliases (ALIAS and ALIAS+1)
and concatenates the two values to form the first 32-bit REAL value (D01). The 16 most
significant bits are at ALIAS, and the 16 least significant bits are at ALIAS+1. For example, to
read a REAL value from aliases 35003 and 35004, set ALIAS=35003, and N=1.
On each scan, the sequence of Modbus function block calls must be the same, from the start of
the first program to the end of the last program. A change detected in the sequence of Modbus
function blocks causes error status 106.
Note The number of Modbus reads and writes per scan is limited.
Example
For examples of using Modbus Read function blocks, see these sample projects:
(Tricon) My Documents\Triconex\TriStation 1131 4.x\Projects\Exmodbus.pt2
(Trident) My Documents\Triconex\TriStation 1131 4.x\Projects\Tdmodbus.pt2
Runtime Errors
See the description for the STATUS output for runtime error conditions and codes.
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
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
.
.
.
D25
REAL
.
.
.
REAL
Receive data 01.
.
.
.
Receive data 25.
Condition Return Value Error Flag
If STATUS is greater than or equal to 100 ERROR=true None
Table 168 Output Parameters (continued)
Name Data Type Description
MBREAD_REAL_TRD 145
TriStation 1131 Libraries Reference
Application Notes
Can be used in Safety or Control applications.
Library
Tricon (TR1LIB/TX1LIB)
Trident (TRDLIB)
146 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
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 169 Input Parameters
Name Data Type Description
ACTIVE BOOL Requests a Modbus write operation when the internal status equals 0 or 3.
ALIAS DINT The starting alias of the slave (19999).
N DINT The number of values to write (132).
PORT DINT The port number.
STATION DINT The slave station address (1247).
D01
.
.
.
D32
BOOL
.
.
.
BOOL
Send data 01.
.
.
.
Send data 32.
Table 170 Output Parameters
Name Data Type Description
IDLE BOOL Idle (STATUS = 0).
I BOOL Write initiated (STATUS = 1 or 4).
ACK BOOL Write acknowledged (STATUS = 3 or 4).
ERROR BOOL True if STATUS is greater than or equal to 100.
STATUS DINT Status:
0 = Idle, no operation.
1 = Write initiated.
2 = Busy (waiting for response to previous operation).
3 = Response received.
4 = Response received and next write initiated.
100 = PORT is not a Modbus port.
101 = ALIAS in function is not a valid alias.
102 = N is not valid.
103 = Port is malfunctioning or the port is not a Modbus master port.
106 = Sequence error (conditional execution of Modbus function block).
201 = Modbus slave returned an Illegal Function response code.
MBWRITE_BOOL 147
TriStation 1131 Libraries Reference
Description
The MBWRITE_BOOL function block writes Boolean values to a Modbus slave.
On each scan, the sequence of Modbus function block calls must be the same, from the start of
the first program to the end of the last program. A change detected in the sequence of Modbus
function blocks causes error status 106.
Note The number of Modbus reads and writes per scan is limited.
Example
For examples of using the MBWRITE_BOOL function block, see these sample projects:
(Tricon) My Documents\Triconex\TriStation 1131 4.x\Projects\Exmodbus.pt2
(Trident) My Documents\Triconex\TriStation 1131 4.x\Projects\Tdmodbus.pt2
Runtime Errors
See the description for the STATUS output for runtime error conditions and codes.
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Exactly Once: each instance should be executed exactly once per scan.
Library
Tricon (TR1LIB/TX1LIB)
Trident (TRDLIB)
202 = Modbus slave returned an Illegal Data Address response code
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.
Condition Return Value Error Flag
If STATUS is greater than or equal to 100 ERROR=true None
Table 170 Output Parameters (continued)
Name Data Type Description
148 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
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 171 Input Parameters
Name Data Type Description
ACTIVE BOOL Requests a Modbus write operation when the internal status equals 0 or 3.
ALIAS DINT The starting alias of the slave (4000149999).
N DINT The number of values to write (132).
PORT DINT The port number.
STATION DINT The slave station address (1247).
D01
.
.
.
D32
DINT
.
.
.
DINT
Send data 01.
.
.
.
Send data 32.
Table 172 Output Parameters
Name Data Type Description
IDLE BOOL Idle (STATUS = 0).
I BOOL Write initiated (STATUS = 1 or 4).
ACK BOOL Write acknowledged (STATUS = 3 or 4).
ERROR BOOL True if STATUS is greater than or equal to 100.
STATUS DINT Status:
0 = Idle, no operation.
1 = Write initiated.
2 = Busy (waiting for response to previous operation).
3 = Response received.
4 = Response received and next write initiated.
100 = PORT is not a Modbus port.
101 = ALIAS in function is not a valid alias.
102 = N is not valid.
103 = Port is malfunctioning or the port is not a Modbus master port.
106 = Sequence error (conditional execution of Modbus function block).
201 = Modbus slave returned an Illegal Function response code.
MBWRITE_DINT 149
TriStation 1131 Libraries Reference
Description
The MBWRITE_DINT function block writes the least significant 16 bits of a DINT to a Modbus
slave.
On each scan, the sequence of Modbus function block calls must be the same, from the start of
the first program to the end of the last program. A change detected in the sequence of Modbus
function blocks causes error status 106.
Note The number of Modbus reads and writes per scan is limited.
Example
For examples of using the MBWRITE_DINT function block, see these sample projects:
(Tricon) My Documents\Triconex\TriStation 1131 4.x\Projects\Exmodbus.pt2
(Trident) My Documents\Triconex\TriStation 1131 4.x\Projects\Tdmodbus.pt2
Runtime Errors
See the description for the STATUS output for runtime error conditions and codes.
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Exactly Once: each instance should be executed exactly once per scan.
Library
Tricon (TR1LIB/TX1LIB)
Trident (TRDLIB)
202 =Modbus slave returned an Illegal Data Address response code.
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.
Condition Return Value Error Flag
If STATUS is greater than or equal to 100 ERROR=true None
Table 172 Output Parameters (continued)
Name Data Type Description
150 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
MBWRITE_REAL
Allows a Triconex Modbus master controller to write real numbers to a Trident Modbus slave
controller or non-Triconex device.
Syntax
MY_MBWRITE_REAL(ACTIVE:=b1, ALIAS:=n1, N:=n2, PORT:=n3, STATION:=n4,
SPECIAL:=b2, D01:=x1 );
Table 173 Input Parameters
Name Data Type Description
ACTIVE BOOL Requests a Modbus write operation when the internal status equals 0 or 3.
ALIAS DINT The starting alias of the slave.
ALIAS Range:
4100142000 = Memory real, read/write.
Special ALIAS Range:
4200144000 = Memory real, read/write.
N DINT The number of values to write (125).
PORT DINT The Modbus master port number.
STATION DINT The slave station address (1247).
SPECIAL BOOL True if special aliases are used. For more information, see Special Alias
Mapping in Tricon Controller on page 152.
D01
.
.
.
D25
REAL
.
.
.
REAL
Send data 01.
.
.
.
Send data 25.
Table 174 Output Parameters
Name Data Type Description
IDLE BOOL Idle (STATUS = 0).
I BOOL Write initiated (STATUS = 1 or 4).
ACK BOOL Write acknowledged (STATUS = 3 or 4).
ERROR BOOL True if STATUS is greater than or equal to 100.
MBWRITE_REAL 151
TriStation 1131 Libraries Reference
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 controller or non-Triconex device.
On each scan, the sequence of Modbus function block calls must be the same, from the start of
the first program to the end of the last program. A change detected in the sequence of Modbus
function blocks causes error status 106.
Note The number of Modbus reads and writes per scan is limited.
Writing Real Values to a Tricon Controller
To write a real value to a Tricon controller, Triconex recommends setting SPECIAL=False (the
default value). The value of the ALIAS input is the same as the value configured in the slave
controller. For example, to write a real value to ALIAS 41002 in the slave, set ALIAS=41002 and
N=1.
STATUS DINT Status:
0 = Idle, no operation.
1 = Write initiated.
2 = Busy (waiting for response to previous operation).
3 = Response received.
4 = Response received and next write initiated.
100 = PORT is not a Modbus port.
101 = ALIAS in function is not a valid alias.
102 = N is not valid.
103 = Port is malfunctioning or the port is not a Modbus master port.
106 = Sequence error (conditional execution of Modbus function block).
201 = Modbus slave returned an Illegal Function response code.
202 = Modbus slave returned an Illegal Data Address response code.
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.
Table 174 Output Parameters (continued)
Name Data Type Description
152 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Writing Real Values to a Non-Triconex Device
You can use MBWRITE_REAL to write a real value to a non-Triconex device if the alias you
want to write is a special alias. To write a real value to a non-Triconex device, set SPECIAL=true.
The function block splits the first 32-bit real value (D01) into two 16-bit values and writes the
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. 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 Mapping in Tricon Controller
The Tricon controller provides special aliases for real variables. Each real variable is mapped
into two aliases to produce a 32-bit value. The following table shows the mapping of real-
variable aliases to the special aliases:
Example
For examples of using the MBWRITE_REAL function block, see these sample projects:
(Tricon) My Documents\Triconex\TriStation 1131 4.x\Projects\Exmodbus.pt2
(Trident) My Documents\Triconex\TriStation 1131 4.x\Projects\Tdmodbus.pt2
Runtime Errors
See the description for the STATUS output for runtime error conditions and codes.
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Exactly Once: each instance should be executed exactly once per scan.
Library
Tricon (TR1LIB/TX1LIB)
Trident (TRDLIB)
Alias Special Alias Description
41001 4200142002 Memory real, read/write.
41002
.
.
.
42000
4200342004
.
.
.
439994400
Memory real, read/write.
.
.
.
Memory real, read/write.
Condition Return Value Error Flag
If STATUS is greater than or equal to 100 ERROR=true None
MBWRITE_REAL_TRD 153
TriStation 1131 Libraries Reference
MBWRITE_REAL_TRD
Writes real numbers to a Modbus slave.
The Modbus slave should be a Trident controller or 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 175 Input Parameters
Name Data Type Description
ACTIVE BOOL Requests a Modbus write operation when the internal status equals 0 or 3.
ALIAS DINT The starting alias of the slave.
ALIAS Range:
3000149998.
N DINT The number of values to write (125).
PORT DINT The port number.
STATION DINT The slave station address (1247).
D01
.
.
.
D25
REAL
.
.
.
REAL
Send data 01.
.
.
.
Send data 25.
Table 176 Output Parameters
Name Data Type Description
IDLE BOOL Idle (STATUS = 0).
I BOOL Write initiated (STATUS = 1 or 4).
ACK BOOL Write acknowledged (STATUS = 3 or 4).
ERROR BOOL True if STATUS is greater than or equal to 100.
154 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Description
The MBWRITE_REAL_TRD function block writes real numbers to a Modbus slave.
The Modbus slave should be a Trident controller or non-Triconex device. Use MBWRITE_REAL
if the Modbus slave is a Tricon controller.
The function block splits the first 32-bit REAL value (D01) into two 16-bit values and writes the
two 16-bit values to two consecutive aliases (ALIAS and ALIAS+1). The 16 most significant bits
are at ALIAS, and the 16 least significant bits are at ALIAS+1. For example, to write a REAL
value to aliases 42003 and 42004, set ALIAS=42003 and N=1.
On each scan, the sequence of Modbus function block calls must be the same, from the start of
the first program to the end of the last program. A change detected in the sequence of Modbus
function blocks causes error status 106.
Note The number of Modbus reads and writes per scan is limited.
Example
For examples of using Modbus Write function blocks, see these sample projects:
(Tricon) My Documents\Triconex\TriStation 1131 4.x\Projects\Exmodbus.pt2
(Trident) My Documents\Triconex\TriStation 1131 4.x\Projects\Tdmodbus.pt2
STATUS DINT Status:
0 = Idle, no operation.
1 = Write initiated.
2 = Busy (waiting for response to previous operation).
3 = Response received.
4 = Response received and next write initiated.
100 = PORT is not a Modbus port.
101 = ALIAS in function is not a valid alias.
102 = N is not valid.
103 = Port is malfunctioning or the port is not a Modbus master port.
106 = Sequence error (conditional execution of Modbus function block).
201 = Modbus slave returned an Illegal Function response code.
202 = Modbus slave returned an Illegal Data Address 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.
Table 176 Output Parameters (continued)
Name Data Type Description
MBWRITE_REAL_TRD 155
TriStation 1131 Libraries Reference
Runtime Errors
See the description for the STATUS output for runtime error conditions and codes.
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Tricon (TR1LIB/TX1LIB)
Trident (TRDLIB)
Condition Return Value Error Flag
If STATUS is greater than or equal to 100 ERROR=true None
156 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
MEDSEL
Returns the median of the input numbers.
Syntax
y := MEDSEL( x1, x2, ..., xn ) ;
Description
The MEDSEL function returns the median of the input numbers. If the number of inputs is odd,
the median is the middle number. If the number of inputs is even, the median is the average of
the two middle numbers, which means half the numbers are greater than the median and half
the numbers are smaller.
The maximum number of function inputs is 50.
All inputs must have the same data type as the return value. If any operand is not a number
(NAN), the result is NAN.
Example
VAR y : REAL ; END_VAR
y := MEDSEL( 15.0, 10.0, 20.0 ) ; (* result is 15.0 *)
y := MEDSEL( 15.0, 10.0, 20.0, 30.0 ) ; (* result is 17.5 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the
error flags to true, and resets ENO to false. For more information about error flags and runtime
errors, see the CHK_ERR function block.
Table 177 Input Parameters
Name Data Type Description
x1
.
.
.
xn
ANY_REAL
.
.
.
ANY_REAL
Input value 1.
.
.
.
Input value n.
Table 178 Return Value
Data Type Description
ANY_REAL The median value of x1xn.
Table 179 Runtime Errors
Condition Return Value Error Flags
If an input is not a number. NAN BADPARAM, ERROR
MEDSEL 157
TriStation 1131 Libraries Reference
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
158 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
MIN
Find the minimum of the input values.
Syntax
M := MIN( I1, I2, ..., In ) ;
Description
The MIN function returns the minimum of input values I1 ... In.
The maximum number of function inputs is 50.
The function can be used with these data types:
BOOL
DATE
DINT
DT
DWORD
INT
LREAL
REAL
TIME
TOD
All operands must have the same data type as the return value. For data type REAL or LREAL,
if any operand is not a number (NAN), the result is NAN.
Note STRING data types are not supported for this function.
Example
VAR m : DINT ; END_VAR
m := MIN( 3, 1, 2 ); (* Result is 1 *)
Table 180 Input Parameters
Name Data Type Description
I1
.
.
.
In
ANY_ NOTE1
.
.
.
ANY_ NOTE1
Input value 1.
.
.
.
Input value n.
Table 181 Return Value
Data Type Description
ANY_NOTE1 The smallest value of I1In.
MIN 159
TriStation 1131 Libraries Reference
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
160 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
MINUS_INFINITY_LREAL
Returns minus infinity.
Syntax
y := MINUS_INFINITY_LREAL();
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)
Table 182 Input Parameters
Name Data Type Description
NA NA No inputs.
Table 183 Return Value
Data Type Description
LREAL Minus infinity.
MINUS_INFINITY_REAL 161
TriStation 1131 Libraries Reference
MINUS_INFINITY_REAL
Returns minus infinity.
Syntax
y := MINUS_INFINITY_REAL();
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)
Table 184 Input Parameters
Name Data Type Description
NA NA No inputs.
Table 185 Return Value
Data Type Description
REAL Minus infinity.
162 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
MOD
Divides two integers and returns the remainder.
Syntax
i := j MOD k ;
Description
The MOD (modulus) function divides one integer by another and returns the remainder.
Both operands must have the same data type as the return value.
Example
VAR i : DINT ; END_VAR
i := 5 MOD 3 ; (* result is 2 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the
error flags to true, and resets ENO to false. For more information about error flags and runtime
errors, see the CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
Table 186 Input Parameters
Name Data Type Description
j ANY_INT First operand.
k ANY_INT Second operand.
Table 187 Return Value
Data Type Description
ANY_INT The remainder.
Condition Return Value Error Flags
If the divisor is equal to 0. 0 DIVBYZERO, ERROR
MOVE 163
TriStation 1131 Libraries Reference
MOVE
Assigns an input value to an output value.
Syntax
OUT := IN ;
Description
In a graphical language, the MOVE function assigns an input value to an output value.
In Structured Text, use an assignment statement instead of the MOVE function.
Example
VAR OUT : DINT ; END_VAR
OUT := 3 ; (* move 3 to variable OUT *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Can be used in CEM Cause, Effect, and Intersection cells.
Library
Standard (STDLIB)
Table 188 Input Parameters
Name Data Type Description
IN ANY The input value.
Table 189 Return Value
Data Type Description
ANY The value of IN.
164 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
MUL
Multiplies two or more numbers, or multiplies a time by a number.
Syntax
P := I1 * I2 * ... * In ;
T2 := T1 * N ;
Multiplying Two or More Numbers
Multiplying a Time by a Number
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.
Table 190 Input Parameters
Name Data Type Description
I1
.
.
.
In
ANY_NUM
.
.
.
ANY_NUM
First operand.
.
.
.
Last operand.
Table 191 Return Value
Data Type Description
ANY_NUM The product.
Table 192 Input Parameters
Name Type Description
T1 TIME The time.
N ANY_NUM A number.
Table 193 Return Value
Data Type Description
TIME Product.
MUL 165
TriStation 1131 Libraries Reference
Example
Calculate the product of three numbers
VAR p : DINT; END_VAR
p := 2 * 3 * 4 ; (* result is 24 *)
Multiply time by a number
VAR t : TIME; END_VAR
t := T#1s ;
t := t * 2 ; (* result is T#2s *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the
error flags to true, and resets ENO to false. For more information about error flags and runtime
errors, see the CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
Condition Return Value Error Flags
If the result is infinite INF OVERFLOW, ERROR
If an operand is not a number (NAN) NAN OVERFLOW, ERROR
If the time is out of range Invalid time BADPARAM, ERROR
166 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
MUX
Selects a value from multiple inputs.
Syntax
v := MUX( K, I
0
, I
1
, ..., I
n-1
) ;
Description
The MUX function selects a value from multiple inputs, depending on an input selector (K).
The maximum number of data values is 49.
Normally, the value of K should be from 0 to n-1, where n is the number of data inputs. In this
case, the function returns I
K
. If K is less than 0, the function returns I
0
. If K is greater than n-1,
the function returns I
n-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
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.
Table 194 Input Parameters
Name Data Type Description
K ANY_INT The selector.
I
0
..
.
.
I
n-1
ANY
.
.
.
ANY
Data value 0.
.
.
.
Data value n-1.
Table 195 Return Value
Data Type Description
ANY The selected data value.
Conditions Return Values Error Flags
If K is less than 0 [K can be from 0 to (n1)]. Input I
0
BADPARAM, ERROR
If K is greater than the index number of the last input. Last input I
n-1
BADPARAM, ERROR
MUX 167
TriStation 1131 Libraries Reference
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
168 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
NAN_LREAL
Returns not a number (NAN).
Syntax
y := NAN_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)
Table 196 Input Parameters
Name Data Type Description
NA NA No inputs.
Table 197 Return Value
Data Type Description
LREAL Not a number (NAN).
NAN_REAL 169
TriStation 1131 Libraries Reference
NAN_REAL
Returns not a number (NAN).
Syntax
y := NAN_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)
Table 198 Input Parameters
Name Data Type Description
NA NA No inputs.
Table 199 Return Value
Data Type Description
REAL Not a number (NAN).
170 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
NE
Compares two operands for inequality.
Syntax
b := x <> y;
Description
The NE function is used in graphical languages to determine if two operands are not equal. In
Structured Text, the <> operator is used to determine inequality. The result is true if the
operands are not equal; otherwise the result is false.
The operands can be any data type, but both operands must be the same data type. For type
REAL or LREAL, if either operand is not a number (NAN), the result is undefined.
Example
Structured Text
VAR b : BOOL; END_VAR
b := 10 <> 11; (* result is TRUE *)
b := 11 <> 11; (* result is FALSE *)
b := 'abcd' <> 'abcd'; (* result is FALSE *)
Function Block Diagram
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Can be used in CEM Cause cells.
Library
Standard (STDLIB)
Table 200 Input Parameters
Name Data Type Description
x ANY First operand
y ANY Second operand
Table 201 Return Value
Data Type Description
BOOL True if x is not equal to y.
NOT 171
TriStation 1131 Libraries Reference
NOT
Performs a logical negation of a Boolean operand or a bitwise complement of a bit-string.
Syntax
v := 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.
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.
The operand and the return value are the same data type, that is, they are both BOOL or both
DWORD.
Table 202 Input Parameters
Name Data Type Description
b ANY_BIT Operand
Table 203 Return Value
Data Type Description
ANY_BIT NOT b
Table 204 logical NOT
b NOT b
FALSE TRUE
TRUE FALSE
Table 205 bitwise complement
Bit Complement
0 1
1 0
172 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
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 *)
Using Bit-String Operands
VAR w, w1 : DWORD; END_VAR
w1 := 2#10101010101010101010101010101010 ;
w := NOT w1 ; (* result is 2#01010101010101010101010101010101 *)
Note that on the Controller Panel, you will see the example values in hex. The value of operand
w1 is 16#AAAAAAAA, and the value of result w is 16#55555555.
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Can be used in CEM Cause, Effect, and Intersection cells.
Library
Standard (STDLIB)
NUMBITS 173
TriStation 1131 Libraries Reference
NUMBITS
Counts the number of Boolean parameters with value true.
Syntax
n := NUMBITS(b1, b2, ... , bn) ;
Description
The NUMBITS function counts the number of parameters with value equal to true.
The maximum number of function inputs is 50.
Example
n := NUMBITS(TRUE, FALSE, TRUE, TRUE); (* result is 3 *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
Table 206 Input Parameters
Name Data Type Description
b1..bn BOOL Boolean parameters
Table 207 Return Value
Data Type Description
DINT Number of true parameters.
174 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
NUMBITS_DWORD
Counts the number of 1-bits in a DWORD.
Syntax
n := NUMBITS_DWORD( w ) ;
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)
Table 208 Input Parameters
Name Data Type Description
w DWORD A bit-string
Table 209 Return Value
Data Type Description
DINT The number of 1-bits in w.
OR 175
TriStation 1131 Libraries Reference
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 ;
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.
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 210 Input Parameters
Name Data Type Description
b1..bn ANY_BIT Operands
Table 211 Return Value
Data Type Description
ANY_BIT b1 OR b2 OR ... OR bn
Table 212 logical OR
b1 b2 b1 OR b2
FALSE FALSE FALSE
FALSE TRUE TRUE
TRUE FALSE TRUE
TRUE TRUE TRUE
Table 213 bitwise OR
w1 w2 w1 OR w2
2#0011 2#0101 2#0111
176 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
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 *)
Using Bit-String Operands
VAR w, w1, w2, w3 : DWORD; END_VAR
w1 := 2#00000000000000000000000000000001 ;
w2 := 2#00000000000000000000000000000010 ;
w3 := 2#00000000000000000000000000000100 ;
w := w1 OR w2 OR w3; (* 2#00000000000000000000000000000111 *)
w := w1 OR w3; (* 2#00000000000000000000000000000101 *)
Note that on the Controller Panel, you will see the example values in hex. The hex values of the
operands are w1=16#00000001, w2=16#00000002, w3=16#00000004, and the hex values of the
results are 16#00000007 and 16#00000005.
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Can be used in CEM Cause cells.
Library
Standard (STDLIB)
OVDDISABLE 177
TriStation 1131 Libraries Reference
OVDDISABLE
Disables output voter diagnostics (OVD) for a selected Digital Output (DO) Module.
Syntax
MY_OVDDISABLE( CI:=b1, CHASSIS:=n1, SLOT:=n2 ) ;
Description
The OVDDISABLE function block disables output voter diagnostics (OVD) for the Digital
Output (DO) Module selected by CHASSIS and SLOT.
Example
VAR MY_OVDDISABLE : OVDDISABLE ; END_VAR
(* Disable OVD for the module in chassis 9 slot 5. *)
MY_OVDDISABLE( CI:=true, CHASSIS:=9, SLOT:=5 ) ;
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, see Using a Space Saver
Function Block on page 5.
Library
Tricon (TR1LIB/TX1LIB)
Table 214 Input Parameters
Name Data Type Description
CI BOOL Enables OVDDISABLE.
CHASSIS DINT The chassis number (115).
SLOT DINT The physical slot number.
Table 215 Output Parameters
Name Data Type Description
CO BOOL True if OVDDISABLE executes successfully.
Condition Return Value Error Flags
The chassis or the slot is out of range. CO=false BADPARAM, ERROR
178 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
OVDENABLE
Enables output voter diagnostics (OVD) for a selected Digital Output (DO) Module.
Syntax
MY_OVDENABLE( CI:=b1, CHASSIS:=n1, SLOT:=n2 ) ;
Description
The OVDENABLE function block disables output voter diagnostics (OVD) for the Digital
Output (DO) Module selected by CHASSIS and SLOT.
Example
VAR MY_OVDENABLE : OVDENABLE ; END_VAR
(* Enable OVD for the module in chassis 9 slot 5. *)
MY_OVDENABLE( CI:=true, CHASSIS:=9, SLOT:=5 ) ;
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, see Using a Space Saver
Function Block on page 5.
Library
Tricon (TR1LIB/TX1LIB)
Table 216 Input Parameters
Name Data Type Description
CI BOOL Enables OVDENABLE.
CHASSIS DINT The chassis number (115).
SLOT DINT The physical slot number.
Table 217 Output Parameters
Name Data Type Description
CO BOOL True if OVDENABLE executes successfully.
Condition Return Value Error Flags
The chassis or the slot is out of range. CO=false BADPARAM, ERROR
PACK16 179
TriStation 1131 Libraries Reference
PACK16
Packs 16 bits into a DWORD.
Syntax
w := PACK16(IN01, IN02, ... , IN16) ;
Description
The PACK16 function packs 16 bits into a DWORD. The 16 bits are packed into the least
significant 16 bits of a 32-bit DWORD. The values for the 16 bits are given in 16 Boolean
parameters. The first parameter, IN01, is packed into the least significant bit of the result.
Example
w := PACK16(0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0);
(* result is 2#00000000000000000000000000111100 *)
Note that the result displayed on the controller panel is in hex, i.e.,
16#0000003C.
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Triconex (TCXLIB)
Table 218 Input Parameters
Name Data Type Description
IN01 BOOL Input bit 01 (least significant).
IN02 BOOL Input bit 02.
IN03 BOOL Input bit 03.
IN04 BOOL Input bit 04.
INnn BOOL Input bit nn.
IN16 BOOL Input bit 16 (most significant).
Table 219 Return Value
Data Type Description
DWORD The packed result
180 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
PACK32
Packs 32 bits into a DWORD.
Syntax
w := PACK32(IN01, IN02, ... , IN32) ;
Description
The PACK32 function packs 32 bits into a DWORD. The values for the 32 bits are given in 32
Boolean parameters. The first parameter, IN01, is packed into the least significant bit of the
result.
Example
w := PACK32(0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0) ;
(* result is 2#00000000000000000000000000111100 *)
Note that the result displayed on the controller panel is in hex, i.e.,
16#0000003C.
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Triconex (TCXLIB)
Table 220 Input Parameters
Name Data Type Description
IN01 BOOL Input bit 01 (least significant).
IN02 BOOL Input bit 02.
IN03 BOOL Input bit 03.
IN04 BOOL Input bit 04.
INnn BOOL Input bit nn.
IN32 BOOL Input bit 32 (most significant).
Table 221 Return Value
Data Type Description
DWORD The packed result
PAGE_EJECT 181
TriStation 1131 Libraries Reference
PAGE_EJECT
Ejects paper (feeds the form) to the top of the next page.
Syntax
MY_PAGE_EJECT( CI:=b1, PRINTER:=n1 ) ;
Description
The PAGE_EJECT function block ejects paper (feeds the form) to the top of the next page.
CI is the control input. CI enables evaluation. If CI is true, then perform the print operation. If
CI is false, then do nothing. The default initial value of CI is true.
PRINTER is a number that identifies the printer or print server. The valid range is different for
different controllers. For the Tricon controller, all values are 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 controller, the valid range is 1 through 10.
CO is the control ouput. CO follows CI if no runtime error is detected. CO=true indicates that
the function block was enabled and executed successfully, with no runtime error. CO=false and
CI=true indicates a runtime error was detected. CO=false and CI=false indicates no operation.
Example
VAR MY_PAGE_EJECT : PAGE_EJECT ; END_VAR
(* Eject a page on printer 5. *)
MY_PAGE_EJECT( PRINTER:=5 ) ;
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
If the PRINTER parameter is invalid, then the function block aborts the print operation.
Table 222 Input Parameters
Name Data Type Description
CI BOOL Enables PAGE_EJECT.
PRINTER DINT Printer number.
Table 223 Output Parameters
Name Data Type Description
CO BOOL True if PAGE_EJECT executes successfully.
Condition Return Value Error Flags
If PRINTER is invalid. CO=false BADPARAM, ERROR
182 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Note that this function block simply adds the print operation to a buffer and does not check the
status of the printer or print server. To read printer status (like printer ready, buffer overflow,
bytes free, bytes used), see SYS_CM_STATUS or TR_PORT_STATUS.
Application Notes
Can be used in Safety or Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, see Using a Space Saver
Function Block on page 5.
Library
Tricon (TR1LIB/TX1LIB)
Trident (TRDLIB)
PERDEV 183
TriStation 1131 Libraries Reference
PERDEV
Computes percent deviation.
Syntax
b := PERDEV( NAME1, NAME2, SPAN, FRACTION );
Description
The PERDEV function computes percent deviation. This function is used to measure a signal as
a ratio, regardless of the engineering units used. PERDEV computes the difference between the
NAME1 and NAME2 inputs, divides this difference by the SPAN, and then takes the absolute
value of the result.
The result is a floating-point number between 0.0 and 1.0, which is then compared to the
reference input FRACTION. If the measured ratio is less than or equal to the reference fraction,
the return value is true. Otherwise, the return value is false.
Example
VAR b: BOOL ; END_VAR
b := PERDEV( 10.0, 30.0, 100.0, 0.5 ) ; (* result is TRUE *)
b := PERDEV( 10.0, 80.0, 100.0, 0.5 ) ; (* result is FALSE *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Triconex (TCXLIB)
Table 224 Input Parameters
Name Data Type Description
NAME1 REAL The first argument.
NAME2 REAL The second argument.
SPAN REAL The range used to calculate fraction.
FRACTION REAL The reference value.
Table 225 Return Value
Data Type Description
BOOL True if measured ratio less than or equal to FRACTION.
184 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
PID
Performs the proportional integral derivative (PID) algorithm.
Syntax
MY_PID( SP:=x1, CV:=x2, CI:=b1, PV:=x3, AUTO_MAN:=b2, RATE:=x4, RESET:=x5,
KPB:=x6, MAXCV:=x7, MINCV:=x8, MAXRATE:=x9, DELTAT:=t1 ) ;
Description
The PID function block performs the proportional integral derivative (PID) algorithm. PID
provides for anti-reset windup, bumpless transfer, and limitation of the maximum rate of
change for the control variable. Bumpless transfer is handled in the setpoint-tracking form.
Neither the SP nor the PV argument is limited in its dynamic range.
To impose limitations, use the LIMIT function prior to calling PID. The control variable CV is
typically scaled to range from 0 to 100 percent. KPB represents the proportional gain. For direct-
acting control, PID is programmed for KPB to be positive (that is to say, increasing the control
variable causes an increasing process variable).
Table 226 VAR_IN_OUT Parameters
Name Data Type Description
SP REAL The set point.
CV REAL The control variable.
Table 227 Input Parameters
Name Data Type Description
CI BOOL Enables PID.
PV REAL The process variable.
AUTO_MAN BOOL Controls auto/manual state of PID (auto = 1, manual = 0).
RATE REAL The derivative time constant in seconds.
RESET REAL The integral time constant in seconds.
KPB REAL The proportional gain.
MAXCV REAL The maximum CV value.
MINCV REAL The minimum CV value.
MAXRATE REAL The maximum change of CV between evaluations.
DELTAT TIME The time between PID evaluations.
Table 228 Output Parameters
Name Data Type Description
CO BOOL True if PID executes successfully.
PID 185
TriStation 1131 Libraries Reference
For reverse-acting control (increasing the control variable causes a decreasing process variable),
KPB should be negative. You should determine the value of KPB by making control changes
and observing the effect on the process variable being controlled. For example, if a 5 percent
change in the control variable causes a 150-unit change in the process variable, then the process
gain is 150/5 or 30. KPB is typically set near the reciprocal of the process gain.
The integral time constant RESET adjusts the integral action of the PID. If RESET is increased,
the integral action is decreased and the response is slower. If RESET is decreased, the integral
action is increased and the response is faster. To avoid excessive integral action, RESET should
be set initially to a few seconds.
The derivative time constant RATE is used to provide damping of the control loop response. As
RATE is increased, the derivative action is increased and a damping action is applied to the
response. Typically RATE is set to a value of one second or less; in many cases, it can be set to
zero.
Note To schedule execution using a CSCHED or TSCHED function block, connect the
DELTAT input to the ACTUAL output of a CSCHED or TSCHED function block, and
connect the CI input to the Q output.
Runtime Errors
None.
Application Notes
Can be used in Control applications.
Only Once: each instance should be executed only once per scan, but does not need to
be executed every scan.
Library
Triconex (TCXLIB)
186 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
PID_R
Performs the proportional integral derivative (PID) algorithm.
Syntax
MY_PID_R( SPIN:=x1, CVIN:=x2, CI:=b1, PV:=x3, AUTO_MAN:=b2, RATE:=x4,
RESET:=x5, KPB:=x6, MAXCV:=x7, MINCV:=x8, MAXRATE:=x9, DLT:=x10 ) ;
x1 := MY_PID_R.SPOUT ;
x2 := MY_PID_R.CVOUT ;
Description
The PID_R function block performs the proportional integral derivative (PID) algorithm. PID
provides for anti-reset windup, bumpless transfer, and limitation of the maximum rate of
change for the control variable. Bumpless transfer is handled in the setpoint-tracking form.
Neither the SP nor the PV argument is limited in its dynamic range. To impose limitations, use
the LIMIT function prior to calling PID. The control variable CV is typically scaled to range from
0 to 100 percent. KPB represents the proportional gain. For direct-acting control, PID is
programmed for KPB to be positive (that is, increasing the control variable causes an increasing
process variable).
Table 229 Input Parameters
Name Data Type Description
CI BOOL Enables PID_R.
SPIN REAL The set point.
CVIN REAL The control variable.
PV REAL The process variable.
AUTO_MAN BOOL Controls auto/manual state of PID (auto = 1, manual = 0).
RATE REAL The derivative time constant (seconds).
RESET REAL The integral time constant (seconds).
KPB REAL The proportional gain.
MAXCV REAL The maximum CV value.
MINCV REAL The minimum CV value.
MAXRATE REAL The maximum change of CV between evaluations.
DLT REAL The execution interval in seconds.
Table 230 Output Parameters
Name Data Type Description
CO BOOL True if PID_R executes successfully.
SPOUT REAL Set point out.
CVOUT REAL Control variable out.
PID_R 187
TriStation 1131 Libraries Reference
For reverse-acting control (increasing the control variable causes a decreasing process variable),
KPB should be negative. You should determine the value of KPB by making control changes
and observing the effect on the process variable being controlled. For example, if a 5 percent
change in the control variable causes a 150-unit change in the process variable, then the process
gain is 150/5 or 30. KPB is typically set near the reciprocal of the process gain.
The integral time constant RESET adjusts the integral action of the PID. If RESET is increased,
the integral action is decreased and the response is slower. If RESET is decreased, the integral
action is increased and the response is faster. To avoid excessive integral action, initially you
should set RESET to a few seconds.
Rate Parameter
The derivative time constant RATE is used to provide damping of the control loop response. As
RATE is increased, the derivative action is increased and a damping action is applied to the
response. Typically RATE is set to a value of one second or less; in many cases, it can be set to
zero.
Runtime Errors
None.
Application Notes
Can be used in Control applications.
Only Once: each instance should be executed only once per scan, but does not need to
be executed every scan.
Library
Triconex (TCXLIB)
188 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
POLY4
Returns the value of a polynomial with four coefficients.
Syntax
y := POLY4( X, C0, C1, C2, C3 ) ;
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)
Table 231 Input Parameters
Name Data Type Description
X LREAL The input variable.
C0 LREAL Coefficient 0.
C1 LREAL Coefficient 1.
C2 LREAL Coefficient 2.
C3 LREAL Coefficient 3.
Table 232 Return Value
Data Type Description
LREAL The returned value (C0 + C1*X + C2*X*X + C3*X*X*X).
POLY5 189
TriStation 1131 Libraries Reference
POLY5
Returns the value of a polynomial with five coefficients.
Syntax
y := POLY4( X, C0, C1, C2, C3, C4 ) ;
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)
Table 233 Input Parameters
Name Data Type Description
X LREAL The input variable.
C0 LREAL Coefficient 0.
C1 LREAL Coefficient 1.
C2 LREAL Coefficient 2.
C3 LREAL Coefficient 3.
C4 LREAL Coefficient 4.
Table 234 Return Value
Data Type Description
LREAL The returned value (C0 + C1*X + C2*X*X + C3*X*X*X + C4*X*X*X*X).
190 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
PRINT_BOOL
Prints a three-character field containing either Off or On.
Syntax
MY_PRINT_BOOL( CI:=b1, PRINTER:=n1, IN:=b2 ) ;
Description
The PRINT_BOOL function block prints a three-character field containing either Off or On. (On
is left-justified in the field.) Prints Off if IN is false or 0. Prints On if IN is true or 1. When printed,
each argument is preceded by a blank space.
CI is the control input. CI enables evaluation. If CI is true, then perform the print operation. If
CI is false, then do nothing. The default initial value of CI is true.
PRINTER is a number that identifies the printer or print server. The valid range is different for
different controllers.
For the Tricon controller, all values are valid, however, the function block prints to port
10 if PRINTER=10, but prints to port 5 if PRINTER is any other number.
For the Trident v1.x controller, the valid range is 1 through 10.
For the Trident v2.x 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 ) ;
Table 235 Input Parameters
Name Data Type Description
CI BOOL Enables PRINT_BOOL .
PRINTER DINT Printer number.
IN BOOL The value to be printed.
Table 236 Output Parameters
Name Data Type Description
CO BOOL True if PRINT_BOOL executes successfully.
PRINT_BOOL 191
TriStation 1131 Libraries Reference
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
If the PRINTER parameter is invalid, then the function block aborts the print operation.
Note that this function block simply adds the print operation to a buffer and does not check the
status of the printer or print server. To read printer status (like printer ready, buffer overflow,
bytes free, bytes used), see SYS_CM_STATUS or TR_PORT_STATUS.
Application Notes
Can be used in Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, see Using a Space Saver
Function Block on page 5.
Library
Tricon (TR1LIB/TX1LIB)
Trident (TRDLIB)
Condition Return Value Error Flags
If PRINTER is invalid. CO=false BADPARAM, ERROR
192 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
PRINT_CDT
Prints the current date and time of day.
Syntax
MY_PRINT_CDT( CI:=b1, PRINTER:=n1 ) ;
Description
The PRINT_CDT function block prints the current date and time of day in this format:
mm/dd/yy hh:mm:ss.msec
When printed, each argument is preceded by a blank space.
CI is the control input. CI enables evaluation. If CI is true, then perform the print operation. If
CI is false, then do nothing. The default initial value of CI is true.
PRINTER is a number that identifies the printer or print server. The valid range is different for
different controllers.
For the Tricon controller, all values are valid, however, the function block prints to port
10 if PRINTER=10, but prints to port 5 if PRINTER is any other number.
For the Trident v1.x controller, the valid range is 1 through 10.
For the Trident v2.x 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 ) ;
Table 237 Input Parameters
Name Data Type Description
CI BOOL Enables PRINT_CDT.
PRINTER DINT Printer number.
Table 238 Output Parameters
Name Data Type Description
CO BOOL True if PRINT_CDT executes successfully.
PRINT_CDT 193
TriStation 1131 Libraries Reference
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
If the PRINTER parameter is invalid, then the function block aborts the print operation.
Note that this function block simply adds the print operation to a buffer and does not check the
status of the printer or print server. To read printer status (like printer ready, buffer overflow,
bytes free, bytes used), see SYS_CM_STATUS or TR_PORT_STATUS.
Application Notes
Can be used in Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, see Using a Space Saver
Function Block on page 5.
Library
Tricon (TR1LIB/TX1LIB)
Trident (TRDLIB)
Condition Return Value Error FlagS
If PRINTER is invalid. CO=false BADPARAM, ERROR
194 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
PRINT_CRLF
Prints a new line (a carriage return and line feed).
Syntax
MY_PRINT_CRLF( CI:=b1, PRINTER:=n1 ) ;
Description
The PRINT_CRLF function block prints a new line (a carriage return and line feed).
CI is the control input. CI enables evaluation. If CI is true, then perform the print operation. If
CI is false, then do nothing. The default initial value of CI is true.
PRINTER is a number that identifies the printer or print server. The valid range is different for
different controllers.
For the Tricon controller, all values are valid, however, the function block prints to port
10 if PRINTER=10, but prints to port 5 if PRINTER is any other number.
For the Trident v1.x controller, the valid range is 1 through 10.
For the Trident v2.x 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 ) ;
Table 239 Input Parameters
Name Data Type Description
CI BOOL Enables PRINT_CRLF.
PRINTER DINT Printer number.
Table 240 Output Parameters
Name Data Type Description
CO BOOL True if PRINT_CRLF executes successfully.
PRINT_CRLF 195
TriStation 1131 Libraries Reference
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
If the PRINTER parameter is invalid, then the function block aborts the print operation.
Note that this function block simply adds the print operation to a buffer and does not check the
status of the printer or print server. To read printer status (like printer ready, buffer overflow,
bytes free, bytes used), see SYS_CM_STATUS or TR_PORT_STATUS.
Application Notes
Can be used in Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, see Using a Space Saver
Function Block on page 5.
Library
Tricon (TR1LIB/TX1LIB)
Trident (TRDLIB)
Condition Return Value Error Flags
If PRINTER is invalid. CO=false BADPARAM, ERROR
196 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
PRINT_CTOD
Prints the current time of day.
Syntax
MY_PRINT_CTOD( CI:=b1, PRINTER:=n1 ) ;
Description
The PRINT_CTOD function block prints the current time of day in this format:
hh:mm:ss.msec
When printed, each argument is preceded by a blank space.
CI is the control input. CI enables evaluation. If CI is true, then perform the print operation. If
CI is false, then do nothing. The default initial value of CI is true.
PRINTER is a number that identifies the printer or print server. The valid range is different for
different controllers.
For the Tricon controller, all values are valid, however, the function block prints to port
10 if PRINTER=10, but prints to port 5 if PRINTER is any other number.
For the Trident v1.x controller, the valid range is 1 through 10.
For the Trident v2.x 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 ) ;
Table 241 Input Parameters
Name Data Type Description
CI BOOL Enables PRINT_CTOD.
PRINTER DINT Printer number.
Table 242 Output Parameters
Name Data Type Description
CO BOOL True if PRINT_CTOD executes successfully.
PRINT_CTOD 197
TriStation 1131 Libraries Reference
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
If the PRINTER parameter is invalid, then the function block aborts the print operation.
Note that this function block simply adds the print operation to a buffer and does not check the
status of the printer or print server. To read printer status (like printer ready, buffer overflow,
bytes free, bytes used), see SYS_CM_STATUS or TR_PORT_STATUS.
Application Notes
Can be used in Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, see Using a Space Saver
Function Block on page 5.
Library
Tricon (TR1LIB/TX1LIB)
Trident (TRDLIB)
Condition Return Value Error Flag
If PRINTER is invalid. CO=false BADPARAM, ERROR
198 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
PRINT_DINT
Prints a double integer right-justified in an eight-character field.
Syntax
MY_PRINT_DINT( CI:=b1, PRINTER:=n1, IN:=n2 ) ;
Description
The PRINT_DINT function block prints a double integer right-justified in an eight-character
field. If the value is negative, the minus () sign immediately precedes the value. When printed,
each argument is preceded by a blank space.
CI is the control input. CI enables evaluation. If CI is true, then perform the print operation. If
CI is false, then do nothing. The default initial value of CI is true.
PRINTER is a number that identifies the printer or print server. The valid range is different for
different controllers.
For the Tricon controller, all values are valid, however, the function block prints to port
10 if PRINTER=10, but prints to port 5 if PRINTER is any other number.
For the Trident v1.x controller, the valid range is 1 through 10.
For the Trident v2.x 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.
Table 243 Input Parameters
Name Data Type Description
CI BOOL Enables PRINT_DINT.
PRINTER DINT Printer number.
IN DINT The value to be printed.
Table 244 Output Parameters
Name Data Type Description
CO BOOL True if PRINT_DINT executes successfully.
PRINT_DINT 199
TriStation 1131 Libraries Reference
Example
VAR MY_PRINT_DINT : PRINT_DINT ; END_VAR
(* Print " 999" on printer 5. *)
MY_PRINT_DINT( PRINTER:=5, IN:=999 ) ;
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
If the PRINTER parameter is invalid, then the function block aborts the print operation.
Note that this function block simply adds the print operation to a buffer and does not check the
status of the printer or print server. To read printer status (like printer ready, buffer overflow,
bytes free, bytes used), see SYS_CM_STATUS or TR_PORT_STATUS.
Application Notes
Can be used in Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, see Using a Space Saver
Function Block on page 5.
Library
Tricon (TR1LIB/TX1LIB)
Trident (TRDLIB)
Condition Return Value Error Flags
If PRINTER is invalid. CO=false BADPARAM, ERROR
200 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
PRINT_REAL
Prints a real (floating-point) value right justified in an eight-character field.
Syntax
MY_PRINT_REAL( CI:=b1, PRINTER:=n1, IN:=x1, PRECISION:=n2 ) ;
Description
The PRINT_REAL function block prints a real (floating-point) value right justified in an eight-
character field. If the value is negative, a minus () sign immediately precedes the first printed
digit. The PRECISION argument specifies the number of decimal places. The default is 4
decimal places.
If a real number does not fit in the eight-character field, then significance to the right of the
decimal point is reduced. If this fails, then the number is printed in scientific notation. When
printed, each argument is preceded by a blank space.
CI is the control input. CI enables evaluation. If CI is true, then perform the print operation. If
CI is false, then do nothing. The default initial value of CI is true.
PRINTER is a number that identifies the printer or print server. The valid range is different for
different controllers.
For the Tricon controller, all values are valid, however, the function block prints to port
10 if PRINTER=10, but prints to port 5 if PRINTER is any other number.
For the Trident v1.x controller, the valid range is 1 through 10.
For the Trident v2.x 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.
Table 245 Input Parameters
Name Data Type Description
CI BOOL Enables PRINT_REAL.
PRINTER DINT Printer number.
IN REAL The value to be printed.
PRECISION DINT The number of fraction digits (0 . 7).
Table 246 Output Parameters
Name Data Type Description
CO BOOL True if PRINT_REAL executes successfully.
PRINT_REAL 201
TriStation 1131 Libraries Reference
CO is the control ouput. CO follows CI if no runtime error is detected. CO=true indicates that
the function block was enabled and executed successfully, with no runtime error. CO=false and
CI=true indicates a runtime error was detected. CO=false and CI=false indicates no operation.
Example
VAR MY_PRINT_REAL : PRINT_REAL ; END_VAR
(* Print " 1.0625" on printer 5. *)
MY_PRINT_REAL( PRINTER:=5, IN:=1.0625 ) ;
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
If the PRINTER parameter is invalid, then the function block aborts the print operation.
Note that this function block simply adds the print operation to a buffer and does not check the
status of the printer or print server. To read printer status (like printer ready, buffer overflow,
bytes free, bytes used), see SYS_CM_STATUS or TR_PORT_STATUS.
Application Notes
Can be used in Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, see Using a Space Saver
Function Block on page 5.
Library
Tricon (TR1LIB/TX1LIB)
Trident (TRDLIB)
Condition Return Value Error Flags
If PRINTER is invalid. CO=false BADPARAM, ERROR
202 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
PRINT_STRING
Prints a string of text (not including quotation marks).
Syntax
MY_PRINT_STRING( CI:=b1, PRINTER:=n1, IN:=s1 ) ;
Description
The PRINT_STRING function block prints a string of text (not including quotation marks).
CI is the control input. CI enables evaluation. If CI is true, then perform the print operation. If
CI is false, then do nothing. The default initial value of CI is true.
PRINTER is a number that identifies the printer or print server. The valid range is different for
different controllers.
For the Tricon controller, all values are valid, however, the function block prints to port
10 if PRINTER=10, but prints to port 5 if PRINTER is any other number.
For the Trident v1.x controller, the valid range is 1 through 10.
For the Trident v2.x controller, the PRINTER parameter must be 5 or 10. The Left and
Right CM ports cannot have the same PRINTER parameter.
IN represents the string to be printed.
CO is the control ouput. CO follows CI if no runtime error is detected. CO=true indicates that
the function block was enabled and executed successfully, with no runtime error. CO=false and
CI=true indicates a runtime error was detected. CO=false and CI=false indicates no operation.
Example
VAR MY_PRINT_STRING : PRINT_STRING ; END_VAR
(* Print "Now is the time." on printer 5. *)
MY_PRINT_BOOL( PRINTER:=5, IN:=Now is the time. ) ;
Table 247 Input Parameters
Name Data Type Description
CI BOOL Enables PRINT_STRING.
PRINTER DINT Printer number.
IN STRING The value to be printed.
Table 248 Output Parameters
Name Data Type Description
CO BOOL True if PRINT_STRING executes successfully.
PRINT_STRING 203
TriStation 1131 Libraries Reference
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
If the PRINTER parameter is invalid, then the function block aborts the print operation.
Note that this function block simply adds the print operation to a buffer and does not check the
status of the printer or print server. To read printer status (like printer ready, buffer overflow,
bytes free, bytes used), see SYS_CM_STATUS or TR_PORT_STATUS.
Application Notes
Can be used in Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, see Using a Space Saver
Function Block on page 5.
Library
Tricon (TR1LIB/TX1LIB)
Trident (TRDLIB)
Condition Return Value Error Flags
If PRINTER is invalid. CO=false BADPARAM, ERROR
204 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
PRNTR_FLUSH
Clears the print buffer for the specified printer without printing the contents of the buffer.
Syntax
MY_PRNTR_FLUSH( CI:=b1, PRINTER:=n1 ) ;
Description
The PRNTR_FLUSH function block clears the print buffer for the specified printer without
printing the contents of the buffer.
CI is the control input. CI enables evaluation. If CI is true, then perform the print operation. If
CI is false, then do nothing. The default initial value of CI is true.
PRINTER is a number that identifies the printer or print server. The valid range is different for
different controllers.
For the Tricon controller, all values are valid, however, the function block prints to port
10 if PRINTER=10, but prints to port 5 if PRINTER is any other number.
For the Trident v1.x controller, the valid range is 1 through 10.
For the Trident v2.x 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 ) ;
Table 249 Input Parameters
Name Data Type Description
CI BOOL Enables PRNTR_FLUSH.
PRINTER DINT Printer number.
Table 250 Output Parameters
Name Data Type Description
CO BOOL True if PRNTR_FLUSH executes successfully.
PRNTR_FLUSH 205
TriStation 1131 Libraries Reference
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
If the PRINTER parameter is invalid, then the function block aborts the print operation.
Note that this function block simply adds the print operation to a buffer and does not check the
status of the printer or print server. To read printer status (like printer ready, buffer overflow,
bytes free, bytes used), see SYS_CM_STATUS or TR_PORT_STATUS.
Application Notes
Can be used in Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, see Using a Space Saver
Function Block on page 5.
Library
Tricon (TR1LIB/TX1LIB)
Trident (TRDLIB)
Condition Return Value Error Flags
If PRINTER is invalid. CO=false BADPARAM, ERROR
206 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
R_TRIG
Detects a rising edge.
Syntax
MY_R_TRIG( CLK:=b1 ) ;
b2 := MY_R_TRIG.Q ;
Description
The R_TRIG function block sets the output Q on the rising edge of the CLK input. A rising edge
is a change from false to true (0 to 1). The output Q is true if the input CLK was false during the
previous evaluation but true during the current evaluation of the function block instance;
otherwise, the output Q is false.
Example
VAR CHECK_FOR_RISING_EDGE : R_TRIG ; END_VAR
VAR b : BOOL ; END_VAR
b := 0 ; (* no rising edge *)
CHECK_FOR_RISING_EDGE( CLK:=b ); (* Q is FALSE *)
b := 1 ; (* rising edge, 0 to 1 *)
CHECK_FOR_RISING_EDGE( CLK:=b ); (* Q is TRUE *)
b := 1 ; (* no rising edge *)
CHECK_FOR_RISING_EDGE( CLK:=b ); (* Q is FALSE *)
b := 0 ; (* no rising edge *)
CHECK_FOR_RISING_EDGE( CLK:=b ); (* Q is FALSE *)
(************ here is a bad example *********************)
b := 0 ; (* no rising edge *)
b := 1 ; (* rising edge, missed *)
b := 0 ; (* no rising edge *)
CHECK_FOR_RISING_EDGE( CLK:=b ); (* Q is FALSE *)
(************ end of bad example *********************)
Table 251 Input Parameters
Name Data Type Description
CLK BOOL Clock.
Table 252 Output Parameters
Name Data Type Description
Q BOOL True indicates rising edge detected.
R_TRIG 207
TriStation 1131 Libraries Reference
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Only Once: each instance should be executed only once per scan, but does not need to
be executed every scan. However, to prevent missing an edge, the instance should be
executed after every possible change in input value, which could be every scan or even
more than once per scan.
Can be used in CEM Cause and Effect cells.
Library
Standard (STDLIB)
208 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
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.
Gradual Underflow for REAL Data Types
In PCs and safety controllers, the floating-point implementation includes a standard feature
called gradual underflow. This feature extends the range of a REAL number and gradually
changes the precision as values approach zero.
This table compares the values obtained when gradual underflow is not present, to the values
obtained when it is present.
Attribute Description
Keyword/type REAL
Description Real number
Size 32 bits
Default value 0.0
Most positive number 3.402823466 e +38
Least positive number 1.401298464 e 45
Least negative number 1.401298464 e 45
Most negative number 3.402823466 e +38
Result if intermediate value is less than lower limit Infinity or HUGE
Result if upper limit is less than intermediate value +Infinity or HUGE
Without Gradual Underflow With Underflow
The smallest positive number that can be stored
in a REAL variable is:
2
126
= 1.175494351E-38.
The smallest positive number that can be stored in
a REAL variable is:
2
149
= 1.401298464E45.
The precision changes abruptly from 7 digits to 0
digits when the value changes from a number
greater than 2
127
to a number less than 2
127
.
The precision changes gradually from 7 digits to 1
digit as the value changes from 2
127
to 2
149
.
The maximum relative error changes abruptly
from 2
24
to 1 when the value changes from a
number greater than 2
127
to a number less than
2
127
.
The maximum relative error changes gradually
from 2
24
to 1 as the value changes from 2
127
to
2
149
.
For values from 2
150
to 2
126
, the maximum
absolute error equals the value.
For values from 2
150
to 2
126
, the maximum
absolute error is a constant 2
150
.
REAL 209
TriStation 1131 Libraries Reference
This table shows how the precision changes as numbers approach zero.
Absolute error is the absolute value of x a, where x is the exact value and a is the actual value
stored.
Relative error is the absolute value of (x a)/x, where x is the exact value and a is the actual value
stored.
This table shows how gradual underflow affects absolute error and relative error as REAL
numbers approach zero.
Application Notes
Can be used in Safety or Control applications.
Can be used in CEM Cause, Effect, and Intersection cells.
If |x| Is Greater Than:
Then the Precision 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
Range
Maximum
Absolute Error
Maximum
Relative Error
0 < |x| s 2
150
|x| 1
2
150
< |x| s 2
126
2
150
2
150
/ |x|
2
126
s |x| < 2
128
2
103
2
24
* |x| 2
24

210 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
REAL_TO_DINT
Converts a 32-bit real number to a 32-bit integer.
Syntax
k := REAL_TO_DINT( x );
Description
The REAL_TO_DINT function converts a 32-bit real number to a 32-bit integer. The result is
rounded to the nearest integer.
Note IEC 1131-3 requires strict data type checking. It does not permit assigning the value of a
variable directly to a variable of a different data type. When it is necessary to use
variables of different data types, an explicit conversion must be made using a data type
conversion function.
Example
VAR k : DINT; x : REAL; END_VAR;
x := -123.6;
k := REAL_TO_DINT( x ); (* result is -124 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the
error flags to true, and resets ENO to false. For more information about error flags and runtime
errors, see the CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
Table 253 Input Parameters
Name Data Type Description
x REAL The 32-bit number to be converted.
Table 254 Return Value
Data Type Description
DINT The value of x converted to a 32-bit integer.
Conditions Return Values Error Flags
If x is not a number. 2147483648 BADPARAM, ERROR
If x is less than -2147483648.5 2147483648 BADCONV, ERROR
If x is greater than or equal to +2147483647.5 +2147483647 BADCONV, ERROR
REAL_TO_INT 211
TriStation 1131 Libraries Reference
REAL_TO_INT
Converts a 32-bit real number to a 16-bit integer.
Syntax
k := REAL_TO_INT( x );
Description
The REAL_TO_INT function converts a 32-bit real number to a 16-bit integer. The result is
rounded to the nearest integer.
Note IEC 1131-3 requires strict data type checking. It does not permit assigning the value of a
variable directly to a variable of a different data type. When it is necessary to use
variables of different data types, an explicit conversion must be made using a data type
conversion function.
Example
VAR k : INT; x : REAL; END_VAR;
x := -123.6;
k := REAL_TO_INT( x ); (* result is -124 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the
error flags to true, and resets ENO to false. For more information about error flags and runtime
errors, see the CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
Table 255 Input Parameters
Name Data Type Description
x REAL The 32-bit number to be converted.
Table 256 Return Value
Data Type Description
INT The value of x converted to a 16-bit integer.
Conditions Return Values Error Flags
If x is not a number. 32768 BADPARAM, ERROR
If x is less than -32768.5 32768 BADCONV, ERROR
If x is greater than or equal to +32757.5 +32767 BADCONV, ERROR
212 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
REAL_TO_LREAL
Converts a 32-bit real number to a 64-bit long real number.
Syntax
y := REAL_TO_LREAL( x );
Description
The REAL_TO_LREAL function converts a 32-bit real number to a 64-bit long real number.
Note IEC 1131-3 requires strict data type checking. It does not permit assigning the value of a
variable directly to a variable of a different data type. When it is necessary to use
variables of different data types, an explicit conversion must be made using a data type
conversion function.
Example
VAR x : REAL END_VAR;
VAR y : LREAL END_VAR;
x := 6.25;
y = REAL_TO_LREAL(x); (* result is 6.25 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the
error flags to true, and resets ENO to false. For more information about error flags and runtime
errors, see the CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
Table 257 Input Parameters
Name Data Type Description
x REAL The 32-bit number to be converted.
Table 258 Return Value
Data Type Description
LREAL The value of x converted to a 64-bit long real number.
Condition Return Value Error Flags
If x is not a number NAN BADPARAM, ERROR
ReportBadParam 213
TriStation 1131 Libraries Reference
ReportBadParam
Reports a bad parameter error.
Syntax
b1 := ReportBadParam(I1) ;
Description
The ReportBadParam function resets ENO and sets the BAD PARAM and ERROR status flags.
When a Triconex library function detects a bad parameter, the function typically resets ENO
and sets the BADPARAM status flag. A user-defined function can call ReportBadParam() to do
the same thing.
A programmer can use ENO to isolate an error or to stop execution after detection of an error.
A programmer can use the status flags to read what errors have been detected. The CHK_ERR
function block reads the status flags.
Example
VAR NOT_USED, b1, b2 : BOOL ; STATUS : CHK_ERR ; END_VAR
ENO := true ;
NOT_USED := ReportBadParam(0) ;
b1 := ENO ; (* result is false *)
STATUS() ;
b2 := STATUS.BADPARAM ; (* result is true *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
Table 259 Input Parameters
Name Data Type Description
I1 INT Not used.
Table 260 Return Value
Data Type Description
BOOL Not used, always false.
214 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
ROL
Rotates left N bits, where N is the shift count.
Syntax
w := ROL( IN, N ) ;
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)
Table 261 Input Parameters
Name Data Type Description
IN ANY_BIT Operand
N ANY_INT Shift count.
Table 262 Return Value
Data Type Description
ANY_BIT IN rotated left N bits
ROR 215
TriStation 1131 Libraries Reference
ROR
Rotates right N bits, where N is the shift count.
Syntax
w := ROR( IN, N ) ;
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)
Table 263 Input Parameters
Name Data Type Description
IN ANY_BIT Operand.
N ANY_INT Shift count.
Table 264 Return Value
Data Type Description
ANY_BIT IN rotated left N bits
216 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
RS
RS is a bistable function block (reset dominant).
Syntax
RS( S:=b1, R1:=b2 ) ;
b3 := SR.Q1
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.
Example
VAR MY_RS : RS ; END_VAR
MY_RS( S:=FALSE, R1:=TRUE ); (* Q1 is FALSE *)
MY_RS( S:=FALSE, R1:=FALSE ); (* Q1 is FALSE *)
MY_RS( S:=TRUE, R1:=TRUE ); (* Q1 is FALSE *)
MY_RS( S:=TRUE, R1:=FALSE ); (* Q1 is TRUE *)
MY_RS( S:=FALSE, R1:=FALSE ); (* Q1 is TRUE *)
Runtime Errors
None.
Table 265 Input Parameters
Name Data Type Description
S BOOL Set.
R1 BOOL Reset.
Table 266 Output Parameters
Name Data Type Description
Q1 BOOL State
Table 267 Truth Table
S R1 Q1
false false no change
false true false
true false true
true true false
RS 217
TriStation 1131 Libraries Reference
Application Notes
Can be used in Safety or Control applications.
Only Once: each instance should be executed only once per scan, but does not need to
be executed every scan.
Can be used in CEM Cause and Effect cells.
Library
Standard (STDLIB)
218 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
RTC
Provides a real-time clock.
Syntax
MY_RTC( IN:=b1, PDT:=dt1 ) ;
Description
The RTC function block provides a real-time clock. Output CDT gives the current system date
and time. Output Q is a copy of input IN.
These are deviations from the IEC 61131-3 standard:
TriStation 1131 does not allow the program to set the system date and time, therefore
RTC does not use the PDT input.
TriStation 1131 names the enable input IN because the name EN has a special meaning
for functions (the standard conflicts with itself).
Output CDT is valid even when input IN is false.
Example
VAR MY_RTC : RTC ; END_VAR
MY_RTC() ; (* Output CDT is the current date and time. *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, see Using a Space Saver
Function Block on page 5.
Library
Standard (STDLIB)
Table 268 Input Parameters
Name Data Type Description
IN BOOL Enables RTC.
PDT DT Preset date and time.
Table 269 Output Parameters
Name Data Type Description
Q BOOL Copy of IN.
CDT DT The current date and time.
SCALE 219
TriStation 1131 Libraries Reference
SCALE
Scales a value from one engineering unit to another.
Syntax
y := SCALE( INPUT, MAX1, MIN1, MAX2, MIN2 )
Description
The Scale function scales a value from one engineering unit to another. The function returns the
scaled value.
The equation for the return value is:
SCALE := ((INPUT - MIN1)/(MAX1 - MIN1))* (MAX2 - MIN2) + MIN2 ;
Example
VAR y : REAL; END_VAR
y := SCALE( 8.0, 10.0, 5.0, 100.0, 50.0 ); (* result is 80.0 *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Triconex (TCXLIB)
Table 270 Input Parameters
Name Data Type Description
INPUT REAL The input value.
MAX1 REAL The maximum value in input units.
MIN1 REAL The minimum value in input units.
MAX2 REAL The maximum value in output units.
MIN2 REAL The minimum value in output units.
Table 271 Return Value
Data Type Description
REAL The scaled output value.
220 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
SEL
Selects one of two data values.
Syntax
v := SEL( G, IN0, IN1 ) ;
Description
The SEL function selects one of two data values depending on an input selector (G). If G is false,
the return value is the first data value IN0. If G is true, the return value is the second data value
IN1.
The data values can be any data type, but both data values must have the same data type as the
return value.
Example
v := SEL( G, IN0, IN1 ) ;
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
Table 272 Input Parameters
Name Data Type Description
G BOOL False selects IN0, true selects IN1.
IN0 ANY First data value..
IN1 ANY Second data value..
Table 273 Return Value
Data Type Description
ANY The output value.
SHL 221
TriStation 1131 Libraries Reference
SHL
Shifts left N bits, where N is the shift count.
Syntax
w := SHL( IN, N ) ;
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)
Table 274 Input Parameters
Name Data Type Description
IN ANY_BIT Operand
N ANY_INT Shift count.
Table 275 Return Value
Data Type Description
ANY_BIT IN shifted left N bits
222 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
SHR
Shifts right N bits, where N is the shift count.
Syntax
w := SHR( IN, N ) ;
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)
Table 276 Input Parameters
Name Data Type Description
IN ANY_BIT Operand
N ANY_INT Shift count
Table 277 Return Value
Data Type Description
ANY_BIT IN shifted right N bits
SIN 223
TriStation 1131 Libraries Reference
SIN
Calculates the sine of an angle.
Syntax
y := SIN( x ) ;
Description
The SIN function returns the sine of an angle given in radians. The result is in the range -1 to 1.
Example
VAR y : REAL; END_VAR
y := SIN( 1.570796 ); {* result is 1.0 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the
error flags to true, and resets ENO to false. For more information about error flags and runtime
errors, see the CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
Table 278 Input Parameters
Name Data Type Description
x ANY_REAL The angle, in radians.
Table 279 Return Value
Data Type Description
ANY_REAL The sine of x.
Conditions Return Values Error Flags
If x is not a number. NAN BADPARAM, ERROR
If the absolute value of x is greater than 2**63 NAN BADPARAM, ERROR
224 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
SOECLR
Clears a sequence of events (SOE) block.
Syntax
MY_SOECLR( CI:=b1, BLOCK:=n1 ) ;
Description
The SOECLR function block clears a sequence of events (SOE) block. SOECLR removes all
entries from the block and writes a SOECLR time stamp into the block. You must stop event
collection (using SOESTOP) before clearing the block.
If the SOECLR operation is successful, the output status is 2, indicating that the block is cleared.
If the event collection was not stopped before the SOECLR operation was attempted, the output
status is 0, 1, or 3.
If CI is false, no operation occurs (no output changes).
Example
For examples of using SOE function blocks, see these SOE sample projects:
(Tricon) My Documents\Triconex\TriStation 1131 4.x\Projects\ExSOE.pt2
(Trident) My Documents\Triconex\TriStation 1131 4.x\Projects\TdSOE.pt2
Table 280 Input Parameters
Name Data Type Description
CI BOOL Enables SOECLR.
BLOCK DINT The block number (116).
Table 281 Output Parameters
Name Data Type Description
CO BOOL True if SOECLR executes successfully.
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.
SOECLR 225
TriStation 1131 Libraries Reference
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, see Using a Space Saver
Function Block on page 5.
Library
Tricon (TR1LIB/TX1LIB)
Trident (TRDLIB)
Condition Return Value Error Flags
If the block number is out of range CO=false,
STAT=0
BADPARAM, ERROR
226 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
SOESTAT
Returns status for a sequence of events (SOE) block.
Syntax
MY_SOESTAT( CI:=b1, BLOCK:=n1 ) ;
Description
The SOESTAT function block returns status for a sequence of events (SOE) block, including the
number of 8-byte entries that are used, and the number of 8-byte entries that are free.
If CI is false, no operation occurs.
Example
For examples of using SOE function blocks, see these SOE sample projects:
(Tricon) My Documents\Triconex\TriStation 1131 4.x\Projects\ExSOE.pt2
(Trident) My Documents\Triconex\TriStation 1131 4.x\Projects\TdSOE.pt2
Table 282 Input Parameters
Name Data Type Description
CI BOOL Enables SOESTAT.
BLOCK DINT The block number (116).
Table 283 Output Parameters
Name Data Type Description
CO BOOL True if SOESTAT executes successfully.
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 The number of unused 8-byte entries in the block.
USED DINT The number of used 8-byte entries in the block.
SOESTAT 227
TriStation 1131 Libraries Reference
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, see Using a Space Saver
Function Block on page 5.
Library
Tricon (TR1LIB/TX1LIB)
Trident (TRDLIB)
Condition Return Value Error Flags
If the block number is out of range CO=false,
STAT=0,
FREE=0,
USED=0
BADPARAM, ERROR
228 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
SOESTOP
Writes a time stamp into a sequence of events (SOE) block, and changes the state of the block
from collecting to stopped.
Syntax
MY_SOESTOP( CI:=b1, BLOCK:=n1 ) ;
Description
The SOESTOP function block writes a time stamp into a sequence of events (SOE) block, and
changes the state of the block from collecting to stopped. Event collection stops until the next
SOESTRT operation.
If the SOESTOP operation is successful, the output status is 2, indicating that the event collection
is stopped. If CI is false, no operation occurs (no output changes).
Example
For examples of using SOE function blocks, see these SOE sample projects:
(Tricon) My Documents\Triconex\TriStation 1131 4.x\Projects\ExSOE.pt2
(Trident) My Documents\Triconex\TriStation 1131 4.x\Projects\TdSOE.pt2
Runtime Errors
Table 284 Input Parameters
Name Data Type Description
CI BOOL Enables SOESTOP.
BLOCK DINT The block number (116).
Table 285 Output Parameters
Name Data Type Description
CO BOOL True if SOESTOP executes successfully.
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.
Condition Return Value Error Flags
If the block number is out of range CO=false,
STAT=0
BADPARAM, ERROR
SOESTOP 229
TriStation 1131 Libraries Reference
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, see Using a Space Saver
Function Block on page 5.
Library
Tricon (TR1LIB/TX1LIB)
Trident (TRDLIB)
230 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
SOESTRT
Starts sequence of events (SOE) collection for an SOE block.
Syntax
MY_SOESTRT( CI:=b1, BLOCK:=n1 ) ;
Description
The SOESTRT function block starts sequence of events (SOE) collection for an SOE block. The
Main Processor writes an SOESTRT time stamp entry into the block and changes the state of the
block from not started or stopped to collecting. If the SOESTRT operation is successful, the
output status is 1, indicating that the block is collecting data.
If CI is false, no operation occurs (no output changes).
The SOESTRT function block must be executed for each SOE block you want to collect events
from.
Note The SOESTRT function block is executed once per scan, which means the resulting STAT
output is valid only for that scan.
Example
For examples of using SOE function blocks, see these SOE sample projects:
(Tricon) My Documents\Triconex\TriStation 1131 4.x\Projects\ExSOE.pt2
(Trident) My Documents\Triconex\TriStation 1131 4.x\Projects\TdSOE.pt2
Table 286 Input Parameters
Name Data Type Description
CI BOOL Enables SOESTRT.
BLOCK DINT The block number (116).
Table 287 Output Parameters
Name Data Type Description
CO BOOL True if SOESTRT executes successfully.
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.
SOESTRT 231
TriStation 1131 Libraries Reference
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, see Using a Space Saver
Function Block on page 5.
Library
Tricon (TR1LIB/TX1LIB)
Trident (TRDLIB)
Condition Return Value Error Flags
If the block number is out of range CO=false,
STAT=0
BADPARAM, ERROR
232 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
SQRT
Calculates the square root of a number.
Syntax
y := SQRT( x ) ;
Description
The SQRT function returns the square root of a number.
Example
VAR y : REAL; END_VAR
y := SQRT( 4.0 ); {* result is 2.0 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the
error flags to true, and resets ENO to false. For more information about error flags and runtime
errors, see the CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
Table 288 Input Parameters
Name Data Type Description
x ANY_REAL A real number.
Table 289 Return Value
Data Type Description
ANY_REAL The square root of x.
Conditions Return Values Error Flags
If x is not a number. NAN BADPARAM, ERROR
If x less than or equal to zero. NAN BADPARAM, ERROR
SR 233
TriStation 1131 Libraries Reference
SR
SR is a bistable function block (set dominant).
Syntax
SR( S1:=b1, R:=b2 ) ;
b3 := SR.Q1
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.
Example
VAR MY_SR : SR ; END_VAR
MY_SR( S1:=FALSE, R:=TRUE ); (* Q1 is FALSE *)
MY_SR( S1:=FALSE, R:=FALSE ); (* Q1 is FALSE *)
MY_SR( S1:=TRUE, R:=TRUE ); (* Q1 is TRUE *)
MY_SR( S1:=TRUE, R:=FALSE ); (* Q1 is TRUE *)
MY_SR( S1:=FALSE, R:=FALSE ); (* Q1 is TRUE *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Table 290 Input Parameters
Name Data Type Description
S1 BOOL Set
R BOOL Reset
Table 291 Output Parameters
Name Data Type Description
Q1 BOOL State
Table 292 Truth Table
S1 R Q1
false false no change
false true false
true false true
true true true
234 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Only Once: each instance should be executed only once per scan, but does not need to
be executed every scan.
Can be used in CEM Cause and Effect cells.
Library
Standard (STDLIB)
STRING 235
TriStation 1131 Libraries Reference
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.
Application Notes
Can be used in Safety or Control applications.
Can be used in CEM Cause, Effect, and Intersection cells.
Attribute Description
Keyword/type STRING
Description Character string
Size 136 bytes
Default Value Empty string (two single quotation marks not
separated by any characters)
Lower limit 0 characters
Upper limit 132 characters
Result if intermediate value is less than lower
limit
Truncated string
Result if upper limit is less than intermediate
value
N/A
236 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
SUB
Calculates the difference between two operands.
Subtracting a Number from Another Number
z := x - y ;
Subtracting a Time from a Date and Time
d2 := d1 - t ;
Subtracting a Time from a Time
t3 := t1 - t2 ;
Table 293 Input Parameters
Name Data Type Description
x ANY_NUM Minuend
y ANY_NUM Subtrahend
Table 294 Return Value
Data Type Description
ANY_NUM The difference x - y
Table 295 Input Parameters
Name Data Type Description
d1 DT Minuend
t TIME Subtrahend
Table 296 Return Value
Data Type Description
DT The difference d1 - t
Table 297 Input Parameters
Name Data Type Description
t1 TIME Minuend
t2 TIME Subtrahend
Table 298 Return Value
Data Type Description
TIME The difference t1 - t2
SUB 237
TriStation 1131 Libraries Reference
Subtracting a Time from a Time of Day
tod2 := tod1 - t ;
Description
The subtract operator () is used in Structured Text to calculate the difference between two
operands.
In the graphical languages, the SUB function is used instead of the subtract operator.
The subtract operator and SUB function:
Subtract a number from another number
Subtract a time from a date and time
Subtract a time from a time
Subtract a time from a time of day
Example
Subtract two numbers:
VAR m : DINT; END_VAR
m := 1564 - 10; (* result is 1554 *)
Subtract a time from a date and time:
VAR d : DT; END_VAR
d := DT#2002-01-27-08:00:00 - T#3h30m45s;
(* result is DT#2002-01-27-05:29:15 *)
Subtract a time from a time:
VAR t : TIME; END_VAR
t := T#11d22h33m - T#3h10m; (* result is T#11d19h23m *)
Subtract a time from a time of day:
VAR tod1 : TOD; END_VAR
tod1 := TOD#08:00:00 - T#3h30m45s; (* result is TOD#04:29:15 *)
Table 299 Input Parameters
Name Data Type Description
tod1 TIME OF DAY Minuend
t TIME Subtrahend
Table 300 Return Value
Data Type Description
TOD The difference tod1 - t
238 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the
error flags to true, and resets ENO to false. For more information about error flags and runtime
errors, see the CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
Condition Return Value Error Flags
If the result is infinite INF OVERFLOW, ERROR
If an operand is not a number (NAN) NAN OVERFLOW, ERROR
If the date and time is out of range Invalid date BADPARAM, ERROR
If the time is out of range Invalid time BADPARAM, ERROR
SYS_AI32_STATUS 239
TriStation 1131 Libraries Reference
SYS_AI32_STATUS
Gets the status of an Analog Input Module in a Trident controller.
Syntax
MY_SYS_AI32_STATUS( CI:=b1, IOP:=n1, SLOT:=n2 ) ;
Table 301 Input Parameters
Name Data Type Description
CI BOOL Enables SYS_AI32_STATUS.
IOP DINT The IOP (015).
SLOT DINT The slot number (056).
Table 302 Output Parameters
Name Data Type Description
CO BOOL True if SYS_AI32_STATUS executes successfully.
TMR BOOL Three channels are operating without fatal faults
detected.
GE_DUAL BOOL At least two channels are operating without fatal faults
detected.
GE_SINGLE BOOL At least one channel is operating without fatal faults
detected.
NO_FLTS BOOL No failed modules detected.
NO_ACTIVE_FLTS BOOL No faults on the active module detected.
LOGIC_PWR1_OK BOOL Logic Power 1 is OK.
LOGIC_PWR2_OK BOOL Logic Power 2 is OK.
PASS_LEFT BOOL The left module has no faults.
ACTIVE_LEFT BOOL The left module is active.
INSTALLED_LEFT BOOL The left module is installed.
LOCKED_LEFT BOOL The left module is locked.
PASS_RIGHT BOOL The right module has no faults.
ACTIVE_RIGHT BOOL The right module is active.
INSTALLED_RIGHT BOOL The right module is installed.
LOCKED_RIGHT BOOL The right module is locked.
NO_FLD_ALARM_LEFT BOOL The left module field alarm indicator is off.
NO_FLD_ALARM_RIGHT BOOL The right module field alarm indicator is off.
FLD_PWR1_OK BOOL Field power 1 is OK.
FLD_PWR2_OK BOOL Field power 2 is OK.
240 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Description
The SYS_AI32_STATUS function block gets the status of an Analog Input Module in a Trident
controller.
Example
VAR MY_AI : SYS_AI32_STATUS ; END_VAR
VAR AI_ACTIVE : BOOL ; END_VAR
MY_AI( CI:=TRUE, IOP:=1, SLOT:=5 ) ;
AI_ACTIVE := MY_AI.LEFT_ACTIVE OR MY_AI.RIGHT_ACTIVE ;
(*
* Result : AI_ACTIVE is TRUE if there is
* an active AI32 module in slot 5.
*)
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, see Using a Space Saver
Function Block on page 5.
Library
Trident (TRDLIB)
NO_FLD_FLTS BOOL No field faults detected.
NO_VOTER_FLTS BOOL No voter faults detected.
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.
Condition Return Value Error Flags
If ERROR_NUM is non-zero Reset all BOOL outputs to false BADPARAM, ERROR
Table 302 Output Parameters (continued)
Name Data Type Description
SYS_AO04_STATUS 241
TriStation 1131 Libraries Reference
SYS_AO04_STATUS
Gets the status of an Analog Output Module.
Syntax
MY_SYS_AO04_STATUS( CI:=b1, IOP:=n1, SLOT:=n2 ) ;
Table 303 Input Parameters
Nam
e
Data Type Description
CI BOOL Enables SYS_AO04_STATUS.
IOP DINT The IOP (015).
SLOT DINT The slot number (056).
Table 304 Output Parameters
Name Data Type Description
CO BOOL True if SYS_AO04_ST executes successfully.
TMR BOOL Three channels are operating without fatal faults detected.
GE_DUAL BOOL At least two channels are operating without fatal faults
detected.
GE_SINGLE BOOL At least one channel are operating without fatal faults
detected.
NO_FLTS BOOL No failed modules detected.
NO_ACTIVE_FLTS BOOL No faults on the active module detected.
LOGIC_PWR1_OK BOOL Logic Power 1 is OK.
LOGIC_PWR2_OK BOOL Logic Power 2 is OK.
PASS_LEFT BOOL The left module has no faults.
ACTIVE_LEFT BOOL The left module is active.
INSTALLED_LEFT BOOL The left module is installed.
LOCKED_LEFT BOOL The left module is locked.
PASS_RIGHT BOOL The right module has no faults.
ACTIVE_RIGHT BOOL The right module is active.
INSTALLED_RIGHT BOOL The right module is installed.
LOCKED_RIGHT BOOL The right module is locked.
NO_FLD_ALARM_LEFT BOOL The left module field alarm indicator is off.
NO_FLD_ALARM_RIGHT BOOL The right module field alarm indicator is off.
FLD_PWR1_OK BOOL Field power 1 is OK.
FLD_PWR2_OK BOOL Field power 2 is OK.
242 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Description
The SYS_AO04_STATUS function block gets the status of an Analog Output Module.
Example
VAR MY_AO : SYS_AO04_STATUS ; END_VAR
VAR AO_ACTIVE : BOOL ; END_VAR
MY_AO( CI:=TRUE, IOP:=1, SLOT:=5 ) ;
AO_ACTIVE := MY_AO.LEFT_ACTIVE OR MY_AO.RIGHT_ACTIVE ;
(*
* Result : AO_ACTIVE is TRUE if there is
* an active AO04 module in slot 5.
*)
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, see Using a Space Saver
Function Block on page 5.
Library
Trident (TRDLIB)
NO_FLD_FLTS BOOL No field faults detected on module.
NO_VOTER_FLTS BOOL No voter faults detected on module.
FLD_OK01 BOOL Field wiring for point 01 is OK .
FLD_OK02 BOOL Field wiring for point 02 is OK .
FLD_OK03 BOOL Field wiring for point 03 is OK .
FLD_OK04 BOOL Field wiring for point 04 is OK .
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.
Condition Return Value Error Flags
If ERROR_NUM is non-zero Reset all BOOL outputs to false BADPARAM, ERROR
Table 304 Output Parameters (continued)
Name Data Type Description
SYS_APP_HALT 243
TriStation 1131 Libraries Reference
SYS_APP_HALT
Halts the application.
Syntax
n1 := SYS_APP_HALT( b1 ) ;
Description
The SYS_APP_HALT function halts the application. Halting the application stops execution of
the control program at the end of the current scan and initializes the variables.
APP_HALT enables the function. If APP_HALT is true, then halt the application. If APP_HALT
is false, then do not halt.
Example
(* Halt the application. *)
VAR n : DINT; END_VAR
n := SYS_APP_HALT( TRUE ); {* result is 0 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the
error flags to true, and resets ENO to false. For more information about error flags and runtime
errors, see the CHK_ERR function block.Application Notes
Can be used in Safety or Control applications.
Library
Trident (TRDLIB)
Table 305 Input Parameters
Name Data Type Description
APP_HALT BOOL True means halt the application; false means do not halt.
Table 306 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.
Condition Return Value Error Flags
If error number is non-zero. Error number BADPARAM, ERROR
244 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
SYS_CLEAR_FLTS
Clear all faults in the system.
Syntax
n1 := SYS_CLEAR_FLTS( b1 ) ;
Description
The SYS_CLEAR_FLTS clears all faults in the system.
Halting the application stops execution of the control program at the end of the current scan and
initializes the variables.
CLEAR_FLTS enables the function. If APP_HALT is true, then halt the application. If
APP_HALT is false, then do not halt.
Example
(* Clear system faults. *)
VAR n : DINT; END_VAR
n := SYS_CLEAR_FLTS( TRUE ); {* result is 0 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the
error flags to true, and resets ENO to false. For more information about error flags and runtime
errors, see the CHK_ERR function block.
Table 307 Input Parameters
Name Data Type Description
CLEAR_FLTS BOOL True means clear faults; false means do not clear.
Table 308 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.
Condition Return Value Error Flags
If error number is non-zero. Error number BADPARAM, ERROR
SYS_CLEAR_FLTS 245
TriStation 1131 Libraries Reference
Application Notes
Can be used in Safety or Control applications.
Library
Trident (TRDLIB)
246 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
SYS_CM_STATUS
Gets the status of a Trident Communication Module.
Syntax
MY_SYS_CM_STATUS( CI:=b1, IOP:=n1, SLOT:=n2 ) ;
Table 309 Input Parameters
Name Data Type Description
CI BOOL Enables SYS_CM_STATUS.
IOP DINT The IOP (0).
SLOT DINT The slot number (2 or 3).
Table 310 Output Parameters
Name Data Type Description
CO BOOL True if executes SYS_CM_STATUS successfully.
NO_FLTS BOOL No faults on CM detected.
LOGIC_PWR1_OK BOOL Logic Power 1 is OK.
LOGIC_PWR2_OK BOOL Logic Power 2 is OK.
PASS BOOL The CM has no faults.
ACTIVE BOOL The CM is active.
INSTALLED BOOL The CM is installed.
LOCKED BOOL The CM is locked.
NET1_OK BOOL Net1 port is receiving messages.
NET2_OK BOOL Net2 port is receiving messages.
PRNTR_READY BOOL The print server is connected.
PRNTR_NO_OVRFLW BOOL No printer buffer overflow.
STATS_RESET_SERIAL_1 BOOL The statistics were reset for serial port 1.
STATS_RESET_SERIAL_2 BOOL The statistics were reset for serial port 2.
STATS_RESET_SERIAL_3 BOOL The statistics were reset for serial port 3.
CM_TEMP DINT The current CM temperature.
MSGS_SERIAL_1 DINT The number of messages received on serial port 1.
BRDCSTS_SERIAL_1 DINT The number of broadcast messages received on serial port
1.
RSPNS_SERIAL_1 DINT The number of responses sent on serial port 1.
BAD_MSGS_SERIAL_1 DINT The number of bad messages received on serial port 1.
SYS_CM_STATUS 247
TriStation 1131 Libraries Reference
Description
The Status 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.
*)
ELAPSED_SERIAL_1 DINT The milliseconds since the last message was received on
serial port 1.
MSGS_SERIAL_2 DINT The number of messages received on serial port 2.
BRDCSTS_SERIAL_2 DINT The number of broadcast messages received on serial port
2.
RSPNS_SERIAL_2 DINT The number of responses sent on serial port 2.
BAD_MSGS_SERIAL_2 DINT The number of bad messages received on serial port 2.
ELAPSED_SERIAL_2 DINT The milliseconds since the last message was received on
serial port 2.
MSGS_SERIAL_3 DINT The number of messages received on serial port 3.
BRDCSTS_SERIAL_3 DINT The number of broadcast messages received on serial port
3.
RSPNS_SERIAL_3 DINT The number of responses sent on serial port 3.
BAD_MSGS_SERIAL_3 DINT The number of bad messages received on serial port 3.
ELAPSED_SERIAL_3 DINT The milliseconds since the last message was received on
serial port 3.
PRNTR_BYTES_FREE DINT The printer buffer bytes free.
PRNTR_BYTES_USED DINT The printer buffer bytes used.
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.
Table 310 Output Parameters (continued)
Name Data Type Description
248 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, see Using a Space Saver
Function Block on page 5.
Library
Trident (TRDLIB)
Condition Return Value Error Flags
If ERROR_NUM is non-zero Reset all outputs except ERROR_NUM to
zero.
BADPARAM, ERROR
SYS_CRITICAL_IO 249
TriStation 1131 Libraries Reference
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 ) ;
Description
The SYS_CRITICAL_IO function block accumulates the status of safety-critical I/O modules.
For more information, see the Trident Safety Considerations Guide.
Instructions for Use
To initialize, invoke once with RESET := TRUE.
Table 311 Input Parameters
Name Data Type Description
CI BOOL Enables SYS_CRITICAL_IO.
RESET BOOL Resets .
IOP DINT The IOP (015).
SLOT DINT The slot number (056).
APP DINT The application number (1-2).
RELAY_OK BOOL The relay is energized and not stuck.
Table 312 Output Parameters
Name Data Type Description
CO BOOL True if SYS_CRITICAL_IO executes successfully.
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 No voter faults detected on critical modules.
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.
250 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
To complete initialization, invoke again with these input settings:
RESET := FALSE
CI := TRUE
APP := DE_ENERGIZED
RELAY_OK := false
To get the status of a safety-critical I/O module:
For each module, invoke specifying the input values:
IOP
SLOT
APP
RELAY_OK
For example, if IOP 1 SLOT 1 is a critical DO module with a relay, and SCIO is the
function block instance name:
SCIO( IOP:=1, SLOT:=1, APP:=RELAY,RELAY_OK:=RELAY1_OK );
Read the output values:
CO
TMR
GE_DUAL
GE_SINGLE
Example
For shutdown examples, see this sample project:
My Documents\Triconex\TriStation 1131 4.x\Projects\TdTUV.pt2
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Trident (TRDLIB)
Condition Return Value Error Flags
If ERROR_NUM is non-zero Reset all BOOL outputs to false BADPARAM, ERROR
SYS_DI16_AI16_STATUS 251
TriStation 1131 Libraries Reference
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 313 Input Parameters
Name Data Type Description
CI BOOL Enables SYS_DI16_A16_STATUS.
IOP DINT The IOP (015).
SLOT DINT The slot number (056).
Table 314 Output Parameters
Name Data Type Description
CO BOOL True if SYS_DI16_A16_STATUS executes successfully.
TMR BOOL Three channels are operating without faults on all critical
I/O modules.
GE_DUAL BOOL At least two channels are operating without faults on all
critical I/O modules.
GE_SINGLE BOOL At least one channel is operating without faults on all
critical I/O modules.
NO_FLTS BOOL No failed modules detected.
NO_ACTIVE_FLTS BOOL No faults on the active module detected.
LOGIC_PWR1_OK BOOL Logic Power 1 is OK.
LOGIC_PWR2_OK BOOL Logic Power 2 is OK.
PASS_LEFT BOOL The left module has no faults.
ACTIVE_LEFT BOOL The left module is active.
INSTALLED_LEFT BOOL The left module is installed.
LOCKED_LEFT BOOL The left module is locked.
PASS_RIGHT BOOL The right module has no faults.
ACTIVE_RIGHT BOOL The right module is active.
INSTALLED_RIGHT BOOL The right module is installed.
LOCKED_RIGHT BOOL The right module is locked.
NO_FLD_ALARM_LEFT BOOL The left module field alarm indicator is off.
NO_FLD_ALARM_RIGHT BOOL The right module field alarm indicator is off.
FLD_PWR1_OK BOOL Field power 1 is OK.
FLD_PWR2_OK BOOL Field power 2 is OK.
252 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Description
The SYS_DI16_A16_STATUS function block gets the status of a combo AI/DI input module.
Example
VAR MY_AIDI : SYS_DI16_AI16_STATUS ; END_VAR
VAR AIDI_ACTIVE : BOOL ; END_VAR
MY_AIDI( CI:=TRUE, IOP:=1, SLOT:=5 ) ;
AIDI_ACTIVE := MY_AIDI.LEFT_ACTIVE OR MY_AIDI.RIGHT_ACTIVE ;
(*
* Result : AIDI_ACTIVE is TRUE if there is
* an active AI/DI combo module in slot 5.
*)
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, see Using a Space Saver
Function Block on page 5.
Library
Trident (TRDLIB)
5

NO_FLD_FLTS BOOL No field faults detected.
NO_VOTER_FLTS BOOL No voter faults detected.
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.
Condition Return Value Error Flags
If ERROR_NUM is non-zero Reset all BOOL outputs to false BADPARAM, ERROR
5. This function was added to the library in v1.114 of TRDLIB, first released with TriStation 1131 v4.3.
Table 314 Output Parameters (continued)
Name Data Type Description
SYS_DI32_STATUS 253
TriStation 1131 Libraries Reference
SYS_DI32_STATUS
Gets the status of a discrete input module.
Syntax
MY_SYS_DI32_STATUS( CI:=b1, IOP:=n1, SLOT:=n2 ) ;
Table 315 Input Parameters
Name Data Type Description
CI BOOL Enables SYS_DI32_STATUS.
IOP DINT The IOP (015).
SLOT DINT The slot number (056).
Table 316 Output Parameters
Name Data Type Description
CO BOOL True if SYS_DI32_STATUS executes successfully.
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_FLTS BOOL No failed modules detected.
NO_ACTIVE_FLTS BOOL No faults on the active module detected.
LOGIC_PWR1_OK BOOL Logic Power 1 is OK.
LOGIC_PWR2_OK BOOL Logic Power 2 is OK.
PASS_LEFT BOOL The left module has no faults.
ACTIVE_LEFT BOOL The left module is active.
INSTALLED_LEFT BOOL The left module is installed.
LOCKED_LEFT BOOL The left module is locked.
PASS_RIGHT BOOL The right module has no faults.
ACTIVE_RIGHT BOOL The right module is active.
INSTALLED_RIGHT BOOL The right module is installed.
LOCKED_RIGHT BOOL The right module is locked.
NO_FLD_ALARM_LEFT BOOL The left module field alarm indicator is off.
NO_FLD_ALARM_RIGHT BOOL The right module field alarm indicator is off.
FLD_PWR1_OK BOOL Field power 1 is OK.
FLD_PWR2_OK BOOL Field power 2 is OK.
254 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Description
The SYS_DI32_STATUS function block gets the status of a discrete input module.
Example
VAR MY_DI : SYS_DI32_STATUS ; END_VAR
VAR DI_ACTIVE : BOOL ; END_VAR
MY_DI( CI:=TRUE, IOP:=1, SLOT:=5 ) ;
DI_ACTIVE := MY_DI.LEFT_ACTIVE OR MY_DI.RIGHT_ACTIVE ;
(*
* Result : DI_ACTIVE is TRUE if there is
* an active DI32 module in slot 5.
*)
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, see Using a Space Saver
Function Block on page 5.
Library
Trident (TRDLIB)
NO_FLD_FLTS BOOL No field faults detected (always true
a
).
NO_VOTER_FLTS BOOL No voter faults detected (always true
a
).
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.
Condition Return Value Error Flags
If ERROR_NUM is non-zero Reset all BOOL outputs to false BADPARAM, ERROR
Table 316 Output Parameters (continued)
Name Data Type Description
SYS_DO16_STATUS 255
TriStation 1131 Libraries Reference
SYS_DO16_STATUS
Gets the status of a discrete output module.
Syntax
MY_SYS_DO16_STATUS( CI:=b1, IOP:=n1, SLOT:=n2 ) ;
Table 317 Input Parameters
Name Data Type Description
CI BOOL Enables SYS_DO16_STATUS.
IOP DINT The IOP (015).
SLOT DINT The slot number (056).
Table 318 Output Parameters
Name Data Type Description
CO BOOL True if SYS_DO16_STATUS executes successfully.
TMR BOOL Three channels are operating without fatal faults detected.
GE_DUAL BOOL At least two channels are operating without fatal faults
detected.
GE_SINGLE BOOL At least one channel are operating without fatal faults
detected.
NO_FLTS BOOL No failed modules detected.
NO_ACTIVE_FLTS BOOL No faults on the active module detected.
LOGIC_PWR1_OK BOOL Logic Power 1 is OK.
LOGIC_PWR2_OK BOOL Logic Power 2 is OK.
PASS_LEFT BOOL The left module has no faults.
ACTIVE_LEFT BOOL The left module is active.
INSTALLED_LEFT BOOL The left module is installed.
LOCKED_LEFT BOOL The left module is locked.
PASS_RIGHT BOOL The right module has no faults.
ACTIVE_RIGHT BOOL The right module is active.
INSTALLED_RIGHT BOOL The right module is installed.
LOCKED_RIGHT BOOL The right module is locked.
NO_FLD_ALARM_LEFT BOOL The left module field alarm indicator is off.
NO_FLD_ALARM_RIGHT BOOL The right module field alarm indicator is off.
FLD_PWR1_OK BOOL Field power 1 is OK.
FLD_PWR2_OK BOOL Field power 2 is OK.
256 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Description
The SYS_DO16_STATUS function block gets the status of a discrete output module.
Example
VAR MY_DO : SYS_DO16_STATUS ; END_VAR
VAR DO_ACTIVE : BOOL ; END_VAR
MY_DO( CI:=TRUE, IOP:=1, SLOT:=5 ) ;
DO_ACTIVE := MY_DO.LEFT_ACTIVE OR MY_DO.RIGHT_ACTIVE ;
(*
* Result : DO_ACTIVE is TRUE if there is
* an active DO16 module in slot 5.
*)
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, see Using a Space Saver
Function Block on page 5.
Library
Trident (TRDLIB)
NO_FLD_FLTS BOOL No field faults detected on module.
NO_VOTER_FLTS BOOL No voter faults detected on module.
OVD_RUNNING_01_16 DWORD OVD points 0116 are OK.
FLD_OK_01_16 DWORD Field points 0116 are OK.
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.
Condition Return Value Error Flags
If ERROR_NUM is non-zero Reset all BOOL outputs to false BADPARAM, ERROR
Table 318 Output Parameters (continued)
Name Data Type Description
SYS_HRDI32_STATUS 257
TriStation 1131 Libraries Reference
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 319 Input Parameters
Name Data Type Description
CI BOOL Enables SYS_HRDI32_STATUS.
IOP DINT The IOP (015).
SLOT DINT The slot number (056).
Table 320 Output Parameters
Name Data Type Description
CO BOOL True if SYS_HRDI32_STATUS executes successfully.
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_FLTS BOOL No failed modules detected.
NO_ACTIVE_FLTS BOOL No faults on the active module detected.
LOGIC_PWR1_OK BOOL Logic Power 1 is OK.
LOGIC_PWR2_OK BOOL Logic Power 2 is OK.
PASS_LEFT BOOL The left module has no faults.
ACTIVE_LEFT BOOL The left module is active.
INSTALLED_LEFT BOOL The left module is installed.
LOCKED_LEFT BOOL The left module is locked.
PASS_RIGHT BOOL The right module has no faults.
ACTIVE_RIGHT BOOL The right module is active.
INSTALLED_RIGHT BOOL The right module is installed.
LOCKED_RIGHT BOOL The right module is locked.
NO_FLD_ALARM_LEFT BOOL The left module field alarm indicator is off.
NO_FLD_ALARM_RIGHT BOOL The right module field alarm indicator is off.
FLD_PWR1_OK BOOL Field power 1 is OK.
FLD_PWR2_OK BOOL Field power 2 is OK.
258 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Description
The SYS_HRDI32_STATUS function block gets the status of a high-resolution discrete input
module.
CO is the control ouput. CO follows CI if no runtime error is detected. CO=true indicates that
the function block was enabled and executed successfully, with no runtime error. CO=false and
CI=true indicates a runtime error was detected. CO=false and CI=false indicates no operation.
Example
VAR MY_HRDI : SYS_HRDI32_STATUS ; END_VAR
VAR HRDI_ACTIVE : BOOL ; END_VAR
MY_HRDI( CI:=TRUE, IOP:=1, SLOT:=5 ) ;
HRDI_ACTIVE := MY_HRDI.LEFT_ACTIVE OR MY_HRDI.RIGHT_ACTIVE ;
(*
* Result : HRDI_ACTIVE is TRUE if there is
* an active HRDI32 module in slot 5.
*)
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
NO_FLD_FLTS BOOL No field faults detected (always true
a
).
NO_VOTER_FLTS BOOL No voter faults detected (always true
a
).
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.
Condition Return Value Error Flags
If ERROR_NUM is non-zero Reset all BOOL outputs to false BADPARAM, ERROR
Table 320 Output Parameters (continued)
Name Data Type Description
SYS_HRDI32_STATUS 259
TriStation 1131 Libraries Reference
Application Notes
Can be used in Safety or Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, see Using a Space Saver
Function Block on page 5.
Library
Trident (TRDLIB)
6

6. This function was added to the library in v1.120 of TRDLIB, first released with TriStation 1131 v4.6.
260 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
SYS_IO_STATUS
Gets the status of an I/O module.
Syntax
MY_SYS_IO_STATUS( CI:=b1, IOP:=n1, SLOT:=n2 ) ;
Table 321 Input Parameters
Name Data Type Description
CI BOOL Enables SYS_IO_STATUS.
IOP DINT The IOP (015).
SLOT DINT The slot number (056).
Table 322 Output Parameters
Name Data Type Description
CO BOOL True if SYS_IO_STATUS executes successfully.
TMR BOOL Three channels are operating without fatal faults detected.
GE_DUAL BOOL At least two channels are operating without fatal faults
detected.
GE_SINGLE BOOL At least one channel are operating without fatal faults
detected.
NO_FLTS BOOL No failed modules detected.
NO_ACTIVE_FLTS BOOL No faults on the active module detected.
LOGIC_PWR1_OK BOOL Logic Power 1 is OK.
LOGIC_PWR2_OK BOOL Logic Power 2 is OK.
PASS_LEFT BOOL The left module has no faults.
ACTIVE_LEFT BOOL The left module is active.
INSTALLED_LEFT BOOL The left module is installed.
LOCKED_LEFT BOOL The left module is locked.
PASS_RIGHT BOOL The right module has no faults.
ACTIVE_RIGHT BOOL The right module is active.
INSTALLED_RIGHT BOOL The right module is installed.
LOCKED_RIGHT BOOL The right module is locked.
NO_FLD_ALARM_LEFT BOOL The left module field alarm indicator is off.
NO_FLD_ALARM_RIGHT BOOL The right module field alarm indicator is off.
FLD_PWR1_OK BOOL Field power 1 is OK.
FLD_PWR2_OK BOOL Field power 2 is OK.
SYS_IO_STATUS 261
TriStation 1131 Libraries Reference
Description
The SYS_IO_STATUS function block gets the status of an I/O module.
Example
VAR MY_IO : SYS_IO_STATUS ; END_VAR
VAR IO_ACTIVE : BOOL ; END_VAR
MY_IO( CI:=TRUE, IOP:=1, SLOT:=5 ) ;
IO_ACTIVE := MY_IO.LEFT_ACTIVE OR MY_IO.RIGHT_ACTIVE ;
(*
* Result : IO_ACTIVE is TRUE if there is
* an active IO module in slot 5.
*)
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, see Using a Space Saver
Function Block on page 5.
Library
Trident (TRDLIB)
NO_FLD_FLTS BOOL No field faults detected on module.
NO_VOTER_FLTS BOOL No voter faults detected on module.
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.
Condition Return Value Error Flags
If ERROR_NUM is non-zero Reset all BOOL outputs to false BADPARAM, ERROR
Table 322 Output Parameters (continued)
Name Data Type Description
262 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
SYS_IOP_STATUS
Gets the status of a Trident I/O Processor.
Syntax
MY_SYS_IOP_STATUS( CI:=b1, IOP:=n1 ) ;
Table 323 Input Parameters
Name Data Type Description
CI BOOL Enables SYS_IOP_STATUS.
IOP DINT The IOP (015).
Table 324 Output Parameters
Name Data Type Description
CO BOOL True if SYS_IOP_STATUS executes successfully.
TMR BOOL Three channels are operating without fatal faults
detected.
GE_DUAL BOOL At least two channels are operating without fatal faults
detected.
GE_SINGLE BOOL At least one channel is operating without fatal faults
detected.
NO_FLTS BOOL No failed modules detected.
LOGIC_PWR1_OK BOOL Logic power 1 is OK.
LOGIC_PWR2_OK BOOL Logic power 2 is OK.
PASS_LEFT BOOL The left module has no faults.
ACTIVE_LEFT BOOL The left module is active.
INSTALLED_LEFT BOOL The left module is installed.
LOCKED_LEFT BOOL The left module is locked.
PASS_MID BOOL The middle module has no faults.
ACTIVE_MID BOOL The middle module is active.
INSTALLED_MID BOOL The middle module is installeds
LOCKED_MID BOOL The middle module is locked.
PASS_RIGHT BOOL The right module has no faults.
ACTIVE_RIGHT BOOL The right module is active.
INSTALLED_RIGHT BOOL The right module is installed.
LOCKED_RIGHT BOOL The right module is locked.
IO_TMR BOOL Three channels are operating without fatal faults detected
on the I/O string.
SYS_IOP_STATUS 263
TriStation 1131 Libraries Reference
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.
*)
IO_GE_Dual BOOL At least two channels are operating without fatal faults
detected on the I/O string.
IO_GE_Single BOOL At least one channel is operating without fatal faults
detected on the I/O string.
IO_NO_FLTS BOOL No faults on the I/O string detected.
IO_NO_ACTIVE_FLTS BOOL No faults on the active I/O module detected.
IO_NO_VOTER_FLTS BOOL No voter faults on the I/O string detected.
IO_NO_FLD_FLTS BOOL No field faults on the I/O string detected.
IO_LOGIC_PWR1_OK BOOL Logic power 1 is OK on I/O string.
IO_LOGIC_PWR2_OK BOOL Logic power 2 is OK on I/O string.
IO_FLD_PWR1_OK BOOL Field power 1 is OK on I/O string.
IO_FLD_PWR2_OK BOOL Field power 2 is OK on I/O string.
DISCRETE_POLL_TIME DINT The discrete poll time.
ANALOG_POLL_TIME DINT The analog poll time.
REAL_POLL_TIME DINT The real poll time.
STRUCTURE_POLL_TIME DINT The structure poll time.
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.
Table 324 Output Parameters (continued)
Name Data Type Description
264 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, see Using a Space Saver
Function Block on page 5.
Library
Trident (TRDLIB)
Condition Return Value Error Flags
If ERROR_NUM is non-zero Reset all outputs except ERROR_NUM to
zero.
BADPARAM, ERROR
SYS_MP_EXT_STATUS 265
TriStation 1131 Libraries Reference
SYS_MP_EXT_STATUS
Gets the extended status of a Trident Main Processor Module.
Syntax
MY_SYS_MP_EXT_STATUS( CI:=b1 ) ;
Table 325 Input Parameters
Name Data Type Description
CI BOOL Enables SYS_MP_STATUS.
Table 326 Output Parameters
Name Data Type Description
CO BOOL True if SYS_MP_STATUS executes successfully.
REQUESTED_SCAN_TIME DINT The requested scan time in milliseconds.
ACTUAL_SCAN_TIME DINT The actual scan time in milliseconds.
SURPLUS_SCAN_TIME DINT The surplus scan time in milliseconds.
SCAN_OVERRUNS DINT The number of scan overruns.
TEMP_LEFT DINT The temperature of the left MP.
TEMP_MID DINT The temperature of the middle MP.
TEMP_RIGHT DINT The temperature of the right MP.
POINTS_DISABLED DINT The number of disabled points.
APP_STATE DINT Application states:
0 = Running
1 = Halted
2 = Paused
3 = Trapped
MSGS_PORT_LEFT DINT The number of messages received on the left port.
BRDCSTS_PORT_LEFT DINT The number of broadcast messages received on the left
port.
RSPNS_PORT_LEFT DINT The number of response messages sent on the left port.
BAD_MSGS_PORT_LEFT DINT The number of bad messages received on the left port.
ELAPSED_PORT_LEFT DINT The number of milliseconds since last message was
received on left port.
MSGS_PORT_MID DINT The number of messages received on the middle port.
BRDCSTS_PORT_MID DINT The number of broadcast messages received on the
middle port.
RSPNS_PORT_MID DINT The number of response messages sent on the middle
port.
266 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
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
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.
BAD_MSGS_PORT_MID DINT The number of bad messages received on the middle
port.
ELAPSED_PORT_MID DINT The number of milliseconds since last message was
received on middle port.
MSGS_PORT_RIGHT DINT The number of messages received on the right port.
BRDCSTS_PORT_RIGHT DINT The number of broadcast messages received on the right
port.
RSPNS_PORT_RIGHT DINT The number of response messages sent on the right port.
BAD_MSGS_PORT_RIGHT DINT The number of bad messages received on the right port.
ELAPSED_PORT_RIGHT DINT The number of milliseconds since last message was
received on right port.
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.
Condition Return Value Error Flags
If ERROR_NUM is non-zero Reset all outputs except ERROR_NUM to
zero.
BADPARAM, ERROR
Table 326 Output Parameters (continued)
Name Data Type Description
SYS_MP_EXT_STATUS 267
TriStation 1131 Libraries Reference
Application Notes
Can be used in Safety or Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, see Using a Space Saver
Function Block on page 5.
Library
Trident (TRDLIB)
268 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
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 )
;
Description
The SYS_MP_RESET_PORTS function block resets statistics for Modbus ports on the MP.
Each Boolean input controls one Modbus port on the main processor (MP). Calling the function
with a Boolean input true resets statistics for the corresponding Modbus port. If a Boolean input
is false, then do not reset statistics for the corresponding Modbus port.
Example
(* Reset statistics for the left port on the MP. *)
VAR n : DINT; END_VAR
n := SYS_MP_RESET_PORTS( TRUE, FALSE, FALSE );
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the
error flags to true, and resets ENO to false. For more information about error flags and runtime
errors, see the CHK_ERR function block.
Table 327 Input Parameters
Name Data Type Description
RESET_PORT_LEFT BOOL Reset statistics for the left Modbus port on the MP.
RESET_PORT_MID BOOL Reset statistics for the middle Modbus port on the MP.
RESET_PORT_RIGHT BOOL Reset statistics for the right Modbus port on the MP.
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.
Condition Return Value Error Flags
If error number is non-zero. Error number BADPARAM, ERROR
SYS_MP_RESET_PORTS 269
TriStation 1131 Libraries Reference
Application Notes
Can be used in Safety or Control applications.
Library
Trident (TRDLIB)
270 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
SYS_MP_STATUS
Gets the status of the Trident Main Processor Modules.
Syntax
MY_SYS_MP_STATUS( CI:=b1 ) ;
Table 329 Input Parameters
Name Data Type Description
CI BOOL Enables SYS_MP_STATUS.
Table 330 Output Parameters
Name Data Type Description
CO BOOL True if SYS_MP_STATUS executes successfully.
TMR BOOL Three channels are operating without fatal faults
detected.
GE_DUAL BOOL At least two channels are operating without fatal
faults detected.
NO_FLTS BOOL No failed modules detected.
LOGIC_PWR1_OK BOOL Logic Power 1 is OK.
LOGIC_PWR2_OK BOOL Logic Power 2 is OK.
PASS_LEFT BOOL The left module has no faults.
ACTIVE_LEFT BOOL The left module is active.
INSTALLED_LEFT BOOL The left module is installed.
LOCKED_LEFT BOOL The left module is locked.
BATT_OK_LEFT BOOL The left module battery is OK.
NET_OK_LEFT BOOL The left port is receiving messages.
PASS_MID BOOL The middle module has no faults.
ACTIVE_MID BOOL The middle module is active.
INSTALLED_MID BOOL The middle module is installed.
LOCKED_MID BOOL The middle module is locked.
BATT_OK_MID BOOL The middle module battery is OK.
NET_OK_MID BOOL The middle port is receiving messages.
PASS_RIGHT BOOL The right module has no faults.
ACTIVE_RIGHT BOOL The right module is active.
INSTALLED_RIGHT BOOL The right module is installed.
LOCKED_RIGHT BOOL The right module is locked.
SYS_MP_STATUS 271
TriStation 1131 Libraries Reference
Description
The SYS_MP_STATUS function block gets the status of Trident Main Processor modules. Use
the SYS_MP_STATUS function block with BOOL MP status variables and the
SYS_MP_EXT_STATUS function block with DINT MP status variables.
Example
VAR MY_MP : SYS_MP_STATUS ; END_VAR
VAR MP_TEMPERATURE_OK : BOOL ; END_VAR
MY_MP( CI:=TRUE ) ;
MP_TEMPERATURE_OK := MY_MP.TEMP_OK ;
(*
* Result : MP_TEMPERATURE_OK is TRUE if
* the MP temperature is OK.
*)
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
BATT_OK_RIGHT BOOL The right module battery is OK.
NET_OK_RIGHT BOOL The right port is receiving messages.
APP_LOCKED BOOL Application changes are locked out.
APP_RUNNING BOOL The application is running.
TEMP_OK BOOL MP temperature is OK.
SYSTEM_OK BOOL No faults in the controller detected.
LOGIC_PWR_OK BOOL System logic power supplies are OK.
FLD_PWR_OK BOOL System field power supplies are OK.
PROG_ALARM_ON BOOL The program alarm is on.
REMOTE_WRT_ENABLE BOOL Write from remote host is allowed.
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.
Condition Return Value Error Flags
If ERROR_NUM is non-zero Reset all BOOL outputs to false BADPARAM, ERROR
Table 330 Output Parameters
Name Data Type Description
272 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Application Notes
Can be used in Safety or Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, see Using a Space Saver
Function Block on page 5.
Library
Trident (TRDLIB)
SYS_OVD_INHIBIT 273
TriStation 1131 Libraries Reference
SYS_OVD_INHIBIT
Inhibits output voter diagnostics.
Syntax
n1 := SYS_OVD_INHIBIT( IOP, SLOT, IOVD_01_16 ) ;
Description
The SYS_OVD_INHIBIT function block turns output voter diagnostic inhibits on or off.
When enabled, the Trident 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.
Table 331 Input Parameters
Name Data Type Description
IOP DINT IOP number 0-15.
SLOT DINT SLOT number 0-56.
IOVD_01_16 DWORD Inhibit Output Voter Diagnostics points 01..16
Table 332 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.
WARNING
Points on the Trident 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 SDO module.
274 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Programming tip: the bit numbers in parameter IOVD_01_16 are the same as the bit numbers in
the PACK16 function, so if you prefer using separate Boolean inputs, you can use PACK16.
The format of IOVD_01_16 parameter is:
* bit --> |32 ... 17|16 ... 01|
* output point --> |16 ... 01|
* where the most significant bits 17..32 are not used.
Example
(* Inhibit voter diagnostic for chassis 1 slot 5 points 01 thru 06. *)
VAR n : DINT; END_VAR
n := SYS_OVD_INHIBIT( 1, 5, 2#00000000000000000000000000111111 );
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the
error flags to true, and resets ENO to false. For more information about error flags and runtime
errors, see the CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Trident (TRDLIB)
Condition Return Value Error Flags
If error number is non-zero. Error number BADPARAM, ERROR
SYS_PI06_STATUS 275
TriStation 1131 Libraries Reference
SYS_PI06_STATUS
Gets the status of a Trident Pulse Input or Enhanced Pulse Input Module.
Syntax
MY_SYS_PI06_STATUS( CI:=b1, IOP:=n1, SLOT:=n2 ) ;
Table 333 Input Parameters
Name Data Type Description
CI BOOL Enables SYS_PI06_STATUS.
IOP DINT The IOP (015).
SLOT DINT The slot number (056).
Table 334 Output Parameters
Name Data Type Description
CO BOOL True if SYS_PI06_STATUS executes successfully.
TMR BOOL Three channels are operating without fatal faults
detected.
GE_DUAL BOOL At least two channels are operating without fatal faults
detected.
GE_SINGLE BOOL At least one channel is operating without fatal faults
detected.
NO_FLTS BOOL No failed modules detected.
NO_ACTIVE_FLTS BOOL No faults on the active module detected.
LOGIC_PWR1_OK BOOL Logic Power 1 is OK.
LOGIC_PWR2_OK BOOL Logic Power 2 is OK.
PASS_LEFT BOOL The left module has no faults.
ACTIVE_LEFT BOOL The left module is active.
INSTALLED_LEFT BOOL The left module is installed.
LOCKED_LEFT BOOL The left module is locked.
PASS_RIGHT BOOL The right module has no faults.
ACTIVE_RIGHT BOOL The right module is active.
INPUT_STABLE_1 BOOL The measured input for pulse input 1 or enhanced pulse
input 1 is stable.
INPUT_STABLE_2 BOOL The measured input for pulse input 2 or enhanced pulse
input 2 is stable.
INPUT_STABLE_3 BOOL The measured input for pulse input 3 or enhanced pulse
input 3 is stable.
276 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Description
The SYS_PI06_STATUS function block gets the status of a Trident Pulse Input or Enhanced
Pulse Input Module.
INPUT_STABLE_4 BOOL The measured input for pulse input 4 or enhanced pulse
input 4 is stable.
INPUT_STABLE_5 BOOL The measured input for pulse input 5 or enhanced pulse
input 5 is stable.
INPUT_STABLE_6 BOOL The measured input for pulse input 6 or enhanced pulse
input 6 is stable.
INSTALLED_RIGHT BOOL The right module is installed.
LOCKED_RIGHT BOOL The right module is locked.
NO_FLD_ALARM_LEFT BOOL The left module field alarm indicator is off.
NO_FLD_ALARM_RIGHT BOOL The right module field alarm indicator is off.
FLD_PWR1_OK BOOL Field power 1 is OK.
FLD_PWR2_OK BOOL Field power 2 is OK.
NO_FLD_FLTS BOOL No field faults detected.
NO_VOTER_FLTS BOOL No voter faults detected.
SIGNAL_PRESENT_1 BOOL The frequency of pulse input 1 or enhanced pulse input 1
is >= 0.5 Hz.
SIGNAL_PRESENT_2 BOOL The frequency of pulse input 2 or enhanced pulse input 2
is >= 0.5 Hz.
SIGNAL_PRESENT_3 BOOL The frequency of pulse input 3 or enhanced pulse input 3
is >= 0.5 Hz.
SIGNAL_PRESENT_4 BOOL The frequency of pulse input 4 or enhanced pulse input 4
is >= 0.5 Hz.
SIGNAL_PRESENT_5 BOOL The frequency of pulse input 5 or enhanced pulse input 5
is >= 0.5 Hz.
SIGNAL_PRESENT_6 BOOL The frequency of pulse input 6 or enhanced pulse input 6
is >= 0.5 Hz.
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.
Table 334 Output Parameters (continued)
Name Data Type Description
SYS_PI06_STATUS 277
TriStation 1131 Libraries Reference
Example
VAR MY_PI : SYS_PI06_STATUS ; END_VAR
VAR PI_ACTIVE : BOOL ; END_VAR
MY_PI( CI:=TRUE, IOP:=1, SLOT:=5 ) ;
PI_ACTIVE := MY_PI.LEFT_ACTIVE OR MY_PI.RIGHT_ACTIVE ;
(*
* Result : PI_ACTIVE is TRUE if there is
* an active PI06 module in slot 5.
*)
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, see Using a Space Saver
Function Block on page 5.
Library
Trident (TRDLIB)
Condition Return Value Error Flags
If ERROR_NUM is non-zero Reset all BOOL outputs to false BADPARAM, ERROR
278 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
SYS_RO32_STATUS
Gets the status of a Trident Relay Output Module.
Syntax
MY_SYS_RO32_STATUS( CI:=b1, IOP:=n1, SLOT:=n2 ) ;
Table 335 Input Parameters
Name Data Type Description
CI BOOL Enables SYS_RO32_STATUS.
IOP DINT The IOP (015).
SLOT DINT The slot number (056).
Table 336 Output Parameters
Name Data Type Description
CO BOOL True if SYS_RO32_STATUS executes successfully.
TMR BOOL Three channels are operating without fatal faults
detected.
GE_DUAL BOOL At least two channels are operating without fatal faults
detected.
GE_SINGLE BOOL At least one channel is operating without fatal faults
detected.
NO_FLTS BOOL No failed modules detected.
NO_ACTIVE_FLTS BOOL No faults on the active module detected.
LOGIC_PWR1_OK BOOL Logic Power 1 is OK.
LOGIC_PWR2_OK BOOL Logic Power 2 is OK.
PASS_LEFT BOOL The left module has no faults.
ACTIVE_LEFT BOOL The left module is active.
INSTALLED_LEFT BOOL The left module is installed.
LOCKED_LEFT BOOL The left module is locked.
PASS_RIGHT BOOL The right module has no faults.
ACTIVE_RIGHT BOOL The right module is active.
INSTALLED_RIGHT BOOL The right module is installed.
LOCKED_RIGHT BOOL The right module is locked.
NO_FLD_ALARM_LEFT BOOL The left module field alarm indicator is off.
NO_FLD_ALARM_RIGHT BOOL The right module field alarm indicator is off.
FLD_PWR1_OK BOOL Field power 1 is OK.
FLD_PWR2_OK BOOL Field power 2 is OK.
SYS_RO32_STATUS 279
TriStation 1131 Libraries Reference
Description
The SYS_RO32_STATUS function block gets the the status of a Relay Output module.
If CI = false, then CO = false and no operation occurs (no output changes). If CI = true, then CO
= true if no errors occur (ERROR_NUM=0).
Example
VAR MY_RO : SYS_RO32_STATUS ; END_VAR
VAR RO_ACTIVE : BOOL ; END_VAR
MY_RO( CI:=TRUE, IOP:=1, SLOT:=5 ) ;
RO_ACTIVE := MY_RO.LEFT_ACTIVE OR MY_RO.RIGHT_ACTIVE ;
(*
* Result : RO_ACTIVE is TRUE if there is
* an active RO32 module in slot 5.
*)
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, see Using a Space Saver
Function Block on page 5.
Library
Trident (TRDLIB)
NO_FLD_FLTS BOOL No field faults detected.
NO_VOTER_FLTS BOOL No voter faults detected.
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.
Condition Return Value Error Flags
If ERROR_NUM is non-zero Reset all BOOL outputs to false BADPARAM, ERROR
Table 336 Output Parameters (continued)
Name Data Type Description
280 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
SYS_SDO16_STATUS
Gets the status of a supervised discrete output module.
Syntax
MY_SYS_SDO16_STATUS( CI:=b1, IOP:=n1, SLOT:=n2 ) ;
Table 337 Input Parameters
Name Data Type Description
CI BOOL Enables SYS_SDO16_STATUS.
IOP DINT The IOP (015).
SLOT DINT The slot number (056).
Table 338 Output Parameters
Name Data Type Description
CO BOOL True if SYS_SDO16_STATUS executes successfully.
TMR BOOL Three channels are operating without fatal faults detected.
GE_DUAL BOOL At least two channels are operating without fatal faults
detected.
GE_SINGLE BOOL At least one channel are operating without fatal faults
detected.
NO_FLTS BOOL No failed modules detected.
NO_ACTIVE_FLTS BOOL No faults on the active module detected.
LOGIC_PWR1_OK BOOL Logic Power 1 is OK.
LOGIC_PWR2_OK BOOL Logic Power 2 is OK.
PASS_LEFT BOOL The left module has no faults.
ACTIVE_LEFT BOOL The left module is active.
INSTALLED_LEFT BOOL The left module is installed.
LOCKED_LEFT BOOL The left module is locked.
PASS_RIGHT BOOL The right module has no faults.
ACTIVE_RIGHT BOOL The right module is active.
INSTALLED_RIGHT BOOL The right module is installed.
LOCKED_RIGHT BOOL The right module is locked.
NO_FLD_ALARM_LEFT BOOL The left module field alarm indicator is off.
NO_FLD_ALARM_RIGHT BOOL The right module field alarm indicator is off.
FLD_PWR1_OK BOOL Field power 1 is OK.
FLD_PWR2_OK BOOL Field power 2 is OK.
SYS_SDO16_STATUS 281
Tri St at i on 1131 Li brari es Ref erence
Descr i pt i on
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.
Exampl e
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.
*)
Runt i me Er r or s
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.
Appl i cat i on Not es
Can be used in Safety or Control applications.
NO_FLD_FLTS BOOL No field faults detected on module.
NO_VOTER_FLTS BOOL No voter faults detected on module.
OVD_RUNNING_01_16 DWORD OVD points 0116 are OK.
FLD_OK_01_16 DWORD Field points 0116 are OK.
SPRVSD_ON_01_16 DWORD Supervision status for points 01-16. TRUE: Supervision
enabled. FALSE: Supervision disabled.
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.
Condi t i on Ret urn Val ue Error Fl ags
If ERROR_NUM is non-zero Reset all BOOL outputs to false BADPARAM, ERROR
Tabl e 338 Out put Paramet ers (cont i nued)
Name Dat a Type Descri pt i on
282 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
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 5.
Library
Trident (TRDLIB)
7

7. This function was added to the library in v1.120 of TRDLIB, first released with TriStation 1131 v4.6.
SYS_SERIAL_PORT 283
TriStation 1131 Libraries Reference
SYS_SERIAL_PORT
Resets statistics for one or more serial ports.
Syntax
MY_SYS_SERIAL_PORT( CI:=b1, IOP:=n1, RESET_STATS_SERIAL_1:=b2,
RESET_STATS_SERIAL_2:=b3, RESET_STATS_SERIAL_3:=b4 ) ;
Description
The SYS_SERIAL_PORT function block resets statistics for one or more serial ports.
CI is a control input. If CI is false, then CO is false and there is no operation, which means that
new requests are ignored. If CI is true, then CO is false if there are errors (ERROR_NUM not
zero). If CI is true, then CO is true if there are no errors (ERROR_NUM = 0).
Each input RESET_STATS_SERIAL_n is a request to reset the statistics for port "n". The function
block latches the request until the port acknowledges the request, that is, until the transition of
STATS_RESET_SERIAL_n from false to true.
Each output STATS_RESET_SERIAL_n is true when the statistics are reset, false otherwise.
Table 339 Input Parameters
Name Data Type Description
CI BOOL Enables SYS_SERIAL_PORT.
IOP DINT IOP number 0
SLOT DINT SLOT number 2-3
RESET_STATS_SERIAL_1 BOOL Reset statistics for serial port 1.
RESET_STATS_SERIAL_2 BOOL Reset statistics for serial port 2.
RESET_STATS_SERIAL_3 BOOL Reset statistics for serial port 3.
Table 340 Output Parameters
Name Data Type Description
CO BOOL True if SYS_SERIAL_PORT executes successfully.
STATS_RESET_SERIAL_1 BOOL Statististics were reset for serial port 1.
STATS_RESET_SERIAL_2 BOOL Statististics were reset for serial port 2.
STATS_RESET_SERIAL_3 BOOL Statististics were reset for serial port 3.
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.
284 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Invoke SYS_CM_STATUS to read statistics for each serial port. The statistics for serial port 1 are
MSGS_SERIAL_1, BRDCSTS_SERIAL_1, RSPNS_SERIAL_1, and BAD_MSGS_SERIAL_1, and
similarly for ports 2 and 3.
Example
(* Reset statistics for all three ports. *)
VAR MY_SYS_SERIAL_PORT : SYS_SERIAL_PORT; END_VAR
MY_SYS_SERIAL_PORT( RESET_STATS_SERIAL_1:=TRUE, RESET_STATS_SERIAL_2:=TRUE,
RESET_STATS_SERIAL_3:=TRUE );
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Exactly Once: each instance should be executed exactly once per scan.
Library
Trident (TRDLIB)
Condition Return Value Error Flags
If ERROR_NUM is non-zero Reset all BOOL outputs to false BADPARAM, ERROR
SYS_SET_APP_LOCK 285
TriStation 1131 Libraries Reference
SYS_SET_APP_LOCK
Turns the application lock on or off.
Syntax
n1 := SYS_SET_APP_LOCK( b1 ) ;
Description
The SYS_SET_APP_LOCK function turns the application lock on or off.
The application lock controls the TriStation 1131 permissions for performing application
changes. When locked, TriStation 1131 cannot download changes, download all, set variable
values, or disable points on a Trident controller.
Invoke function block SYS_MP_STATUS to read APP_LOCKED.
Table 341 Input Parameters
Name Data Type Description
VALUE BOOL True means locked; false means unlocked.
Table 342 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.
CAUTION
Once the application has been locked by setting SYS_SET_APP_LOCK to
True, the only way to unlock the application is to reseat all three MPs.
Simply changing the value to False will not unlock the application.
To be able to unlock the application without reseating the MPs, before
locking the application, you must configure a call to the
SYS_SET_APP_LOCK function that passes an externally controlled value
to the function. The following are two examples of how to use this
technique:
Connect a switch to a DI input, and then connect the DI input to
the SYS_SET_APP_LOCK function.
Or, connect a Read/Write aliased variable to the
SYS_SET_APP_LOCK function and use Modbus to control the
variable.
286 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Example
(* Lock the application. *)
VAR n : DINT; END_VAR
n := SYS_SET_APP_LOCK( TRUE ); {* result is 0 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the
error flags to true, and resets ENO to false. For more information about error flags and runtime
errors, see the CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Trident (TRDLIB)
Condition Return Value Error Flags
If error number is non-zero. Error number BADPARAM, ERROR
SYS_SET_PROG_ALARM 287
TriStation 1131 Libraries Reference
SYS_SET_PROG_ALARM
Turns the programmable alarm on or off.
Syntax
n1 := SYS_SET_PROG_ALARM( b1 ) ;
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 MP module.
Invoke function block SYS_MP_STATUS to read PROG_ALARM_ON.
Example
(* Turn the blue programmable alarm indicator on. *)
VAR n : DINT; END_VAR
n := SYS_SET_PROG_ALARM( TRUE ); {* result is 0 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the
error flags to true, and resets ENO to false. For more information about error flags and runtime
errors, see the CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Trident (TRDLIB)
Table 343 Input Parameters
Name Data Type Description
VALUE BOOL True means alarm on; false means alarm off.
Table 344 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.
Condition Return Value Error Flags
If error number is non-zero. Error number BADPARAM, ERROR
288 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
SYS_SET_REMOTE_WRT_ENBL
Turns remote write enable on or off.
Syntax
n1 := SYS_SET_REMOTE_WRT_ENBL( b1 ) ;
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
controller.
Invoke function block SYS_MP_STATUS to read REMOTE_WRT_ENBL.
Example
(* Allow writes from remote hosts. *)
VAR n : DINT; END_VAR
n := SYS_SET_REMOTE_WRT_ENBL( TRUE ); {* result is 0 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the
error flags to true, and resets ENO to false. For more information about error flags and runtime
errors, see the CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Trident (TRDLIB)
Table 345 Input Parameters
Name Data Type Description
VALUE BOOL True means enable writes; false means disable writes.
Table 346 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.
Condition Return Value Error Flags
If error number is non-zero. Error number BADPARAM, ERROR
SYS_SHUTDOWN 289
TriStation 1131 Libraries Reference
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 347 Input Parameters
Name Data Type Description
CI BOOL Enables SYS_SHUTDOWN.
IO_CO BOOL True if SYS_SHUTDOWN executes successfully.
IO_TMR BOOL Three channels are operating without faults on every critical
I/O module.
IO_GE_DUAL BOOL At least two channels are operating without faults on every
critical I/O module.
IO_GE_SINGLE BOOL At least one channel is operating without faults on every
critical I/O module.
IO_NO_VOTER_FLTS BOOL No voter faults on critical modules detected.
IO_ERROR DINT Error number, not used.
MAX_TIME_DUAL TIME The maximum time permittedof continuous operation
permitted with two channels operating.
MAX_TIME_SINGLE TIME The maximum time of continuous operation permitted with
one channel operating.
MAX_SCAN_TIME TIME 50% of the maximum response time.
Table 348 Output Parameters
Name Data Type Description
CO BOOL True if SYS_SHUTDOWN executes
successfully.
OPERATING BOOL Shutdown if OPERATING is false.
TMR BOOL Three channels are operating without fatal
faults detected.
DUAL BOOL At least two channels are operating
without fatal faults detected.
SINGL BOOL At least one channel is operating without
fatal faults detected.
ZERO BOOL No channels are operating.
TIMER_RUNNING BOOL Shutdown timer is running
TIME_LEFT TIME Time remaining to shutdown
290 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Description
The SYS_SHUTDOWN function block enables a system shutdown according to industry
guidelines. For more information, see the Trident Safety Considerations Guide.
Example
For shutdown examples, see this sample project:
My Documents\Triconex\TriStation 1131 4.x\Projects\TdTUV.pt2
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
If 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 (TRDLIB)
ALARM_PROGRAMMING_PERMITTED BOOL True if application changes are permitted
ALARM_REMOTE_ACCESS BOOL True if remote-host writes are enabled
ALARM_RESPONSE_TIME BOOL True if actual scan time >
MAX_SCAN_TIME
ALARM_DISABLED_POINTS BOOL True if one or more points are disabled
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.
Condition Return Value Error Flags
If ERROR is non-zero Set alarm outputs to true, reset the other BOOL
outputs to false, and reset TIME_LEFT to zero.
BADPARAM, ERROR
Table 348 Output Parameters (continued)
Name Data Type Description
SYS_SYSTEM_STATUS 291
TriStation 1131 Libraries Reference
SYS_SYSTEM_STATUS
Gets the status of an entire Trident system, including Main Processors, I/O modules,
communication, power and time.
Syntax
MY_SYS_SYSTEM_STATUS( CI:=b1 ) ;
Table 349 Input Parameters
Name Data Type Description
CI BOOL Enables SYS_SYSTEM_STATUS.
Table 350 Output Parameters
Name Data Type Description
CO BOOL True if SYS_SYSTEM_STATUS executes successfully.
TMR BOOL Three channels are operating without fatal faults
detected.
GE_DUAL BOOL At least two channels are operating without fatal faults
detected.
GE_SINGLE BOOL At least one channel is operating without fatal faults
detected.
NO_FLTS BOOL No failed modules detected.
NO_ACTIVE_FLTS BOOL No faults on the active module detected.
LOGIC_PWR1_OK BOOL Logic Power 1 is OK.
LOGIC_PWR2_OK BOOL Logic Power 2 is OK.
POWER_UP BOOL The first scan after power up.
FIRST_SCAN BOOL The first scan.
COLD_START BOOL The first scan after initializing retentive variables.
PT_DISABLING_OFF BOOL Disabling points is not permitted.
MASTER_CLK BOOL The system owns the master clock.
LOCAL_TIME BOOL The system is using local time.
DAYLIGHT_TIME BOOL Daylight Savings Time is in effect.
DSBL_REMOTE_CHGS BOOL Remote changes to output disallowed.
IO_TMR BOOL Three channels are operating without fatal faults
detected on the I/O string.
IO_GE_Dual BOOL At least two channels are operating without fatal faults
detected on the I/O string.
IO_GE_Single BOOL At least one channel is operating without fatal faults
detected on the I/O string.
292 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Description
The SYS_SYSTEM_STATUS function block gets the status of an entire Trident system, including
Main Processors, I/O modules, communication, power and time.
IO_NO_FLTS BOOL No faults on the I/O string detected.
IO_NO_ACTIVE_FLTS BOOL No faults on the active I/O module detected.
IO_NO_VOTER_FLTS BOOL No voter faults on the I/O string detected.
IO_NO_FLD_FLTS BOOL No field faults on the I/O string detected.
FLD_PWR1_OK BOOL Field power supply 1 is OK.
FLD_PWR2_OK BOOL Field power supply 2 is OK.
NODE_OK_01_32 DWORD Valid communication links (nodes 01 to 32).
NODE_OK_33_64 DWORD Valid communication links (nodes 33 to 64).
NODE_REDUNDANT_01_32 DWORD Redundant communication links (nodes 01 to 32).
NODE_REDUNDANT_33_64 DWORD Redundant communication links (nodes 33 to 64).
YEAR DINT The year (for example, 1999).
MONTH DINT The month (112)
DAY DINT The day of the month (131)
HOUR DINT The hour (023)
MINUTE DINT The minute (059)
SECOND DINT The second (059)
MILLISECOND DINT The millisecond (0999)
MICROSECOND DINT The millisecond (0999)
RELATIVE_SECONDS DINT The relative seconds since January 1, 1970
DAY_OF_WEEK DINT The current day of the week (06, 0=Sunday)
APP_MAJOR_VRSN DINT The application major version
APP_MINOR_VRSN DINT The application minor version
APP_NAME STRING The application name
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.
Table 350 Output Parameters (continued)
Name Data Type Description
SYS_SYSTEM_STATUS 293
TriStation 1131 Libraries Reference
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_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
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, see Using a Space Saver
Function Block on page 5.
Library
Trident (TRDLIB)
Condition Return Value Error Flags
If ERROR_NUM is non-zero Reset all outputs except ERROR_NUM to
zero.
BADPARAM, ERROR
294 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
SYS_VOTE_MODE
Converts redundancy status.
Syntax
MY_SYS_VOTE_MODE( CI:=b1, IN_TMR:=b2, GE_DUAL:=b3, GE_SINGLE:=b4 ) ;
Description
The SYS_VOTE_MODE function block converts redundancy status, as shown in this truth table.
Note GE_ means greater than or equal to.
Table 351 Input Parameters
Name Data Type Description
CI BOOL Enables SYS_VOTE_MODE.
IN_TMR BOOL Three channels are operating.
GE_DUAL BOOL Two or more channels are operating.
GE_SINGLE BOOL One or more channels are operating.
Table 352 Output Parameters
Name Data Type Description
CO BOOL True if SYS_VOTE_MODE executes successfully.
TMR BOOL Three channels are operating.
DUAL BOOL Two channels are operating.
SINGLE BOOL One or more channels are operating.
ZERO BOOL No channel is operating.
Table 353 Truth Table
TMR GE_DUAL GE_SINGLE TMR DUAL SINGL ZERO
T T T T F F F
F T T F T F F
F F T F F T F
F F F F F F T
Other
a
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).
F F F F
SYS_VOTE_MODE 295
TriStation 1131 Libraries Reference
Example
For shutdown examples, see this sample project:
My Documents\Triconex\TriStation 1131 4.x\Projects\TdTUV.pt2
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, see Using a Space Saver
Function Block on page 5.
Library
Trident (TRDLIB)
Condition Return Value Error Flags
If the inputs do not match one of the first
four rows of the truth table
Reset all BOOL outputs to false BADPARAM, ERROR
296 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
TAN
Calculates the tangent of an angle.
Syntax
y := TAN( x ) ;
Description
The TAN function returns the tangent of an angle given in radians.
Example
VAR y : REAL; END_VAR
y := TAN( 3.141593/4.0 ); {* result is 1.0 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the
error flags to true, and resets ENO to false. For more information about error flags and runtime
errors, see the CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
Table 354 Input Parameters
Name Data Type Description
x ANY_REAL The angle, in radians.
Table 355 Return Value
Data Type Description
ANY_REAL The tangent of x.
Conditions Return Values Error Flags
If x is not a number. NAN BADPARAM, ERROR
If the absolute value of x is greater than 2**63 NAN BADPARAM, ERROR
TCJ_CONV 297
TriStation 1131 Libraries Reference
TCJ_CONV
Converts a Type J thermocouple input into degrees Celsius and returns the result.
Syntax
y := TCJ_CONV( MC, CONVM, CONVB, COLDJNC ) ;
Description
The TCJ_CONV function converts a Type J thermocouple input into degrees Celsius and returns
the result.
First, a thermocouple input machine count (MC) from an Analog Input Module is converted to
millivolts using a bias and scale factor. Next, the millivolts are corrected by cold-junction
compensation using a quartic equation, which is a function of cold-junction temperature. Lastly,
the temperature in degrees Celsius is computed using a set of quartic equations, which are
functions of the corrected millivolts.
Temperatures ranging from 200 C to 1200 C are supported for Type J thermocouples. The
cold-junction compensation temperature must be in the range from 20 C to 500 C.
Note Conversion from millivolts to degrees Celsius is based on the Type J quartic equation
approximation done in four ranges. If the intermediate result is outside the calculable
range, the function returns either 10000 or 10000. For example, if coldJnc < 20 or result
< 200, then return 10000; if coldJnc > 500 or result > 1200, then return +10000
Runtime Errors
None.
Table 356 Input Parameters
Name Data Type Description
MC DINT The machine count input from thermocouple wire to be converted (0
4095).
CONVM REAL The conversion from machine counts to millivolts (see the Thermocouple
and Amplifier specification sheets).
CONVB REAL The conversion bias from machine count to millivolts (see the
Thermocouple and Amplifier specification sheets).
COLDJNC REAL The cold-junction compensation temperature in degrees Celsius.
Table 357 Return Value
Data Type Description
REAL The temperature in degrees Celsius.
WARNING
The TCJ_CONV function should be used when thermocouple wiring is
tied to an Analog Input module through an amplifier. TCJ_CONV is not
intended for use with Thermocouple modules.
298 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Application Notes
Can be used in Safety or Control applications.
Library
Triconex (TCXLIB)
TCK_CONV 299
TriStation 1131 Libraries Reference
TCK_CONV
Converts a Type K thermocouple input into degrees Celsius and returns the result.
Syntax
y := TCJ_CONV( MC, CONVM, CONVB, COLDJNC ) ;
Description
The TCK_CONV function converts a Type K thermocouple input into degrees Celsius and
returns the result.
First, a thermocouple input machine count MC from an Analog Input Module is converted to
millivolts using a bias and scale factor. Next, the millivolts are corrected by cold-junction
compensation, using a quartic equation, which is a function of cold-junction temperature.
Lastly, the temperature in degrees Celsius is computed using a set of quartic equations, which
are functions of the corrected millivolts.
Temperatures ranging from 200 C to 1370 C are supported for Type K thermocouples. The
cold-junction compensation temperature must be in the range from 20 C to 500 C.
Note Conversion from millivolts to degrees Celsius is based on the Type K quartic equation
approximation done in three ranges. If the intermediate result is outside the calculable
range, the function returns either 10000 or 10000. For example, if coldJnc < 20 or
output < 200, then output = 10000; if coldJnc > 500 or output > 1370, then output =
+10000.
Table 358 Input Parameters
Name Data Type Description
MC DINT The machine count input from thermocouple wire to be converted
(04095).
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 The cold-junction compensation temperature in degrees Celsius.
Table 359 Return Value
Data Type Description
REAL The temperature in degrees Celsius.
WARNING
The TCK_CONV function should be used when thermocouple wiring is
tied to an Analog Input module through an amplifier. TCK_CONV is not
intended for use with Thermocouple modules.
300 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Library
Triconex (TCXLIB)
TDD_I 301
TriStation 1131 Libraries Reference
TDD_I
Provides a time delay to de-energize.
Syntax
MY_TDD_I( I1:=b1, TGT:=n1 ) ;
Description
The TDD_I function block provides a time delay to de-energize. The delay time is given in
integer milliseconds. If the input is true, then the output is true. After the input changes to false,
the output remains true for the specified delay time, then the output changes to false.
Note If TGT is within one scan period of 2147483647 milliseconds (25 days), then the time
accumulator can overflow to a negative value.
Note You must invoke an instance of TDD_I exactly once per scan.
Example
VAR MY_TDD_I : TDD_I ; END_VAR
VAR b1, b2 : BOOL ; END_VAR
MY_TDD_I( I1:=b1, 10000 ) ;
b2 := MY_TDD_I.Q1 ;
(* result: The delay time is about 10 seconds from the falling edge of b1 to
the falling edge of b2. *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Exactly Once: each instance should be executed exactly once per scan.
Can be used in CEM Cause, Effect, and Intersection cells.
Library
Standard (STDLIB)
Table 360 Input Parameters
Name Data Type Description
I1 BOOL The input state.
TGT DINT The target delay time in integer milliseconds.
Table 361 Output Parameters
Name Data Type Description
Q1 BOOL The output state.
302 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
TDD_R
Provides a time delay to de-energize.
Syntax
MY_TDD_R( I1:=b1, TGT:=x1 ) ;
Description
The TDD_R function block provides a time delay to de-energize. The delay time is given in real
seconds. If the input is true, then the output is true. After the input changes to false, the output
remains true for the specified delay time, then the output changes to false.
Note You must invoke an instance of TDD_R exactly once per scan.
Note The rounding error in the time accumulator increases with time until the accumulator
eventually stops. The rounding error in seconds is less than ACC ACC (50,000,000
T), where ACC is the accumulated time in seconds and T is the scan period in seconds.
The accumulator stops after ACC > 16,000,000 T. For example, if the scan period is 20
milliseconds, then after one hour, the rounding error is less than 13 seconds.
Example
VAR MY_TDD_R : TDD_R ; END_VAR
VAR b1, b2 : BOOL ; END_VAR
MY_TDD_R( I1:=b1, 10.0 ) ;
b2 := MY_TDD_R.Q1 ;
(* result: The delay time is about 10 seconds from the falling edge of b1 to
the falling edge of b2. *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Exactly Once: each instance should be executed exactly once per scan.
Can be used in CEM Cause, Effect, and Intersection cells.
Library
Standard (STDLIB)
Table 362 Input Parameters
Name Data Type Description
I1 BOOL The input state.
TGT REAL The target delay time in real seconds.
Table 363 Output Parameters
Name Data Type Description
Q1 BOOL The output state.
TDE_I 303
TriStation 1131 Libraries Reference
TDE_I
Provides a time delay to energize.
Syntax
MY_TDE_I( I1:=b1, TGT:=n1 ) ;
Description
The TDE_I function block provides a time delay to energize. The delay time is given in integer
milliseconds. If the input is false, then the output is false. After the input changes to true, the
output remains false for the specified delay time, then the output changes to true.
Note If TGT is within one scan period of 2147483647 milliseconds (25 days), then the time
accumulator can overflow to a negative value.
Note You must invoke an instance of TDE_I exactly once per scan.
Example
VAR MY_TDE_I : TDE_I ; END_VAR
VAR b1, b2 : BOOL ; END_VAR
MY_TDE_I( I1:=b1, 10000 ) ;
b2 := MY_TDE_I.Q1 ;
(* result: The delay time is about 10 seconds from the rising edge of b1 to
the rising edge of b2. *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Exactly Once: each instance should be executed exactly once per scan.
Can be used in CEM Cause, Effect, and Intersection cells.
Library
Standard (STDLIB)
Table 364 Input Parameters
Name Data Type Description
I1 BOOL The input state.
TGT DINT The target delay time in integer milliseconds.
Table 365 Output Parameters
Name Data Type Description
Q1 BOOL The output state.
304 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
TDE_R
Provides a time delay to energize.
Syntax
MY_TDE_R( I1:=b1, TGT:=x1 ) ;
Description
Note 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.
Note You must invoke an instance of TDE_R exactly once per scan.
Note The rounding error in the time accumulator increases with time until the accumulator
eventually stops. The rounding error in seconds is less than ACC ACC (50,000,000
T), where ACC is the accumulated time in seconds and T is the scan period in seconds.
The accumulator stops after ACC > 16,000,000 T. For example, if the scan period is 20
milliseconds, then after one hour, the rounding error is less than 13 seconds.
Example
VAR MY_TDE_R : TDE_R ; END_VAR
VAR b1, b2 : BOOL ; END_VAR
MY_TDE_R( I1:=b1, 10.0 ) ;
b2 := MY_TDE_R.Q1 ;
(* result: The delay time is about 10 seconds from the rising edge of b1 to
the rising edge of b2. *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Exactly Once: each instance should be executed exactly once per scan.
Can be used in CEM Cause, Effect, and Intersection cells.
Library
Standard (STDLIB)
Table 366 Input Parameters
Name Data Type Description
I1 BOOL The input state.
TGT REAL The target delay time in real seconds.
Table 367 Output Parameters
Name Data Type Description
Q1 BOOL The output state.
TIME 305
TriStation 1131 Libraries Reference
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.
Note With the release of TriStation v4.4, the syntax of the TIME data type is no longer
case-sensitive.
Application Notes
Can be used in Safety or Control applications.
Can be used in CEM Cause, Effect, and Intersection cells.
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
Result if intermediate value is less than lower limit Inv Time
Result if upper limit is less than intermediate value Inv Time
306 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
TIME_TO_SECS
Converts time to number of seconds.
Syntax
y := TIME_TO_SECS( t ) ;
Description
The TIME_TO_SECS function converts time to number of seconds.
Example
VAR t : TIME ; y : LREAL ; END_VAR
t := T#500ms ;
y := TIME_TO_SECS( t ) ; (* result is 0.5 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the
error flags to true, and resets ENO to false. For more information about error flags and runtime
errors, see the CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
Table 368 Input Parameters
Name Data Type Description
t TIME The time.
Table 369 Return Value
Data Type Description
LREAL The number of seconds.
Condition Return Value Error Flags
If t is out of range. NAN BADPARAM, ERROR
TIME_TO_SECS_REAL 307
TriStation 1131 Libraries Reference
TIME_TO_SECS_REAL
Converts time to number of seconds.
Syntax
y := TIME_TO_SECS_REAL( t ) ;
Description
The TIME_TO_SECS_REAL function converts time to number of seconds.
Example
VAR t : TIME ; y : REAL ; END_VAR
t := T#500ms ;
y := TIME_TO_SECS( t ) ; (* result is 0.5 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the
error flags to true, and resets ENO to false. For more information about error flags and runtime
errors, see the CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
Table 370 Input Parameters
Name Data Type Description
t TIME The time.
Table 371 Return Value
Data Type Description
REAL The number of seconds.
Condition Return Value Error Flags
If t is out of range. NAN BADPARAM, ERROR
308 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
TIMEADJ
Adjusts the calendar clock.
Syntax
MY_TIMEADJ( CI:=b1, MS:=n1 ) ;
Description
The TIMEADJ function block adjusts the calendar clock.
CI is the control input. Call the function block with CI=true to adjust the clock. Then change CI
to false for the next evaluation.
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.
Note You must clear CI to 0 (False) after adjusting the clock.
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 ;
Table 372 Input Parameters
Name Data Type Description
CI BOOL Enables TIMEADJ.
MS DINT The number of milliseconds, positive or negative, to adjust the clock.
Table 373 Output Parameters
Name Data Type Description
CO BOOL True if TIMEADJ executes successfully.
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.
TIMEADJ 309
TriStation 1131 Libraries Reference
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Only Once: each instance should be executed only once per scan, but does not need to
be executed every scan.
Library
Triconex (TCXLIB)
Condition Return Value Error Flags
If the adjusted time is before 00:00:00 on January 1, 1970 or
after 23:59:59 on December 31, 2029
CO=false BADPARAM, ERROR
310 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
TIMESET
Sets the calendar clock.
Syntax
MY_TIMESET( CI:=b1, GMT:=n1, MS:=n2 ) ;
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.
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.
Note You must clear CI to 0 (False) after adjusting the clock.
Table 374 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 The number of milliseconds (0999) past the time given in GMT.
Table 375 Output Parameters
Name Data Type Description
CO BOOL True if TIMESET executes successfully.
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 does not allow you to set the time to a date earlier than
December 31, 1993.
TIMESET 311
TriStation 1131 Libraries Reference
Example
(*
* Set the time and date
* to 18:43:53 on February 24, 2003
* plus 160 milliseconds.
*)
VAR MY_TIMESET : TIMESET ; END_VAR
VAR SET_THE_TIME : BOOL ; END_VAR
MY_TIMESET( CI:=SET_THE_TIME, GMT:=1046112233, MS:=160 ) ;
SET_THE_TIME := false ;
Runtime Errors
The range of GMT is 0 <= GMT <= 1893455999 seconds, which represents 00:00:00 on January 1,
1970 to 23:59:59 on December 31, 2029.
The range of MS is 0 <= MS <= 999 milliseconds.
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Only Once: each instance should be executed only once per scan, but does not need to
be executed every scan.
Library
Triconex (TCXLIB)
Condition Return Value Error Flags
If GMT or MS is out of range CO=false BADPARAM, ERROR
312 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
TMR
Provides a timer to replace the functionality of the TMR coil in TriStation MSW.
Syntax
MY_TMR( IN:=b1, RESET:=b2, PT:=t1, IT:=t2 ) ;
Description
The TMR function block replaces the functionality of the TMR coil in TriStation MSW.
While the input IN is true, the timer increments the elapsed time accumulator until its value is
greater than or equal to the preset time (input PT). After the preset time is reached, the output
Q remains true until reset.
RESET clears Q and copies IT to ET.
Input IN adds the previous scan period to ET. If IN is true and ET is greater than or equal to PT,
then the function block copies PT to ET and sets Q. If IN is false, then ET holds its current value
until reset
PT is the preset time which means the timer expires when ET is greater than or equal to PT.
IT is the initial time that is loaded into ET. The default initial value is T#0s.
Q indicates when the timer expires. Q is set to true when ET increases to PT or beyond. RESET
clears Q.
ET is the elapsed time during which input IN is true.
Table 376 Input Parameters
Name Data Type Description
IN BOOL Enables TMR.
RESET BOOL Resets TMR.
PT TIME The preset time.
IT TIME The initial time.
Table 377 Output Parameters
Name Data Type Description
Q BOOL The current state.
ET TIME The elapsed time accumulator.
TMR 313
TriStation 1131 Libraries Reference
Example
VAR MY_TMR : TMR ; END_VAR
VAR b1, b2 : BOOL ; END_VAR
MY_TMR( IN:=b1, RESET:=NOT b1, PT:=T#10s ) ;
b2 := MY_TMR.Q ;
(* result: The delay time is about 10 seconds from the rising edge of b1 to
the rising edge of b2. *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Exactly Once: each instance should be executed exactly once per scan.
Can be used in CEM Cause, Effect, and Intersection cells.
Library
Triconex (TCXLIB)
314 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
TMR_I
Provides a timer to replace the functionality of the TMR coil in TriStation MSW.
Syntax
MY_TMR_I( IN:=b1, RESET:=b2, PT:=n1 ) ;
Description
The TMR_I function block replaces the functionality of the TMR coil in TriStation MSW. It
differs from TMR in that the time is in milliseconds.
While the input IN is true, the timer increments the elapsed time accumulator until its value is
greater than or equal to the preset time (input PT). After the preset time is reached, the output
Q remains true until reset.
RESET clears Q and resets ET to 0.
Input IN adds the previous scan period to ET. If IN is true and ET is greater than or equal to PT,
then the function block copies PT to ET and sets Q. If IN is false, then ET holds its current value
until reset
PT is the preset time in milliseconds which means the timer expires when ET is greater than or
equal to PT.
Q indicates when the timer expires. Q is set to true when ET increases to PT or beyond. RESET
clears Q.
ET accumulates the elapsed time in milliseconds while input IN is true. ET starts at 0
milliseconds. While input IN is true, the timer adds the previous scan period to ET until its value
is greater than or equal to PT. After the preset time is reached, the timer sets ET equal to PT.
Note If PT is within one scan period of 2147483647 milliseconds (25 days), then the elapsed
time accumulator can overflow to a negative value.
Note You must invoke an instance of TDD_I exactly once per scan.
Table 378 Input Parameters
Name Data Type Description
IN BOOL Enables TMR_I.
RESET BOOL Resets TMR_I.
PT DINT The preset time in milliseconds.
Table 379 Output Parameters
Name Data Type Description
Q BOOL The current state.
ET DINT The elapsed time accumulator in milliseconds.
TMR_I 315
TriStation 1131 Libraries Reference
Example
VAR MY_TMR_I : TMR_I ; END_VAR
VAR b1, b2 : BOOL ; END_VAR
MY_TMR_I( IN:=b1, RESET:=NOT b1, PT:=10000 ) ;
b2 := MY_TMR_I.Q ;
(* result: The delay time is about 10 seconds from the rising edge of b1 to
the rising edge of b2. *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Exactly Once: each instance should be executed exactly once per scan.
Can be used in CEM Cause, Effect, and Intersection cells.
Library
Triconex (TCXLIB)
316 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
TMR_R
Provides a timer to replace the functionality of the TMR coil in TriStation MSW.
Syntax
MY_TMR_R( IN:=b1, RESET:=b2, PT:=x1 ) ;
Description
The TMR_R function block replaces the functionality of the TMR coil in TriStation MSW. It
differs from TMR in that the time is in seconds.
While the input IN is true, the timer increments the elapsed time accumulator until its value is
greater than or equal to the preset time (input PT). After the preset time is reached, the output
Q remains true until reset.
RESET clears Q and resets ET to 0.0.
Input IN adds the previous scan period to ET. If IN is true and ET is greater than or equal to PT,
then the function block copies PT to ET and sets Q. If IN is false, then ET holds its current value
until reset
PT is the preset time in milliseconds which means the timer expires when ET is greater than or
equal to PT.
Q indicates when the timer expires. Q is set to true when ET increases to PT or beyond. RESET
clears Q.
ET accumulates the elapsed time in seconds while input IN is true. ET starts at 0.0 seconds.
While input IN is true, the timer adds the previous scan period to ET until its value is greater
than or equal to PT. After the preset time is reached, the timer sets ET equal to PT.
Note 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
Table 380 Input Parameters
Name Data Type Description
IN BOOL Enables TMR_I.
RESET BOOL Resets TMR_I.
PT REAL The preset time in seconds.
Table 381 Output Parameters
Name Data Type Description
Q BOOL The current state.
ET REAL The elapsed time accumulator in seconds.
TMR_R 317
TriStation 1131 Libraries Reference
the scan period is 20 milliseconds, then after one hour, the rounding error is less than 13
seconds.
Example
VAR MY_TMR_R : TMR_R ; END_VAR
VAR b1, b2 : BOOL ; END_VAR
MY_TMR_R( IN:=b1, RESET:=NOT b1, PT:=10.0 ) ;
b2 := MY_TMR_R.Q ;
(* result: The delay time is about 10 seconds from the rising edge of b1 to
the rising edge of b2. *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Exactly Once: each instance should be executed exactly once per scan.
Can be used in CEM Cause, Effect, and Intersection cells.
Library
Triconex (TCXLIB)
318 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
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.
Application Notes
Can be used in Safety or Control applications.
Can be used in CEM Cause, Effect, and Intersection cells.
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
Result if intermediate value is less than lower limit V modulo 24 hours
Result if upper limit is less than intermediate value V modulo 24 hours
TOF 319
TriStation 1131 Libraries Reference
TOF
Delays the falling edge of a pulse.
Syntax
MY_TOF( IN:=b1, PT:=t1 ) ;
Description
The TOF function block provides a delay of duration PT from the falling edge of input IN to the
falling edge of output Q.
IN is the input pulse. The falling edge of IN starts the timer. While IN is false, after a delay of
duration PT, the timer changes Q to false. If at any time the input IN changes to true, the timer
resets, changing Q to true and ET to zero.
PT gives the duration of the delay.
Q is the output pulse. Q is initially true. Q changes from true to false after the specified delay
time. Q changes from false to true when the input changes from false to true.
Table 382 Input Parameters
Name Data Type Description
IN BOOL The input pulse.
PT TIME The pulse time.
Table 383 Output Parameters
Name Data Type Description
Q BOOL The output pulse.
ET TIME The elapsed time.
320 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
ET gives the elapsed time from the falling edge of IN, while IN is false and Q is true. While IN
is false and Q is false, ET is equal to PT. If IN is true, then ET is zero.
If input IN is true, then TOF sets output Q to true and the elapsed time to zero. If the width of
input IN is less than PT, then output Q does not change, but while IN is false, output ET still
gives the elapsed time since the falling edge of input IN.
If the initial value of input IN is false, then the timer does not start and Q remains false until
input IN changes to true.
Example
VAR MY_TOF : TOF ; END_VAR
TOF 321
TriStation 1131 Libraries Reference
VAR b1, b2 : BOOL ; END_VAR
MY_TOF( IN:=b1, PT:=T#10s ) ;
b2 := MY_TOF.Q ;
(* result: The delay time is about 10 seconds from the falling edge of b1 to
the falling edge of b2. *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Only Once: each instance should be executed only once per scan, but does not need to
be executed every scan.
Can be used in CEM Cause, Effect, and Intersection cells.
Library
Standard (STDLIB)
322 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
TOGGLE
Replaces the functionality of the TGL coil in TriStation MSW.
Syntax
MY_TOGGLE( IN:=b1, RESET:=b2 ) ;
Description
The TOGGLE function block replaces the functionality of the TGL coil in TriStation MSW.
IN toggles Q if RESET is false. Toggle means to change the state, that is, from false to true or
true to false.
RESET resets Q (to false).
Q is the output that toggles.
Example
VAR MY_TOGGLE : TOGGLE ; END_VAR
MY_TOGGLE( IN:=FALSE, RESET:=TRUE ); (* Q is FALSE *)
MY_TOGGLE( IN:=FALSE, RESET:=FALSE ); (* Q is FALSE *)
MY_TOGGLE( IN:=TRUE, RESET:=TRUE ); (* Q is FALSE *)
MY_TOGGLE( IN:=TRUE, RESET:=FALSE ); (* Q is TRUE *)
MY_TOGGLE( IN:=FALSE, RESET:=FALSE ); (* Q is TRUE *)
MY_TOGGLE( IN:=TRUE, RESET:=FALSE ); (* Q is FALSE *)
Runtime Errors
None.
Table 384 Input Parameters
Name Data Type Description
IN BOOL Enables TOGGLE.
RESET BOOL Resets TOGGLE.
Table 385 Output Parameters
Name Data Type Description
Q BOOL The current state.
Table 386 Truth Table
IN RESET Q
false false no change
false true false
true false not Q
true true false
TOGGLE 323
TriStation 1131 Libraries Reference
Application Notes
Can be used in Safety or Control applications.
Only Once: each instance should be executed only once per scan, but does not need to
be executed every scan.
Can be used in CEM Cause, Effect, and Intersection cells.
Library
Triconex (TCXLIB)
324 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
TON
Delays the rising edge of a pulse.
Syntax
MY_TON( IN:=b1, PT:=t1 ) ;
Description
The TON function block provides a delay of duration PT from the rising edge of input IN to the
rising edge of output Q.
IN is the input pulse. The rising edge of IN starts the timer. While IN is true, after a delay of
duration PT, the timer changes Q to true. If at any time the input IN changes to false, the timer
resets, changing Q to false and ET to zero.
PT gives the duration of the delay.
Q is the output pulse. Q is initially false. Q changes from false to true after the specified delay
time. Q changes from true to false when the input changes from true to false.
Output ET (elapsed time) gives the time since the rising edge of input IN. The maximum value
of ET is PT.
Table 387 Input Parameters
Name Data Type Description
IN BOOL The input pulse.
PT TIME The pulse time.
Table 388 Output Parameters
Name Data Type Description
Q BOOL The output pulse.
ET TIME The elapsed time.
TON 325
TriStation 1131 Libraries Reference
ET gives the elapsed time from the rising edge of IN, while IN is true and Q is false. While IN is
true and Q is true, ET is equal to PT. If IN is false, then ET is zero.
If the width of input IN is less than PT, then output Q does not change.
Example
VAR MY_TON : TON ; END_VAR
VAR b1, b2 : BOOL ; END_VAR
MY_TON( IN:=b1, PT:=T#10s ) ;
b2 := MY_TON.Q ;
(* result: The delay time is about 10 seconds from the rising edge of b1 to
the rising edge of b2. *)
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Only Once: each instance should be executed only once per scan, but does not need to
be executed every scan.
Can be used in CEM Cause, Effect, and Intersection cells.
Library
Standard (STDLIB)
326 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
TP
Generates a timed pulse.
Syntax
MY_TP( IN:=b1, PT:=t1 ) ;
Description
The TP function block generates a pulse of duration PT starting on the rising edge of input IN.
IN is an input pulse. The rising edge of IN starts the timer, setting Q to true. While Q is true, the
timer ignores IN.
PT gives the requested duration of the pulse. When Q is true and ET is greater than or equal to
PT, the timer resets Q to false.
Q is the output pusle. 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.
Table 389 Input Parameters
Name Data Type Description
IN BOOL The input pulse.
PT TIME The pulse time.
Table 390 Output Parameters
Name Data Type Description
Q BOOL The output pulse.
ET TIME The elapsed time.
TP 327
TriStation 1131 Libraries Reference
Application Notes
Can be used in Safety or Control applications.
Only Once: each instance should be executed only once per scan, but does not need to
be executed every scan.
Can be used in CEM Cause, Effect, and Intersection cells.
Library
Standard (STDLIB)
328 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
TP_I
Generates a timed pulse.
Syntax
MY_TP_I( IN:=b1, PT:=n1 ) ;
Description
The TP_I function block generates a pulse of width PT milliseconds starting on the rising edge
of input IN.
IN is an input pulse. The rising edge of IN starts the timer, setting Q to true. While Q is true, the
timer ignores IN.
PT gives the requested duration of the pulse in milliseconds. When Q is true and the pulse width
is greater than or equal to PT milliseconds, the timer resets Q to false.
Q is the output pusle. The timer sets Q true on the rising edge of IN. Q remains true for time PT
milliseconds, and then changes to false.
Notes If PT is within one scan period of 2147483647 milliseconds (25 days), then the time
accumulator can overflow to a negative value.
You must invoke an instance of TP_I exactly once per scan.
Example
VAR MY_TP_I : TP_I ; END_VAR
VAR b1, b2 : BOOL ; END_VAR
MY_TP_I( IN:=b1, PT:=10000 ) ;
b2 := MY_TP_I.Q ;
(* The result b2 is a pulse of approximately 10 seconds following the rising
edge of b1. *)
Runtime Errors
None.
Table 391 Input Parameters
Name Data Type Description
IN BOOL The input pulse.
PT DINT The pulse time in milliseconds.
Table 392 Output Parameters
Name Data Type Description
Q BOOL The output pulse.
TP_I 329
TriStation 1131 Libraries Reference
Application Notes
Can be used in Safety or Control applications.
Exactly Once: each instance should be executed exactly once per scan.
Can be used in CEM Cause, Effect, and Intersection cells.
Library
Standard (STDLIB)
330 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
TP_R
Generates a timed pulse.
Syntax
MY_TP_R( IN:=b1, PT:=x1 ) ;
Description
The TP_R function block generates a pulse of width PT seconds starting on the rising edge of
input IN.
IN is an input pulse. The rising edge of IN starts the timer, setting Q to true. While Q is true, the
timer ignores IN.
PT gives the requested duration of the pulse in seconds. When Q is true and the pulse width is
greater than or equal to PT seconds, the timer resets Q to false.
Q is the output pusle. The timer sets Q true on the rising edge of IN. Q remains true for time PT
seconds, and then changes to false.
Note 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.
Table 393 Input Parameters
Name Data Type Description
IN BOOL The input pulse.
PT REAL The pulse time in seconds.
Table 394 Output Parameters
Name Data Type Description
Q BOOL The output pulse.
TP_R 331
TriStation 1131 Libraries Reference
Application Notes
Can be used in Safety or Control applications.
Exactly Once: each instance should be executed exactly once per scan.
Can be used in CEM Cause, Effect, and Intersection cells.
Library
Standard (STDLIB)
332 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
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 ) ;
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.
Table 395 Input Parameters
Name Data Type Description
CI BOOL Enables TR_64_POINT_STATUS.
CHASSIS DINT The chassis number.
SLOT DINT The physical slot number.
Table 396 Output Parameters
Name Data Type Description
CO BOOL False if the chassis or the slot is invalid.
FUSE_01_32 DWORD The status of a point on a module (point 01 is least significant bit, point
32 is most significant bit).
0 = Good point
1 = Bad point
FUSE_33_64 DWORD The status of a point on a module (point 33 is least significant bit, point
64 is most significant bit).
FAULT_01_32 DWORD The diagnostic status of a point on a module (point 01 is least
significant bit, point 32 is most significant bit).
If an output module:
0 = Point passed output voter diagnostic (OVD) most significant bit.
1 = Point failed OVD.
If an input module:
0 = Point passed the compare test.
1 = Point failed the compare test.
FAULT_33_64 DWORD The diagnostic status of a point on a module (point 33 is least
significant bit, point 64 is most significant bit).
TR_64_POINT_STATUS 333
TriStation 1131 Libraries Reference
Example
(* Get the status for chassis 1 slot 5. *)
VAR MY_TR_64_POINT_STATUS : TR_64_POINT_STATUS ; END_VAR
MY_TR_64_POINT_STATUS( CI:=TRUE, CHASSIS:=1, SLOT:=5 ) ;
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, Using a Space Saver Function
Block on page 5.
Library
Tricon (TR1LIB/TX1LIB)
Condition Return Value Error Flags
If the chassis or slot is invalid. CO=false BADPARAM, ERROR
334 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
TR_CALENDAR
Gets calendar values from a Tricon controller.
Syntax
MY_TR_CALENDAR( CI:= b1 ) ;
Description
The TR_CALENDAR function block gets the date and time from a Tricon controller.
Example
(*
* Get the current day of the month.
*)
VAR NOW : TR_CALENDAR ; END_VAR
VAR TODAY : DINT ; END_VAR
NOW() ;
TODAY := NOW.DAY
Runtime Errors
None.
Table 397 Input Parameters
Name Data Type Description
CI BOOL Enables TR_CALENDAR.
Table 398 Output Parameters
Name Data Type Description
CO BOOL True if TR_CALENDAR executes successfully.
YEAR DINT The year (for example, 1998).
MONTH DINT The month (112).
DAY DINT The day of the month (131).
HOUR DINT The hour (023).
MINUTE DINT The minute (059).
SECOND DINT The second (059).
MILLISEC DINT The millisecond (0999).
WEEKDAY DINT The day of the week (06, 0=Sunday).
RELSEC DINT The seconds since Jan 01 1970 00:00:00.
TR_CALENDAR 335
TriStation 1131 Libraries Reference
Application Notes
Can be used in Safety or Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, see Using a Space Saver
Function Block on page 5.
Library
Tricon (TR1LIB/TX1LIB)
336 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
TR_CHASSIS_STATUS
Gets the chassis status from a Tricon controller.
Syntax
MY_TR_CHASSIS_STATUS( CI:=b1, CHASSIS:=n1 ) ;
Description
The TR_CHASSIS_STATUS function block gets the chassis status from a Tricon controller.
Example
(* Get the status for chassis 3. *)
VAR MY_TR_CHASSIS_STATUS : TR_CHASSIS_STATUS ; END_VAR
MY_TR_CHASSIS_STATUS( CHASSIS:=3 ) ;
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Table 399 Input Parameters
Name Data Type Description
CI BOOL Enables TR_CHASSIS_STATUS.
CHASSIS DINT The chassis number.
Table 400 Output Parameters
Name Data Type Description
CO BOOL True if TR_CHASSIS_STATUS executes successfully.
MAINTENANCE BOOL True if the chassis requires maintenance.
UPPERPOWER BOOL True if the upper power supply in the chassis has a fault.
LOWERPOWER BOOL True if the lower power supply in the chassis has a fault.
IOFAULT BOOL True if an active module in the chassis has a fault.
Condition Return Value Error Flags
If the chassis number is invalid. CO=false BADPARAM, ERROR
TR_CHASSIS_STATUS 337
TriStation 1131 Libraries Reference
Application Notes
Can be used in Safety or Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, see Using a Space Saver
Function Block on page 5.
Library
Tricon (TR1LIB/TX1LIB)
338 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
TR_CLEAR_FLTS
Clears all faults in the system.
Syntax
ERROR_NUMBER := TR_CLEAR_FLTS( CLEAR_FLTS := TRUE );
Description
The TR_CLEAR_FLTS function clears all alarms from the system. If the input is true, all alarms
are cleared.
Example
(* Clear fault alarms. *)
VAR ERROR_NUMBER : DINT ; END_VAR
ERROR_NUMBER := TR_CLEAR_FLTS( CLEAR_FLTS := TRUE );
Runtime Errors
Upon detection of a runtime error, the function resets ENO and sets the BADPARAM status
flag. For more information about error flags and runtime errors, see the CHK_ERR function
block.
Application Notes
Can be used in Safety or Control applications.
Library
Tricon (TX1LIB)
8
Table 401 Input Parameters
Name Data Type Description
CLEAR_FLTS BOOL Clears fault alarms.
Table 402 Return Value
Data Type Description
DINT If zero, the function is successful.
If -1, the function is unsuccessful because the TSX version does not support this feature.
Only available with Tricon v10 and later systems.
Condition Return Value Error Flags
If the system is not Tricon v10 or later, the function is not supported. -1 BADPARAM
8. This function was added to the library in v1.62 of TX1LIB, first released with TriStation 1131 v4.1.419.
TR_CRITICAL_IO 339
TriStation 1131 Libraries Reference
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 ) ;
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 Tricon Safety Considerations Guide.
Table 403 Input Parameters
Name Data Type Description
CI BOOL Enables TR_CRITICAL_IO.
INIT BOOL Initializes TR_CRITICAL_IO.
CHASSIS DINT The chassis number (115).
SLOT DINT The physical slot number.
APP DINT The application number (1-2).
RELAY_OK BOOL The relay is energized and not stuck.
Table 404 Output Parameters
Name Data Type Description
CO BOOL True if TR_CRITICAL_IO executes successfully.
TMR BOOL Three channels are operating without fatal faults on critical I/O
modules detected.
GE_DUAL BOOL Two channels are operating without fatal faults on critical I/O
modules detected.
GE_SINGLE BOOL At least one channel is operating without faults on critical I/O
modules detected.
NO_VOTER_FLTS BOOL No voter faults on critical I/O modules detected.
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.
4 = An invalid application number is used.
5 = Not initialized.
340 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Instructions for Use
The following instructions for using the TR_CRITICAL_IO function block apply to the
Structured Text (ST) language.
To obtain the accumulated status of critical I/O modules:
1 Initialize TR_CRITICAL_IO by invoking it once with INIT := TRUE.
2 To complete initialization, invoke TR_CRITICAL_IO again with these input settings:
INIT := FALSE
CI := TRUE
APP := DE_ENERGIZED
RELAY_OK := FALSE
3 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);
4 Read the output values:
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:
My Documents\Triconex\TriStation 1131 4.x\Projects\ExTUV.pt2
TR_CRITICAL_IO 341
TriStation 1131 Libraries Reference
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Library
Tricon (TR1LIB/TX1LIB)
Condition Return Value Error Flags
If ERROR_NUM is non-zero Reset all BOOL outputs to false BADPARAM, ERROR
342 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
TR_MP_STATUS
Gets the status of the Main Processor.
Syntax
MY_TR_MP_STATUS( CI:=b1 ) ;
Description
Main Processor Status 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.
Table 405 Input Parameters
Name Data Type Description
CI BOOL Enables TR_MP_STATUS.
Table 406 Output Parameters
Name Data Type Description
CO BOOL True if TR_MP_STATUS executes successfully.
MPMAIN BOOL At least one MP is out-of-sync or has failed.
MPBAD BOOL Two MPs are out-of-sync or have failed, or the controller is running in
simplex mode.
IOMAIN BOOL One of these conditions is true:
One channel of an I/O module is reporting a major or fatal error.
The communication to a channel of an I/O module has failed.
At least one MP is out-of-sync or has failed.
IOBAD BOOL One of these conditions is true:
A channel of a digital output module has an OVD error followed by a
failure of an MP.
A channel of a digital output module has an OVD error and a channel
of the same module has a bad module error.
Channel x of an I/O module has a bad module error and MP y has
failed, where x < > y.
Two MPs have failed and/or are out-of- sync.
Two channels of an I/O module have bad module errors.
TR_MP_STATUS 343
TriStation 1131 Libraries Reference
Application Notes
Can be used in Safety or Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, see Using a Space Saver
Function Block on page 5.
Library
Tricon (TR1LIB/TX1LIB)
344 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
TR_PEER_STATUS
Gets the Peer-to-Peer status of a node.
Syntax
MY_TR_PEER_STATUS( CI:=b1, NODE:=n1 ) ;
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:
(Tricon) My Documents\Triconex\TriStation 1131 4.x\Projects\ExPeer.pt2
(Trident) My Documents\Triconex\TriStation 1131 4.x\Projects\TdPeer.pt2
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, see Using a Space Saver
Function Block on page 5.
Library
Tricon (TR1LIB/TX1LIB)
Table 407 Input Parameters
Name Data Type Description
CI BOOL Enables TR_PEER_STATUS.
NODE DINT The node number.
Table 408 Output Parameters
Name Data Type Description
CO BOOL True if TR_PEER_STATUS executes successfully.
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.
Condition Return Value Error Flags
If the node number is invalid. CO=false BADPARAM, ERROR
TR_POINT_STATUS 345
TriStation 1131 Libraries Reference
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 ) ;
Description
The TR_POINT_STATUS function block gets the status of a point from a Tricon controller.
Example
(* Get the status for chassis 1 slot 5 point 7. *)
VAR MY_TR_POINT_STATUS : TR_POINT_STATUS ; END_VAR
MY_TR_POINT_STATUS( CI:=TRUE, CHASSIS:=1, SLOT:=5, POINT:=7 ) ;
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Table 409 Input Parameters
Name Data Type Description
CI BOOL Enables TR_POINT_STATUS.
CHASSIS DINT The chassis number.
SLOT DINT The physical slot number.
POINT DINT The point number.
Table 410 Output Parameters
Name Data Type Description
CO BOOL False if chassis, slot, or point is invalid.
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.
Condition Return Value Error Flags
If the chassis, slot, or point is invalid. CO=false BADPARAM, ERROR
346 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Application Notes
Can be used in Safety or Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, see Using a Space Saver
Function Block on page 5.
Library
Tricon (TR1LIB/TX1LIB)
TR_PORT_STATUS 347
TriStation 1131 Libraries Reference
TR_PORT_STATUS
Gets the status of a , Network Communication Module (NCM) or an Advanced Communication
Module (ACM).
Syntax
MY_TR_PORT_STATUS( CI:=b1 ) ;
Description
The TR_PORT_STATUS function block gets the status of a, Network Communication Module
(NCM), or an Advanced Communication Module (ACM). The NCM_NET1L_OK and
NCM_NET1R_OK inputs always reflect the status of the NET1 port on the NCM; they are not
used with the ACM. The NCM_NET2L_OK and NCM_NET2R_OK inputs always reflect the
status of the NET2 port on the NCM whenever NCMs are configured in the controller. If only
ACMs are configured, these inputs reflect the status of the ACM Net2 ports.
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() ;
Table 411 Input Parameters
Name Data Type Description
CI BOOL Enables TR_PORT_STATUS.
Table 412 Output Parameters
Name Data Type Description
CO BOOL True if TR_PORT_STATUS executes successfully.
ICM_P5_OVFL BOOL The printer on EICM port 5 has a buffer overflow.
ICM_P10_OVFL BOOL The printer on EICM port 10 has a buffer overflow.
ICM_P5_RDY BOOL The printer on EICM port 5 is ready.
ICM_P10_RDY BOOL The printer on EICM port 10 is ready.
NCM_NET1L_OK BOOL Port 1 of an NCM in the left slot is operational.
NCM_NET2L_OK BOOL Port 2 of an NCM in the left slot is operational
a
.
a. Reflects status of NCM, unless only ACMs are configured.
NCM_NET1R_OK BOOL Port 1 of an NCM in the right slot is. operational.
NCM_NET2R_OK BOOL Port 2 of an NCM in the right slot is operational.
348 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, see Using a Space Saver
Function Block on page 5.
Library
Tricon (TR1LIB/TX1LIB)
TR_PROGRAM_STATUS 349
TriStation 1131 Libraries Reference
TR_PROGRAM_STATUS
Gets the status of a Tricon program.
Syntax
MY_TR_PROGRAM_STATUS( CI:=b1 ) ;
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.
Table 413 Input Parameters
Name Data Type Description
CI BOOL Enables TR_PROGRAM_STATUS.
Table 414 Output Parameters
Name Data Type Description
CO BOOL True if TR_PROGRAM_STATUS executes successfully.
MAJOR_VERSION DINT The major version number of a program.
MINOR_VERSION DINT The minor version number of a program.
WRITE_ENABLED BOOL True if write access from an external host is enabled for
any ALIAS.
DISABLE_NOT_ALLOWED BOOL True if a program does not allow disabling of points.
POINTS_DISABLED DINT The number of points currently disabled.
350 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Application Notes
Can be used in Safety or Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, see Using a Space Saver
Function Block on page 5.
Library
Tricon (TR1LIB/TX1LIB)
TR_SCAN_STATUS 351
TriStation 1131 Libraries Reference
TR_SCAN_STATUS
Gets the status of a scan.
Syntax
MY_TR_SCAN_STATUS( CI:=b1 ) ;
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.
Table 415 Input Parameters
Name Data Type Description
CI BOOL Enables TR_SCAN_STATUS.
Table 416 Output Parameters
Name Data Type Description
CO BOOL True if TR_SCAN_STATUS executes successfully.
POWERUP BOOL The system has been powered up.
FIRSTSCAN BOOL The first scan of a program after a reset.
SCANREQUEST DINT The scan time, in milliseconds, set by the user.
SCANSURPLUS DINT The average surplus scan time for last 100 scans.
SCANDELTA DINT The measured scan time, in milliseconds, for the current scan.
DELTAT TIME The measured scan time for the current scan.
SCANOVERRUN DINT The average number of scan overruns for the last 100 scans.
KEYSWITCH DINT Setting:
0 = STOP
1 = PROGRAM
2 = RUN
3 = REMOTE
352 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Application Notes
Can be used in Safety or Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, see Using a Space Saver
Function Block on page 5.
Library
Tricon (TR1LIB/TX1LIB)
TR_SHUTDOWN 353
TriStation 1131 Libraries Reference
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 417 Input Parameters
Name Data Type Description
CI BOOL Enables TR_SHUTDOWN.
IO_CO BOOL True if TR_SHUTDOWN executes successfully.
IO_TMR BOOL Three channels are operating without fatal faults detected.
IO_GE_DUAL BOOL Two channels are operating without fatal faults detected.
IO_GE_SINGLE BOOL One channel is operating without fatal faults detected.
IO_NO_VOTER_FLTS BOOL No failed critical modules detected.
IO_ERROR DINT Zero = no error.
Non-zero = programming or configuration error.
MAX_TIME_DUAL TIME The maximum time of continuous operation in dual mode
(two channels operating).
MAX_TIME_SINGLE TIME The maximum time of continuous operation in single mode
(one channel operating).
MAX_SCAN_TIME TIME 50% of the maximum response time.
Table 418 Output Parameters
Name Data Type Description
CO BOOL True if TR_SHUTDOWN executes
successfully.
OPERATING BOOL If false, shut down.
TMR BOOL Three channels are operating.
DUAL BOOL Two channels are operating.
SINGL BOOL One channel is operating.
ZERO BOOL No channels are operating.
TIMER_RUNNING BOOL The shutdown timer is running
TIME_LEFT TIME The time remaining to shutdown.
ALARM_PROGRAMMING_PERMITTED BOOL True if application changes are permitted.
ALARM_REMOTE_ACCESS BOOL True if remote-host writes are enabled.
354 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Description
The TR_SHUTDOWN function block enables a Tricon system shutdown according to industry
guidelines. For more information, see the Tricon Safety Considerations Guide.
Example
For shutdown examples, see this sample project:
My Documents\Triconex\TriStation 1131 4.x\Projects\ExTUV.pt2
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
If 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)
ALARM_RESPONSE_TIME BOOL True if actual scan time is greater than or
equal to MAX_SCAN_TIME.
ALARM_DISABLED_POINTS BOOL True if one or more points are disabled.
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.
Condition Return Value Error Flags
If ERROR is non-zero Set alarm outputs to true, reset the other BOOL
outputs to false, and reset TIME_LEFT to zero.
BADPARAM, ERROR
Table 418 Output Parameters (continued)
Name Data Type Description
TR_SLOT_STATUS 355
TriStation 1131 Libraries Reference
TR_SLOT_STATUS
Gets the status of a Tricon slot.
Syntax
MY_TR_SLOT_STATUS( CI:=b1, CHASSIS:=n1, SLOT:=n2 ) ;
Description
The TR_SLOT_STATUS function block gets the status of a Tricon 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 ) ;
Table 419 Input Parameters
Name Data Type Description
CI BOOL Enables TR_SLOT_STATUS.
CHASSIS DINT The chassis number.
SLOT DINT The physical slot number.
Table 420 Output Parameters
Name Data Type Description
CO BOOL False if the chassis or the slot is invalid.
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 An I/O module is installed and configured in the slot.
VOTER_FAULT BOOL An I/O module is installed in the slot and a point has a voter fault.
OVD_ENABLED BOOL An I/O module is installed in the slot and output voter diagnostics
are enabled.
NOGOOD BOOL The I/O module installed in the slot is operating in SINGLE mode
for at least one point. Please refer to the Safety Considerations Guide
for Tricon v9-v10 Systems for SINGLE mode SIL operation time
guidelines.
356 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, see Using a Space Saver
Function Block on page 5.
Library
Tricon (TR1LIB/TX1LIB)
Condition Return Value Error Flags
If the chassis or slot is invalid. CO=false BADPARAM, ERROR
TR_URCV_BOOL 357
TriStation 1131 Libraries Reference
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 ) ;
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.
Table 421 Input Parameters
Name Data Type Description
CI BOOL Enables TR_URCV_BOOL.
RECVID DINT The unique identifier for a TR_URCV_BOOL function block (199).
SENDNODE DINT Specifies which node sends data to a TR_URCV_BOOL function block
(120).
SENDID DINT The unique identifier for a matching TR_USEND_BOOL function block
in a sending controller (199).
N DINT The number of values to receive (120).
Table 422 Output Parameters
Name Data Type Description
NDR BOOL New data received.
ERROR BOOL True if STATUS is equal to or greater than 100.
STATUS DINT 0 = Ready to receive data from sending controller.
1 = New data received, ready for processing.
102 = Invalid RECVID, SENDNODE, or SENDID input.
103 = Mismatched data type or number of values in SEND and RECV
function calls.
105 = More than one RECV function has the same RECVID.
RD_01
.
.
.
RD_20
BOOL
.
.
.
BOOL
Receive data 01.
.
.
.
Receive data 20.
358 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Example
For Peer-to-Peer examples, see these sample projects:
(Tricon) My Documents\Triconex\TriStation 1131 4.x\Projects\ExPeer.pt2
(Trident) My Documents\Triconex\TriStation 1131 4.x\Projects\TdPeer.pt2
Runtime Errors
For error numbers, see the description for the STATUS output.
Application Notes
Can be used in Safety or Control applications.
Exactly Once: each instance should be executed exactly once per scan.
Library
Tricon (TR1LIB/TX1LIB)
Condition Return Value Error Flags
If STATUS is greater than or equal to 100. ERROR=true None
TR_URCV_DINT 359
TriStation 1131 Libraries Reference
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 ) ;
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.
Table 423 Input Parameters
Name Data Type Description
CI BOOL Enables TR_URCV_DINT.
RECVID DINT The unique identifier for a TR_URCV_DINT function block (199).
SENDNODE DINT Specifies which node sends data to a TR_URCV_DINT function block
(120).
SENDID DINT The unique identifier for a matching TR_USEND_DINT function block
in a sending controller (199).
N DINT The number of values to receive (120).
Table 424 Output Parameters
Name Data Type Description
NDR BOOL New data received.
ERROR BOOL True if STATUS is equal to or greater than 100.
STATUS DINT 0 = Ready to receive data from sending controller.
1 = New data received, ready for processing.
102 = Invalid RECVID, SENDNODE, or SENDID input.
103 = Mismatched data type or number of values in SEND and RECV
function calls.
105 = More than one RECV function has the same RECVID.
RD_01
.
.
.
RD_20
DINT
.
.
.
DINT
Receive data 01.
.
.
.
Receive data 20.
360 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Example
For Peer-to-Peer examples, see these sample projects:
(Tricon) My Documents\Triconex\TriStation 1131 4.x\Projects\ExPeer.pt2
(Trident) My Documents\Triconex\TriStation 1131 4.x\Projects\TdPeer.pt2
Runtime Errors
For error numbers, see the description for the STATUS output.
Application Notes
Can be used in Safety or Control applications.
Exactly Once: each instance should be executed exactly once per scan.
Library
Tricon (TR1LIB/TX1LIB)
Condition Return Value Error Flags
If STATUS is greater than or equal to 100. ERROR=true None
TR_URCV_DINT_32 361
TriStation 1131 Libraries Reference
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 ) ;
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.
Table 425 Input Parameters
Name Data Type Description
CI BOOL Enables TR_URCV_DINT_32.
RECVID DINT The unique identifier for a TR_URCV_DINT_32 function block (199).
SENDNODE DINT Specifies which node sends data to a TR_URCV_DINT_32 function
block (132).
SENDID DINT The unique identifier for a matching TR_USEND_DINT_32 function
block in a sending controller (199).
N DINT The number of values to receive (132).
Table 426 Output Parameters
Name Data Type Description
NDR BOOL New data received.
ERROR BOOL True if STATUS is equal to or greater than 100.
STATUS DINT 0 = Ready to receive data from sending controller.
1 = New data received, ready for processing.
102 = Invalid RECVID, SENDNODE, or SENDID input.
103 = Mismatched data type or number of values in SEND and RECV
function calls.
105 = More than one RECV function has the same RECVID.
RD_01
.
.
.
RD_32
DINT
.
.
.
DINT
Receive data 01.
.
.
.
Receive data 32.
362 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Example
For Peer-to-Peer examples, see these sample projects:
(Tricon) My Documents\Triconex\TriStation 1131 4.x\Projects\ExPeer.pt2
(Trident) My Documents\Triconex\TriStation 1131 4.x\Projects\TdPeer.pt2
Runtime Errors
For error numbers, see the description for the STATUS output.
Application Notes
Can be used in Safety or Control applications.
Exactly Once: each instance should be executed exactly once per scan.
Library
Tricon (TR1LIB/TX1LIB)
Condition Return Value Error Flags
If STATUS is greater than or equal to 100. ERROR=true None
TR_URCV_REAL 363
TriStation 1131 Libraries Reference
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 ) ;
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.
Table 427 Input Parameters
Name Data Type Description
CI BOOL Enables TR_URCV_REAL.
RECVID DINT The unique identifier for a TR_URCV_REAL function block (199).
SENDNODE DINT Specifies which node sends data to a TR_URCV_REAL function block
(120).
SENDID DINT The unique identifier for a matching TR_USEND_REAL function block
in a sending controller (199).
N DINT The number of values to receive (120).
Table 428 Output Parameters
Name Data Type Description
NDR BOOL New data received.
ERROR BOOL True if STATUS is equal to or greater than 100.
STATUS DINT 0 = Ready to receive data from sending controller.
1 = New data received, ready for processing.
102 = Invalid RECVID, SENDNODE, or SENDID input.
103 = Mismatched data type or number of values in SEND and RECV
function calls.
105 = More than one RECV function has the same RECVID.
RD_01
.
.
.
RD_20
REAL
.
.
.
REAL
Receive data 01.
.
.
.
Receive data 20.
364 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Example
For Peer-to-Peer examples, see these sample projects:
(Tricon) My Documents\Triconex\TriStation 1131 4.x\Projects\ExPeer.pt2
(Trident) My Documents\Triconex\TriStation 1131 4.x\Projects\TdPeer.pt2
Runtime Errors
For error numbers, see the description for the STATUS output.
Application Notes
Can be used in Safety or Control applications.
Exactly Once: each instance should be executed exactly once per scan.
Library
Tricon (TR1LIB/TX1LIB)
Condition Return Value Error Flags
If STATUS is greater than or equal to 100. ERROR=true None
TR_URCV_REAL_32 365
TriStation 1131 Libraries Reference
TR_URCV_REAL_32
Receives up to 32 data values from a matching TR_USEND_REAL function block on another
Triconex controller.
Syntax
MY_TR_URCV_REAL_32( CI:=b1, RECVID:=n1, SENDNODE:=n2, SENDID:=n3, N:=n4 ) ;
Description
The TR_URCV_REAL_32 function block receives up to 32 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.
Table 429 Input Parameters
Name Data Type Description
CI BOOL Enables TR_URCV_REAL_32.
RECVID DINT The unique identifier for a TR_URCV_REAL_32 function block (199).
SENDNODE DINT Specifies which node sends data to a TR_URCV_REAL_32 function
block (132).
SENDID DINT The unique identifier for a matching TR_USEND_REAL_32 function
block in a sending controller (199).
N DINT The number of values to receive (132).
Table 430 Output Parameters
Name Data Type Description
NDR BOOL New data received.
ERROR BOOL True if STATUS is equal to or greater than 100.
STATUS DINT 0 = Ready to receive data from sending controller.
1 = New data received, ready for processing.
102 = Invalid RECVID, SENDNODE, or SENDID input.
103 = Mismatched data type or number of values in SEND and RECV
function calls.
105 = More than one RECV function has the same RECVID.
RD_01
.
.
.
RD_32
REAL
.
.
.
REAL
Receive data 01.
.
.
.
Receive data 32.
366 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Example
For Peer-to-Peer examples, see these sample projects:
(Tricon) My Documents\Triconex\TriStation 1131 4.x\Projects\ExPeer.pt2
(Trident) My Documents\Triconex\TriStation 1131 4.x\Projects\TdPeer.pt2
Runtime Errors
For error numbers, see the description for the STATUS output.
Application Notes
Can be used in Safety or Control applications.
Exactly Once: each instance should be executed exactly once per scan.
Library
Tricon (TR1LIB/TX1LIB)
Condition Return Value Error Flags
If STATUS is greater than or equal to 100. ERROR=true None
TR_USEND_BOOL 367
TriStation 1131 Libraries Reference
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 431 Input Parameters
Name Data Type Description
SENDFLG BOOL Enables TR_USEND_BOOL.
SENDID DINT The unique identifier for a TR_USEND_BOOL function block (199).
RECVNODE DINT Specifies which controller node receives data from a TR_USEND_BOOL
function block (120).
RECVID DINT The unique identifier for a matching TR_URCV_BOOL function block in
a receiving controller (199).
N DINT The number of values to send (120).
SD_01
.
.
.
SD_20
BOOL
.
.
.
BOOL
Send data 01.
.
.
.
Send data 20.
Table 432 Output Parameters
Name Data Type Description
SENT BOOL Send initiated (STATUS = 1 or 4).
ACK BOOL Send acknowledged (STATUS = 3 or 4).
ERROR BOOL True if STATUS is greater than or equal to 100.
368 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
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:
(Tricon) My Documents\Triconex\TriStation 1131 4.x\Projects\ExPeer.pt2
(Trident) My Documents\Triconex\TriStation 1131 4.x\Projects\TdPeer.pt2
Runtime Errors
For error numbers, see the description for the STATUS output.
Application Notes
Can be used in Safety or Control applications.
Exactly Once: each instance should be executed exactly once per scan.
Library
Tricon (TR1LIB/TX1LIB)
STATUS DINT 0 = Connected to a controller node, ready to SEND.
1 = SEND initiated with SENDFLG set to 1.
2 = SEND function is busy sending data.
3 = Last SEND completed (receiving node has received SEND data).
4 = SEND completed and new SEND initiated.
100 = Not connected to controller node.
101 = Last SEND failed (communication problem with receiving node).
102 = Invalid SENDID, RECVNODE, or RECVID input.
103 = Mismatched data type or number of values in SEND and RECV
function calls.
104 = Number of values specified by input N is out of range.
105 = More than one SEND function has same SENDID.
Condition Return Value Error Flags
If STATUS is greater than or equal to 100. ERROR=true None
Table 432 Output Parameters (continued)
Name Data Type Description
TR_USEND_DINT 369
TriStation 1131 Libraries Reference
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 433 Input Parameters
Name Data Type Description
SENDFLG BOOL Enables TR_USEND_DINT.
SENDID DINT The unique identifier for a TR_USEND_DINT function block (199).
RECVNODE DINT Specifies which controller node receives data from a TR_USEND_DINT
function block (120).
RECVID DINT The unique identifier for a matching TR_URCV_DINT function block in
a receiving controller (199).
N DINT The number of values to send (120).
SD_01
.
.
.
SD_20
DINT
.
.
.
DINT
Send data 01.
.
.
.
Send data 20.
Table 434 Output Parameters
Name Data Type Description
SENT BOOL Send initiated (STATUS = 1 or 4).
ACK BOOL Send acknowledged (STATUS = 3 or 4).
ERROR BOOL True if STATUS is greater than or equal to 100.
370 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
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:
(Tricon) My Documents\Triconex\TriStation 1131 4.x\Projects\ExPeer.pt2
(Trident) My Documents\Triconex\TriStation 1131 4.x\Projects\TdPeer.pt2
Runtime Errors
For error numbers, see the description for the STATUS output.
Application Notes
Can be used in Safety or Control applications.
Exactly Once: each instance should be executed exactly once per scan.
Library
Tricon (TR1LIB/TX1LIB)
STATUS DINT 0 = Connected to a controller node, ready to SEND.
1 = SEND initiated with SENDFLG set to 1.
2 = SENDFLGSEND function is busy sending data.
3 = Last SEND completed (receiving node has received SEND data).
4 = SEND completed and new SEND initiated.
100 = Not connected to controller node.
101 = Last SEND failed (communication problem with receiving node).
102 = Invalid SENDID, RECVNODE, or RECVID input.
103 = Mismatched data type or number of values in SEND and RECV
function calls.
104 = Number of values specified by input N is out of range.
105 = More than one SEND function has same SENDID.
Condition Return Value Error Flags
If STATUS is greater than or equal to 100. ERROR=true None
Table 434 Output Parameters (continued)
Name Data Type Description
TR_USEND_DINT_32 371
TriStation 1131 Libraries Reference
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 435 Input Parameters
Name Data Type Description
SENDFLG BOOL Enables TR_USEND_DINT_32.
SENDID DINT The unique identifier for a TR_USEND_DINT_32 function block (199).
RECVNODE DINT Specifies which controller node receives data from a
TR_USEND_DINT_32 function block (132).
RECVID DINT The unique identifier for a matching TR_URCV_DINT_32 function
block in a receiving controller (199).
N DINT The number of values to send (132).
SD_01
.
.
.
SD_32
DINT
.
.
.
DINT
Send data 01.
.
.
.
Send data 32.
Table 436 Output Parameters
Name Data Type Description
SENT BOOL Send initiated (STATUS = 1 or 4).
ACK BOOL Send acknowledged (STATUS = 3 or 4).
ERROR BOOL True if STATUS is greater than or equal to 100.
372 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
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:
(Tricon) My Documents\Triconex\TriStation 1131 4.x\Projects\ExPeer.pt2
(Trident) My Documents\Triconex\TriStation 1131 4.x\Projects\TdPeer.pt2
Runtime Errors
For error numbers, see the description for the STATUS output.
Application Notes
Can be used in Safety or Control applications.
Exactly Once: each instance should be executed exactly once per scan.
Library
Tricon (TR1LIB/TX1LIB)
STATUS DINT 0 = Connected to a controller node, ready to SEND.
1 = SEND initiated with SENDFLG set to 1.
2 = SEND function is busy sending data.
3 = Last SEND completed (receiving node has received SEND data).
4 = SEND completed and new SEND initiated.
100 = Not connected to controller node.
101 = Last SEND failed (communication problem with receiving node).
102 = Invalid SENDID, RECVNODE, or RECVID input.
103 = Mismatched data type or number of values in SEND and RECV
function calls.
104 = Number of values specified by input N is out of range.
105 = More than one SEND function has same SENDID.
Condition Return Value Error Flags
If STATUS is greater than or equal to 100. ERROR=true None
Table 436 Output Parameters (continued)
Name Data Type Description
TR_USEND_REAL 373
TriStation 1131 Libraries Reference
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 437 Input Parameters
Name Data Type Description
SENDFLG BOOL Enables TR_USEND_REAL.
SENDID DINT The unique identifier for a TR_USEND_REAL function block (199).
RECVNODE DINT Specifies which controller node receives data from a TR_USEND_REAL
function block (120).
RECVID DINT The unique identifier for a matching TR_URCV_REAL function block in
a receiving controller (199).
N DINT The number of values to send (120).
SD_01
.
.
.
SD_20
REAL
.
.
.
REAL
Send data 01.
.
.
.
Send data 20.
Table 438 Output Parameters
Name Data Type Description
SENT BOOL Send initiated (STATUS = 1 or 4).
ACK BOOL Send acknowledged (STATUS = 3 or 4).
ERROR BOOL True if STATUS is greater than or equal to 100.
374 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
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:
(Tricon) My Documents\Triconex\TriStation 1131 4.x\Projects\ExPeer.pt2
(Trident) My Documents\Triconex\TriStation 1131 4.x\Projects\TdPeer.pt2
Runtime Errors
For error numbers, see the description for the STATUS output.
Application Notes
Can be used in Safety or Control applications.
Exactly Once: each instance should be executed exactly once per scan.
Library
Tricon (TR1LIB/TX1LIB)
STATUS DINT 0 = Connected to a controller node, ready to SEND.
1 = SEND initiated with SENDFLG set to 1.
2 = SEND function is busy sending data.
3 = Last SEND completed (receiving node has received SEND data).
4 = SEND completed and new SEND initiated.
100 = Not connected to controller node.
101 = Last SEND failed (communication problem with receiving node).
102 = Invalid SENDID, RECVNODE, or RECVID input.
103 = Mismatched data type or number of values in SEND and RECV
function calls.
104 = Number of values specified by input N is out of range.
105 = More than one SEND function has same SENDID.
Condition Return Value Error Flags
If STATUS is greater than or equal to 100. ERROR=true None
Table 438 Output Parameters (continued)
Name Data Type Description
TR_USEND_REAL_32 375
TriStation 1131 Libraries Reference
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 439 Input Parameters
Name Data Type Description
SENDFLG BOOL Enables TR_USEND_REAL_32.
SENDID DINT The unique identifier for a TR_USEND_REAL_32 function block (1-99).
RECVNODE DINT Specifies which controller node receives data from a
TR_USEND_REAL_32 function block (132).
RECVID DINT The unique identifier for a matching TR_URCV_REAL_32 function
block in a receiving controller (199).
N DINT The number of values to send (132).
SD_01
.
.
.
SD_32
REAL
.
.
.
REAL
Send data 01.
.
.
.
Send data 32.
Table 440 Output Parameters
Name Data Type Description
SENT BOOL Send initiated (STATUS = 1 or 4).
ACK BOOL Send acknowledged (STATUS = 3 or 4).
ERROR BOOL True if STATUS is greater than or equal to 100.
376 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
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:
(Tricon) My Documents\Triconex\TriStation 1131 4.x\Projects\ExPeer.pt2
(Trident) My Documents\Triconex\TriStation 1131 4.x\Projects\TdPeer.pt2
Runtime Errors
For error numbers, see the description for the STATUS output.
Application Notes
Can be used in Safety or Control applications.
Exactly Once: each instance should be executed exactly once per scan.
Library
Tricon (TR1LIB/TX1LIB)
STATUS DINT 0 = Connected to a controller node, ready to SEND.
1 = SEND initiated with SENDFLG set to 1.
2 = SEND function is busy sending data.
3 = Last SEND completed (receiving node has received SEND data).
4 = SEND completed and new SEND initiated.
100 = Not connected to controller node.
101 = Last SEND failed (communication problem with receiving node).
102 = Invalid SENDID, RECVNODE, or RECVID input.
103 = Mismatched data type or number of values in SEND and RECV
function calls.
104 = Number of values specified by input N is out of range.
105 = More than one SEND function has same SENDID.
Condition Return Value Error Flags
If STATUS is greater than or equal to 100. ERROR=true None
Table 440 Output Parameters (continued)
Name Data Type Description
TR_VOTE_MODE 377
TriStation 1131 Libraries Reference
TR_VOTE_MODE
Converts redundancy status.
Syntax
MY_TR_VOTE_MODE( CI:=b1, IN_TMR:=b2, GE_DUAL:=b3, GE_SINGLE:=b4 ) ;
Description
The TR_VOTE_MODE function block converts redundancy status, as shown in this truth table.
Note GE_ means greater than or equal to.
Table 441 Input Parameters
Name Data Type Description
CI BOOL Enables TR_VOTE_MODE.
IN_TMR BOOL Three channels are operating.
GE_DUAL BOOL Two or more channels are operating.
GE_SINGLE BOOL One or more channels are operating.
Table 442 Output Parameters
Name Data Type Description
CO BOOL True if TR_VOTE_MODE executes successfully.
TMR BOOL Three channels are operating.
DUAL BOOL Two or more channels are operating.
SINGL BOOL One or more channels are operating.
ZERO BOOL No channels are operating.
Table 443 Truth Table
TMR GE_DUAL GE_SINGLE TMR DUAL SINGL ZERO
T T T T F F F
F T T F T F F
F F T F F T F
F F F F F F T
Other
a
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).
F F F F
378 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Example
For shutdown examples, see this sample project:
My Documents\Triconex\TriStation 1131 4.x\Projects\ExTUV.pt2
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, see Using a Space Saver
Function Block on page 5.
Library
Tricon (TR1LIB/TX1LIB)
Condition Return Value Error Flags
If the inputs do not match one of the first
four rows of the truth table
Reset all BOOL outputs to false BADPARAM, ERROR
TRUNC_LREAL_TO_DINT 379
TriStation 1131 Libraries Reference
TRUNC_LREAL_TO_DINT
Truncates a 64-bit long real number to a 32-bit integer.
Syntax
k := TRUNC_LREAL_TO_DINT(x);
Description
The TRUNC_LREAL_TO_DINT function converts a 64-bit long real number to a 32-bit integer
with truncation instead of rounding, which means the fraction is dropped.
Note IEC 1131-3 requires strict data type checking. It does not permit assigning the value of a
variable directly to a variable of a different data type. When it is necessary to use
variables of different data types, an explicit conversion must be made using a data type
conversion function.
Example
VAR k : DINT; x : LREAL; END_VAR;
x := -123.6;
k := TRUNC_LREAL_TO_DINT( x ); (* result is -123 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the
error flags to true, and resets ENO to false. For more information about error flags and runtime
errors, see the CHK_ERR function block.
Table 444 Input Parameters
Name Data Type Description
x LREAL A 64-bit long real number.
Table 445 Return Value
Data Type Description
DINT The integer part of x.
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
380 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
TRUNC_LREAL_TO_INT 381
TriStation 1131 Libraries Reference
TRUNC_LREAL_TO_INT
Truncates a 64-bit long real number to a 16-bit integer.
Syntax
k := TRUNC_LREAL_TO_INT(x);
Description
The TRUNC_LREAL_TO_INT function converts a 64-bit long real number to a 16-bit integer
with truncation instead of rounding, which means the fraction is dropped.
Note IEC 1131-3 requires strict data type checking. It does not permit assigning the value of a
variable directly to a variable of a different data type. When it is necessary to use
variables of different data types, an explicit conversion must be made using a data type
conversion function.
Example
VAR k : INT; x : LREAL; END_VAR;
x := -123.6;
k := TRUNC_LREAL_TO_INT( x ); (* result is -123 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the
error flags to true, and resets ENO to false. For more information about error flags and runtime
errors, see the CHK_ERR function block.
Table 446 Input Parameters
Name Data Type Description
x LREAL A 64-bit long real number.
Table 447 Return Value
Data Type Description
INT The integer part of x.
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
382 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
TRUNC_REAL_TO_DINT 383
TriStation 1131 Libraries Reference
TRUNC_REAL_TO_DINT
Truncates a 32-bit real number to a 32-bit integer.
Syntax
k := TRUNC_REAL_TO_DINT(x);
Description
The TRUNC_REAL_TO_DINT function converts a 32-bit real number to a 32-bit integer with
truncation instead of rounding which means the fraction is dropped.
Note IEC 1131-3 requires strict data type checking. It does not permit assigning the value of a
variable directly to a variable of a different data type. When it is necessary to use
variables of different data types, an explicit conversion must be made using a data type
conversion function.
Example
VAR k : DINT; x : REAL; END_VAR;
x := -123.6;
k := TRUNC_REAL_TO_DINT( x ); (* result is -123 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the
error flags to true, and resets ENO to false. For more information about error flags and runtime
errors, see the CHK_ERR function block.
Table 448 Input Parameters
Name Data Type Description
x REAL A 32-bit real number.
Table 449 Return Value
Data Type Description
DINT The integer part of x.
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
384 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
TRUNC_REAL_TO_INT 385
TriStation 1131 Libraries Reference
TRUNC_REAL_TO_INT
Truncates a 32-bit real number to a 16-bit integer.
Syntax
k := TRUNC_REAL_TO_INT(x);
Description
The TRUNC_REAL_TO_INT function converts a 32-bit real number to a 16-bit integer with
truncation instead of rounding, which means the fraction is dropped.
Note IEC 1131-3 requires strict data type checking. It does not permit assigning the value of a
variable directly to a variable of a different data type. When it is necessary to use
variables of different data types, an explicit conversion must be made using a data type
conversion function.
Example
VAR k : INT; x : REAL; END_VAR;
x := -123.6;
k := TRUNC_REAL_TO_INT( x ); (* result is -123 *)
Runtime Errors
Upon detection of a runtime error condition, the function returns the indicated value, sets the
error flags to true, and resets ENO to false. For more information about error flags and runtime
errors, see the CHK_ERR function block.
Table 450 Input Parameters
Name Data Type Description
x REAL A 32-bit real number.
Table 451 Return Value
Data Type Description
INT The integer part of x.
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
386 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Application Notes
Can be used in Safety or Control applications.
Library
Standard (STDLIB)
TSCHED 387
TriStation 1131 Libraries Reference
TSCHED
Schedules periodic execution.
Syntax
MY_TSCHED( CI:=b1, PERIOD:=t1, OFFSET:=t2 ) ;
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.
Table 452 Input Parameters
Name Data Type Description
CI BOOL Enables TCSCHED.
PERIOD TIME The desired time period between settings of output Q.
OFFSET TIME Time offset before the first setting of output Q (0.0 s OFFSET < PERIOD).
Table 453 Output Parameters
Name Data Type Description
CO BOOL True if TCSCHED executes successfully.
Q BOOL True for one scan each period.
ACTUAL TIME The measured time since last setting of output.
388 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Application Notes
Can be used in Safety or Control applications.
Exactly Once: each instance should be executed exactly once per scan.
Library
Triconex (TCXLIB)
TSCHED_I 389
TriStation 1131 Libraries Reference
TSCHED_I
Schedules periodic execution.
Syntax
MY_TSCHED_I( CI:=b1, PERIOD:=n1, OFFSET:=n2 ) ;
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.
Table 454 Input Parameters
Name Data Type Description
CI BOOL Enables TCSCHED_I.
PERIOD DINT The desired time period, in milliseconds, between settings of output Q.
OFFSET DINT Time offset, in milliseconds, before the first setting of output Q (0.0 is less
than or equal to OFFSET).
Table 455 Output Parameters
Name Data Type Description
CO BOOL True if TCSCHED_I executes successfully.
Q BOOL True for one scan each period.
ACTUAL DINT The measured time, in milliseconds, since last
setting of output Q.
390 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Application Notes
Can be used in Safety or Control applications.
Exactly Once: each instance should be executed exactly once per scan.
Library
Triconex (TCXLIB)
TSCHED_R 391
TriStation 1131 Libraries Reference
TSCHED_R
Schedules periodic execution.
Syntax
MY_TSCHED_R( CI:=b1, PERIOD:=x1, OFFSET:=x2 ) ;
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 ;
Table 456 Input Parameters
Name Data Type Description
CI BOOL Enables TCSCHED_R
PERIOD REAL The desired time period, in seconds, between settings of output Q.
OFFSET REAL Time offset, in seconds, before the first setting of output Q
(0.0 is less than or equal to OFFSET).
Table 457 Output Parameters
Name Data Type Description
CO BOOL True if TCSCHED_R executes successfully.
Q BOOL True for one scan each period.
ACTUAL REAL The measured time, in seconds, since last setting of output Q.
392 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Exactly Once: each instance should be executed exactly once per scan.
Library
Triconex (TCXLIB)
UNPACK16 393
TriStation 1131 Libraries Reference
UNPACK16
Unpacks a DWORD into 16 separate Boolean outputs.
Syntax
MY_UNPACK16( CI:=b1, INPUT:=w1 ) ;
Description
The UNPACK16 function block unpacks the low-order 16 bits of INPUT, a 32-bit word, into 16
separate Boolean outputs (Q01 through Q16). Q01 is the least significant bit and Q16 is the most
significant.
The INPUT data type is DWORD. Output NZ is true if any bits are true, and false if all 16 bits
are false. The UNPACK16 function block is useful for unpacking 16 bits that have been
transmitted using a Modbus alias.
Example
VAR MY_UNPACK16 : UNPACK16 ; END_VAR
MY_UNPACK16( CI:=TRUE, INPUT:=16#0000001F ) ;
(*
* Result on Q outputs of MY_UNPACK16:
* Q16 Q01
* 0000000000011111
*)
Runtime Errors
None.
Table 458 Input Parameters
Name Data Type Description
CI BOOL Enables UNPACK16.
INPUT DWORD The input value.
Table 459 Output Parameters
Name Data Type Description
CO BOOL True if UNPACK16 executes successfully.
NZ BOOL Not zero.
Q01 BOOL Output bit 01 (least significant bit).
Q02 BOOL Output bit 02.
Q03 BOOL Output bit 03.
Qnn BOOL Output bit nn.
Q16 BOOL Output bit 16 (most significant bit).
394 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Application Notes
Can be used in Safety or Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, see Using a Space Saver
Function Block on page 5.
Library
Triconex (TCXLIB)
UNPACK32 395
TriStation 1131 Libraries Reference
UNPACK32
Unpacks a DWORD into 32 separate Boolean outputs.
Syntax
MY_UNPACK32( CI:=b1, INPUT:=w1 ) ;
Description
The UNPACK32 function block unpacks the 32 bits of INPUT, a 32-bit word, into 32 separate
Boolean outputs (Q01 through Q32). Q01 is the least significant bit and Q32 is the most
significant.
The INPUT data type is DWORD. Output NZ is true if any of the bits are true, and false if all 32
bits are false. The UNPACK32 function is useful for unpacking 32 bits that have been
transmitted using peer-to-peer communications.
Example
VAR MY_UNPACK32 : UNPACK32 ; END_VAR
MY_UNPACK32( CI:=TRUE, INPUT:=16#0000001F ) ;
(*
* Result on Q outputs of MY_UNPACK32:
* Q32 Q01
* 00000000000000000000000000011111
*)
Runtime Errors
None.
Table 460 Input Parameters
Name Data Type Description
CI BOOL Enables UNPACK32.
INPUT DWORD The input value.
Table 461 Output Parameters
Name Data Type Description
CO BOOL True if UNPACK32 executes successfully.
NZ BOOL Not zero.
Q01 BOOL Output bit 01 (least significant bit).
Q02 BOOL Output bit 02.
Q03 BOOL Output bit 03.
Qnn BOOL Output bit nn.
Q32 BOOL Output bit 32 (most significant bit).
396 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Application Notes
Can be used in Safety or Control applications.
Space Saver: a single instance can be executed more than once per scan to reduce
memory usage and increase performance. For directions, see Using a Space Saver
Function Block on page 5.
Library
Triconex (TCXLIB)
X_OF_N 397
TriStation 1131 Libraries Reference
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 ) ;
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.
*)
Table 462 Input Parameters
Name Data Type Description
CI BOOL Enables X of N.
RESET BOOL Restarts with 0 measurements.
VALUE REAL The latest measurement.
LMT REAL The limit against which the value is tested.
X DINT The minimum number of N measurements that must exceed the limit to turn
output Q on, where X is less than N.
N DINT The number of measurements entailed, where N is less than or equal to 32.
Table 463 Output Parameters
Name Data Type Description
CO BOOL True if X of N executes successfully.
Q BOOL X of N values exceeding the limit.
398 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
Runtime Errors
Upon detection of a runtime error condition, the function block returns the indicated values and
sets the error flags to true. For more information about error flags and runtime errors, see the
CHK_ERR function block.
Application Notes
Can be used in Safety or Control applications.
Internal State: a single instance can be executed more than once per scan. However, you
should be aware of the internal states that are used from one scan to the next.
Library
Triconex (TCXLIB)
Conditions Return Values Error Flags
If N is less than or equal to 0. CO=false, Q=false BADPARAM, ERROR
If N is greater than 32. CO=false, Q=false BADPARAM, ERROR
If X is less than or equal to 0. CO=false, Q=false BADPARAM, ERROR
If X is greater than or equal to N. CO=false, Q=false BADPARAM, ERROR
XOR 399
TriStation 1131 Libraries Reference
XOR
Performs a logical exclusive OR of two or more Boolean operands or a bitwise exclusive OR of
two or more bit-strings.
Syntax
b := b1 XOR b2 XOR ... XOR bn ;
Description
In graphical languages, the XOR function returns the logical XOR of Boolean operands or the
bitwise XOR of bit-strings. In Structured Text, the XOR operator is used instead of the XOR
function.
The maximum number of function inputs is 50.
All operands must be the same type as the return value either all BOOL or all DWORD.
If the operand type is BOOL, then the result is true if the number of true operands is odd. The
result is false if the number of true operands is even.
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 464 Input Parameters
Name Data Type Description
b1..bn ANY_BIT Operands
Table 465 Output Parameters
Data Type Description
ANY_BIT b1 XOR b2 XOR ... XOR bn
Table 466 Logical XOR
b1 b2 b1 XOR b2
FALSE FALSE FALSE
FALSE TRUE TRUE
TRUE FALSE TRUE
TRUE TRUE FALSE
Table 467 Bitwise XOR
w1 w2 w1 XOR w2
2#0011 2#0101 2#0110
400 Chapter 2 Functions and Data Types
TriStation 1131 Libraries Reference
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 *)
Using Bit-String Operands
VAR w, w1, w2, w3 : DWORD; END_VAR
w1 := 2#00000000000000000000000000000001 ;
w2 := 2#00000000000000000000000000000011 ;
w3 := 2#00000000000000000000000000000111 ;
w := w1 XOR w2 XOR w3; (* 2#00000000000000000000000000000101 *)
w := w1 XOR w2; (* 2#00000000000000000000000000000010 *)
Note that on the Controller Panel, you will see the example values in hex. The hex values of the
operands are w1=16#00000001, w2=16#00000003, w3=16#00000007, and the hex values of the
results are 16#00000005 and 16#00000002.
Runtime Errors
None.
Application Notes
Can be used in Safety or Control applications.
Can be used in CEM Cause cells.
Library
Standard (STDLIB)
TriStation 1131 Libraries Reference
A
Modbus Protocol
Overview 402
Message Response Time 403
Modbus Messages 405
Modbus Functions 411
Transmission Errors and Exception Conditions 422
402 Appendix A Modbus Protocol
TriStation 1131 Libraries Reference
Overview
This sppendix provides detailed information about Modbus protocol, which is a
communication protocol used with serial ports to transmit data between a Modbus master and
slave. Modbus protocol includes functions which define the message format for the query and
response.
Query-Response Sessions
Modbus communication is a query-response session, in which the Modbus master initiates a
query and a Modbus slave responds. In Modbus communication, a serial link transmits data in
both directions, but in only one direction at a time.
A query-response session consists of these actions:
The master sends a query to a slave.
The master starts a fail-safe timer while it waits for the slave response. Typical slave
response time is in hundreds of milliseconds.
The slave returns a response to the master.
The master waits until it has received the response from the slave before sending
another query.
If there is a slave response timeout, the master will retry the query. The number of
retries and the timeout interval is configured by the MBCTRL function block (see
page 133).
For information on configuring Modbus communication, see the Tricon and Trident
Communication Guides.
Message Response Time 403
TriStation 1131 Libraries Reference
Message Response Time
This section explains how to estimate the message response time, which is the total time for
preparing, transmitting, receiving, and processing a Modbus query. Function blocks that are the
least and most affected by scan time increases are also identified in this section.
Topics include:
Determining Message Response Time on page 403
Modbus Functions and Scan Time on page 404
Determining Message Response Time
This table explains how to estimate the number of milliseconds required for the message
response time on a Triconex controller acting as a Modbus slave.
Modbus Operation Equation or Constraints
Prepare Query (master) Varies depending on the specific Modbus function (message) and any
other program processing
Transmit Query (master) (1000 Baud Rate) x Bits per Characters x Number of Characters
Receive and Process Query Tricon EICM slave:
Writes: 3 x Scan Time
Reads: 10 milliseconds
Trident MP slave:
Writes: 3 x Scan Time
Reads: 2 x Scan Time
Trident CM slave:
Writes: 3 x Scan Time
Reads: 10 milliseconds
Transmit Response (slave)
(in milliseconds)
(1000 Baud Rate) x Bits per Characters x Number of Characters
Process Response (master)
(in milliseconds)
Depends on customer-provided equipment performance.
Time-Out and Retry Values Varies depending on settings for the MBCTRL function block, which
determines the time-out and retry values which can increase the
message time (see page 133)
Message Response Time = the sum of all the results
404 Appendix A Modbus Protocol
TriStation 1131 Libraries Reference
Modbus Functions and Scan Time
Modbus performance degrades slightly as the scan time of the controller increases.
When the controller acts as a slave, the functions most affected by scan time increases are:
Force Single Coil (Function Code 05) on page 416
Preset Single Register (Function Code 06) on page 417
Force Multiple Coils (Function Code 15) on page 420
Preset Multiple Registers (Function Code 16) on page 421
The functions least affected by scan time increases are:
Read Coil Status Function (Function Code 01) on page 412
Read Input Status (Function Code 02) on page 413
Read Holding Registers (Function Code 03) on page 414
Read Input Registers (Function Code 04) on page 415
Modbus Messages 405
TriStation 1131 Libraries Reference
Modbus Messages
This section describes the Modbus messages (query and response functions) supported by
Triconex communication modules. The serial ports on Triconex communication modules
support several Modbus message formats and functions (queries and responses).
Topics include:
Communication Modes on page 405
Function Names and Aliases on page 406
Modbus Message Formats on page 407
Sample Query and Response Messages on page 409
Modbus Message Lengths on page 410
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 01001111
2
(4F
16
) is sent as the two ASCII characters
4 and F (34
16
and 46
16
). 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.
406 Appendix A Modbus Protocol
TriStation 1131 Libraries Reference
Function Names and Aliases
The starting address field of a Modbus message ranges from 0 to one less than the number of
coils or registers available.
A Trident CM or MP serial port maps the Modbus starting address field to an alias by adding a
constant determined by the function code, as shown in this table.
Function Name Code Coil or Register Constant
Read Coil Status 01 Coil 1
Read Input Status 02 Coil 10001
Read Holding Registers 03 Register 40001
Read Input Registers 04 Register 30001
Force Single Coil 05 Coil 1
Preset Single Register 06 Register 40001
Read Exception Status 07 Coil n/a
Loop Back Diagnostic Test 08 Register n/a
Force Multiple Coils 15 Coil 1
Preset Multiple Registers 16 Register 40001
Modbus Messages 407
TriStation 1131 Libraries Reference
Modbus Message Formats
For each Modbus function, the message formats for RTU and ASCII modes are depicted as
shown in the following figures.
Message Header Field (ASCII Only)
The Message Header in ASCII mode is a colon (:) and is required. There is no message header
in RTU mode.
Station Address Field
The Station Address field identifies the station to which a query is directed or the station that is
sending a response. In RTU mode, the station address has one character (8 bits). In ASCII mode,
the station address has two characters.
The range for station addresses is 1 through 247. Each station connected to a Modbus serial link
must have a unique address. Station address 0 (zero) is the broadcast address and addresses all
slaves. When a slave receives a query with the broadcast address, the slave processes the query
but does not send a response.
Function Code Field
The Function Code field identifies the operation to be performed (the query), or the operation
that was performed (the response). If the most significant bit of the function code in a response
is 1, the response is an exception response.
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.
Checksum Field (CRC or LRC)
The Checksum field is a 16-bit word which is a CRC in RTU mode or an LRC in ASCII mode.
The error check is performed by both the transmitting and the receiving units to detect
transmission errors. These sections describe the error check calculations that are performed for
CRC and LRC.
:
408 Appendix A Modbus Protocol
TriStation 1131 Libraries Reference
CRC Error Check RTU Mode
During a CRC error check, the CRC-16 polynomial is used to compute a checksum for the entire
message. The CRC-16 polynomial is:
x
16
+ x
15
+x
2
+ 1
The CRC is computed across the station address, the function code, and the data and appended
to the end of the message.
LRC Error Check ASCII Mode
The LRC checksum is an 8-bit binary number represented and transmitted as two ASCII
hexadecimal characters. To calculate the LRC:
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.
Take the twos complement.
This table shows how to calculate the LRC for a sample message.
CR Field and LF Field (ASCII Only)
The CR field contains an ASCII carriage return and the LF field contains an ASCII line feed.
LRC Checksum Sample Calculation
Message Field Message Content
Address 0x30
0x32
Function Code 0x30
0x31
Starting Address (high order) 0x30
0x30
Starting Address (low order) 0x31
0x33
Number of Points (high order) 0x30
0x30
Number of Points (low order) 0x32
0x35
Sum of message content. 0x4E
Take the twos complement. 0xB2
The resulting Error Check (LRC) 0x42 (B)
0x32 (2)
Modbus Messages 409
TriStation 1131 Libraries Reference
Sample Query and Response Messages
This table shows the content of a sample query and response in RTU and ASCII modes. The
query is a Read Input Status (Function 02) requesting 37 (25
16
) points starting at point 20 (13
16
+
1). The response packs the 37 points into five 8-bit bytes, and clears the three high-order bits of
the last byte.
Query Message RTU ASCII
Header None :
Station Address 0000 0010 0 2
Function Code 0000 0001 0 1
Starting Address (High Order) 0000 0000 0 0
Starting Address (Low Order) 0001 0011 1 3
Number of Points (High Order) 0000 0000 0 0
Number of Points (Low Order) 0010 0101 2 5
Error Check 0000 1100 C 5
0010 0111
Trailer None CR LF
Response Message RTU ASCII
Header None :
Station Address 0000 0010 0 2
Function Code 0000 0001 0 1
Byte Count 0000 0101 0 5
Data Byte 1 1100
a
1101
b
a. The underscored digit indicates that Coil #27 is in the On state.
b. The underscored digit indicates that Coil #20 is in the On state.
C D
Data Byte 2 0110 1011 6 B
Data Byte 3 1011 0010 B 2
Data Byte 4 0000 1110 0 E
Data Byte 5 0001 1011 1 B
Error Check 0000 0100 E 5
1111 1111
Trailer None CR LF
410 Appendix A Modbus Protocol
TriStation 1131 Libraries Reference
Modbus Message Lengths
The length of a Modbus message depends on the function being used and whether the message
is a query or a response.
Function
Code
Query
Number of RTU
Characters
Number of ASCII
Characters
01 Read Coil Status 8 17
02 Read Input Status 8 17
03 Read Holding Registers 8 17
04 Read Input Registers 8 17
05 Force Single Coil 8 17
06 Preset Single Register 8 17
15 Force Multiple Coils 9 + (1 per 8 coils) 19 + (2 per 8 coils)
16 Preset Multiple Registers 9 + (2 per register) 19 + (4 per register)
Function
Code
Response
Number of RTU
Characters
Number of ASCII
Characters
01 Read Coil Status 5 + (1 per 8 coils) 11 + (2 per 8 coils)
02 Read Input Status 5 + (1 per 8 coils) 11 + (2 per 8 coils)
03 Read Holding Registers 5 + (2 per register) 11 + (4 per register)
04 Read Input Register 5 + (2 per register) 11 + (4 per register)
05 Force Single Coil 8 17
06 Preset Single Register 8 17
15 Force Multiple Coils 8 17
16 Preset Multiple Registers 8 17
Modbus Functions 411
TriStation 1131 Libraries Reference
Modbus Functions
This section includes details on Modbus functions.
Functions include:
Read Coil Status Function (Function Code 01) on page 412
Read Input Status (Function Code 02) on page 413
Read Holding Registers (Function Code 03) on page 414
Read Input Registers (Function Code 04) on page 415
Force Single Coil (Function Code 05) on page 416
Preset Single Register (Function Code 06) on page 417
Read Exception Status (Function Code 07) on page 418
Loop-Back Diagnostic Test (Function Code 08) on page 419
Force Multiple Coils (Function Code 15) on page 420
Preset Multiple Registers (Function Code 16) on page 421
412 Appendix A Modbus Protocol
TriStation 1131 Libraries Reference
Read Coil Status Function (Function Code 01)
The Read Coil Status function requests the On/Off status of a group of logic coils from a station.
You can request the status for as many as 2,000 coils with each query, but some Modbus devices
have lower limits. The coils are numbered beginning at 0. For example, coil 0 is alias 1, coil 1 is
alias 2, and so forth.
The Read Coil Status query is also known as the Read Output Status query.
Query Format
Response Format
The Read Coil Status response data is packed with one bit for each coil, where 1=On, and 0=Off.
The low-order bit of the first RTU character contains the status of the first coil. For coil quantities
that are not even multiples of eight, the last RTU character is zero-filled at the high-order end.
:
:
Modbus Functions 413
TriStation 1131 Libraries Reference
Read Input Status (Function Code 02)
The Read Input Status function operates in the same manner as Read Coil Status (Function Code
01), except that the status of digital inputs is obtained. Inputs are also numbered beginning at 0.
For example, input status 0 is alias 10001, input status 1 is alias 10002, and so forth. You can
request the status of as many as 2,000 coils with each query, but some Modbus devices have
lower limits.
Query Format
Response Format
:
:
414 Appendix A Modbus Protocol
TriStation 1131 Libraries Reference
Read Holding Registers (Function Code 03)
The Read Holding Registers function requests the binary content of holding registers from a
station. You can request the status of as many as 125 registers with each query, but some
Modbus devices have lower limits. The registers are numbered beginning at 0. For example,
register 0 is alias 40001, register 1 is alias 40002, and so forth.
The Read Holding Registers query is also known as the Read Output Registers query.
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 415
TriStation 1131 Libraries Reference
Read Input Registers (Function Code 04)
The Read Input Registers function operates in the same manner as the Read Holding Registers
query (Function Code 03), except that it obtains the status of input registers. You can request the
status of as many as 125 registers with each query, but some Modbus devices have lower limits.
The registers are numbered beginning at 0. For example, register 0 is alias 30001, register 1 is
alias 30002, and so forth.
Query Format
Response Format
:
:
416 Appendix A Modbus Protocol
TriStation 1131 Libraries Reference
Force Single Coil (Function Code 05)
The Force Single Coil function turns a single coil On or Off, depending on its current state.
Because the slave is actively scanning, it can also alter the state of the coil (unless the coil is
disabled). Coils are numbered beginning at 0. For example, coil 0 is alias 1, coil 1 is alias 2, and
so forth.
A coil value of 65,280 (FF00
16
) turns the coil On, and a coil value of zero (0000
16
) turns the coil
Off. All other values are illegal and do not affect the coil. If the query contains legal values, the
slave responds after the coil state has been altered.
Query Format
Response Format
:
:
Modbus Functions 417
TriStation 1131 Libraries Reference
Preset Single Register (Function Code 06)
The Preset Single Register function modifies the content of one holding register. Because the
slave is actively scanning, it can also alter the content of the register. Register values are 16 bits.
Holding registers are numbered beginning at 0. For example, register 0 is alias 40001, register 1
is alias 40002.
Query Format
Response Format
:
:
418 Appendix A Modbus Protocol
TriStation 1131 Libraries Reference
Read Exception Status (Function Code 07)
The Read Exception Status function returns the status of eight coils from the slave application
running in the controller. Which coils and what they represent depends on the slave.
When a serial port, configured as a slave, responds to this query, it sends the status of the first
eight coils (aliases 00001 through 00008) defined in the application. Coils are numbered
beginning at 0. For example, coil 0 is alias 1, coil 1 is alias 2, and so forth.
The status of each coil is packed in the data field, one bit for each coil (1=On, 0=Off). You can
program these coils to hold any type of information; for example, machine on or off, heads
retracted, safeties satisfied, and receipt-in-process error conditions.
Note A serial port configured as a Modbus master cannot use the Read Exception Status
function.
Query Format
Response Format
:
:
Modbus Functions 419
TriStation 1131 Libraries Reference
Loop-Back Diagnostic Test (Function Code 08)
The Loop-Back Diagnostic Test function tests the communications link between the Modbus
master and slave. This query does not affect point values in the slave. When the serial port
acting as a slave receives this query, it re-transmits the query as the response.
Note A serial port configured as a Modbus Master cannot use the Loop-Back Diagnostic Test
function.
Query Format
Response Format
:
420 Appendix A Modbus Protocol
TriStation 1131 Libraries Reference
Force Multiple Coils (Function Code 15)
The Force Multiple Coils function sets each coil in a consecutive block of coils to the specified
state (On or Off) regardless of whether the coils are enabled or disabled. Because the slave is
actively scanning, it can also alter the state of a coil (unless it is disabled). Coils are numbered
beginning at 0. For example, coil 0 is alias 1, coil 1 is alias 2, and so forth. The status of each coil
is packed in the data field, one bit for each coil (1=On, 0=Off).
A single Force Multiple Coils query can set a maximum of 128 coils. The query-response time
required by some Modbus masters might require a much smaller quantity.
Query Format
Response Format


:
Modbus Functions 421
TriStation 1131 Libraries Reference
Preset Multiple Registers (Function Code 16)
The Preset Multiple Registers function can change the contents of a maximum of 60 consecutive
holding registers, however, some Modbus devices have lower limits. Because the slave is
actively scanning, it can also alter the state of the registers (unless they are disabled). The values
are provided in binary code up to the maximum valid register value of the controller (16-bit for
Trident). Unused high-order bits must be set to 0. The registers are numbered beginning at 0.
For example, register 0 is alias 40001, register 1 is alias 40002, and so forth.
Query Format
Response Format
:
:
422 Appendix A Modbus Protocol
TriStation 1131 Libraries Reference
Transmission Errors and Exception Conditions
During Modbus communication, transmission errors and exception conditions can occur.
Transmission errors do not cause exception conditions and are not acknowledged by Modbus
slaves. Programming and operation errors do cause exception conditions which elicit exception
responses from slaves.
Topics include:
Transmission Errors on page 422
Exception Conditions on page 423
Exception Responses on page 424
Exception Response Codes on page 425
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.
Related Topics
Checksum Field (CRC or LRC) on page 407
Transmission Errors and Exception Conditions 423
TriStation 1131 Libraries Reference
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
Query Message CRC or LRC
Error
The slave does not respond, because the error could be in the station
address. The master uses its response fail-safe timer to recover.
Query Function Code Error The slave sends an Illegal Function (01) response code when it detects
an error in the function code field.
Query Address Error The slave sends an Illegal Data Address (02) response code when it
detects an error in the starting address field.
Query Data Error The slave sends an Illegal Data Value (03) response code when it
detects an error in the data field.
Main Processors Not
Communicating
This exception applies only to serial ports which are configured as slaves.
If the slave port receives a query requiring a data exchange and it
cannot communicate with the Main Processors, it sends a Busy, Reject
Message (06) response code and turns off the Active indicator on the
communication module.
Remote Write Disabled The slave port sends a Busy, Reject Message (06) response code if a
master sends one of these queries and the slave port is not enabled for
remote (external) writes:
Force Single Coil (Function Code 05)
Preset Single Register (Function Code 06)
Force Multiple Coils (Function Code 15)
Preset Multiple Registers (Function Code 16)
424 Appendix A Modbus Protocol
TriStation 1131 Libraries Reference
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
query.
Sample Query
Sample Exception Response
Transmission Errors and Exception Conditions 425
TriStation 1131 Libraries Reference
Exception Response Codes
This table lists exception response codes which are sent by the slave after an invalid query.
Code Name Description
01 Illegal Function The requested function is not in the slaves repertoire.
02 Illegal Data Address The alias in the query does not exist in the slave.
03 Illegal Data Value The value is not in the range allowed for the alias.
04 Failure in Associated
Device
The slave failed to respond to a message or an error that
occurred in the controller. When a master receives this response
code, it must issue a supervisory alert.
05 Acknowledge A slave port does not send this exception response code.
06 Busy, Rejected Message The query was received without error, but the slave cannot
comply.
07 Negative Acknowledge A slave port does not send this exception response code.
08 Memory Parity Error A slave port does not send this exception response code.
426 Appendix A Modbus Protocol
TriStation 1131 Libraries Reference
TriStation 1131 Libraries Reference
B
Peer-to-Peer Parameters
Overview 428
Parameters of Send Function Blocks 428
Parameters of Receive Function Blocks 432
Peer-to-Peer Runtime Errors 434
428 Appendix B Peer-to-Peer Parameters
TriStation 1131 Libraries Reference
Overview
This appendix describes the input and output parameters for Peer-to-Peer function blocks, and
runtime errors.
Parameters of Send Function Blocks
This section describes the operation of each parameter in a Send function block and provides
details about the error values returned by the STATUS parameter.
SENDFLG
The SENDFLG input parameter specifies whether a send is initiated. If the value is true, a send
is initiated. If the value is false, a send is not initiated even if the Send function block is executed.
In other words, no data transfer takes place unless the SENDFLG parameter is set to true.
When a Send function block is executed by the TriStation 1131 application for the first time with
SENDFLG set to false, the sending controller attempts to establish communication with the
receiving controller and sets the STATUS parameter to 100.
The sending controller sets the STATUS parameter of the Send function block to 0 if:
Communication is established with the receiving controller
A receiving controller has a matching Send function block with a matching Receive
identifier, Send node number, and Send identifier
If the STATUS parameter of a Send function block (with SENDFLG set to 0) is greater than or
equal to 100, there is a problem in the network. The STATUS parameter indicates the type of
problem and the action you should to take to resolve it. For more information on codes, see
STATUS on page 433.
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.
Parameters of Send Function Blocks 429
TriStation 1131 Libraries Reference
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 32. (Note: Triconex controllers currently do not support node 32.) If RECVNODE
is out of range, calls to the function block set the STATUS output to 102.
RECVID
The RECVID input parameter specifies the unique Receive function block that receives data
from this Send function block. A receive call with a matching RECVID must be defined in the
receiving controller. The legal range for RECVID identifiers is from 1 to the value specified for
Maximum Number of Peer-to-Peer Receive. If RECVID is out of range, calls to the function
block set the STATUS output to 102.
N
The N input parameter specifies the number of data values to send (1 to 20 for TR_USEND
function blocks and 1 to 32 for TR_USEND_32 function blocks). The receiving function block
must specify the same value for the N output parameter.
SD_01SD_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.
430 Appendix B Peer-to-Peer Parameters
TriStation 1131 Libraries Reference
Send Function Block STATUS Output Parameter Values
Status Meaning and Action
0 Communication is established with the receive node. When you execute a Send function
block with SENDFLG = false, you should receive STATUS = 0 to indicate that
communication is established with the receiving controller and that the receiving
TriStation 1131 application has an exactly matching Receive function block. You can
initiate a send operation by setting SENDFLG to true.
1 A send was initiated by a Send function block call with SENDFLG set to true. Set
SENDFLG to false to coordinate the acknowledgment from the receiving node of the last
send. If you do not set SENDFLG to false, the controller will initiate another send as soon
as it completes the current send (in other words, as soon as it receives an acknowledgment
from the receiving controller).
2 The Send identifier is currently busy sending data to the receiving controller. STATUS is
set to 2 on the scan that immediately follows a scan during which a send was initiated.
STATUS remains 2 until an acknowledgment is received from the receiving controller or a
5-second time-out expires. If an acknowledgment is received, STATUS changes to 3 and
then to 0 (if SENDFLG = false) or 4 (if SENDFLG = true). If the 5-second time-out expires,
STATUS changes to 100 (described below).
3 The last send operation was completed successfully and the receiving controller sent an
acknowledgment. STATUS = 3 only if SENDFLG was set to false after STATUS was equal
to 1.
The sending controller gets an acknowledgment from the receiving controller for each
successfully completed send (STATUS = 3). As soon as the acknowledgment is received,
the sending controller initiates another send because SENDFLG is set to true. If SENDFLG
is set to true all the time, the STATUS value oscillates between 2 and 4 unless a
communication problem causes another type of error.
4 The last send was completed successfully and a new send was initiated. The receiving
controller acknowledged that its TriStation 1131 application received the data.
STATUS = 3 only if SENDFLG was set to false after STATUS was equal to 1.
The sending controller gets an acknowledgment from the receiving node for each
successfully completed send (STATUS = 3). However, as soon as the acknowledgment is
received, the sending controller initiates another send because SENDFLG is set to true. If
SENDFLG is set to true all the time, the STATUS value oscillates between 2 and 4 unless a
communication problem causes another type of error.
100 The controller is trying to recover or establish communication with the receiving
controller. This can happen if there is no receiving controller connected to the network, or
if there is no matching Receive function block in the TriStation 1131 application of the
receiving controller. The sending controller will retry every 2 seconds to establish
communication.
Make sure that the receiving controller is connected to the network. If the receiving
controller is connected and running, verify that the TriStation 1131 application includes a
Receive function block with parameters that exactly match those of the Send function
block. If STATUS = 100, the application should inform the operator of communication loss
with the receiving controller.
Parameters of Send Function Blocks 431
TriStation 1131 Libraries Reference
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.
Send Function Block STATUS Output Parameter Values (continued)
Status Meaning and Action
432 Appendix B Peer-to-Peer Parameters
TriStation 1131 Libraries Reference
Parameters of Receive Function Blocks
This section describes the operation of each parameter in a Receive function block and provides
details about the error values returned by the Status parameter.
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 32. (Note: Triconex controllers currently do not support node 32.) 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.
Parameters of Receive Function Blocks 433
TriStation 1131 Libraries Reference
STATUS
The STATUS output parameter allows the application to determine the status of communication
with the sending controller. This table describes the STATUS values.
RD_01RD_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.
Receive Function Block STATUS Ouput Parameter Values
Status Meaning and Action
0 The Receive function block is ready to receive data.
1 New data has been received from the sending controller and is available in outputs
RD_01...RD_nn until new data is received again.
100 Reserved for future use.
101 Reserved for future use.
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 Reserved for future use.
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.
434 Appendix B Peer-to-Peer Parameters
TriStation 1131 Libraries Reference
Peer-to-Peer Runtime Errors
The section explains runtime errors associated with these Peer-to-Peer function blocks:
TR_PEER_STATUS
All Send function blocks
All Receive function blocks
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.
Peer-to-Peer Runtime Error Descriptions
Error Description Detection Suggested Action
COMM_OK is false on
TR_PEER_STATUS
function block
No communication
path between the
sending and receiving
controllers.
One of the controllers
is disconnected from
the network, the CM
has failed, or the
Ethernet cable or field
termination is bad.
Diagnostics on the CM
send a message to
each node. If no
response is received
within 1 second, the
CM sets the output
false.
The CM reports the
status to the MPs
every 30 seconds.
After initial start-up,
the TriStation 1131
application can use
this output to set an
alarm.
COMM_REDUNDANT
is false on
TR_PEER_STATUS
function block
No redundant
communication path
between the sending
and receiving
controllers.
One of the controllers
has only one CM or
has a failed CM, or the
Ethernet cable or field
termination is bad.
The MPs set the
output based on the
status received from
each of two CMs.
The CMs report their
status to the MPs
every 30 seconds.
This might or might
not be an error,
depending on system
configuration.
If redundancy is used,
after initial start-up
the TriStation 1131
application can use the
STATUS output to set
an alarm.
STATUS is 100 on a
Send function block
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.
The STATUS output is
updated whenever the
Send function block is
executed. If the
acknowledgment for
the last Send is not
received in 1 second,
the sending controller
tries to send the
message again. If the
retry fails, then a
STATUS of 100 is
returned.
After initial start-up,
the TriStation 1131
application can use the
STATUS output to set
an alarm.
Peer-to-Peer Runtime Errors 435
TriStation 1131 Libraries Reference
STATUS is greater than
or equal to 102 on a
Send function block
There is a
programming error in
the sending or
receiving controller.
The MPs detect
programming errors.
After initial start-up,
programming errors
should not occur. If
they do, then the
TriStation 1131
application should use
the STATUS output to
set an alarm.
STATUS is 100 on a
Receive function block
The receiving
controller is trying to
establish
communication with
the sending controller.
The STATUS output is
updated whenever the
Receive function block
is executed.
After initial start-up,
the TriStation 1131
application can use the
STATUS output to set
an alarm.
STATUS is greater than
or equal to 101 on a
Receive function block
There is a
programming error in
the sending or
receiving controller.
The MPs detect
programming errors.
After initial start-up,
programming errors
should not occur. If
they do, then the
TriStation 1131
application should use
the STATUS output to
set an alarm.
Peer-to-Peer Runtime Error Descriptions (continued)
Error Description Detection Suggested Action
436 Appendix B Peer-to-Peer Parameters
TriStation 1131 Libraries Reference
Index
Symbols
* operator 164
** operator 76
+ operator 10
/ operator 63
<= operator> 110, 129
<> operator 170
= operator 71
> operator 94
operator 236
>= operator 87
Numerics
-1.#INF 160, 161
A
ABS function 8
absolute value 8
ACK output parameter 429
ACOS function 9
ADD function 10
AIN function 12
AIN_BP function 13
AIN_BP12 function 14
AIN_HR function 16
analog input 12, 13, 14, 16
analog output 19, 20
AND function 17
AND operator 17
AOUT function 19
AOUT_BP12 function 20
arc cosine 9
arc sine 28
arc tangent 29
array 22, 24, 26
ARRAY32_BOOL function block 22
ARRAY32_DINT function block 24
ARRAY32_REAL function block 26
ARRAYERR error flag 39
ASCII mode
characters in station address 407
defined 405
ASIN function 28
ATAN function 29
B
BADCONV error flag 39
BADPARAM error flag 39
BADPARAM status flag 213
base ten logarithm 121
bistable 216, 233
bitwise AND 17
bitwise complement 171
bitwise NOT 171
bitwise OR 175
bitwise XOR 399
BLINK function block 30
BLINK_I function block 32
BLINK_R function block 34
BOOL data type 36
BOOL_TO_DWORD function 37
C
calendar clock
adjusting 308
setting 310
CEIL function 38
ceiling 38
checksum field, in Modbus message format 407
CHK_ERR function block 39
CLR_ERR function block 43
CONCAT_DT function 45
concatenate 45
COS function 46
cosine 46
count down 51
count up 53
count up-down 55
counting bits 173, 174
CR field 408
CRC error check 408
CSCHED function block 47
438 Index
TriStation 1131 Libraries Reference
CSCHED_I function block 48
CSCHED_R function block 50
CTD function block 51
CTU function block 53
CTUD function block 55
customer support xii
D
data types
BOOL 36
DATE 57
DINT 58
DT 65
DWORD 68
INT 98
LREAL 124
REAL 208
STRING 235
TIME 305
TOD 318
date and time 66, 67
data type 65
DATE data type 57
deviation 183
differential bipolar analog input 13, 14
DINT data type 58
DINT_TO_DWORD function 59
DINT_TO_INT function 60
DINT_TO_LREAL function 61
DINT_TO_REAL function 62
DIV function 63
DIVBYZERO error flag 39
down counter 51
DT data type 65
DT_TO_DATE function 66
DT_TO_TOD function 67
DWORD data type 68
DWORD_TO_BOOL function 69
DWORD_TO_DINT function 70
E
edge detector 78
rising 206
EQ function 71
error flags 39
ERROR output parameter 429, 432
errors 39
errors, Modbus data transmission 422
event collection 224, 226, 228, 230
exception conditions, Modbus 423
exception responses, Modbus 424, 425
exclusive OR 399
execution scheduling 47, 48, 50, 387, 389, 391
EXP function 73
EXPFLTR function block 74
exponential 73
exponential filter 74
exponentiation 76
EXPT function 76
F
F_TRIG function block 78
falling edge 78
faults, clear faults function 338
flags 39
flipflop 216, 233
floating-point underflow
for LREAL data types 124
for REAL data types 208
FLOOR function 80
Force Multiple Coils function 420
Force Single Coil function 416
G
gas detector 81
GASDETR function block 81
GATDIS function block 84
gate disable 84
gate enable 85
GATENB function block 85
GE function 87
GetDelta_DINT function 89
GetDelta_REAL function 90
GetDeltaT function 91
GetTimer function 92
gradual underflow
effect on absolute and relative error 125, 209
for LREAL data types 124
for REAL data types 208
GT function 94
H
high-resolution analog input 16
I
i.LREAL numbers, precision when approaching
zero 125
I/O modules, status 339
IEC-559 Standard Floating-Point format 208
inclusive OR 175
-INF 160, 161
Index 439
TriStation 1131 Libraries Reference
INFINITY_LREAL function 96
INFINITY_REAL function 97
INT data type 98
INT_TO_DINT function 99
INT_TO_LREAL function 100
INT_TO_REAL function 101
integration 102, 104
INTERNALERR error flag 39
INTGTOR function block 102
INTGTOR_R function block 104
IsFinite_LREAL function 106
IsFinite_REAL function 107
IsNan_LREAL function 108
IsNan_REAL function 109
L
latch 216, 233
LE function 110
lead-lag compensation 112, 114
LEADLAG function block 112
LEADLAG_R function block 114
LF field 408
LIMIT function 116
line monitor 118
LINEMNTR function block 118
LN function 120
LOG function 121
logarithm
base ten 121
natural 120
logical AND 17
logical NOT 171
logical OR 175
logical XOR 399
long reals, precision when approaching zero 125
longitudinal redundancy check. See LRC checksum.
loop detector 122
Loop-Back Diagnostic Test function 419
LOOPDETR function block 122
LRC checksum, calculation 408
LREAL data type 124
LREAL_TO_DINT function 126
LREAL_TO_INT function 127
LREAL_TO_REAL function 128
LT function 129
M
MAX function 131
MBCTRL function block 133
MBREAD_BOOL function block 135
MBREAD_DINT function block 137
MBREAD_REAL function block 139
MBREAD_REAL_TRD function block 143
MBWRITE_BOOL function block 146
MBWRITE_DINT function block 148
MBWRITE_REAL function block 150
MBWRITE_REAL_TRD function block 153
median 156
MEDSEL function 156
message response time 403
MIN function 158
MINUS_INFINITY_LREAL function 160
MINUS_INFINITY_REAL function 161
MOD function 162
Modbus, alias mapping 139, 150
Modbus communication, noise sources 422
Modbus devices, RTU and ASCII modes 405
Modbus functions
list of names and codes 405
supported by serial ports 405
Modbus master
reading values from a slave 135, 137, 139, 143
setting timeout and retry values 133
writing values to a slave 146, 148, 150, 153
Modbus protocol
checksum field 407
exception conditions 423
exception responses 424, 425
function code field, described 407
message format 407
message header 407
message lengths 410
overview 402
performance considerations 404
query and response 409
station address field 407
modulo 162
monitoring analog current loops 118
MOVE function 163
MUL function 164
MUX function 166
N
N input parameter 429, 432
NAN 108, 109, 168, 169
NAN_LREAL function 168
NAN_REAL function 169
natural exponential 73
natural logarithm 120
NDR output parameter 432
NE function 170
440 Index
TriStation 1131 Libraries Reference
noise sources, Modbus communication 422
not a number (NAN) 108, 109, 168, 169
NOT function 171
NOT operator 171
NUMBITS function 173
NUMBITS_DWORD function 174
O
OR function 175
OR operator 175
OTHER error flag 39
output voter diagnostics 177, 178
OVDDISABLE function block 177
OVDENABLE function block 178
OVERFLOW error flag 39
P
PACK16 function 179
PACK32 function 180
packing bits 179, 180, 393, 395
PAGE_EJECT function block 181
parity checking, Modbus transmission errors 422
Peer-to-Peer
receive 357, 359, 361, 363, 365
runtime errors 434
send 367, 369, 371, 373, 375
percent deviation 183
PERDEV function 183
performance, Modbus functions 404
PID function block 184
PID_R function block 186
Poly4 function 188
POLY5 function 189
polynomial 188, 189
power 76
Preset Multiple Registers function 421
Preset Single Register function 417
PRINT_BOOL function block 190
PRINT_CDT function block 192
PRINT_CRLF function block 194
PRINT_CTOD function block 196
PRINT_DINT function block 198
PRINT_REAL function block 200
PRINT_STRING function block 202
PRNTR_FLUSH function block 204
proportional integral derivative (PID) 184, 186
R
R_TRIG function block 206
RANGE error flag 39
RD_nn 433
Read Coil Status function 412
Read Exception Status function 418
Read Holding Registers function 414
Read Input Registers function 415
Read Input Status function 413
REAL data type 208
real number, precision when approaching zero 209
real time clock 218
REAL_TO_DINT function 210
REAL_TO_INT function 211
REAL_TO_LREAL function 212
RECVID input parameter 429, 432
RECVNODE input parameter 429
remainder 162
remote access 85
remote write access 84
ReportBadParam function 213
reset set 216
rising edge detector 206
rising edge trigger 206
ROL function 214
ROR function 215
RS function block 216
RTC function block 218
RTU mode 405
runtime error flags 39
runtime errors, Peer-to-Peer 434
S
SCALE function 219
scan time, effect on Modbus performance 404
scheduling execution 47, 48, 50, 387, 389, 391
SD_nn input parameters 429
SEL function 220
select 220
SENDFLG input parameter 428
SENDID input parameter 428, 432
SENDNODE input parameter 432
SENT output parameter 429
sequence of events 224, 226, 228, 230
set reset 233
shift left 221
shift right 222
SHL function 221
SHR function 222
shutdown 249, 260, 289, 294, 339, 353, 377
SIN function 223
sine 223
SOECLR function block 224
Index 441
TriStation 1131 Libraries Reference
SOESTAT function block 226
SOESTOP function block 228
SOESTRT function block 230
special numbers 96, 97, 106, 107, 108, 109
SQRT function 232
square root 232
SR function block 233
station address field, Modbus message 407
status
critical I/O modules 339
safety-critical I/O modules 249
Tricon 64 point 332
Tricon chassis 336
Tricon main processor 342
Tricon Peer-to-Peer 344
Tricon points 345
Tricon port 347
Tricon program 349
Tricon scan 351
Tricon slot 355
Trident analog input module 239
Trident analog output module 241
Trident combo AI/DI input module 251
Trident communication module 246
Trident discrete input module 253
Trident discrete output module 255
Trident high resolution discrete input module 257
Trident I/O module 260
Trident I/O processor 262
Trident main processor 265, 270
Trident pulse input module 275
Trident relay output module 278
Trident supervised discrete output module 280
Trident system 291
status flags 39
STATUS output parameter 429
STATUS output values 433
STRING data type 235
STRLEN error flag 39
SUB function 236
SYS_AI32_STATUS function block 239
SYS_AO04_STATUS function block 241
SYS_APP_HALT function 243
SYS_CLEAR_FLTS function 244
SYS_CM_STATUS function block 246
SYS_CRITICAL_IO function block 249
SYS_DI16_AI16_STATUS function block 251
SYS_DI32_STATUS function block 253
SYS_DO16_STATUS function block 255
SYS_HRDI32_STATUS function block 257
SYS_IO_STATUS function block 260
SYS_IOP_STATUS function block 262
SYS_MP_EXT_STATUS function block 265
SYS_MP_RESET_PORTS function 268
SYS_MP_STATUS function block 270
SYS_OVD_INHIBIT function 273
SYS_PI06_STATUS function block 275
SYS_RO32_STATUS function block 278
SYS_SDO16_STATUS function block 280
SYS_SERIAL_PORT function block 283
SYS_SET_APP_LOCK function 285
SYS_SET_PROG_ALARM function 287
SYS_SET_REMOTE_WRT_ENBL function 288
SYS_SHUTDOWN function block 289
SYS_SYSTEM_STATUS function block 291
SYS_VOTE_MODE function block 294
T
TAN function 296
tangent 296
TCJ_CONV function 297
TCK_CONV function 299
TDD_I function block 301
TDD_R function block 302
TDE_I function block 303
TDE_R function block 304
technical support xii
TGL coil 322
thermocouple 297, 299
TIME data type 305
time of day 67
TIME_TO_SECS function 306, 307
TIMEADJ function block 308
TIMESET function block 310
TMR function block 312
TMR_I function block 314
TMR_R function block 316
TOD data type 318
TOF function block 319
TOGGLE function block 322
TON function block 324
TP function block 326
TP_I function block 328
TP_R function block 330
TR_64_POINT_STATUS function block 332
TR_CALENDAR function block 334
TR_CHASSIS_STATUS function block 336
TR_CLEAR_FLTS 338
TR_CRITICAL_IO function block 339
TR_MP_STATUS function block 342
TR_PEER_STATUS function block 344
TR_POINT_STATUS function block 345
442 Index
TriStation 1131 Libraries Reference
TR_PORT_STATUS function block 347
TR_PROGRAM_STATUS function block 349
TR_SCAN_STATUS function block 351
TR_SHUTDOWN function block 353
TR_SLOT_STATUS function block 355
TR_URCV_BOOL function block 357
TR_URCV_DINT function block 359
TR_URCV_DINT_32 function block 361
TR_URCV_REAL function block 363
TR_URCV_REAL_32 function block 365
TR_USEND_BOOL function block 367
TR_USEND_DINT function block 369
TR_USEND_DINT_32 function block 371
TR_USEND_REAL function block 373
TR_USEND_REAL_32 function block 375
TR_VOTE_MODE function block 377
training xii
transmission errors, Modbus 422
Triconex contact information xii
trigger 78
rising edge 206
TRUNC_LREAL_TO_DINT function 379
TRUNC_LREAL_TO_INT function 381
TRUNC_REAL_TO_DINT function 383
TRUNC_REAL_TO_INT function 385
TSCHED function block 387
TSCHED_I function block 389
TSCHED_R function block 391
Type J thermocouple 297
Type K thermocouple 299
U
underflow
gradual for LREAL data types 124
gradual for REAL data types 208
UNDERFLOW error flag 39
UNPACK16 function block 393
UNPACK32 function block 395
up counter 53
up-down counter 55
W
write access 84
X
X_OF_N function block 397
XOR function 399
XOR operator 399

S-ar putea să vă placă și