tristation 1131 libraries reference, v4.8 infi90 documentation... · tristation™ 1131...

512
TriStation 1131 Developer’s Workbench Versions 4.0 and Later Assembly Number 9700098-010 November 2010 TriStation 1131 Libraries Reference

Upload: others

Post on 14-Apr-2020

191 views

Category:

Documents


36 download

TRANSCRIPT

Page 1: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TriStation 1131 Developer’s WorkbenchVersions 4.0 and Later

Assembly Number 9700098-010November 2010

TriStation 1131Libraries Reference

Page 2: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

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.

© 2003–2010 by Invensys Systems, Inc. All rights reserved.

Invensys, the Invensys logo, Triconex, Tricon, Trident, and TriStation are trademarks of Invensys plc, its subsidiaries and affiliates. All other brands may be trademarks of their respective owners.

Document Number 9720098-010

Printed in the United States of America.

Page 3: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TriStation 1131 Libraries Reference

Contents

Preface ixSummary of Sections. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ixRelated Documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ixProduct and Training Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xTechnical Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xWe Welcome Your Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi

Chapter 1 Introduction 1How to Use This Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Name and Brief Description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2Parameters and Return Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2Description and Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3Runtime Errors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3Application Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

Sample Projects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

Chapter 2 Functions and Data Types 9ABS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10ACOS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11ADD. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12AIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14AIN_BP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15AIN_BP12 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17AIN_HR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19ALARM_DEVIATION_DINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21ALARM_DEVIATION_REAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25ALARM_LEVEL_DINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29ALARM_LEVEL_REAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33ALARM_ROC_DINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37ALARM_ROC_REAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41ALARM_TRIP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45AND. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48AOUT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50AOUT_BP12 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51ARRAY32_BOOL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53ARRAY32_DINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55ARRAY32_REAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57ASIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59ATAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60BLINK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61BLINK_I . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63BLINK_R. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65BOOL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67

Page 4: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

iv Contents

TriStation 1131 Libraries Reference

BOOL_TO_DWORD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68BYPASS_BOOL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69BYPASS_DINT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71BYPASS_REAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73CEIL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75CHK_ERR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76CLR_ERR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80CONCAT_DT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82COS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83CSCHED . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84CSCHED_I . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86CSCHED_R. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88CTD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89CTU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91CTUD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93DATE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95DINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96DINT_TO_DWORD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97DINT_TO_INT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98DINT_TO_LREAL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99DINT_TO_REAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100DIV. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101DT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103DT_TO_DATE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104DT_TO_TOD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105DWORD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106DWORD_TO_BOOL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107DWORD_TO_DINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108EQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109EXP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111EXPFLTR. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113EXPT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115F_TRIG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117FLOOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119GASDETR. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120GATDIS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123GATENB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124GE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126GetDelta_DINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128GetDelta_REAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130GetDeltaT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132GetTimer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134GT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136INFINITY_LREAL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138INFINITY_REAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139INT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140INT_TO_DINT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141INT_TO_LREAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142INT_TO_REAL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143INTGTOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144INTGTOR_R. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146IsFinite_LREAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148IsFinite_REAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149IsNan_LREAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150

Page 5: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

Contents v

TriStation 1131 Libraries Reference

IsNan_REAL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151LE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152LEADLAG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154LEADLAG_R . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156LIMIT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158LINEMNTR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160LN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162LOG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163LOOPDETR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164LREAL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166LREAL_TO_DINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168LREAL_TO_INT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170LREAL_TO_REAL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172LT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174MAX. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176MBCTRL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178MBREAD_BOOL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180MBREAD_DINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182MBREAD_REAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184MBREAD_REAL_TRD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188MBWRITE_BOOL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191MBWRITE_DINT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193MBWRITE_REAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195MBWRITE_REAL_TRD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198MEDSEL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201MIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203MINUS_INFINITY_LREAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205MINUS_INFINITY_REAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206MOD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207MOVE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208MUL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209MUX. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211NAN_LREAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213NAN_REAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214NE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215NOT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217NUMBITS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219NUMBITS_DWORD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220OR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221OVDDISABLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223OVDENABLE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224PACK16. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225PACK32. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226PAGE_EJECT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227PERDEV . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229PID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230PID_R. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232POLY4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234POLY5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235PRINT_BOOL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236PRINT_CDT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238PRINT_CRLF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240PRINT_CTOD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242PRINT_DINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244

Page 6: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

vi Contents

TriStation 1131 Libraries Reference

PRINT_REAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246PRINT_STRING. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248PRNTR_FLUSH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250R_TRIG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252REAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254REAL_TO_DINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256REAL_TO_INT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258REAL_TO_LREAL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260ReportBadParam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261ROL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262ROR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263RS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264RTC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266SCALE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267SEL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268SHL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269SHR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270SIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271SOECLR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272SOESTAT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274SOESTOP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276SOESTRT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278SQRT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280SR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281STRING. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283SUB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284SYS_AI32_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287SYS_AO04_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289SYS_APP_HALT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291SYS_CLEAR_FLTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293SYS_CM_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295SYS_CRITICAL_IO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298SYS_DI16_AI16_STATUS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300SYS_DI32_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302SYS_DO16_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304SYS_HRDI32_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306SYS_IO_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309SYS_IOP_STATUS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311SYS_MP_EXT_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314SYS_MP_RESET_PORTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317SYS_MP_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319SYS_OVD_INHIBIT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322SYS_PI06_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324SYS_RO32_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327SYS_SDO16_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329SYS_SERIAL_PORT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332SYS_SET_APP_LOCK. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334SYS_SET_PROG_ALARM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336SYS_SET_REMOTE_WRT_ENBL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338SYS_SHUTDOWN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340SYS_SYSTEM_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342SYS_VOTE_MODE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345TAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347TCJ_CONV . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348

Page 7: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

Contents vii

TriStation 1131 Libraries Reference

TCK_CONV . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350TDD_I . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352TDD_R. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353TDE_I. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355TDE_R . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356TIME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358TIME_TO_SECS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359TIME_TO_SECS_REAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360TIMEADJ. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361TIMESET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363TMR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365TMR_I . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367TMR_R . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369TOD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371TOF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372TOGGLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375TON . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377TP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379TP_I . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381TP_R. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383TR_64_POINT_STATUS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385TR_CALENDAR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387TR_CHASSIS_STATUS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389TR_CLEAR_FLTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391TR_CRITICAL_IO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392TR_MP_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395TR_PEER_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397TR_POINT_STATUS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399TR_PORT_STATUS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 401TR_PROGRAM_STATUS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403TR_SCAN_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405TR_SHUTDOWN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407TR_SLOT_STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409TR_URCV_BOOL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411TR_URCV_DINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413TR_URCV_DINT_32 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415TR_URCV_REAL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417TR_URCV_REAL_32. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419TR_USEND_BOOL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 421TR_USEND_DINT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423TR_USEND_DINT_32. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425TR_USEND_REAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427TR_USEND_REAL_32 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429TR_VOTE_MODE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 431TRUNC_LREAL_TO_DINT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433TRUNC_LREAL_TO_INT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435TRUNC_REAL_TO_DINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437TRUNC_REAL_TO_INT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439TSCHED . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441TSCHED_I . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443TSCHED_R . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445UNPACK16 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447UNPACK32 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449X_OF_N. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 451

Page 8: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

viii Contents

TriStation 1131 Libraries Reference

XOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453

Appendix A Modbus Protocol 455Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 456Message Response Time. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 457

Determining Message Response Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 457Modbus Functions and Scan Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 458

Modbus Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459Communication Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459Function Names and Aliases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 460Modbus Message Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 461Sample Query and Response Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463Modbus Message Lengths . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 464

Modbus Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 465Read Coil Status Function (Function Code 01) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 466Read Input Status (Function Code 02) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467Read Holding Registers (Function Code 03) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 468Read Input Registers (Function Code 04) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469Force Single Coil (Function Code 05) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 470Preset Single Register (Function Code 06) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471Read Exception Status (Function Code 07) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 472Loop-Back Diagnostic Test (Function Code 08) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473Force Multiple Coils (Function Code 15) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474Preset Multiple Registers (Function Code 16) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475

Transmission Errors and Exception Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 476Transmission Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 476Exception Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 477Exception Responses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 478Exception Response Codes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 479

Appendix B Peer-to-Peer Parameters 481Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 482Parameters of Send Function Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483Parameters of Receive Function Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 486Peer-to-Peer Runtime Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 488

Index 491

Page 9: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TriStation 1131 Libraries Reference

Preface

The Triconex® libraries include IEC-compliant functions and function blocks which are part of the TriStation™ 1131 Developer’s Workbench software.

This reference guide provides detailed descriptions of each of the functions and function blocks in the libraries. The functions and function blocks described herein can be used in applications created with TriStation 1131 versions 4.0 and later.

Note For detailed information about the libraries released with each version of TriStation 1131, refer to the Product Release Notice for TriStation 1131, available on the Invensys Global Customer Support (GCS) Web site.

Summary of Sections

• Chapter 1, Introduction—Explains how the functions and function blocks are described.

• Chapter 2, Functions and Data Types—Describes the parameters, return values, runtime error flags, and usage constraints for each function and function block.

• Appendix A, Modbus Protocol—Provides information about Modbus protocol including Modbus message formats and error codes.

• Appendix B, Peer-to-Peer Parameters—Provides detailed information about the Peer-to-Peer input and output parameters, and runtime errors.

Related Documents

• TriStation 1131 Developer’s Guide

• Safety Considerations Guides for Tricon, Trident, and Tri-GP Systems

• Product Release Notice for TriStation 1131

Page 10: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

x Preface

TriStation 1131 Libraries Reference

Product and Training Information

To obtain information about Invensys products and in-house and on-site training, see the Invensys Web site or contact your regional customer center.

Web Site

http://www.iom.invensys.com

Technical Support

Customers in the U.S. and Canada can obtain technical support from the Invensys Global Customer Support (GCS) center at the numbers below. International customers should contact their regional support center.

Requests for support are prioritized as follows:

• Emergency requests are given the highest priority

• Requests from participants with a support agreement 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 do not have a support agreement, you may incur a charge. Please have a purchase order or credit card available for billing.

Telephone

Toll-free number 866-746-6477, orToll number 508-549-2424 (outside U.S.)

Fax

Toll number 508-549-4999

Web Site

http://support.ips.invensys.com/ (registration required)

E-mail

[email protected]

Page 11: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

Preface xi

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:

[email protected]

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 Invensys Global Customer Support (GCS) center. See Technical Support on page x for contact information.

Or, you can write to us at:

Attn: Technical Publications — TriconexInvensys15345 Barranca ParkwayIrvine, CA 92618USA

Thank you for your feedback.

Page 12: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

xii Preface

TriStation 1131 Libraries Reference

Page 13: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TriStation 1131 Libraries Reference

1Introduction

How to Use This Reference 2

Sample Projects 7

Page 14: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

2 Chapter 1 Introduction

TriStation 1131 Libraries Reference

How to Use This ReferenceThis section explains how the library elements (functions, function blocks, and data types) are described in this reference. 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

• Library on page 6

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:

Syntaxw := 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.

Page 15: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

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.

ExampleVAR 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

Page 16: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

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 TypeUsed in a Safety Element

Used in a Control (Non-Safety) Element

Safety element OK OK

Control (non-safety) element WF0050 or WF0051 OK

Page 17: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

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:

Option Description

Exactly Once Each function block instance should be executed exactly once per scan.

Only Once Each function block instance should be executed only once per scan, but does not need to be executed every scan.

Space Saver Each function block instance can be executed more than once per scan to reduce memory usage and increase performance. See Using a Space Saver Function Block on page 6.

Internal State Each function block instance may have an internal state which is remembered from one execution to the next and from one scan to the next. There are no restricitons on usage of a function block labeled internal state; that is, you can execute the function block instance more than once per scan, or you can skip scans.

Page 18: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

6 Chapter 1 Introduction

TriStation 1131 Libraries Reference

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.

3 Do not use the function block instance more than once in a network—the 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 warning—whereas 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

• Standard Sheet Library (STDSHEET) for all Triconex controllers (used only for selecting a sheet template in a new function block diagram)

• Triconex Library (TCXLIB) for all Triconex controllers

• Tricon™ Library (TR1LIB or Tx1Lib) for Tricon controllers

• Trident™ Library (TRDLIB) for Trident and Tri-GP controllers

• Alarms Library (ALARMS) for all Triconex controllers (first released with TriStation 4.7.0)

Page 19: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

Sample Projects 7

TriStation 1131 Libraries Reference

Sample ProjectsSeveral of the functions or function blocks described in this reference are used in the sample projects provided with TriStation 1131. These sample projects provide examples for how to use the selected function or function block.

Starting with TriStation 1131 v4.7.0, sample projects are found in the following locations on the PC where you installed TriStation 1131 (where x.x.x is the TriStation 1131 version number):

• Windows® XP and Windows Server® 2003: C:\Documents and Settings\All Users\Application Data\Triconex\TriStation 1131 x.x.x\Projects

• Windows 7 and Windows Server 2008 R2: C:\Program Data\Triconex\TriStation 1131 x.x.x\Projects

Note Older versions of TriStation 1131 (v4.6 or earlier) may have installed the sample projects in a different location. If you cannot locate the sample projects in the above directories, simply search your hard drive for the name of the sample project you are looking for.

Page 20: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

8 Chapter 1 Introduction

TriStation 1131 Libraries Reference

Page 21: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TriStation 1131 Libraries Reference

2Functions and Data Types

This section describes the functions, function blocks, and data types included in TriStation 1131 Libraries.

Page 22: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

10 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

ABSCalculates the absolute value of a number.

Syntaxk := 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.

ExampleVAR k : DINT; END_VARk := 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.

Page 23: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

ACOS 11

TriStation 1131 Libraries Reference

ACOSCalculates the principal arc cosine of a real number.

Syntaxy := 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.

ExampleVAR y : REAL; END_VARy := 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

Page 24: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

12 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

ADDCalculates 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.

OperationParameter 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.

OperationParameterData Type

Return ValueData 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.

Page 25: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

ADD 13

TriStation 1131 Libraries Reference

Example

Calculate the Sum of Numeric Values

VAR m : DINT; END_VARm := 10 + 1564; (* result is 1574 *)m := 10 + 1564 + 32761 + –512; (* result is 33823 *)

Calculate the Sum of Two Times

VAR t : TIME; END_VARt := T#11d22h33m + T#3h10m; (* result is T#12d1h43m *)

Add a Time to a Date and Time

VAR d : DT; END_VARd := 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_VARt := 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

Page 26: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

14 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

AINConverts an analog input to a real number.

Syntaxy := 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.

ExampleVAR y : REAL; END_VARy := 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.

Page 27: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

AIN_BP 15

TriStation 1131 Libraries Reference

AIN_BPConverts a differential bipolar analog input to a real number.

Syntaxy := 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.

ExampleVAR y : REAL; END_VARy := 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.

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.

IN LO–HI LO–--------------------- MX MN– MN+

Page 28: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

16 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

Application Notes

Can be used in Safety or Control applications.

Library

Triconex (TCXLIB)

This function was added to the library in v1.31 of TCXLIB, first released with TriStation 1131 v4.1.419.

Page 29: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

AIN_BP12 17

TriStation 1131 Libraries Reference

AIN_BP12Converts 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

EngineeringUnits

Page 30: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

18 Chapter 2 Functions and Data Types

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)

This function was added to the library in v1.32 of TCXLIB, first released with TriStation 1131 v4.3.

in y

-4095 -10.0

0 0.0

+4095 +10.0

Page 31: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

AIN_HR 19

TriStation 1131 Libraries Reference

AIN_HRConverts a high-resolution analog input to a real number.

Syntaxy := 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.

ExampleVAR y : REAL; END_VARy := 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.

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.

IN LO–HI LO–--------------------- MX MN– MN+

Page 32: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

20 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

Application Notes

Can be used in Safety or Control applications.

Library

Triconex (TCXLIB)

This function was added to the library in v1.31 of TCXLIB, first released with TriStation 1131 v4.1.419.

Page 33: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

ALARM_DEVIATION_DINT 21

TriStation 1131 Libraries Reference

ALARM_DEVIATION_DINTGenerates deviation alarms for DINT tagnames.

SyntaxMy_DevAlm(SOURCE:=Tagname_2_DevByp.VALUE, BYPASS:=Tagname_2_DevByp.BYPASSED, SETPOINT:=55, ACK_REQUEST:=Tagname_1, DISABLE_REQUEST:=Tagname_4, AUTOMATIC_RESET:=Tagname_3, MANUAL_RESET_REQUEST:=Tagname_6, DEADBAND:=2, TIME_DELAY:=T#5ms, RINGBACK:=TRUE, HIGH_HIGH_LIMIT:=10, HIGH_HIGH_SEVERITY:=400, HIGH_LIMIT:=5, HIGH_SEVERITY:=300, LOW_LIMIT:=-5, LOW_SEVERITY:=200, LOW_LOW_LIMIT:=-10, LOW_LOW_SEVERITY:=100);

Table 16 Input Parameters

Name Data Type Description

SOURCE DINT Input value for which deviation alarm will be generated. May be connected to a tagname, or to the output of BYPASS_DINT.

SETPOINT DINT Value from which the deviation alarm will be generated.

BYPASS BOOL If true, the source has been bypassed with the BYPASS_VALUE (from the BYPASS_DINT function block).

Note: SOURCE = BYPASS_VALUE only when you use the BYPASS_DINT function block along with ALARM_DEVIATION_DINT. The output of BYPASS_DINT (VALUE) should be connected to the SOURCE input of ALARM_DEVIATION_DINT. Additionally, BYPASS_REQ on BYPASS_DINT should be true. Simply setting BYPASS to true will not bypass the alarm. You must use BYPASS_DINT to bypass the value, while ALARM_DEVIATION_DINT’s BYPASS input also should be true so that you obtain the correct alarm status.

ACK_REQUEST BOOL If true, acknowledge request is sent, requesting the operator to acknowledge the alarm generated by this function block.

DISABLE_REQUEST BOOL If true, alarms will not be generated (all alarms disabled).

AUTOMATIC_RESET BOOL If true, when the generated alarm returns to normal, it is acknowledged automatically.

MANUAL_RESET_REQUEST BOOL If true, the ringback alarm is reset.

DEADBAND DINT Specifies the difference between the alarm limit and the input value before an alarm goes inactive.

TIME_DELAY TIME Specifies the time delay for an alarm to go active upon detection of an alarm condition.

RINGBACK BOOL If true, generates a ringback alarm when any previously generated alarm returns to normal.

Page 34: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

22 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

HIGH_HIGH_LIMIT DINT Specifies the High High alarm limit for the SOURCE.

When SOURCE is greater than SETPOINT + HIGH_HIGH_LIMIT, then HIGH_HIGH_ACTIVE becomes true, and subsequently, the output parameter ACTIVE becomes true.

HIGH_HIGH_SEVERITY DINT Specifies the severity for the High High limit.

HIGH_LIMIT DINT Specifies the High alarm limit for the SOURCE.

When SOURCE is greater than SETPOINT + HIGH_LIMIT, then HIGH_ACTIVE becomes true, and subsequently, the output parameter ACTIVE becomes true.

HIGH_SEVERITY DINT Specifies the severity for the High limit.

LOW_LIMIT DINT Specifies the Low alarm limit for the SOURCE.

When SOURCE is less than SETPOINT - LOW_LIMIT, then LOW_ACTIVE becomes true, and subsequently, the output parameter ACTIVE becomes true.

LOW_SEVERITY DINT Specifies the severity for the Low limit.

LOW_LOW_LIMIT DINT Specifies the Low Low alarm limit for the SOURCE.

When SOURCE is less than SETPOINT - LOW_LOW_LIMIT, then LOW_LOW_ACTIVE becomes true, and subsequently, the output parameter ACTIVE becomes true.

LOW_LOW_SEVERITY DINT Specifies the severity for the Low Low limit.

SOURCE_ID DINT Reserved for future use.

Table 17 Output Parameters

Name Data Type Description

ACTIVE BOOL If true, an alarm is active. If false, there are no active alarms.

HIGH_HIGH_ACTIVE BOOL If true, a High High alarm is active.

HIGH_ACTIVE BOOL If true, a High alarm is active.

LOW_ACTIVE BOOL If true, a Low alarm is active.

LOW_LOW_ACTIVE BOOL If true, a Low Low alarm is active.

ACKNOWLEDGED BOOL If true, the active alarm has been acknowledged.

ACK_TIME DT The last time when an active alarm was acknowledged.

ACTIVE_TIME DT The last time the alarm was active.

INACTIVE_TIME DT The last time the alarm was inactive.

Table 16 Input Parameters (continued)

Name Data Type Description

Page 35: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

ALARM_DEVIATION_DINT 23

TriStation 1131 Libraries Reference

Description

The ALARM_DEVIATION_DINT function generates deviation alarms (Low Low, Low, High, High High) for DINT tagnames.

Deviation alarms are commonly used to report an excess deviation between a process value’s desired setpoint level, and the actual measured level. They typically relate to instruments (for example, a temperature meter). A deviation alarm becomes active when the deviation exceeds or drops below a defined limit.

For example, assume the setpoint has been set to 10, the High limit is set to 2, and the Low limit is set to -1. If the process value drops below 9, the Low deviation alarm is generated. If the process value goes above 12, the High deviation alarm is generated. If the setpoint is changed to 11, the new deviation values will be 10 and 13, respectively.

The input parameter SOURCE is the process value being measured.

The DEADBAND input parameter specifies the difference between the alarm limit and the input value that will cause an alarm to go inactive. For example, assume the following limit settings:

• Setpoint = 40

• HIGH_HIGH_LIMIT = 10

• HIGH_LIMIT = 5

• LOW_LIMIT = 4

• LOW_LOW_LIMIT = 6

• DEADBAND = 2

The High High alarm will go inactive if SOURCE is less than 48. The High alarm will go inactive if SOURCE is less than 43. The Low alarm will go active if SOURCE is greater than 38. The Low Low alarm will go inactive if SOURCE is greater than 36.

ALARM_STATE DINT The current alarm status. Possible values are:

• NORMAL (16#00000000)

• LOLO_LVL_ACTIVE (16#00000011)

• LOLO_LVL_ACKED (16#00000012)

• LO_LVL_ACTIVE (16#00000021)

• LO_LVL_ACKED (16#00000022)

• HI_LVL_ACTIVE (16#00000031)

• HI_LVL_ACKED (16#00000032)

• HIHI_LVL_ACTIVE (16#00000041)

• HIHI_LVL_ACKED (16#00000042)

• TRIP_ACTIVE (16#00000051)

• TRIP_ACKED (16#00000052)

• ALARM_RINGBACK (16#00000003)

• ALARM_DISABLED (16#00000004)

• ALARM_BYPASSED(16#000000XX)where XX can be any of the above alarm states

Table 17 Output Parameters (continued)

Name Data Type Description

Page 36: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

24 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

The TIME_DELAY input parameter specifies how long before an alarm will go active once the alarm condition is detected. For example, if TIME_DELAY is configured as 5 seconds, and the High alarm is set for 100, once the value exceeds 100, ALARM_DEVIATION_DINT will wait 5 seconds before generating the High alarm. Use of the TIME_DELAY parameter can help prevent nuisance alarms that may be generated due to process noise.

ExampleVAR My_Deviation_Alarm: DEVIATION_ALARM_DINT; END_VARVAR_EXTERNAL My_Tagname: DINT; Tagname2:BOOL;Tagname3:BOOL; Tagname4:BOOL; Tagname5:BOOL;Tagname6:BOOL;END_VAR

My_Deviation_Alarm (SOURCE:=My_Tagname, BYPASS:=Tagname2,SETPOINT:=55, ACK_REQUEST:=Tagname3, DISABLE_REQUEST:=Tagname4,AUTOMATIC_RESET:=Tagname5, MANUAL_RESET_REQUEST:=Tagname6, DEADBAND:=2,TIME_DELAY:=T#5ms, RINGBACK:=TRUE, HIGH_HIGH_LIMIT:=10, HIGH_HIGH_SEVERITY:=4,HIGH_LIMIT:=5, HIGH_SEVERITY:=3, LOW_LIMIT:=5, LOW_SEVERITY:=2, LOW_LOW_LIMIT:=10, LOW_LOW_SEVERITY:=1);

Runtime Errors

None.

Application Notes

Can be used in Safety or Control applications.

Library

Process Alarm Library (ALARMS)

This library was first released with TriStation 1131 v4.7.0, but can be used with all TriStation 1131 versions.

Page 37: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

ALARM_DEVIATION_REAL 25

TriStation 1131 Libraries Reference

ALARM_DEVIATION_REALGenerates deviation alarms for REAL tagnames.

SyntaxMy_DevAlm(SOURCE:=Tagname_2_DevByp.VALUE, BYPASS:=Tagname_2_DevByp.BYPASSED, SETPOINT:=55, ACK_REQUEST:=Tagname_1, DISABLE_REQUEST:=Tagname_4, AUTOMATIC_RESET:=Tagname_3, MANUAL_RESET_REQUEST:=Tagname_6DEAD, BAND:=2.0, TIME_DELAY:=T#5ms, RINGBACK:=TRUE, HIGH_HIGH_LIMIT:=10.0, HIGH_HIGH_SEVERITY:=400, HIGH_LIMIT:=5.0, HIGH_SEVERITY:=300, LOW_LIMIT:=-5.0, LOW_SEVERITY:=200, LOW_LOW_LIMIT:=-10.0, LOW_LOW_SEVERITY:=100);

Table 18 Input Parameters

Name Data Type Description

SOURCE DINT Input value for which deviation alarm will be generated. May be connected to a tagname, or to the output of BYPASS_REAL.

SETPOINT DINT Value from which the deviation alarm will be generated.

BYPASS BOOL If true, the source has been bypassed with the BYPASS_VALUE (from the BYPASS_REAL function block).

Note: SOURCE = BYPASS_VALUE only when you use the BYPASS_REAL function block along with ALARM_DEVIATION_REAL. The output of BYPASS_REAL (VALUE) should be connected to the SOURCE input of ALARM_DEVIATION_REAL. Additionally, BYPASS_REQ on BYPASS_REAL should be true. Simply setting BYPASS to true will not bypass the alarm. You must use BYPASS_REAL to bypass the value, while ALARM_DEVIATION_REAL’s BYPASS input also should be true so that you obtain the correct alarm status.

ACK_REQUEST BOOL If true, acknowledge request is sent, requesting the operator to acknowledge the alarm generated by this function block.

DISABLE_REQUEST BOOL If true, alarms will not be generated (all alarms disabled).

AUTOMATIC_RESET BOOL If true, when the generated alarm returns to normal, it is acknowledged automatically.

MANUAL_RESET_REQUEST BOOL If true, the ringback alarm is reset.

DEADBAND DINT Specifies the difference between the alarm limit and the input value before an alarm goes inactive.

TIME_DELAY TIME Specifies the time delay for an alarm to go active upon detection of an alarm condition.

RINGBACK BOOL If true, generates a ringback alarm when any previously generated alarm returns to normal.

Page 38: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

26 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

HIGH_HIGH_LIMIT DINT Specifies the High High alarm limit for the SOURCE.

When SOURCE is greater than SETPOINT + HIGH_HIGH_LIMIT, then HIGH_HIGH_ACTIVE becomes true, and subsequently, the output parameter ACTIVE becomes true.

HIGH_HIGH_SEVERITY DINT Specifies the severity for the High High limit.

HIGH_LIMIT DINT Specifies the High alarm limit for the SOURCE.

When SOURCE is greater than SETPOINT + HIGH_LIMIT, then HIGH_ACTIVE becomes true, and subsequently, the output parameter ACTIVE becomes true.

HIGH_SEVERITY DINT Specifies the severity for the High limit.

LOW_LIMIT DINT Specifies the Low alarm limit for the SOURCE.

When SOURCE is less than SETPOINT - LOW_LIMIT, then LOW_ACTIVE becomes true, and subsequently, the output parameter ACTIVE becomes true.

LOW_SEVERITY DINT Specifies the severity for the Low limit.

LOW_LOW_LIMIT DINT Specifies the Low Low alarm limit for the SOURCE.

When SOURCE is less than SETPOINT - LOW_LOW_LIMIT, then LOW_LOW_ACTIVE becomes true, and subsequently, the output parameter ACTIVE becomes true.

LOW_LOW_SEVERITY DINT Specifies the severity for the Low Low limit.

SOURCE_ID DINT Reserved for future use.

Table 19 Output Parameters

Name Data Type Description

ACTIVE BOOL If true, an alarm is active. If false, there are no active alarms.

HIGH_HIGH_ACTIVE BOOL If true, a High High alarm is active.

HIGH_ACTIVE BOOL If true, a High alarm is active.

LOW_ACTIVE BOOL If true, a Low alarm is active.

LOW_LOW_ACTIVE BOOL If true, a Low Low alarm is active.

ACKNOWLEDGED BOOL If true, the active alarm has been acknowledged.

ACK_TIME DT The last time when an active alarm was acknowledged.

ACTIVE_TIME DT The last time the alarm was active.

INACTIVE_TIME DT The last time the alarm was inactive.

Table 18 Input Parameters (continued)

Name Data Type Description

Page 39: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

ALARM_DEVIATION_REAL 27

TriStation 1131 Libraries Reference

Description

The ALARM_DEVIATION_REAL function generates deviation alarms (Low Low, Low, High, High High) for REAL tagnames.

Deviation alarms are commonly used to report an excess deviation between a process value’s desired setpoint level, and the actual measured level. They typically relate to instruments (for example, a temperature meter). A deviation alarm becomes active when the deviation exceeds or drops below a defined limit.

For example, assume the setpoint has been set to 10, the High limit is set to 2, and the Low limit is set to -1. If the process value drops below 9, the Low deviation alarm is generated. If the process value goes above 12, the High deviation alarm is generated. If the setpoint is changed to 11, the new deviation values will be 10 and 13, respectively.

The input parameter SOURCE is the process value being measured.

The DEADBAND input parameter specifies the difference between the alarm limit and the input value that will cause an alarm to go inactive. For example, assume the following limit settings:

• Setpoint = 40

• HIGH_HIGH_LIMIT = 10

• HIGH_LIMIT = 5

• LOW_LIMIT = 4

• LOW_LOW_LIMIT = 6

• DEADBAND = 2

The High High alarm will go inactive if SOURCE is less than 48. The High alarm will go inactive if SOURCE is less than 43. The Low alarm will go active if SOURCE is greater than 38. The Low Low alarm will go inactive if SOURCE is greater than 36.

ALARM_STATE DINT The current alarm status. Possible values are:

• NORMAL (16#00000000)

• LOLO_LVL_ACTIVE (16#00000011)

• LOLO_LVL_ACKED (16#00000012)

• LO_LVL_ACTIVE (16#00000021)

• LO_LVL_ACKED (16#00000022)

• HI_LVL_ACTIVE (16#00000031)

• HI_LVL_ACKED (16#00000032)

• HIHI_LVL_ACTIVE (16#00000041)

• HIHI_LVL_ACKED (16#00000042)

• TRIP_ACTIVE (16#00000051)

• TRIP_ACKED (16#00000052)

• ALARM_RINGBACK (16#00000003)

• ALARM_DISABLED (16#00000004)

• ALARM_BYPASSED(16#000000XX)where XX can be any of the above alarm states

Table 19 Output Parameters (continued)

Name Data Type Description

Page 40: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

28 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

The TIMEDELAY input parameter specifies how long before an alarm will go active once the alarm condition is detected. For example, if TIMEDELAY is configured as 5 seconds, and the High alarm is set for 100, once the value exceeds 100, ALARM_DEVIATION_REAL will wait 5 seconds before generating the High alarm. Use of the TIMEDELAY parameter can help prevent nuisance alarms that may be generated due to process noise.

ExampleVAR My_Deviation_Alarm: ALARM_DEVIATION_REAL; END_VARVAR_EXTERNAL My_Tagname: REAL; Tagname2:BOOL;Tagname3:BOOL; Tagname4:BOOL; Tagname5:BOOL;Tagname6:BOOL;END_VAR

My_Deviation_Alarm (SOURCE:=My_Tagname, BYPASS:=Tagname2,SETPOINT:=55, ACK_REQUEST:=Tagname3, DISABLE_REQUEST:=Tagname4,AUTOMATIC_RESET:=Tagname5, MANUAL_RESET_REQUEST:=Tagname6, DEADBAND:=2,TIME_DELAY:=T#5ms, RINGBACK:=TRUE, HIGH_HIGH_LIMIT:=10, HIGH_HIGH_SEVERITY:=4,HIGH_LIMIT:=5, HIGH_SEVERITY:=3, LOW_LIMIT:=5, LOW_SEVERITY:=2, LOW_LOW_LIMIT:=10, LOW_LOW_SEVERITY:=1);

Runtime Errors

None.

Application Notes

Can be used in Safety or Control applications.

Library

Process Alarm Library (ALARMS)

This library was first released with TriStation 1131 v4.7.0, but can be used with all TriStation 1131 versions.

Page 41: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

ALARM_LEVEL_DINT 29

TriStation 1131 Libraries Reference

ALARM_LEVEL_DINTGenerates level alarms for DINT tagnames.

SyntaxMy_LvlAlm(SOURCE:=Tagname_2_LvByp.VALUE, BYPASS:=Tagname_2_LvByp.BYPASSED, ACK_REQUEST:=Tagname_1, DISABLE_REQUEST:=Tagname_5, AUTOMATIC_RESET:=Tagname_3, MANUAL_RESET_REQUEST:=Tagname_6, DEADBAND:=5, TIME_DELAY:=T#10ms, RINGBACK:=TRUE, HIGH_HIGH_LIMIT:=90, HIGH_HIGH_SEVERITY:=400, HIGH_LIMIT:=80, HIGH_SEVERITY:=300, LOW_LIMIT:=20, LOW_SEVERITY:=200, LOW_LOW_LIMIT:=10, LOW_LOW_SEVERITY:=100);

Table 20 Input Parameters

Name Data Type Description

SOURCE DINT Input value for which level alarm will be generated. May be connected to a tagname, or to the output of BYPASS_DINT.

BYPASS BOOL If true, the source has been bypassed with the BYPASS_VALUE (from the BYPASS_DINT function block).

Note: SOURCE = BYPASS_VALUE only when you use the BYPASS_DINT function block along with ALARM_LEVEL_DINT. The output of BYPASS_DINT (VALUE) should be connected to the SOURCE input of ALARM_LEVEL_DINT. Additionally, BYPASS_REQ on BYPASS_DINT should be true. Simply setting BYPASS to true will not bypass the alarm. You must use BYPASS_DINT to bypass the value, while ALARM_LEVEL_DINT’s BYPASS input also should be true so that you obtain the correct alarm status.

ACK_REQUEST BOOL If true, acknowledge request is sent, requesting the operator to acknowledge the alarm generated by this function block.

DISABLE_REQUEST BOOL If true, alarms will not be generated (all alarms disabled).

AUTOMATIC_RESET BOOL If true, when the generated alarm returns to normal, it is acknowledged automatically.

MANUAL_RESET_REQUEST BOOL If true, the ringback alarm is reset.

DEADBAND DINT Specifies the difference between the alarm limit and the input value before an alarm goes inactive.

TIME_DELAY TIME Specifies the time delay for an alarm to go active upon detection of an alarm condition.

RINGBACK BOOL If true, generates a ringback alarm when any previously generated alarm returns to normal.

HIGH_HIGH_LIMIT DINT Specifies the High High alarm limit for the SOURCE.

When SOURCE is greater than HIGH_HIGH_LIMIT, then HIGH_HIGH_ACTIVE becomes true, and subsequently, the output parameter ACTIVE becomes true.

HIGH_HIGH_SEVERITY DINT Specifies the severity for the High High limit.

Page 42: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

30 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

HIGH_LIMIT DINT Specifies the High alarm limit for the SOURCE.

When SOURCE is greater than HIGH_LIMIT, then HIGH_ACTIVE becomes true, and subsequently, the output parameter ACTIVE becomes true.

HIGH_SEVERITY DINT Specifies the severity for the High limit.

LOW_LIMIT DINT Specifies the Low alarm limit for the SOURCE.

When SOURCE is less than LOW_LIMIT, then LOW_ACTIVE becomes true, and subsequently, the output parameter ACTIVE becomes true.

LOW_SEVERITY DINT Specifies the severity for the Low limit.

LOW_LOW_LIMIT DINT Specifies the Low Low alarm limit for the SOURCE.

When SOURCE is less than LOW_LOW_LIMIT, then LOW_LOW_ACTIVE becomes true, and subsequently, the output parameter ACTIVE becomes true.

LOW_LOW_SEVERITY DINT Specifies the severity for the Low Low limit.

SOURCE_ID DINT Reserved for future use.

Table 21 Output Parameters

Name Data Type Description

ACTIVE BOOL If true, an alarm is active. If false, there are no active alarms.

HIGH_HIGH_ACTIVE BOOL If true, a High High alarm is active.

HIGH_ACTIVE BOOL If true, a High alarm is active.

LOW_ACTIVE BOOL If true, a Low alarm is active.

LOW_LOW_ACTIVE BOOL If true, a Low Low alarm is active.

ACKNOWLEDGED BOOL If true, the active alarm has been acknowledged.

ACK_TIME DT The last time when an active alarm was acknowledged.

ACTIVE_TIME DT The last time the alarm was active.

INACTIVE_TIME DT The last time the alarm was inactive.

Table 20 Input Parameters (continued)

Name Data Type Description

Page 43: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

ALARM_LEVEL_DINT 31

TriStation 1131 Libraries Reference

Description

The ALARM_LEVEL_DINT function generates level alarms (Low Low, Low, High, High High) for DINT tagnames.

Level alarms are commonly used to report when a limit is exceeded. They typically relate to instruments (for example, a temperature meter). A level alarm becomes active when the observed value is above a high limit, or below a low limit.

The input parameter SOURCE is the process value being measured.

The DEADBAND input parameter specifies the difference between the alarm limit and the input value that will cause an alarm to go inactive. For example, if a High alarm is set for 100, and the DEADBAND is set to 10, the alarm will go active at 100, and inactive at 90. If a Low alarm is set for 100, it will go active at 100, and inactive at 110.

The TIME_DELAY input parameter specifies how long before an alarm will go active once the alarm condition is detected. For example, if TIME_DELAY is configured as 5 seconds, and the High alarm is set for 100, once the value exceeds 100, ALARM_LEVEL_DINT will wait 5 seconds before generating the High alarm. Use of the TIME_DELAY parameter can help prevent nuisance alarms that may be generated due to process noise.

ExampleVAR My_Level_Alarm: ALARM_LEVEL_DINT; END_VARVAR_EXTERNAL My_Tagname: DINT; Tagname2:BOOL; Tagname3:BOOL; Tagname4:BOOL; Tagname5:BOOL; Tagname6:BOOL;END_VAR

My_Level_Alarm (SOURCE:=My_Tagname, BYPASS:=Tagname2, ACK_REQUEST:=Tagname3, DISABLE_REQUEST:=Tagname4, AUTOMATIC_RESET:=Tagname5, MANUAL_RESET_REQUEST:=Tagname6, DEADBAND:=2, TIME_DELAY:=T#5ms, RINGBACK:=TRUE, HIGH_HIGH_LIMIT:=100, HIGH_HIGH_SEVERITY:=4, HIGH_LIMIT:=80, HIGH_SEVERITY:=3, LOW_LIMIT:=20, LOW_SEVERITY:=2, LOW_LOW_LIMIT:=10, LOW_LOW_SEVERITY:=1

ALARM_STATE DINT The current alarm status. Possible values are:

• NORMAL (16#00000000)

• LOLO_LVL_ACTIVE (16#00000011)

• LOLO_LVL_ACKED (16#00000012)

• LO_LVL_ACTIVE (16#00000021)

• LO_LVL_ACKED (16#00000022)

• HI_LVL_ACTIVE (16#00000031)

• HI_LVL_ACKED (16#00000032)

• HIHI_LVL_ACTIVE (16#00000041)

• HIHI_LVL_ACKED (16#00000042)

• TRIP_ACTIVE (16#00000051)

• TRIP_ACKED (16#00000052)

• ALARM_RINGBACK (16#00000003)

• ALARM_DISABLED (16#00000004)

• ALARM_BYPASSED(16#000000XX)where XX can be any of the above alarm states

Table 21 Output Parameters (continued)

Name Data Type Description

Page 44: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

32 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

);

Runtime Errors

None.

Application Notes

Can be used in Safety or Control applications.

Library

Process Alarm Library (ALARMS)

This library was first released with TriStation 1131 v4.7.0, but can be used with all TriStation 1131 versions.

Page 45: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

ALARM_LEVEL_REAL 33

TriStation 1131 Libraries Reference

ALARM_LEVEL_REALGenerates level alarms for REAL tagnames.

SyntaxMy_LvlAlm(SOURCE:=Tagname_2_LvByp.VALUE, BYPASS:=Tagname_2_LvByp.BYPASSED, ACK_REQUEST:=Tagname_1, DISABLE_REQUEST:=Tagname_5, AUTOMATIC_RESET:=Tagname_3, MANUAL_RESET_REQUEST:=Tagname_6, DEADBAND:=5.0, TIME_DELAY:=T#10ms, RINGBACK:=TRUE, HIGH_HIGH_LIMIT:=90.0, HIGH_HIGH_SEVERITY:=400, HIGH_LIMIT:=80.0, HIGH_SEVERITY:=300, LOW_LIMIT:=20.0, LOW_SEVERITY:=200, LOW_LOW_LIMIT:=10.0, LOW_LOW_SEVERITY:=100);

Table 22 Input Parameters

Name Data Type Description

SOURCE DINT Input value for which level alarm will be generated. May be connected to a tagname, or to the output of BYPASS_REAL.

BYPASS BOOL If true, the source has been bypassed with the BYPASS_VALUE (from the BYPASS_REAL function block).

Note: SOURCE = BYPASS_VALUE only when you use the BYPASS_REAL function block along with ALARM_LEVEL_REAL. The output of BYPASS_REAL (VALUE) should be connected to the SOURCE input of ALARM_LEVEL_REAL. Additionally, BYPASS_REQ on BYPASS_REAL should be true. Simply setting BYPASS to true will not bypass the alarm. You must use BYPASS_REAL to bypass the value, while ALARM_LEVEL_REAL’s BYPASS input also should be true so that you obtain the correct alarm status.

ACK_REQUEST BOOL If true, acknowledge request is sent, requesting the operator to acknowledge the alarm generated by this function block.

DISABLE_REQUEST BOOL If true, alarms will not be generated (all alarms disabled).

AUTOMATIC_RESET BOOL If true, when the generated alarm returns to normal, it is acknowledged automatically.

MANUAL_RESET_REQUEST BOOL If true, the ringback alarm is reset.

DEADBAND DINT Specifies the difference between the alarm limit and the input value before an alarm goes inactive.

TIME_DELAY TIME Specifies the time delay for an alarm to go active upon detection of an alarm condition.

RINGBACK BOOL If true, generates a ringback alarm when any previously generated alarm returns to normal.

HIGH_HIGH_LIMIT DINT Specifies the High High alarm limit for the SOURCE.

When SOURCE is greater than HIGH_HIGH_LIMIT, then HIGH_HIGH_ACTIVE becomes true, and subsequently, the output parameter ACTIVE becomes true.

HIGH_HIGH_SEVERITY DINT Specifies the severity for the High High limit.

Page 46: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

34 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

HIGH_LIMIT DINT Specifies the High alarm limit for the SOURCE.

When SOURCE is greater than HIGH_LIMIT, then HIGH_ACTIVE becomes true, and subsequently, the output parameter ACTIVE becomes true.

HIGH_SEVERITY DINT Specifies the severity for the High limit.

LOW_LIMIT DINT Specifies the Low alarm limit for the SOURCE.

When SOURCE is less than LOW_LIMIT, then LOW_ACTIVE becomes true, and subsequently, the output parameter ACTIVE becomes true.

LOW_SEVERITY DINT Specifies the severity for the Low limit.

LOW_LOW_LIMIT DINT Specifies the Low Low alarm limit for the SOURCE.

When SOURCE is less than LOW_LOW_LIMIT, then LOW_LOW_ACTIVE becomes true, and subsequently, the output parameter ACTIVE becomes true.

LOW_LOW_SEVERITY DINT Specifies the severity for the Low Low limit.

SOURCE_ID DINT Reserved for future use.

Table 23 Output Parameters

Name Data Type Description

ACTIVE BOOL If true, an alarm is active. If false, there are no active alarms.

HIGH_HIGH_ACTIVE BOOL If true, a High High alarm is active.

HIGH_ACTIVE BOOL If true, a High alarm is active.

LOW_ACTIVE BOOL If true, a Low alarm is active.

LOW_LOW_ACTIVE BOOL If true, a Low Low alarm is active.

ACKNOWLEDGED BOOL If true, the active alarm has been acknowledged.

ACK_TIME DT The last time when an active alarm was acknowledged.

ACTIVE_TIME DT The last time the alarm was active.

INACTIVE_TIME DT The last time the alarm was inactive.

Table 22 Input Parameters (continued)

Name Data Type Description

Page 47: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

ALARM_LEVEL_REAL 35

TriStation 1131 Libraries Reference

Description

The ALARM_LEVEL_REAL function generates level alarms (Low Low, Low, High, High High) for REAL tagnames.

Level alarms are commonly used to report when a limit is exceeded. They typically relate to instruments (for example, a temperature meter). A level alarm becomes active when the observed value is above a high limit, or below a low limit.

The input parameter SOURCE is the process value being measured.

The DEADBAND input parameter specifies the difference between the alarm limit and the input value that will cause an alarm to go inactive. For example, if a High alarm is set for 100, and the DEADBAND is set to 10, the alarm will go active at 100, and inactive at 90. If a Low alarm is set for 100, it will go active at 100, and inactive at 110.

The TIME_DELAY input parameter specifies how long before an alarm will go active once the alarm condition is detected. For example, if TIME_DELAY is configured as 5 seconds, and the High alarm is set for 100, once the value exceeds 100, ALARM_LEVEL_REAL will wait 5 seconds before generating the High alarm. Use of the TIME_DELAY parameter can help prevent nuisance alarms that may be generated due to process noise.

ExampleVAR My_Level_Alarm: ALARM_LEVEL_DINT; END_VARVAR_EXTERNAL My_Tagname: DINT; Tagname2:BOOL; Tagname3:BOOL; Tagname4:BOOL; Tagname5:BOOL; Tagname6:BOOL;END_VAR

My_Level_Alarm (SOURCE:=My_Tagname, BYPASS:=Tagname2, ACK_REQUEST:=Tagname3, DISABLE_REQUEST:=Tagname4, AUTOMATIC_RESET:=Tagname5, MANUAL_RESET_REQUEST:=Tagname6, DEADBAND:=2, TIME_DELAY:=T#5ms, RINGBACK:=TRUE, HIGH_HIGH_LIMIT:=100, HIGH_HIGH_SEVERITY:=4, HIGH_LIMIT:=80, HIGH_SEVERITY:=3, LOW_LIMIT:=20, LOW_SEVERITY:=2, LOW_LOW_LIMIT:=10, LOW_LOW_SEVERITY:=1

ALARM_STATE DINT The current alarm status. Possible values are:

• NORMAL (16#00000000)

• LOLO_LVL_ACTIVE (16#00000011)

• LOLO_LVL_ACKED (16#00000012)

• LO_LVL_ACTIVE (16#00000021)

• LO_LVL_ACKED (16#00000022)

• HI_LVL_ACTIVE (16#00000031)

• HI_LVL_ACKED (16#00000032)

• HIHI_LVL_ACTIVE (16#00000041)

• HIHI_LVL_ACKED (16#00000042)

• TRIP_ACTIVE (16#00000051)

• TRIP_ACKED (16#00000052)

• ALARM_RINGBACK (16#00000003)

• ALARM_DISABLED (16#00000004)

• ALARM_BYPASSED(16#000000XX)where XX can be any of the above alarm states

Table 23 Output Parameters (continued)

Name Data Type Description

Page 48: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

36 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

);

Runtime Errors

None.

Application Notes

Can be used in Safety or Control applications.

Library

Process Alarm Library (ALARMS)

This library was first released with TriStation 1131 v4.7.0, but can be used with all TriStation 1131 versions.

Page 49: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

ALARM_ROC_DINT 37

TriStation 1131 Libraries Reference

ALARM_ROC_DINTGenerates rate of change alarms for DINT tagnames.

SyntaxMy_ROCAlm(SOURCE:=Tagname_2_ROCByp.VALUE, BYPASS:=Tagname_2_ROCByp.BYPASSED, RATE_OF_CHANGE:=T#5s, ACK_REQUEST:=Tagname_1, DISABLE_REQUEST:=Tagname_5, AUTOMATIC_RESET:=Tagname_3, MANUAL_RESET_REQUEST:=Tagname_6, DEADBAND:=2, TIME_DELAY:=T#5ms, RINGBACK:=TRUE, HIGH_HIGH_LIMIT:=6, HIGH_HIGH_SEVERITY:=400, HIGH_LIMIT:=3, HIGH_SEVERITY:=300, LOW_LIMIT:=3, LOW_SEVERITY:=200, LOW_LOW_LIMIT:=6, LOW_LOW_SEVERITY:=100);

Table 24 Input Parameters

Name Data Type Description

SOURCE DINT Input value for which a rate of change alarm will be generated. May be connected to a tagname, or to the output of BYPASS_DINT.

RATEOFCHANGE DINT The rate of change in SOURCE, measured in units of time (seconds, minutes, or hours).

BYPASS BOOL If true, the source has been bypassed with the BYPASS_VALUE (from the BYPASS_DINT function block).

Note: SOURCE = BYPASS_VALUE only when you use the BYPASS_DINT function block along with ALARM_ROC_DINT. The output of BYPASS_DINT (VALUE) should be connected to the SOURCE input of ALARM_ROC_DINT. Additionally, BYPASS_REQ on BYPASS_DINT should be true. Simply setting BYPASS to true will not bypass the alarm. You must use BYPASS_DINT to bypass the value, while ALARM_ROC_DINT’s BYPASS input also should be true so that you obtain the correct alarm status.

ACK_REQUEST BOOL If true, acknowledge request is sent, requesting the operator to acknowledge the alarm generated by this function block.

DISABLE_REQUEST BOOL If true, alarms will not be generated (all alarms disabled).

AUTOMATIC_RESET BOOL If true, when the generated alarm returns to normal, it is acknowledged automatically.

MANUAL_RESET_REQUEST BOOL If true, the ringback alarm is reset.

DEADBAND DINT Specifies the difference between the alarm limit and the input value before an alarm goes inactive.

TIME_DELAY TIME Specifies the time delay for an alarm to go active upon detection of an alarm condition.

RINGBACK BOOL If true, generates a ringback alarm when any previously generated alarm returns to normal.

HIGH_HIGH_LIMIT DINT Specifies the High High alarm limit for the SOURCE.

When SOURCE is greater than HIGH_HIGH_LIMIT, then HIGH_HIGH_ACTIVE becomes true, and subsequently, the output parameter ACTIVE becomes true.

Page 50: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

38 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

HIGH_HIGH_SEVERITY DINT Specifies the severity for the High High limit.

HIGH_LIMIT DINT Specifies the High alarm limit for the SOURCE.

When SOURCE is greater than HIGH_LIMIT, then HIGH_ACTIVE becomes true, and subsequently, the output parameter ACTIVE becomes true.

HIGH_SEVERITY DINT Specifies the severity for the High limit.

LOW_LIMIT DINT Specifies the Low alarm limit for the SOURCE.

When SOURCE is less than LOW_LIMIT, then LOW_ACTIVE becomes true, and subsequently, the output parameter ACTIVE becomes true.

LOW_SEVERITY DINT Specifies the severity for the Low limit.

LOW_LOW_LIMIT DINT Specifies the Low Low alarm limit for the SOURCE.

When SOURCE is less than LOW_LOW_LIMIT, then LOW_LOW_ACTIVE becomes true, and subsequently, the output parameter ACTIVE becomes true.

LOW_LOW_SEVERITY DINT Specifies the severity for the Low Low limit.

SOURCE_ID DINT Reserved for future use.

Table 25 Output Parameters

Name Data Type Description

ACTIVE BOOL If true, an alarm is active. If false, there are no active alarms.

HIGH_HIGH_ACTIVE BOOL If true, a High High alarm is active.

HIGH_ACTIVE BOOL If true, a High alarm is active.

LOW_ACTIVE BOOL If true, a Low alarm is active.

LOW_LOW_ACTIVE BOOL If true, a Low Low alarm is active.

ACKNOWLEDGED BOOL If true, the active alarm has been acknowledged.

ACK_TIME DT The last time when an active alarm was acknowledged.

ACTIVE_TIME DT The last time the alarm was active.

INACTIVE_TIME DT The last time the alarm was inactive.

Table 24 Input Parameters (continued)

Name Data Type Description

Page 51: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

ALARM_ROC_DINT 39

TriStation 1131 Libraries Reference

Description

The ALARM_ROC_DINT function generates rate of change alarms for DINT tagnames.

Rate of change alarms are commonly used to report an unusual change or lack of change in a measured value, relative to the speed at which the value has changed. They typically relate to instruments (for example, a temperature meter). A rate of change alarm becomes active when the rate at which the value changes exceeds or drops below a defined limit.

The rate of change is measured in units of time (such as seconds, minutes, or hours). For example, a tank may have a High limit for the rate of change of its level (measured in meters) of 4 meters/minute. If the tank level changes at a rate greater than 4 meters/minute, then a High alarm is generated.

The input parameter SOURCE is the process value being measured.

The DEADBAND input parameter specifies the difference between the alarm limit and the input value that will cause an alarm to go inactive. For example, if a High alarm is set for 100, and the DEADBAND is set to 10, the alarm will go active at 100, and inactive at 90. If a Low alarm is set for 100, it will go active at 100, and inactive at 110.

The TIME_DELAY input parameter specifies how long before an alarm will go active once the alarm condition is detected. For example, if TIME_DELAY is configured as 5 seconds, and the High alarm is set for 100, once the value exceeds 100, ALARM_ROC_DINT will wait 5 seconds before generating the High alarm. Use of the TIME_DELAY parameter can help prevent nuisance alarms that may be generated due to process noise.

ExampleVAR My_RateOfChange_Alarm: ALARM_ROC_DINT; END_VARVAR My_BYPASS_DINT:BYPASS_DINT; END_VAR

VAR_EXTERNAL My_Tagname: DINT; Tagname2:BOOL; Tagname3:BOOL; Tagname4:BOOL; Tagname5:BOOL; Tagname6:BOOL;END_VAR

ALARM_STATE DINT The current alarm status. Possible values are:

• NORMAL (16#00000000)

• LOLO_LVL_ACTIVE (16#00000011)

• LOLO_LVL_ACKED (16#00000012)

• LO_LVL_ACTIVE (16#00000021)

• LO_LVL_ACKED (16#00000022)

• HI_LVL_ACTIVE (16#00000031)

• HI_LVL_ACKED (16#00000032)

• HIHI_LVL_ACTIVE (16#00000041)

• HIHI_LVL_ACKED (16#00000042)

• TRIP_ACTIVE (16#00000051)

• TRIP_ACKED (16#00000052)

• ALARM_RINGBACK (16#00000003)

• ALARM_DISABLED (16#00000004)

• ALARM_BYPASSED(16#000000XX)where XX can be any of the above alarm states

Table 25 Output Parameters (continued)

Name Data Type Description

Page 52: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

40 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

My_BYPASS_DINT(TAG_VALUE:=My_Tagname, BYPASS_VALUE:=55, BYPASS_REQ:=Tagname4);My_RateOfChange_Alarm (SOURCE:=My_BYPASS_DINT.value, BYPASS:=Tagname4, RATE_OF_CHANGE:=time#1m, ACK_REQUEST:=Tagname3, DISABLE_REQUEST:=Tagname4, AUTOMATIC_RESET:=Tagname5, MANUAL_RESET_REQUEST:=Tagname6, DEADBAND:=2, TIME_DELAY:=T#5ms, RINGBACK:=TRUE, HIGH_HIGH_LIMIT:=10, HIGH_HIGH_SEVERITY:=40, HIGH_LIMIT:=5, HIGH_SEVERITY:=300, LOW_LIMIT:=5, LOW_SEVERITY:=200, LOW_LOW_LIMIT:=10, LOW_LOW_SEVERITY:=100);

Runtime Errors

None.

Application Notes

Can be used in Safety or Control applications.

Library

Process Alarm Library (ALARMS)

This library was first released with TriStation 1131 v4.7.0, but can be used with all TriStation 1131 versions.

Page 53: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

ALARM_ROC_REAL 41

TriStation 1131 Libraries Reference

ALARM_ROC_REALGenerates reate of change alarms for REAL tagnames.

SyntaxMy_ROCAlm(SOURCE:=Tagname_2_ROCByp.VALUE, BYPASS:=Tagname_2_ROCByp.BYPASSED, RATE_OF_CHANGE:=T#5s, ACK_REQUEST:=Tagname_1, DISABLE_REQUEST:=Tagname_5, AUTOMATIC_RESET:=Tagname_3, MANUAL_RESET_REQUEST:=Tagname_6, DEADBAND:=2.0, TIME_DELAY:=T#5ms, RINGBACK:=TRUE, HIGH_HIGH_LIMIT:=6.0, HIGH_HIGH_SEVERITY:=400, HIGH_LIMIT:=3.0, HIGH_SEVERITY:=300, LOW_LIMIT:=3.0, LOW_SEVERITY:=200, LOW_LOW_LIMIT:=6.0, LOW_LOW_SEVERITY:=100);

Table 26 Input Parameters

Name Data Type Description

SOURCE DINT Input value for which a rate of change alarm will be generated. May be connected to a tagname, or to the output of BYPASS_REAL.

RATEOFCHANGE DINT The rate of change in SOURCE, measured in units of time (seconds, minutes, or hours).

BYPASS BOOL If true, the source has been bypassed with the BYPASS_VALUE (from the BYPASS_REAL function block).

Note: SOURCE = BYPASS_VALUE only when you use the BYPASS_REAL function block along with ALARM_ROC_REAL. The output of BYPASS_REAL (VALUE) should be connected to the SOURCE input of ALARM_ROC_REAL. Additionally, BYPASS_REQ on BYPASS_REAL should be true. Simply setting BYPASS to true will not bypass the alarm. You must use BYPASS_REAL to bypass the value, while ALARM_ROC_REAL’s BYPASS input also should be true so that you obtain the correct alarm status.

ACK_REQUEST BOOL If true, acknowledge request is sent, requesting the operator to acknowledge the alarm generated by this function block.

DISABLE_REQUEST BOOL If true, alarms will not be generated (all alarms disabled).

AUTOMATIC_RESET BOOL If true, when the generated alarm returns to normal, it is acknowledged automatically.

MANUAL_RESET_REQUEST

BOOL If true, the ringback alarm is reset.

DEADBAND DINT Specifies the difference between the alarm limit and the input value before an alarm goes inactive.

TIME_DELAY TIME Specifies the time delay for an alarm to go active upon detection of an alarm condition.

RINGBACK BOOL If true, generates a ringback alarm when any previously generated alarm returns to normal.

Page 54: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

42 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

HIGH_HIGH_LIMIT DINT Specifies the High High alarm limit for the SOURCE.

When SOURCE is greater than HIGH_HIGH_LIMIT, then HIGH_HIGH_ACTIVE becomes true, and subsequently, the output parameter ACTIVE becomes true.

HIGH_HIGH_SEVERITY DINT Specifies the severity for the High High limit.

HIGH_LIMIT DINT Specifies the High alarm limit for the SOURCE.

When SOURCE is greater than HIGH_LIMIT, then HIGH_ACTIVE becomes true, and subsequently, the output parameter ACTIVE becomes true.

HIGH_SEVERITY DINT Specifies the severity for the High limit.

LOW_LIMIT DINT Specifies the Low alarm limit for the SOURCE.

When SOURCE is less than LOW_LIMIT, then LOW_ACTIVE becomes true, and subsequently, the output parameter ACTIVE becomes true.

LOW_SEVERITY DINT Specifies the severity for the Low limit.

LOW_LOW_LIMIT DINT Specifies the Low Low alarm limit for the SOURCE.

When SOURCE is less than LOW_LOW_LIMIT, then LOW_LOW_ACTIVE becomes true, and subsequently, the output parameter ACTIVE becomes true.

LOW_LOW_SEVERITY DINT Specifies the severity for the Low Low limit.

SOURCE_ID DINT Reserved for future use.

Table 27 Output Parameters

Name Data Type Description

ACTIVE BOOL If true, an alarm is active. If false, there are no active alarms.

HIGH_HIGH_ACTIVE BOOL If true, a High High alarm is active.

HIGH_ACTIVE BOOL If true, a High alarm is active.

LOW_ACTIVE BOOL If true, a Low alarm is active.

LOW_LOW_ACTIVE BOOL If true, a Low Low alarm is active.

ACKNOWLEDGED BOOL If true, the active alarm has been acknowledged.

ACK_TIME DT The last time when an active alarm was acknowledged.

ACTIVE_TIME DT The last time the alarm was active.

INACTIVE_TIME DT The last time the alarm was inactive.

Table 26 Input Parameters (continued)

Name Data Type Description

Page 55: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

ALARM_ROC_REAL 43

TriStation 1131 Libraries Reference

Description

The ALARM_ROC_REAL function generates rate of change alarms for REAL tagnames.

Rate of change alarms are commonly used to report an unusual change or lack of change in a measured value, relative to the speed at which the value has changed. They typically relate to instruments (for example, a temperature meter). A rate of change alarm becomes active when the rate at which the value changes exceeds or drops below a defined limit.

The rate of change is measured in units of time (such as seconds, minutes, or hours). For example, a tank may have a High limit for the rate of change of its level (measured in meters) of 4 meters/minute. If the tank level changes at a rate greater than 4 meters/minute, then a High alarm is generated.

The input parameter SOURCE is the process value being measured.

The DEADBAND input parameter specifies the difference between the alarm limit and the input value that will cause an alarm to go inactive. For example, if a High alarm is set for 100, and the DEADBAND is set to 10, the alarm will go active at 100, and inactive at 90. If a Low alarm is set for 100, it will go active at 100, and inactive at 110.

The TIME_DELAY input parameter specifies how long before an alarm will go active once the alarm condition is detected. For example, if TIME_DELAY is configured as 5 seconds, and the High alarm is set for 100, once the value exceeds 100, ALARM_ROC_REAL will wait 5 seconds before generating the High alarm. Use of the TIME_DELAY parameter can help prevent nuisance alarms that may be generated due to process noise.

ExampleVAR My_RateOfChange_Alarm: ALARM_ROC_REAL; END_VARVAR My_BYPASS_REAL:BYPASS_REAL; END_VAR

VAR_EXTERNAL My_Tagname:REAL; Tagname2:BOOL; Tagname3:BOOL; Tagname4:BOOL; Tagname5:BOOL; Tagname6:BOOL;END_VAR

ALARM_STATE DINT The current alarm status. Possible values are:

• NORMAL (16#00000000)

• LOLO_LVL_ACTIVE (16#00000011)

• LOLO_LVL_ACKED (16#00000012)

• LO_LVL_ACTIVE (16#00000021)

• LO_LVL_ACKED (16#00000022)

• HI_LVL_ACTIVE (16#00000031)

• HI_LVL_ACKED (16#00000032)

• HIHI_LVL_ACTIVE (16#00000041)

• HIHI_LVL_ACKED (16#00000042)

• TRIP_ACTIVE (16#00000051)

• TRIP_ACKED (16#00000052)

• ALARM_RINGBACK (16#00000003)

• ALARM_DISABLED (16#00000004)

• ALARM_BYPASSED(16#000000XX)where XX can be any of the above alarm states

Table 27 Output Parameters (continued)

Name Data Type Description

Page 56: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

44 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

My_BYPASS_REAL(TAG_VALUE:=My_Tagname, BYPASS_VALUE:=55, BYPASS_REQ:=Tagname4);My_RateOfChange_Alarm (SOURCE:=My_BYPASS_REAL.value, BYPASS:=Tagname4, RATE_OF_CHANGE:=time#1m, ACK_REQUEST:=Tagname3, DISABLE_REQUEST:=Tagname4, AUTOMATIC_RESET:=Tagname5, MANUAL_RESET_REQUEST:=Tagname6, DEADBAND:=2, TIME_DELAY:=T#5ms, RINGBACK:=TRUE, HIGH_HIGH_LIMIT:=10, HIGH_HIGH_SEVERITY:=40, HIGH_LIMIT:=5, HIGH_SEVERITY:=300, LOW_LIMIT:=5, LOW_SEVERITY:=200, LOW_LOW_LIMIT:=10, LOW_LOW_SEVERITY:=100);

Runtime Errors

None.

Application Notes

Can be used in Safety or Control applications.

Library

Process Alarm Library (ALARMS)

This library was first released with TriStation 1131 v4.7.0, but can be used with all TriStation 1131 versions.

Page 57: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

ALARM_TRIP 45

TriStation 1131 Libraries Reference

ALARM_TRIPGenerates trip alarms for BOOL tagnames.

SyntaxMy_TripAlarm(SOURCE:=Tagname_1_TRIPByp.VALUE, BYPASS:=Tagname_1_TRIPByp.BYPASSED, ACK_REQUEST:=Tagname_3, DISABLE_REQUEST:=Tagname_5, AUTOMATIC_RESET:=Tagname_4, MANUAL_RESET_REQUEST:=Tagname_6, TIME_DELAY:=T#200ms, RINGBACK:=TRUE, SEVERITY:=200, NORMAL_STATE:=FALSE);

Table 28 Input Parameters

Name Data Type Description

SOURCE DINT Input value for which trip alarm will be generated. May be connected to a tagname, or to the output of BYPASS_BOOL.

BYPASS BOOL If true, the source has been bypassed with the BYPASS_VALUE (from the BYPASS_BOOL function block).

Note: SOURCE = BYPASS_VALUE only when you use the BYPASS_BOOL function block along with ALARM_TRIP. The output of BYPASS_BOOL (VALUE) should be connected to the SOURCE input of ALARM_TRIP. Additionally, BYPASS_REQ on BYPASS_BOOL should be true. Simply setting BYPASS to true will not bypass the alarm. You must use BYPASS_BOOL to bypass the value, while ALARM_TRIP’s BYPASS input also should be true so that you obtain the correct alarm status.

NORMAL_STATE BOOL Specifies the healthy state of a point. If the value of SOURCE changes its state, and the current state is not equal to NORMAL_STATE, then a trip alarm is generated.

ACK_REQUEST BOOL If true, acknowledge request is sent, requesting the operator to acknowledge the alarm generated by this function block.

DISABLE_REQUEST BOOL If true, alarms will not be generated (all alarms disabled).

AUTOMATIC_RESET BOOL If true, when the generated alarm returns to normal, it is acknowledged automatically.

MANUAL_RESET_REQUEST BOOL If true, the ringback alarm is reset.

RINGBACK BOOL If true, generates a ringback alarm when any previously generated alarm returns to normal.

TIME_DELAY TIME Specifies the time delay for an alarm to go active upon detection of an alarm condition.

SEVERITY DINT Specifies the severity for the alarm.

SOURCE_ID DINT Reserved for future use.

Page 58: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

46 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

Description

The ALARM_TRIP function generates a trip alarm when there is a mismatch between the current state and the normal state for a BOOL tagname.

Trip alarms are intended to represent an equipment trip condition. A trip alarm is generated when the monitored piece of equipment experiences an abnormal fault (such as a motor shutting down due to an overload condition).

The input parameter SOURCE is the process value being monitored. The input parameter NORMAL_STATE indicates which of the possible input values indicates the normal condition of the equipment being monitored. When the value of the tagname referenced by the SOURCE parameter is not equal to the value of NORMAL_STATE, then the trip alarm is generated.

The TIME_DELAY input parameter specifies how long before the trip alarm will go active once the alarm condition is detected. For example, if TIME_DELAY is configured as 5 seconds, and the NORMAL_STATE is set for True, once the state changes to False, ALARM_TRIP will wait 5 seconds before generating the trip alarm. Use of the TIME_DELAY parameter can help prevent nuisance alarms that may be generated due to process noise.

ExampleVAR My_TripAlarm:ALARM_TRIP ; END_VARVAR_EXTERNAL My_Tagname: BOOL ; END_VAR

MY_TripAlarm(SOURCE:=My_Tagname,BYPASS:=False(or any BOOL tag), ACK_REQUEST:=False(or any BOOL tag),DISABLE_REQUEST:=False(or any BOOL tag), AUTOMATIC_RESET:=false(or any BOOL tag),MANUAL_RESET_REQUEST:=true(or any BOOL tag), TIME_DELAY:=T#10ms(or any TIME tag), RINGBACK:=TRUE(or any BOOL tag), SEVERITY:=200(or any DINT tag),NORMAL_STATE:=FALSE);

Runtime Errors

None.

Table 29 Output Parameters

Name Data Type Description

ACTIVE BOOL If true, an alarm is active. If false, there are no active alarms.

ACKNOWLEDGED BOOL If true, the active alarm has been acknowledged.

ACK_TIME DT The last time when an active alarm was acknowledged.

ACTIVE_TIME DT The last time the alarm was active.

INACTIVE_TIME DT The last time the alarm was inactive.

ALARM_STATE DINT The current alarm status. Possible values are:

• NORMAL (16#00000000)

• TRIP_ACTIVE (16#00000051)

• TRIP_ACKED (16#00000052)

• ALARM_RINGBACK (16#00000003)

• ALARM_DISABLED (16#00000004)

• ALARM_BYPASSED(16#000000XX)where XX can be any of the above alarm states

Page 59: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

ALARM_TRIP 47

TriStation 1131 Libraries Reference

Application Notes

Can be used in Safety or Control applications.

Library

Process Alarm Library (ALARMS)

This library was first released with TriStation 1131 v4.7.0, but can be used with all TriStation 1131 versions.

Page 60: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

48 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

ANDPerforms a logical AND of two or more Boolean operands or a bitwise AND of two or more bit-strings.

Syntaxb := 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 30 Input Parameters

Name Data Type Description

b1...bn ANY_BIT Operands

Table 31 Return Value

Data Type Description

ANY_BIT b1 AND b2 AND ... AND bn

Table 32 Logical AND

b1 b2 b1 OR b2

FALSE FALSE FALSE

FALSE TRUE FALSE

TRUE FALSE FALSE

TRUE TRUE TRUE

Table 33 Bitwise AND

w1 w2 w1 AND w2

2#0011 2#0101 2#0001

Page 61: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

AND 49

TriStation 1131 Libraries Reference

Example

Using Boolean Operands

VAR b, b1:=TRUE, b2:=FALSE, b3:=TRUE : BOOL; END_VARb := 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_VARw1 := 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)

Page 62: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

50 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

AOUTConverts a real number to an analog output.

Syntaxk := 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.

ExampleVAR k : DINT; END_VARk := 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 34 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 35 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

Page 63: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

AOUT_BP12 51

TriStation 1131 Libraries Reference

AOUT_BP12Converts a real number to a 12-bit differential bipolar analog output.

Syntaxy := 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 36 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 37 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

MachineCount

EngineeringUnits

Page 64: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

52 Chapter 2 Functions and Data Types

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)

This function was added to the library in v1.32 of TCXLIB, first released with TriStation 1131 v4.3.

in y

-60.0 -4095

0.0 0

+60.0 +4095

Page 65: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

ARRAY32_BOOL 53

TriStation 1131 Libraries Reference

ARRAY32_BOOLStores an array of 32 Boolean values.

SyntaxARRAY32_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 38 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 39 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.

Page 66: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

54 Chapter 2 Functions and Data Types

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

Page 67: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

ARRAY32_DINT 55

TriStation 1131 Libraries Reference

ARRAY32_DINTStores an array of 32 integers.

SyntaxARRAY32_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 40 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 41 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.

Page 68: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

56 Chapter 2 Functions and Data Types

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

Page 69: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

ARRAY32_REAL 57

TriStation 1131 Libraries Reference

ARRAY32_REALStores an array of 32 real numbers.

SyntaxARRAY32_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 42 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 43 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.

Page 70: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

58 Chapter 2 Functions and Data Types

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

Page 71: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

ASIN 59

TriStation 1131 Libraries Reference

ASINCalculates the principal arc sine of a real number.

SyntaxY := 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.

ExampleVAR y : REAL; ND VARy := 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 44 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 45 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

Page 72: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

60 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

ATANCalculates the principal arc tangent of a real number.

SyntaxY := 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.

ExampleVAR y : REAL; END_VARy := 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 46 Input Parameters

Name Data Type Description

x ANY_REAL Any real number.

Table 47 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

Page 73: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

BLINK 61

TriStation 1131 Libraries Reference

BLINKGenerates a pulse output.

SyntaxBLINK(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_VARVAR BLINK_ALARM : BLINK; END_VARBLINK_ALARM(IN:=TRUE,RESET:=FALSE,T_ON:=t#1s,T_OFF:=t#500ms);INDICATOR := BLINK_ALARM.Q ;

Table 48 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 49 Output Parameters

Name Data Type Description

Q BOOL The output pulse.

Page 74: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

62 Chapter 2 Functions and Data Types

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)

Page 75: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

BLINK_I 63

TriStation 1131 Libraries Reference

BLINK_IGenerates a pulse output.

SyntaxBLINK_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_VARVAR BLINK_ALARM : BLINK_I; END_VARBLINK_ALARM(IN:=TRUE,RESET:=FALSE,T_ON:=t#1s,T_OFF:=t#500ms);INDICATOR := BLINK_ALARM.Q ;

Table 50 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 51 Output Parameters

Name Data Type Description

Q BOOL The output pulse.

Page 76: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

64 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.

• Can be used in CEM Cause, Effect, and Intersection cells.

Library

Triconex (TCXLIB)

Page 77: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

BLINK_R 65

TriStation 1131 Libraries Reference

BLINK_RGenerates a pulse output.

SyntaxBLINK_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_VARVAR BLINK_ALARM : BLINK_I; END_VARBLINK_ALARM(IN:=TRUE,RESET:=FALSE,T_ON:=t#1s,T_OFF:=t#500ms);INDICATOR := BLINK_ALARM.Q ;

Table 52 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 53 Output Parameters

Name Data Type Description

Q BOOL The output pulse.

Page 78: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

66 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.

• Can be used in CEM Cause, Effect, and Intersection cells.

Library

Triconex (TCXLIB)

Page 79: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

BOOL 67

TriStation 1131 Libraries Reference

BOOLA 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

Page 80: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

68 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

BOOL_TO_DWORDConverts a Boolean (BOOL) value to a DWORD value.

Syntaxw := 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.

ExampleVAR 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 54 Input Parameters

Name Data Type Description

b BOOL The Boolean value to be converted.

Table 55 Return Value

Name Data Type Description

DWORD DWORD The value of b converted to a DWORD value.

Page 81: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

BYPASS_BOOL 69

TriStation 1131 Libraries Reference

BYPASS_BOOLBypasses an alarm generated from a BOOL alarm function block.

SyntaxTagname_2_LvByp(TAG_VALUE:=Tagname_2, BYPASS_VALUE:=TRUE, BYPASS_REQ:=Tagname_4);

Description

The BYPASS_BOOL function can be used to bypass an alarm that is generated from a BOOL alarm function block (ALARM_TRIP).

If the input parameter BYPASS_REQ is true, the source value (TAG_VALUE) will be bypassed and the output parameter VALUE will have the same value as BYPASS_VALUE. The output parameter VALUE should be connected to the SOURCE input parameter of a BOOL alarm function block. Additionally, BYPASS_REQ should be true.

Simply setting the BOOL alarm function block’s BYPASS input to true will not bypass the alarm. You must use BYPASS_BOOL to bypass the value, while the BOOL alarm function block’s BYPASS input also should be true so that you obtain the correct alarm status.

ExampleVAR My_BYPASS_BOOL:BYPASS_BOOL; END_VARVAR My_Trip_Alarm: ALARM_TRIP; END_VAR

VAR_EXTERNAL My_SourceTagname: BOOL;My_BypassTagname: BOOL; END_VAR

My_BYPASS_BOOL(TAG_VALUE:=My_SourceTagname, BYPASS_VALUE:=TRUE, BYPASS_REQ:=My_BypassTagname);

My_Trip_Alarm (SOURCE:=My_BYPASS_BOOL.value, BYPASS:=My_BypassTagname,ACK_REQUEST:=False, DISABLE_REQUEST:=False, AUTOMATIC_RESET:=False, MANUAL_RESET_REQUEST:=True, TIME_DELAY:=T#10ms, RINGBACK:=FALSE, SEVERITY:=200, NORMAL_STATE:=True);

Table 56 Input Parameters

Name Data Type Description

BYPASS_REQ BOOL If true, the output VALUE is BYPASS_VALUE. If false, the output VALUE is TAG_VALUE.

BYPASS_VALUE BOOL The value to be bypassed if BYPASS_REQ is true.

TAG_VALUE BOOL The value of a BOOL tagname.

Table 57 Output Parameters

Name Data Type Description

VALUE BOOL The output value.

BYPASSED BOOL True if input BYPASS_REQ is true. Otherwise, false.

Page 82: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

70 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

Runtime Errors

None.

Application Notes

Can be used in Safety or Control applications.

Library

Process Alarm Library (ALARMS)

This library was initially released with TriStation 1131 v4.7.0, but can be used with all TriStation 1131 versions.

Page 83: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

BYPASS_DINT 71

TriStation 1131 Libraries Reference

BYPASS_DINTBypasses an alarm generated from a DINT alarm function block.

SyntaxTagname_2_LvByp(TAG_VALUE:=Tagname_2, BYPASS_VALUE:=55, BYPASS_REQ:=Tagname_4);

Description

The BYPASS_DINT function can be used to bypass an alarm that is generated from a DINT alarm function block (ALARM_LEVEL_DINT, ALARM_DEVIATION_DINT, or ALARM_ROC_DINT).

If the input parameter BYPASS_REQ is true, the source value (TAG_VALUE) will be bypassed and the output parameter VALUE will have the same value as BYPASS_VALUE. The output parameter VALUE should be connected to the SOURCE input parameter of a DINT alarm function block. Additionally, BYPASS_REQ should be true.

Simply setting the DINT alarm function block’s BYPASS input to true will not bypass the alarm. You must use BYPASS_DINT to bypass the value, while the DINT alarm function block’s BYPASS input also should be true so that you obtain the correct alarm status.

Example

The following example bypasses a deviation alarm SOURCE input with the configured bypass value (55) when BYPASS_REQ is True (Tagname4).

VAR My_Deviation_Alarm: ALARM_DEVIATION_DINT; END_VARVAR My_BYPASS_DINT:BYPASS_DINT; END_VAR

VAR_EXTERNAL My_Tagname: DINT; Tagname2:BOOL;Tagname3:BOOL; Tagname4:BOOL; Tagname5:BOOL;Tagname6:BOOL;END_VAR

My_BYPASS_DINT(TAG_VALUE:=My_Tagname, BYPASS_VALUE:=55, BYPASS_REQ:=Tagname4);

My_Deviation_Alarm (SOURCE:=My_BYPASS_DINT.value, BYPASS:=Tagname4,SETPOINT:=55, ACK_REQUEST:=Tagname3, DISABLE_REQUEST:=Tagname4,

Table 58 Input Parameters

Name Data Type Description

BYPASS_REQ BOOL If true, the output VALUE is BYPASS_VALUE. If false, the output VALUE is TAG_VALUE.

BYPASS_VALUE DINT The value to be bypassed if BYPASS_REQ is true.

TAG_VALUE DINT The value of a DINT tagname.

Table 59 Output Parameters

Name Data Type Description

VALUE DINT The output value.

BYPASSED BOOL True if input BYPASS_REQ is true. Otherwise, false.

Page 84: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

72 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

AUTOMATIC_RESET:=Tagname5, MANUAL_RESET_REQUEST:=Tagname6, DEADBAND:=2,TIME_DELAY:=T#5ms, RINGBACK:=TRUE, HIGH_HIGH_LIMIT:=10, HIGH_HIGH_SEVERITY:=400,HIGH_LIMIT:=5, HIGH_SEVERITY:=300, LOW_LIMIT:=5, LOW_SEVERITY:=200, LOW_LOW_LIMIT:=10, LOW_LOW_SEVERITY:=100);

Runtime Errors

None.

Application Notes

Can be used in Safety or Control applications.

Library

Process Alarm Library (ALARMS)

This library was initially released with TriStation 1131 v4.7.0, but can be used with all TriStation 1131 versions.

Page 85: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

BYPASS_REAL 73

TriStation 1131 Libraries Reference

BYPASS_REALBypasses an alarm generated from a REAL alarm function block.

SyntaxTagname_2_LvByp(TAG_VALUE:=Tagname_2, BYPASS_VALUE:=55.25, BYPASS_REQ:=Tagname_4);

Description

The BYPASS_REAL function can be used to bypass an alarm that is generated from a REAL alarm function block (ALARM_LEVEL_REAL, ALARM_DEVIATION_REAL, or ALARM_ROC_REAL).

If the input parameter BYPASS_REQ is true, the source value (TAG_VALUE) will be bypassed and the output parameter VALUE will have the same value as BYPASS_VALUE. The output parameter VALUE should be connected to the SOURCE input parameter of a REAL alarm function block. Additionally, BYPASS_REQ should be true.

Simply setting the REAL alarm function block’s BYPASS input to true will not bypass the alarm. You must use BYPASS_REAL to bypass the value, while the REAL alarm function block’s BYPASS input also should be true so that you obtain the correct alarm status.

Example

The following example bypasses a deviation alarm SOURCE input with the configured bypass value (55) when BYPASS_REQ is True (Tagname4).

VAR My_Deviation_Alarm: ALARM_DEVIATION_REAL; END_VARVAR My_BYPASS_REAL:BYPASS_REAL; END_VAR

VAR_EXTERNAL My_Tagname: REAL; Tagname2:BOOL;Tagname3:BOOL; Tagname4:BOOL; Tagname5:BOOL;Tagname6:BOOL;END_VAR

My_BYPASS_REAL(TAG_VALUE:=My_Tagname, BYPASS_VALUE:=55, BYPASS_REQ:=Tagname4);

My_Deviation_Alarm (SOURCE:=My_BYPASS_REAL.value, BYPASS:=Tagname4,SETPOINT:=55, ACK_REQUEST:=Tagname3, DISABLE_REQUEST:=Tagname4,

Table 60 Input Parameters

Name Data Type Description

BYPASS_REQ BOOL If true, the output VALUE is BYPASS_VALUE. If false, the output VALUE is TAG_VALUE.

BYPASS_VALUE REAL The value to be bypassed if BYPASS_REQ is true.

TAG_VALUE REAL The value of a REAL tagname.

Table 61 Output Parameters

Name Data Type Description

VALUE REAL The output value.

BYPASSED BOOL True if input BYPASS_REQ is true. Otherwise, false.

Page 86: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

74 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

AUTOMATIC_RESET:=Tagname5, MANUAL_RESET_REQUEST:=Tagname6, DEADBAND:=2,TIME_DELAY:=T#5ms, RINGBACK:=TRUE, HIGH_HIGH_LIMIT:=10, HIGH_HIGH_SEVERITY:=400,HIGH_LIMIT:=5, HIGH_SEVERITY:=300, LOW_LIMIT:=5, LOW_SEVERITY:=200, LOW_LOW_LIMIT:=10, LOW_LOW_SEVERITY:=100);

Runtime Errors

None.

Application Notes

Can be used in Safety or Control applications.

Library

Process Alarm Library (ALARMS)

This library was initially released with TriStation 1131 v4.7.0, but can be used with all TriStation 1131 versions.

Page 87: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

CEIL 75

TriStation 1131 Libraries Reference

CEILReturns the next higher integer.

Syntaxy := CEIL( x )

Description

The CEIL function returns the next higher integer greater than or equal to x.

ExampleVAR 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 62 Input Parameters

Name Data Type Description

x ANY_REAL The operand.

Table 63 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

Page 88: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

76 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

CHK_ERRChecks for runtime errors.

SyntaxCHK_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.

• A function can return an error number or Boolean value indicating success or failure or type of error. See the Return Value section for a function to see the error codes for that function.

• A function block can output an error number or Boolean value indicating success or failure or type of error. See the Output Parameters section for a function block to see the error codes for the function block.

• A function or operator can reset ENO to false, indicating a runtime error. ENO is the variable specified by IEC1131-3 for handling errors. In typical usage, a caller sets ENO to true before calling the function. If the function detects a runtime error, the function resets ENO to false.

Table 64 Input Parameters

Name Data Type Description

CI BOOL Enables CHK_ERR.

Table 65 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.

Page 89: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

CHK_ERR 77

TriStation 1131 Libraries Reference

After calling the function, the caller tests ENO. For example, the caller can continue normal operation if ENO is true, or handle the error if ENO is false. Note that the value of ENO is undefined after calling a function block. See the Runtime Errors section for a function to determine when the function resets ENO.

• A function, function block, or operator can set runtime error flags. The caller can use the CHK_ERR function block to read the runtime error flags. The caller can use the Triconex (TCXLIB) function block to reset the runtime error flags to false. The runtime error flags are automatically reset to false at the start of each scan. See the Runtime Errors section for a function to see which runtime error flags can be set by the function.

This table shows the runtime error flags and the effect on ENO for each runtime error condition.

Note When the ERROR flag is true, it indicates a design flaw in the application that should be corrected. For example, you should never have a divide by zero error because the program should check the divisor before doing the division. To find such errors, a good practice is to add a CHK_ERR function block at the end of the last program and set an alarm if the ERROR output is true.

Divide by zero is detected by the divide operator / , the MOD operator, the DIV function, and the MOD function when the divisor is zero.

Floating point overflow is detected by floating point arithmetic when the result is infinity, that is, when the result is out of range.

Floating point underflow is detected by the exponential operator ** , the EXP function, and the Standard (STDLIB) function. Underflow occurs when the result is very close to zero. Since underflow is not an error, an underflow condition does not set the ERROR flag and does not reset ENO to false.

Bad parameter is detected by library functions and user-defined functions when a parameter is not in the specified range. A user-defined function can use the ReportBadParam function to report a bad parameter error.

A type conversion error is detected by a conversion function ( like REAL_TO_DINT ) when the converted result is out-of-range.

A string length error is detected when a string is too long, that is, too many characters.

ConditionRuntime 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

Page 90: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

78 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

A subrange bound error is detected when a result is out-of-range, that is, not in the specified subrange. If the subrange data type feature is not implemented, then the RANGE flag is always false (reserved for future use).

An array index error is detected when an array index is out-of-bounds—the index bounds are specified in the declaration of each array. By default, if the ARRAYERR flag is true at the end of the last program, the control program traps and the main processors reset to the safe state. To avoid a trap, use the Triconex (TCXLIB) function block to clear the ARRAYERR flag at the end of the last program.

An internal error is an error in the implementation code, that is, not a user programming error. An example is an error in an interface between a compiler and a library, or between a library and an operation system. Such errors may occur during development of Triconex software, but should never occur in released software. In most recent releases, such errors result in a trap and reset the main processors to the safe state. In other words, the INTERNALERR flag is always false when a user program reads it.

The OTHER error flag is reserved for future use.

Example

For runtime error examples, see one of these sample projects:

• Exmodbus.pt2 (Tricon controllers)

• Tdmodbus.pt2 (Trident or Tri-GP controllers)

Note See Sample Projects on page 7 for information about where to find these projects on the PC where you installed TriStation 1131.

These examples, MY_FUNCTION and MY_PROGRAM, illustrate how to report a runtime error, how to stop execution using ENO, and how to read the runtime error flags using the CHK_ERR function block.

FUNCTION MY_FUNCTION : DINTVAR_INPUT k : DINT ;END_VARVAR unused : BOOL ;END_VAR MY_FUNCTION := 0 ; IF k < 0 THEN (* * The following statement * sets the ERROR flag to true, * sets the BADPARAM flag to true, * and resets ENO to false. *) unused := ReportBadParam(0) ; ELSE MY_FUNCTION := k ; END_IF ;END_FUNCTION

PROGRAM MY_PROGRAMVAR FLAGS : CHK_ERR ; n : DINT ;END_VAR

FLAGS() ;

Page 91: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

CHK_ERR 79

TriStation 1131 Libraries Reference

(* 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

None—CHK_ERR reads, but does not change, the runtime error flags.

Application Notes

• Can be used in Safety or Control applications.

• Space Saver: a single instance can be executed more than once per scan to reduce memory usage and increase performance. For directions, see Using a Space Saver Function Block on page 6.

Library

Triconex (TCXLIB)

Page 92: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

80 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

CLR_ERRClears the runtime errors read by the CHK_ERR function block.

SyntaxCLR_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_EXAMPLEVAR 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 66 Input Parameters

Name Data Type Description

CI BOOL Enables CHK_ERR.

Table 67 Output Parameters

Name Data Type Description

CO BOOL True if CLR_ERR executes successfully.

Page 93: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

CLR_ERR 81

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 6.

Library

Triconex (TCXLIB)

Page 94: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

82 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

CONCAT_DTConcatenates date and time-of-day values.

Syntaxdatetime := CONCAT_DT( d, t )

Description

The CONCAT_DT function concatenates a date with a time of day and returns a date-and-time value.

ExampleVAR d : DATE; t : TOD; datetime : DT; END_VARd := 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 68 Input Parameters

Name Data Type Description

d DATE The date.

t TOD The time of day.

Table 69 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

Page 95: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

COS 83

TriStation 1131 Libraries Reference

COSCalculates 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.

ExampleVAR y : REAL; END_VARy := 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 70 Input Parameters

Name Data Type Description

x ANY_REAL The angle in radians.

Table 71 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

Page 96: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

84 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

CSCHEDSchedules the execution of selected program logic after a specified number of scans.

SyntaxCSCHED( 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_VAREXEC_LOGIC(CI := TRUE, NSCANS := 100, NOFFSET := 500 );IF ( EXEC_LOGIC.Q = TRUE ) THEN (* execute these statements *)END_IF

Runtime Errors

None.

Table 72 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 73 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.

Page 97: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

CSCHED 85

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)

Page 98: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

86 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

CSCHED_ISchedules the execution of selected program logic after a specified number of scans.

SyntaxCSCHED_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_VAREXEC_LOGIC(CI := TRUE, NSCANS := 100, NOFFSET := 500 );IF ( EXEC_LOGIC.Q = TRUE ) THEN (* execute these statements *)END_IF

Runtime Errors

None.

Table 74 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 75 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.

Page 99: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

CSCHED_I 87

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)

Page 100: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

88 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

CSCHED_RSchedules 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_VAREXEC_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 76 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 77 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.

Page 101: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

CTD 89

TriStation 1131 Libraries Reference

CTDDown counter. Signals when a value reaches zero while counting down from a preset value (PV).

SyntaxCTD( 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 78 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 79 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.

Page 102: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

90 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)

Page 103: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

CTU 91

TriStation 1131 Libraries Reference

CTUUp counter. Signals when a count reaches a preset value (PV).

SyntaxCTU( 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 80 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 81 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.

Page 104: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

92 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)

Page 105: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

CTUD 93

TriStation 1131 Libraries Reference

CTUDUp-down counter. Signals when a count reaches either zero or a preset value (PV).

SyntaxCTUD( 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.

Table 82 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 83 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.

Page 106: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

94 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

Example

This example counts up from zero to 500. When 500 is reached, the counter counts back down to zero.

VAR COUNT : CTUD; COUNTUP, RESET : BOOL := TRUE; COUNTDN, BOOL := FALSE;END_VAR;COUNT( CU:=COUNTUP, CD:= COUNTDN, R:=RESET, LD:=FALSE, PV:=500 );RESET := FALSE;IF ( COUNT.QU = TRUE ) THEN COUNTUP := FALSE; COUNTDN := TRUE;ELSIF ( COUNT.QD = TRUE ) THEN COUNTUP := TRUE; COUNTDN := FALSE;END_IF

Runtime Errors

None.

Application Notes

• Can be used in Safety or Control applications.

• Only Once: each instance should be executed only once per scan, but does not need to be executed every scan.

• Can be used in CEM Cause and Effect cells.

• IEC 1131-3 specifies that the CTUD function block count up the number of rising-edge triggers detected at the CU input and count down the number of rising-edge triggers detected at the CD input. In the Triconex implementation, these inputs are not rising-edge triggers. The CU and CD inputs enable counting up and counting down.

Library

Standard (STDLIB)

Page 107: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

DATE 95

TriStation 1131 Libraries Reference

DATEA 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

Page 108: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

96 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

DINTA 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**31–1

Result if intermediate valuea 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 valuea 2**31–1 or V modulo 2**32

Page 109: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

DINT_TO_DWORD 97

TriStation 1131 Libraries Reference

DINT_TO_DWORDConverts a 32-bit integer to a DWORD value.

Syntaxw := 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.

ExampleVAR 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 84 Input Parameters

Name Data Type Description

k DINT The 32-bit integer to be converted.

Table 85 Return Value

Data Type Description

DWORD The value of k converted to a DWORD value.

Page 110: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

98 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

DINT_TO_INTConverts a 32-bit integer to a 16-bit integer.

Syntaxm := 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.

ExampleVAR 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 86 Input Parameters

Name Data Type Description

k DINT The 32-bit integer to be converted.

Table 87 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

Page 111: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

DINT_TO_LREAL 99

TriStation 1131 Libraries Reference

DINT_TO_LREALConverts a 32-bit integer to a 64-bit long real number.

Syntaxx := 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.

ExampleVAR 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 88 Input Parameters

Name Data Type Description

k DINT The 32-bit integer to be converted.

Table 89 Return Value

Data Type Description

LREAL The value of k converted to a 64-bit long real number.

Page 112: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

100 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

DINT_TO_REALConverts a 32-bit integer to a 32-bit real number.

Syntaxx := 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.

ExampleVAR 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 90 Input Parameters

Name Data Type Description

k DINT The 32-bit integer to be converted.

Table 91 Return Value

Data Type Description

REAL The value of k converted to a 32-bit real number.

Page 113: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

DIV 101

TriStation 1131 Libraries Reference

DIVDivides two numbers.

Syntaxz := 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_VARVARx = 100 / 10; (* result is 10 *)

Divide a Time by a Number

VAR t : TIME; END_VARt : = T#12d12h12m / 12; (* result is T#1d1h1m0s0.0ms *)

Function Block Diagram

Table 92 DIV Operations

OperationNumeratorData Type

DenominatorData Type

ResultData Type

Divide a number by a number. ANY_NUMa

a. The numerator, denominator and quotient must the same numerical data type.

ANY_NUM1 ANY_NUM

Divide a time by a number. TIME ANY_NUM TIME

Page 114: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

102 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

Page 115: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

DT 103

TriStation 1131 Libraries Reference

DTA 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

Page 116: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

104 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

DT_TO_DATEExtracts the date from a date and time value.

Syntaxd := 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_VARd := 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 93 Input Parameters

Name Data Type Description

dtm DT The date and time from which to extract the date.

Table 94 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

Page 117: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

DT_TO_TOD 105

TriStation 1131 Libraries Reference

DT_TO_TODExtracts the time of day from a date and time value.

Syntaxt := 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_VARt := 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 95 Input Parameters

Name Data Type Description

dtm DT The date and time from which to extract the time of day.

Table 96 Return Value

Data Type Description

TOD The time of day extracted from dtm.

Condition Return Value Error Flags

If dtm is out of range. Invalid time BADPARAM, ERROR

Page 118: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

106 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

DWORDA 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

Page 119: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

DWORD_TO_BOOL 107

TriStation 1131 Libraries Reference

DWORD_TO_BOOLConverts a DWORD value to a Boolean (BOOL) value.

Syntaxb := 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.

ExampleVAR b : BOOL; END_VARb := 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 97 Input Parameters

Name Data Type Description

IN DWORD The DWORD value to be converted.

Table 98 Return Value

Name Data Type Description

OUT BOOL The value of IN converted to a Boolean value.

Page 120: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

108 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

DWORD_TO_DINTConverts a DWORD value to a DINT value (32-bit signed integer).

Syntaxk := DWORD_TO_DINT(w)

Description

The DWORD_TO_DINT function converts a DWORD value to a DINT value (32-bit signed integer).

ExampleVAR k : DINT; END_VARk := 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 99 Parameter

Name Data Type Description

w DWORD The DWORD value to be converted.

Table 100 Return Value

Data Type Description

DINT The value of w converted to a 32-bit integer.

Page 121: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

EQ 109

TriStation 1131 Libraries Reference

EQCompares two operands for equality.

Syntaxb := 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_VARb := 10 = 11; (* result is FALSE *)b := 11 = 11; (* result is TRUE *)b := 'abcd' = 'abcd'; (* result is TRUE *)

Function Block Diagram

Runtime Errors

None.

Table 101 Input Parameters

Name Data Type Description

x ANY First operand.

y ANY Second operand.

Table 102 Return Value

Data Type Description

BOOL True if x is equal to y.

Page 122: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

110 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)

Page 123: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

EXP 111

TriStation 1131 Libraries Reference

EXPCalculates the natural exponential for a real number.

Syntaxx := 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.

ExampleVAR x : REAL; END_VARx := 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.

Table 103 Input Parameters

Name Data Type Description

y ANY_REAL The operand.

Table 104 Return Value

Data Type Description

ANY_REAL The natural exponential ey.

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

Page 124: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

112 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

Application Notes

Can be used in Safety or Control applications.

Library

Standard (STDLIB)

Page 125: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

EXPFLTR 113

TriStation 1131 Libraries Reference

EXPFLTRProvides an exponential filter to smooth a noisy input data value.

SyntaxMYFILTER(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_VARMYFILTERCI:=TRUE,RESET:=INITFLTR,INPUT:=RAWVALUE,FACTOR:=REAL#0.5,IOUTPUT:= REAL#2.0);FILTER_VALUE := MYFILTER.OUTPUT;

Table 105 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 to1.0.

IOUTPUT REAL The initial output value.

Table 106 Output Parameters

Name Data Type Description

CO BOOL True if EXPFLTR executes successfully.

OUTPUT REAL The smoothed output value.

Page 126: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

114 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.

• 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

Page 127: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

EXPT 115

TriStation 1131 Libraries Reference

EXPTRaises a value to a specified power.

Syntaxz := 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_VARz := 10.0 ** 2; (* result is 100.0 *)

Function Block Diagram

Table 107 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 108 Return Value

Data Type Description

ANY_REAL x to the y power, xy.

Page 128: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

116 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

Runtime Errors

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)

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

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

Page 129: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

F_TRIG 117

TriStation 1131 Libraries Reference

F_TRIGTriggers on the falling edge of the CLK input.

SyntaxF_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_VARVAR POWER_FAIL_COUNT : DINT; END_VARVAR 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 109 Input Parameters

Name Data Type Description

CLK BOOL The value being monitored.

Table 110 Output Parameters

Data Type Description

BOOL The detector output.

Page 130: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

118 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, Effect, and Intersection cells.

Library

Standard (STDLIB)

Page 131: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

FLOOR 119

TriStation 1131 Libraries Reference

FLOORTruncates a real number to an integer.

Syntaxy := 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.

ExampleVAR y : REAL; END_VARy := 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 111 Input Parameters

Name Data Type Description

x ANY_REAL The operand.

Table 112 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

Page 132: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

120 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

GASDETRProcesses analog inputs from a gas detector and generates alarms.

SyntaxMY_GASDETR(CI:=b1, INPUT:=n1, INHIBIT:=b2, RESET:=b3, OPFLIM:=n2, SHFLIM:=n3, CALBLIM:=n4, OVRFLIM:=n5, GDMAXAV:=n6, GDMINAV:=n7, GDMAXEU:=x1, GDMINEU:=x2, GHIALIM:=x3, GLOALIM:=x4 );y := MY_GASDETR.OUTPUT;

Table 113 Input Parameters

Name Data Type Description

CI BOOL Enables GASDETR.

INPUT DINT 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 114 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.

Page 133: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

GASDETR 121

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 114 Output Parameters (continued)

Name Data Type Description

Page 134: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

122 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.

Library

Standard (STDLIB)

Page 135: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

GATDIS 123

TriStation 1131 Libraries Reference

GATDISDisables remote writes to aliased variables in a Tricon controller.

Syntax

GATDIS(CI:=b)

Description

In a Tricon controller, the GATDIS function block disables remote writes for all ranges of read/write aliased variables that were previously enabled by Tricon (TX1LIB), thereby restricting write operations by external hosts. GATDIS must be executed after the Tricon (TX1LIB) function. For more information, see Tricon (TX1LIB) on page 123.

ExampleVAR GATE_IS_DISABLED : BOOL ; END_VARVAR DISABLED_GATE : GATDIS ; END_VARDISABLE_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 115 Input Parameters

Name Data Type Description

CI BOOL Enables GATDIS.

Table 116 Output Parameters

Name Data Type Description

CO BOOL True if GATDIS execute successfully.

Page 136: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

124 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

GATENBEnables remote writes to aliased variables in a Tricon controller.

SyntaxGATENB(CI:=b,DRWFRST:=k1,DRWLAST:=k2,IRWFRST:=k3,IRWLAST:=k4,RRWFRST:=k5,KRWLAST:=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 117 Input Parameters

Name Data Type Description

CI BOOL Enables GATENB.

DRWFRST DINT The starting alias number for memory discrete (BOOL) read/write range.

DRWLAST DINT The ending alias number for memory discrete (BOOL) read/write range.

IRWFRST DINT The starting alias number for memory integer (DINT) read/write range.

IRWLAST DINT The ending alias number for memory integer (DINT) read/write range.

RRWFRST DINT The starting alias number for memory real read/write range.

RRWLAST DINT The ending alias number for memory real read/write range.

Table 118 Output Parameters

Name Data Type Description

CO BOOL True if GATENB executes successfully.

Page 137: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

GATENB 125

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_VARENABLE_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

Page 138: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

126 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

GEDetermines if one operand is greater than or equal to another operand.

Syntaxb := 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 119 Input Parameters

Name Data Type Description

x ANY_ NOTE1 First operand.

y ANY_NOTE1 Second operand.

Table 120 Return Value

Data Type Description

BOOL True if x is greater than or equal to y.

Page 139: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

GE 127

TriStation 1131 Libraries Reference

Examples

Structured Text

VAR b : BOOL; END_VARb := 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)

Page 140: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

128 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

GetDelta_DINTReturns the scan period for the previous scan in milliseconds.

Syntaxt := 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.

ExampleVAR t : DINT ; END_VARt := GetDelta_DINT();(* Result is 100 if the measured scan period is 100 milliseconds. *)

Runtime Errors

None.

Table 121 Input Parameters

Name Data Type Description

None None None.

Table 122 Return Value

Data Type Description

DINT The scan period for the previous scan in milliseconds.

Page 141: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

GetDelta_DINT 129

TriStation 1131 Libraries Reference

Application Notes

Can be used in Safety or Control applications.

Library

Triconex (TCXLIB)

Page 142: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

130 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

GetDelta_REALReturns the scan period for the previous scan in seconds.

Syntaxt := 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.

ExampleVAR t : REAL ; END_VARt := GetDelta_REAL();(* Result is 0.1 if the measured scan period is 100 milliseconds. *)

Runtime Errors

None.

Table 123 Input Parameters

Name Data Type Description

None None None.

Table 124 Return Value

Data Type Description

REAL The scan period for the previous scan in seconds.

Page 143: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

GetDelta_REAL 131

TriStation 1131 Libraries Reference

Application Notes

Can be used in Safety or Control applications.

Library

Triconex (TCXLIB)

Page 144: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

132 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

GetDeltaTReturns the scan period for the previous scan.

Syntaxt := 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.

ExampleVAR t : TIME ; END_VARt := GetDeltaT();(* Result is T#100ms if the measured scan period is 100 milliseconds. *)

Runtime Errors

None.

Table 125 Input Parameters

Name Data Type Description

None None None.

Table 126 Return Value

Data Type Description

DINT The scan period for the previous scan.

Page 145: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

GetDeltaT 133

TriStation 1131 Libraries Reference

Application Notes

Can be used in Safety or Control applications.

Library

Triconex (TCXLIB)

Page 146: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

134 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

GetTimerReturns a date and time value that can be used to calculate the elapsed time between two events.

Syntaxdt := 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 127 Input Parameters

Name Data Type Description

None None None.

Table 128 Return Value

Data Type Description

DT The date and time.

Page 147: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

GetTimer 135

TriStation 1131 Libraries Reference

Application Notes

Can be used in Safety or Control applications.

Library

Standard (STDLIB)

Page 148: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

136 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

GTDetermines if two operands have a greater-than-or-equal-to relationship.

Syntaxb := 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 129 Input Parameters

Name Data Type Description

x ANY_ NOTE1 First operand.

y ANY_ NOTE1 Second operand.

Table 130 Return Value

Data Type Description

BOOL True if x is greater than y.

Page 149: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

GT 137

TriStation 1131 Libraries Reference

Example

Structured Text

VAR b : BOOL; END_VARb := 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)

Page 150: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

138 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

INFINITY_LREALReturns plus infinity.

Syntaxy := INFINITY_LREAL();

Description

The INFINITY_LREAL function returns plus infinity.

ExampleVAR 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 131 Input Parameters

Name Data Type Description

NA NA No inputs.

Table 132 Return Value

Data Type Description

LREAL Plus infinity.

Page 151: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

INFINITY_REAL 139

TriStation 1131 Libraries Reference

INFINITY_REALReturns plus infinity.

Syntaxy := INFINITY_REAL();

Description

The INFINITY_REAL function returns plus infinity.

ExampleVAR 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 133 Input Parameters

Name Data Type Description

NA NA No inputs.

Table 134 Return Value

Data Type Description

REAL Plus infinity.

Page 152: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

140 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

INTAn 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**15–1

Result if intermediate value is less than lower limit InvINT

Result if upper limit is less than intermediate value InvINT

Page 153: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

INT_TO_DINT 141

TriStation 1131 Libraries Reference

INT_TO_DINTConverts a 16-bit integer to a 32-bit integer.

Syntaxm := 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.

ExampleVAR 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 135 Input Parameters

Name Data Type Description

k INT The 16-bit integer to be converted.

Table 136 Return Value

Data Type Description

DINT The value of k converted to a 32-bit integer.

Page 154: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

142 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

INT_TO_LREALConverts a 16-bit integer to a 64-bit long real number.

Syntaxx := 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.

ExampleVAR 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 137 Input Parameters

Name Data Type Description

k INT The 16-bit integer to be converted.

Table 138 Return Value

Data Type Description

LREAL The value of k converted to a 64-bit long real number.

Page 155: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

INT_TO_REAL 143

TriStation 1131 Libraries Reference

INT_TO_REALConverts a 16-bit integer to a 32-bit real number.

Syntaxx := 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.

ExampleVAR 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 139 Input Parameters

Name Data Type Description

k INT The 16-bit integer to be converted.

Table 140 Return Value

Data Type Description

REAL The value of k converted to a 32-bit real number.

Page 156: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

144 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

INTGTORIntegrates the INPUT parameter, ignoring noise-level values less than or equal to MINLVL.

SyntaxMY_INTGTOR(CI:=b1, RESET:=b2, INPUT:=x1, MINLVL:=x2, GAIN:=x3, DELTAT := GetDeltaT(), IOUTPUT:=x4 );y := MY_INTGTOR.OUTPUT ;

Description

The INTGTOR function block integrates the INPUT parameter, ignoring noise-level values less than or equal to MINLVL. The result is OUTPUT.

CI is the control input. CI enables evaluation. If CI is false, then the integration step is not executed. See DELTAT herein for suggested scheduling alternatives. The default initial value of CI is true.

RESET initializes OUTPUT to the value of argument IOUTPUT. The default initial value is 0.0. If RESET and CI are both false, no operation occurs.

INPUT is the input value to be integrated.

MINLVL is a lower limit for the input value. If the input value is below this lower limit, then the integration step is skipped and the result OUTPUT does not change. The default lower limit is zero.

GAIN is a gain factor. The input value is multiplied by the gain factor.

DELTAT is the time between executions. To schedule execution using a CSCHED or TSCHED function block, connect the DELTAT input to the ACTUAL output of the CSCHED or TSCHED function block, and connect the CI input to the Q output of the CSCHED or TSCHED function block. To schedule execution every scan, connect the DELTAT input to the ouput of a Triconex (TCXLIB) function, and set CI=true.

IOUTPUT is an optional initial output value. If the RESET input is true, then the function block copies IOUTPUT to OUTPUT. The default initial value is zero.

Table 141 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 142 Output Parameters

Name Data Type Description

CO BOOL True if INTGTOR executes successfully.

OUTPUT REAL The integrated output value.

Page 157: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

INTGTOR 145

TriStation 1131 Libraries Reference

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) ;

ExampleVAR MY_INTGTOR : INTGTOR ; END_VARVAR y : REAL ; END_VARMY_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)

Page 158: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

146 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

INTGTOR_RIntegrates the INPUT parameter, ignoring noise-level values less than or equal to MINLVL.

SyntaxMY_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 143 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 144 Output Parameters

Name Data Type Description

CO BOOL True if INTGTOR_R executes successfully.

OUTPUT REAL Integrated output value.

Page 159: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

INTGTOR_R 147

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() ;

ExampleVAR MY_INTGTOR : INTGTOR_R ; END_VARVAR y : REAL ; END_VARMY_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)

Page 160: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

148 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

IsFinite_LREALReturns true if a number is finite.

Syntaxb := 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).

ExampleVAR 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 145 Input Parameters

Name Data Type Description

x LREAL A number

Table 146 Return Value

Data Type Description

BOOL True if x is finite.

Page 161: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

IsFinite_REAL 149

TriStation 1131 Libraries Reference

IsFinite_REALReturns true if a number is finite.

Syntaxb := 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).

ExampleVAR 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 147 Input Parameters

Name Data Type Description

x REAL A number

Table 148 Return Value

Data Type Description

BOOL True if x is finite.

Page 162: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

150 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

IsNan_LREALReturns true if the operand is not a number (NAN).

Syntaxb := 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.

ExampleVAR 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 149 Input Parameters

Name Data Type Description

x LREAL The operand

Table 150 Return Value

Data Type Description

BOOL True if x is not a number (NAN).

Page 163: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

IsNan_REAL 151

TriStation 1131 Libraries Reference

IsNan_REALReturns true if the operand is not a number (NAN).

Syntaxb := 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.

ExampleVAR 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 151 Input Parameters

Name Data Type Description

x REAL The operand

Table 152 Return Value

Data Type Description

BOOL True if x is not a number (NAN).

Page 164: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

152 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

LEDetermines if one operand is less than or equal to another operand.

Syntaxb := 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 153 Input Parameters

Name Data Type Description

x ANY_ NOTE1 First operand.

y ANY_ NOTE1 Second operand.

Table 154 Return Value

Data Type Description

BOOL True if x is less than or equal to y.

Page 165: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

LE 153

TriStation 1131 Libraries Reference

Example

Structured Text

VAR b : BOOL; END_VARb := 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)

Page 166: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

154 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

LEADLAGProvides 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 155 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 156 Output Parameters

Name Data Type Description

CO BOOL True if LEADLAG executes successfully.

OUT REAL The output value.

Page 167: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

LEADLAG 155

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)

Page 168: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

156 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

LEADLAG_RProvides 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 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.

Table 157 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 158 Output Parameters

Name Data Type Description

CO BOOL True if LEADLAG_R executes successfully.

OUT REAL The output value.

Page 169: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

LEADLAG_R 157

TriStation 1131 Libraries Reference

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)

Page 170: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

158 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

LIMITReturns a value between a minimum limit and a maximum limit.

Syntaxy := 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 159 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 160 Return Value

Data Type Description

ANY_NOTE1 The output value.

Page 171: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

LIMIT 159

TriStation 1131 Libraries Reference

ExampleVAR x, y : REAL ; END_VARx := 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)

Page 172: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

160 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

LINEMNTRMonitors an analog current loop.

Syntax

MY_LINEMNTR_R(CI:=b1, INPUT:=n1, LNOPLIM:=n2, LNSHLIM:=n3, LMONLIM:=n4 ) ;IS_ON := MY_LINEMNTR_R.OUTPUT ;IS_SHORTED := MY_LINEMNTR_R.LNSHORT ;IS_OPEN := MY_LINEMNTR_R.LNOPEN ;

Description

The LINEMNTR function block monitors an input from an analog current loop.

First, the function block compares the analog input value with the open-circuit fault limit. If the analog input value is less than or equal to the open-circuit fault limit, then there is not enough current flowing in the current loop, which means there is an open circuit fault, and the function block sets ouput LNOPEN=true.

If there is no open-circuit fault, then the function block compares the analog input value with the short-circuit fault limit. If the analog input value is greater than or equal to the short-circuit fault limit, then there is too much current flowing in the current loop, which means there is a short circuit fault, and the function block sets output LNSHORT=true.

If there is neither an open-circuit fault nor a short-circuit fault, then the function block compares the analog input value with the "contact input on" limit which is a current threshold that distinguishes data 0 from data 1. If the analog input value is greater than or equal to the "contact input on" limit, then the function block sets OUTPUT=1; otherwise, OUTPUT=0.

CI is the control input. CI enables evaluation. If CI is false, then there is no operation. The default initial value of CI is true.

INPUT is an analog input value that represents (for example, is proportional to) the monitored current.

Table 161 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 162 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.

Page 173: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

LINEMNTR 161

TriStation 1131 Libraries Reference

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.

ExampleVAR MY_LINEMNTR : LINEMNTR ; END_VARVAR IS_ON, IS_SHORTED, IS_OPEN : BOOL ; END_VARMY_LINEMNTR(

LNOPLIM:=819,LMONLIM:=2000,LNSHLIM:=4000,INPUT:=4010

);IS_OPEN := MY_LINEMNTR.LNOPEN; (* result is false *)IS_SHORTED := MY_LINEMNTR.LNSHORT; (* result is true *)IS_ON := MY_LINEMNTR.LNSHORT; (* result is false *)

Runtime Errors

None.

Application Notes

• Can be used in Safety or Control applications.

• Space Saver: a single instance can be executed more than once per scan to reduce memory usage and increase performance. For directions, see Using a Space Saver Function Block on page 6.

Library

Triconex (TCXLIB)

Page 174: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

162 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

LNCalculates the natural logarithm of a real number.

Syntaxy := LN( x );

Description

The LN function calculates the natural logarithm of a real number.

ExampleVAR y : REAL; END_VARy := 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 163 Input Parameters

Name Data Type Description

x ANY_REAL A real number.

Table 164 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

Page 175: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

LOG 163

TriStation 1131 Libraries Reference

LOGCalculates the common (base-ten) logarithm of a real number.

Syntaxy := LOG( x );

Description

The LOG function calculates the common (base-ten) logarithm of a real number.

ExampleVAR y : REAL; END_VARy := 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 165 Input Parameters

Name Data Type Description

x ANY_REAL A real number.

Table 166 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

Page 176: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

164 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

LOOPDETRProcesses an analog input from a detector or group of detectors in an analog current loop.

SyntaxMY_LOOPDETR(IN:=b1, INPUT:=n1, INHIBIT:=b2, RSTIN:=b3, OPFLIM:=n2, SHFLIM:=n3, TRALIM:=n4, HITRIP:=b4, RSTTIME:=t1, DELTAT:=t2);

Table 167 Input Parameters

Name Data Type Description

CI BOOL Enables LOOPDETR.

INPUT DINT 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 168 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.

Page 177: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

LOOPDETR 165

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 Triconex (TCXLIB)() function.

Note To schedule execution using a CSCHED or TSCHED function block, connect the DELTAT input to the ACTUAL output of a CSCHED or TSCHED function block.

Runtime Errors

None.

Application Notes

• Can be used in Safety or Control applications.

• Only Once: each instance should be executed only once per scan, but does not need to be executed every scan.

Library

Triconex (TCXLIB)

Page 178: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

166 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

LREALAn 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.2250738585072014E–308.

The smallest positive number that can be stored in an LREAL variable is:

2–1074 = 4.9406564584124654E–324.

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.

Page 179: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

LREAL 167

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.0E–308 17 digits

5.0E–309 16 digits

5.0E–310

.

.

.

5.0E–322

15 digits

.

.

.

3 digits

5.0E–323 2 digits

5.0E–324 1 digits

0.0 0 digits

RangeMaximum Absolute Error

Maximum Relative Error

0 < |x| 2–1075 |x| 1

2–1075 < |x| 2–1022 2–1075 2–1075 / |x|

2–1022 |x| < 21024 – 2972 2–53 * |x| 2–53

Page 180: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

168 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

LREAL_TO_DINTConverts a 64-bit long real number to a 32-bit integer.

Syntaxk := 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.

ExampleVAR 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.

Table 169 Input Parameters

Name Data Type Description

x LREAL The 64-bit number to be converted.

Table 170 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

Page 181: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

LREAL_TO_DINT 169

TriStation 1131 Libraries Reference

Application Notes

Can be used in Safety or Control applications.

Library

Standard (STDLIB)

Page 182: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

170 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

LREAL_TO_INTConverts a 64-bit long real number to a 16-bit integer.

Syntaxk := 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.

ExampleVAR 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.

Table 171 Input Parameters

Name Data Type Description

x LREAL The 64-bit long real number to be converted.

Table 172 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

Page 183: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

LREAL_TO_INT 171

TriStation 1131 Libraries Reference

Application Notes

Can be used in Safety or Control applications.

Library

Standard (STDLIB)

Page 184: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

172 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

LREAL_TO_REALConverts a 64-bit long real number to a 32-bit real number.

Syntaxy := 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.

ExampleVAR 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.

Table 173 Input Parameters

Name Data Type Description

x LREAL The 64-bit long real number to be converted.

Table 174 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

Page 185: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

LREAL_TO_REAL 173

TriStation 1131 Libraries Reference

Application Notes

Can be used in Safety or Control applications.

Library

Standard (STDLIB)

Page 186: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

174 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

LTDetermines if one operand is less than another operand.

Syntaxb := 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 175 Input Parameters

Name Data Type Description

x ANY_ NOTE1 First operand

y ANY_ NOTE1 Second operand

Table 176 Return Value

Data Type Description

BOOL True if x is less than y.

Page 187: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

LT 175

TriStation 1131 Libraries Reference

Example

Structured Text

VAR b : BOOL; END_VARb := 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)

Page 188: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

176 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

MAXFinds the maximum of the input values.

SyntaxM := 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 177 Input Parameters

Name Data Type Description

I1

.

.

.

In

ANY_ NOTE1

.

.

.

ANY_ NOTE1

Input value 1.

.

.

.

Input value n.

Table 178 Return Value

Data Type Description

ANY_NOTE1 The largest value of I1…In.

Page 189: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

MAX 177

TriStation 1131 Libraries Reference

ExampleVAR y : REAL ; END_VARy := 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)

Page 190: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

178 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

MBCTRLSets time-out and retry values for a Modbus master port.

SyntaxMY_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:

• Exmodbus.pt2 (Tricon controllers)

• Tdmodbus.pt2 (Trident or Tri-GP controllers)

Note See Sample Projects on page 7 for information about where to find these projects on the PC where you installed TriStation 1131.

Table 179 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 180 – 188) and MBWRITE functions (pages 191 – 198) for error codes.

RETRIES DINT The number of retries for a failed inquiry. The default is zero.

Table 180 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.

Page 191: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

MBCTRL 179

TriStation 1131 Libraries Reference

ExampleVAR MY_MBCTRL : MBCTRL ; END_VARVAR bInitialized : BOOL ; END_VAR(* * Increase the port 1 time-out to 4 seconds * and the number of retries to 3. *)MY_MBCTRL( CI:=not bInitialized, PORT:=1, TIME_OUT:=4, RETRIES:=3 ) ;bInitialized := true ;

Runtime Errors

See the description for the STATUS output for runtime error conditions and codes.

Upon detection of a runtime error condition, the function block returns the indicated values and sets the error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function block.

Application Notes

• Can be used in Safety or Control applications.

• Only Once: each instance should be executed only once per scan, but does not need to be executed every scan.

Library

• Tricon (TR1LIB/TX1LIB)

• Trident/Tri-GP (TRDLIB)

Condition Return Value Error Flag

If STATUS is greater than or equal to 100 CO=false None

Page 192: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

180 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

MBREAD_BOOLReads Boolean values from a Modbus slave.

SyntaxMY_MBREAD_BOOL(ACTIVE:=b1, ALIAS:=n1, N:=n2, PORT:=n3, STATION:=n4 );

Table 181 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 (1–19999).

N DINT The number of values to read from slave (1–32).

PORT DINT The port number.

STATION DINT The slave station address (1–247).

Table 182 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 slave’s response has a CRC error.

Page 193: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

MBREAD_BOOL 181

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:

• Exmodbus.pt2 (For Tricon controllers)

• Tdmodbus.pt2 (For Trident or Tri-GP controllers)

Note See Sample Projects on page 7 for information about where to find these projects on the PC where you installed TriStation 1131.

Runtime Errors

See the description for the STATUS output for runtime error conditions and codes. Upon detection of a runtime error condition, the function block returns the indicated values and sets the error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function block.

Application Notes

• Can be used in Safety or Control applications.

• Exactly Once: each instance should be executed exactly once per scan.

Library

• Tricon (TR1LIB/TX1LIB)

• Trident/Tri-GP (TRDLIB)

214 = Modbus slave’s response has an LRC error.

216 = Modbus slave’s response has a length error.

217 = Modbus slave’s 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 182 Output Parameters (continued)

Name Data Type Description

Page 194: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

182 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

MBREAD_DINTReads integers from a Modbus slave.

SyntaxMY_MBREAD_DINT(ACTIVE:=b1, ALIAS:=n1, N:=n2, PORT:=n3, STATION:=n4 );

Table 183 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 (30001–499999).

N DINT The number of values to read from slave (1–32).

PORT DINT The port number.

STATION DINT The slave station address (1–247).

Table 184 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 slave’s response has a CRC error.

214 = Modbus slave’s response has an LRC error.

217 = Modbus slave’s response function code does not match.

216 = Modbus slave’s response has a length error.

219 = Response not received in specified time-out period.

Page 195: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

MBREAD_DINT 183

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:

• Exmodbus.pt2 (For Tricon controllers)

• Tdmodbus.pt2 (For Trident or Tri-GP controllers)

Note See Sample Projects on page 7 for information about where to find these projects on the PC where you installed TriStation 1131.

Runtime Errors

See the description for the STATUS output for runtime error conditions and codes.

Upon detection of a runtime error condition, the function block returns the indicated values and sets the error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function block.

Application Notes

• Can be used in Safety or Control applications.

• Exactly Once: each instance should be executed exactly once per scan.

Library

• Tricon (TR1LIB/TX1LIB)

• Trident/Tri-GP (TRDLIB)

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 184 Output Parameters (continued)

Name Data Type Description

Page 196: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

184 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

MBREAD_REALReads real numbers from a Modbus slave.

The Modbus slave should be a Tricon controller. Use MBREAD_REAL_TRD if the Modbus slave is a Trident or Tri-GP controller, or a non-Triconex device.

SyntaxMY_MBREAD_REAL(ACTIVE:=b1, ALIAS:=n1, N:=n2, PORT:=n3, STATION:=n4, SPECIAL:=b2 );

Table 185 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:

• 32001–32120 = Input real, read only.

• 33001–34000 = Memory real, read only.

• 41001–42000 = Memory real, read/write.

If SPECIAL = true, then the starting alias is a special alias and must be an odd number. If the slave is a Tricon controller, the configured alias in the slave is mapped to two SPECIAL ALIASES.

SPECIAL ALIAS Ranges:

• 34001–34240 = Input real, read only.

• 44001–44240 = Input real, read only.

• 35001–37000 = Memory real, read only.

• 45001–47000 = Memory real, read only.

• 42001–44000 = Memory real, read/write.

N DINT The number of values to read from slave (1–25).

PORT DINT The port number.

STATION DINT The slave station address (1–247).

SPECIAL BOOL True if special aliases are used. For more information, see Description on page 185.

Table 186 Output Parameters

Name Data Type Description

IDLE BOOL 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 to100.

Page 197: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

MBREAD_REAL 185

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 MBWRITE_REAL_TRD if the Modbus slave is a Trident or Tri-GP controller, or a non-Triconex device.

On each scan, the sequence of Modbus function block calls must be the same, from the start of the first program to the end of the last program. A change detected in the sequence of Modbus function blocks causes error status 106.

Note The number of Modbus reads and writes per scan is limited.

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.

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 slave’s response has a CRC error.

214 = Modbus slave’s response has an LRC error.

216 = Modbus slave’s response has a length error.

217 = Modbus slave’s 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 186 Output Parameters (continued)

Name Data Type Description

Page 198: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

186 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

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:

• Exmodbus.pt2 (For Tricon controllers)

• Tdmodbus.pt2 (For Trident or Tri-GP controllers)

Note See Sample Projects on page 7 for information about where to find these projects on the PC where you installed TriStation 1131.

Alias Special Alias Description

32001 34001–34002 or 44001–44002 Input real, read only.

32001

.

.

32120

34003–34004 or 44003–44004

34239–34240 or 44239–44240

Input real, read only.

Input real, read only.

33001 35001–35002 or 45001–45002 Memory real, read only.

33002

.

.

34000

35003–35004 or 45003–45004

36999–37000 or 46999–47000

Memory real, read only.

Memory real, read only.

41001 42001–42002 Memory real, read/write.

41002

.

.

42000

42003–42004

43999–44000

Memory real, read/write.

Memory real, read/write.

Page 199: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

MBREAD_REAL 187

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/Tri-GP (TRDLIB)

Condition Return Value Error Flag

If STATUS is greater than or equal to 100 ERROR=true None

Page 200: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

188 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

MBREAD_REAL_TRDReads real numbers from a Modbus slave.

The Modbus slave should be a Trident or Tri-GP controller, or a non-Triconex device. Use MBREAD_REAL if the Modbus slave is a Tricon controller.

SyntaxMY_MBREAD_REAL_TRD(ACTIVE:=b1, ALIAS:=n1, N:=n2, PORT:=n3, STATION:=n4 );

Table 187 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 (30001–49998).

N DINT The number of values to read from slave (1–25).

PORT DINT The port number.

STATION DINT The slave station address (1–247).

Table 188 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.

Page 201: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

MBREAD_REAL_TRD 189

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 or Tri-GP controller, or a non-Triconex device. Use MBREAD_REAL if the Modbus slave is a Tricon controller.

The function block reads two 16-bit values from two consecutive aliases (ALIAS and ALIAS+1) and concatenates the two values to form the first 32-bit REAL value (D01). The 16 most significant bits are at ALIAS, and the 16 least significant bits are at ALIAS+1. For example, to read a REAL value from aliases 35003 and 35004, set ALIAS=35003, and N=1.

On each scan, the sequence of Modbus function block calls must be the same, from the start of the first program to the end of the last program. A change detected in the sequence of Modbus function blocks causes error status 106.

Note The number of Modbus reads and writes per scan is limited.

Example

For examples of using Modbus Read function blocks, see these sample projects:

• Exmodbus.pt2 (For Tricon controllers)

• Tdmodbus.pt2 (For Trident or Tri-GP controllers)

Note See Sample Projects on page 7 for information about where to find these projects on the PC where you installed TriStation 1131.

Runtime Errors

See the description for the STATUS output for runtime error conditions and codes.

Upon detection of a runtime error condition, the function block returns the indicated values and sets the error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function block.

213 = Modbus slave’s response has a CRC error.

214 = Modbus slave’s response has an LRC error.

216 = Modbus slave’s response has a length error.

217 = Modbus slave’s 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 188 Output Parameters (continued)

Name Data Type Description

Page 202: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

190 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

Application Notes

Can be used in Safety or Control applications.

Library

• Tricon (TR1LIB/TX1LIB)

• Trident/Tri-GP (TRDLIB)

Page 203: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

MBWRITE_BOOL 191

TriStation 1131 Libraries Reference

MBWRITE_BOOLWrites Boolean values to a Modbus slave.

SyntaxMY_MBWRITE_BOOL(ACTIVE:=b1, ALIAS:=n1, N:=n2, PORT:=n3, STATION:=n4, D01 := b2 );

Table 189 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 (1–9999).

N DINT The number of values to write (1–32).

PORT DINT The port number.

STATION DINT The slave station address (1–247).

D01

.

.

D32

BOOL

.

.

BOOL

Send data 01.

.

.

Send data 32.

Table 190 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.

202 = Modbus slave returned an Illegal Data Address response code

Page 204: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

192 Chapter 2 Functions and Data Types

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:

• Exmodbus.pt2 (For Tricon controllers)

• Tdmodbus.pt2 (For Trident or Tri-GP controllers)

Note See Sample Projects on page 7 for information about where to find these projects on the PC where you installed TriStation 1131.

Runtime Errors

See the description for the STATUS output for runtime error conditions and codes.

Upon detection of a runtime error condition, the function block returns the indicated values and sets the error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function block.

Application Notes

• Can be used in Safety or Control applications.

• Exactly Once: each instance should be executed exactly once per scan.

Library

• Tricon (TR1LIB/TX1LIB)

• Trident/Tri-GP (TRDLIB)

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 slave’s response has a CRC error.

214 = Modbus slave’s response has an LRC error.

216 = Modbus slave’s response has a length error.

217 = Modbus slave’s 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 190 Output Parameters (continued)

Name Data Type Description

Page 205: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

MBWRITE_DINT 193

TriStation 1131 Libraries Reference

MBWRITE_DINTWrites the least significant 16 bits of a DINT to a Modbus slave.

SyntaxMY_MBWRITE_DINT(ACTIVE:=b1, ALIAS:=n1, N:=n2, PORT:=n3, STATION:=n4, D01 := n5 );

Table 191 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 (40001–49999).

N DINT The number of values to write (1–32).

PORT DINT The port number.

STATION DINT The slave station address (1–247).

D01

.

.

.

D32

DINT

.

.

.

DINT

Send data 01.

.

.

.

Send data 32.

Table 192 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.

202 = Modbus slave returned an Illegal Data Address response code.

Page 206: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

194 Chapter 2 Functions and Data Types

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:

• Exmodbus.pt2 (For Tricon controllers)

• Tdmodbus.pt2 (For Trident or Tri-GP controllers)

Note See Sample Projects on page 7 for information about where to find these projects on the PC where you installed TriStation 1131.

Runtime Errors

See the description for the STATUS output for runtime error conditions and codes.

Upon detection of a runtime error condition, the function block returns the indicated values and sets the error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function block.

Application Notes

• Can be used in Safety or Control applications.

• Exactly Once: each instance should be executed exactly once per scan.

Library

• Tricon (TR1LIB/TX1LIB)

• Trident/Tri-GP (TRDLIB)

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 slave’s response has a CRC error.

214 = Modbus slave’s response has an LRC error.

216 = Modbus slave’s response has a length error.

217 = Modbus slave’s 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 192 Output Parameters (continued)

Name Data Type Description

Page 207: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

MBWRITE_REAL 195

TriStation 1131 Libraries Reference

MBWRITE_REALAllows a Triconex Modbus master controller to write real numbers to a Trident or Tri-GP Modbus slave controller, or to a non-Triconex device.

SyntaxMY_MBWRITE_REAL(ACTIVE:=b1, ALIAS:=n1, N:=n2, PORT:=n3, STATION:=n4, SPECIAL:=b2, D01:=x1 );

Table 193 Input Parameters

Name Data Type Description

ACTIVE BOOL Requests a Modbus write operation when the internal status equals 0 or 3.

ALIAS DINT The starting alias of the slave.

ALIAS Range:

41001–42000 = Memory real, read/write.

Special ALIAS Range:

42001–44000 = Memory real, read/write.

N DINT The number of values to write (1–25).

PORT DINT The Modbus master port number.

STATION DINT The slave station address (1–247).

SPECIAL BOOL True if special aliases are used. For more information, see Special Alias Mapping in Tricon Controller on page 197.

D01

.

.

.

D25

REAL

.

.

.

REAL

Send data 01.

.

.

.

Send data 25.

Table 194 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 to100.

Page 208: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

196 Chapter 2 Functions and Data Types

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 or Tri-GP controller, or a non-Triconex device.

On each scan, the sequence of Modbus function block calls must be the same, from the start of the first program to the end of the last program. A change detected in the sequence of Modbus function blocks causes error status 106.

Note The number of Modbus reads and writes per scan is limited.

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.

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

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 slave’s response has a CRC error.

214 = Modbus slave’s response has an LRC error.

216 = Modbus slave’s response has a length error.

217 = Modbus slave’s response function code does not match.

219 = Response not received in specified time-out period.

Table 194 Output Parameters (continued)

Name Data Type Description

Page 209: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

MBWRITE_REAL 197

TriStation 1131 Libraries Reference

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:

• Exmodbus.pt2 (For Tricon controllers)

• Tdmodbus.pt2 (For Trident or Tri-GP controllers)

Note See Sample Projects on page 7 for information about where to find these projects on the PC where you installed TriStation 1131.

Runtime Errors

See the description for the STATUS output for runtime error conditions and codes.

Upon detection of a runtime error condition, the function block returns the indicated values and sets the error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function block.

Application Notes

• Can be used in Safety or Control applications.

• Exactly Once: each instance should be executed exactly once per scan.

Library

• Tricon (TR1LIB/TX1LIB)

• Trident/Tri-GP (TRDLIB)

Alias Special Alias Description

41001 42001–42002 Memory real, read/write.

41002

.

.

.

42000

42003–42004

.

.

.

43999–4400

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

Page 210: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

198 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

MBWRITE_REAL_TRDWrites real numbers to a Modbus slave.

The Modbus slave should be a Trident or Tri-GP controller, or a non-Triconex device. Use MBWRITE_REAL if the Modbus slave is a Tricon controller.

SyntaxMY_MBWRITE_REAL_TRD(ACTIVE:=b1, ALIAS:=n1, N:=n2, PORT:=n3, STATION:=n4, D01:=x1 );

Table 195 Input Parameters

Name Data Type Description

ACTIVE BOOL Requests a Modbus write operation when the internal status equals 0 or 3.

ALIAS DINT The starting alias of the slave.

ALIAS Range: 30001–49998.

N DINT The number of values to write (1–25).

PORT DINT The port number.

STATION DINT The slave station address (1–247).

D01

.

.

.

D25

REAL

.

.

.

REAL

Send data 01.

.

.

.

Send data 25.

Table 196 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.

Page 211: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

MBWRITE_REAL_TRD 199

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 or Tri-GP controller, or a non-Triconex device. Use MBWRITE_REAL if the Modbus slave is a Tricon controller.

The function block splits the first 32-bit REAL value (D01) into two 16-bit values and writes the two 16-bit values to two consecutive aliases (ALIAS and ALIAS+1). The 16 most significant bits are at ALIAS, and the 16 least significant bits are at ALIAS+1. For example, to write a REAL value to aliases 42003 and 42004, set ALIAS=42003 and N=1.

On each scan, the sequence of Modbus function block calls must be the same, from the start of the first program to the end of the last program. A change detected in the sequence of Modbus function blocks causes error status 106.

Note The number of Modbus reads and writes per scan is limited.

Example

For examples of using Modbus Write function blocks, see these sample projects:

• Exmodbus.pt2 (For Tricon controllers)

• Tdmodbus.pt2 (For Trident or Tri-GP controllers)

Note See Sample Projects on page 7 for information about where to find these projects on the PC where you installed TriStation 1131.

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 slave’s response has a CRC error.

214 = Modbus slave’s response has an LRC error.

216 = Modbus slave’s response has a length error.

217 = Modbus slave’s response function code does not match.

219 = Response not received in specified time-out period.

Table 196 Output Parameters (continued)

Name Data Type Description

Page 212: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

200 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.

Library

• Tricon (TR1LIB/TX1LIB)

• Trident/Tri-GP (TRDLIB)

Condition Return Value Error Flag

If STATUS is greater than or equal to 100 ERROR=true None

Page 213: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

MEDSEL 201

TriStation 1131 Libraries Reference

MEDSELReturns the median of the input numbers.

Syntaxy := 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.

ExampleVAR y : REAL ; END_VARy := 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 197 Input Parameters

Name Data Type Description

x1

.

.

.

xn

ANY_REAL

.

.

.

ANY_REAL

Input value 1.

.

.

.

Input value n.

Table 198 Return Value

Data Type Description

ANY_REAL The median value of x1...xn.

Table 199 Runtime Errors

Condition Return Value Error Flags

If an input is not a number. NAN BADPARAM, ERROR

Page 214: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

202 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

Application Notes

Can be used in Safety or Control applications.

Library

Standard (STDLIB)

Page 215: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

MIN 203

TriStation 1131 Libraries Reference

MINFind the minimum of the input values.

SyntaxM := 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.

ExampleVAR m : DINT ; END_VARm := MIN( 3, 1, 2 ); (* Result is 1 *)

Table 200 Input Parameters

Name Data Type Description

I1

.

.

.

In

ANY_ NOTE1

.

.

.

ANY_ NOTE1

Input value 1.

.

.

.

Input value n.

Table 201 Return Value

Data Type Description

ANY_NOTE1 The smallest value of I1...In.

Page 216: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

204 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

Runtime Errors

None.

Application Notes

Can be used in Safety or Control applications.

Library

Standard (STDLIB)

Page 217: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

MINUS_INFINITY_LREAL 205

TriStation 1131 Libraries Reference

MINUS_INFINITY_LREALReturns minus infinity.

Syntaxy := MINUS_INFINITY_LREAL();

Description

The MINUS_INFINITY_LREAL function returns minus infinity.

ExampleVAR 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 202 Input Parameters

Name Data Type Description

NA NA No inputs.

Table 203 Return Value

Data Type Description

LREAL Minus infinity.

Page 218: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

206 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

MINUS_INFINITY_REALReturns minus infinity.

Syntaxy := MINUS_INFINITY_REAL();

Description

The MINUS_INFINITY_REAL function returns minus infinity.

ExampleVAR 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 204 Input Parameters

Name Data Type Description

NA NA No inputs.

Table 205 Return Value

Data Type Description

REAL Minus infinity.

Page 219: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

MOD 207

TriStation 1131 Libraries Reference

MODDivides two integers and returns the remainder.

Syntaxi := 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.

ExampleVAR i : DINT ; END_VARi := 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 206 Input Parameters

Name Data Type Description

j ANY_INT First operand.

k ANY_INT Second operand.

Table 207 Return Value

Data Type Description

ANY_INT The remainder.

Condition Return Value Error Flags

If the divisor is equal to 0. 0 DIVBYZERO, ERROR

Page 220: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

208 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

MOVEAssigns an input value to an output value.

SyntaxOUT := 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.

ExampleVAR OUT : DINT ; END_VAROUT := 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 208 Input Parameters

Name Data Type Description

IN ANY The input value.

Table 209 Return Value

Data Type Description

ANY The value of IN.

Page 221: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

MUL 209

TriStation 1131 Libraries Reference

MULMultiplies two or more numbers, or multiplies a time by a number.

SyntaxP := 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 210 Input Parameters

Name Data Type Description

I1

.

.

.

In

ANY_NUM

.

.

.

ANY_NUM

First operand.

.

.

.

Last operand.

Table 211 Return Value

Data Type Description

ANY_NUM The product.

Table 212 Input Parameters

Name Type Description

T1 TIME The time.

N ANY_NUM A number.

Table 213 Return Value

Data Type Description

TIME Product.

Page 222: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

210 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

Example

Calculate the product of three numbers

VAR p : DINT; END_VARp := 2 * 3 * 4 ; (* result is 24 *)

Multiply time by a number

VAR t : TIME; END_VARt := 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

Page 223: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

MUX 211

TriStation 1131 Libraries Reference

MUXSelects a value from multiple inputs.

Syntaxv := MUX( K, I0, I1, ..., In-1 ) ;

Description

The MUX function selects a value from multiple inputs, depending on an input selector (K).

The maximum number of data values is 49.

Normally, the value of K should be from 0 to n-1, where n is the number of data inputs. In this case, the function returns IK. If K is less than 0, the function returns I0. If K is greater than n-1, the function returns In-1.

The data values can be any data type, but all data values must have the same data type as the return value.

ExampleVAR v : REAL ; END_VARv := 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 214 Input Parameters

Name Data Type Description

K ANY_INT The selector.

I0

..

.

.

In-1

ANY

.

.

.

ANY

Data value 0.

.

.

.

Data value n-1.

Table 215 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 (n–1)]. Input I0 BADPARAM, ERROR

If K is greater than the index number of the last input. Last input In-1 BADPARAM, ERROR

Page 224: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

212 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

Application Notes

Can be used in Safety or Control applications.

Library

Standard (STDLIB)

Page 225: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

NAN_LREAL 213

TriStation 1131 Libraries Reference

NAN_LREALReturns not a number (NAN).

Syntaxy := NAN_LREAL();

Description

The NAN_LREAL function returns not a number (NAN).

ExampleVAR 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 216 Input Parameters

Name Data Type Description

NA NA No inputs.

Table 217 Return Value

Data Type Description

LREAL Not a number (NAN).

Page 226: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

214 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

NAN_REALReturns not a number (NAN).

Syntaxy := NAN_REAL();

Description

The NAN_REAL function returns not a number (NAN).

ExampleVAR 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 218 Input Parameters

Name Data Type Description

NA NA No inputs.

Table 219 Return Value

Data Type Description

REAL Not a number (NAN).

Page 227: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

NE 215

TriStation 1131 Libraries Reference

NECompares two operands for inequality.

Syntaxb := 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_VARb := 10 <> 11; (* result is TRUE *)b := 11 <> 11; (* result is FALSE *)b := 'abcd' <> 'abcd'; (* result is FALSE *)

Function Block Diagram

Runtime Errors

None.

Table 220 Input Parameters

Name Data Type Description

x ANY First operand

y ANY Second operand

Table 221 Return Value

Data Type Description

BOOL True if x is not equal to y.

Page 228: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

216 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)

Page 229: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

NOT 217

TriStation 1131 Libraries Reference

NOTPerforms a logical negation of a Boolean operand or a bitwise complement of a bit-string.

Syntaxv := 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 222 Input Parameters

Name Data Type Description

b ANY_BIT Operand

Table 223 Return Value

Data Type Description

ANY_BIT NOT b

Table 224 logical NOT

b NOT b

FALSE TRUE

TRUE FALSE

Table 225 bitwise complement

Bit Complement

0 1

1 0

Page 230: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

218 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

Example

Using Boolean Operands

VAR b, b1:=TRUE, b2:=FALSE : BOOL; END_VARb := NOT b1; (* result is FALSE *)b := NOT b2; (* result is TRUE *)

Using Bit-String Operands

VAR w, w1 : DWORD; END_VARw1 := 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)

Page 231: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

NUMBITS 219

TriStation 1131 Libraries Reference

NUMBITSCounts the number of Boolean parameters with value true.

Syntaxn := 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.

Examplen := 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 226 Input Parameters

Name Data Type Description

b1...bn BOOL Boolean parameters

Table 227 Return Value

Data Type Description

DINT Number of true parameters.

Page 232: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

220 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

NUMBITS_DWORDCounts the number of 1-bits in a DWORD.

Syntaxn := NUMBITS_DWORD( w ) ;

Description

The NUMBITS_DWORD function counts the number of 1-bits in a DWORD.

ExampleVAR n : DINT ; w : DWORD ; END_VARw := 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 228 Input Parameters

Name Data Type Description

w DWORD A bit-string

Table 229 Return Value

Data Type Description

DINT The number of 1-bits in w.

Page 233: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

OR 221

TriStation 1131 Libraries Reference

ORPerforms a logical OR of two or more Boolean operands or a bitwise OR of two or more bit-strings.

Syntaxb := 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 230 Input Parameters

Name Data Type Description

b1...bn ANY_BIT Operands

Table 231 Return Value

Data Type Description

ANY_BIT b1 OR b2 OR ... OR bn

Table 232 logical OR

b1 b2 b1 OR b2

FALSE FALSE FALSE

FALSE TRUE TRUE

TRUE FALSE TRUE

TRUE TRUE TRUE

Table 233 bitwise OR

w1 w2 w1 OR w2

2#0011 2#0101 2#0111

Page 234: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

222 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

Example

Using Boolean Operands

VAR b, b1:=FALSE, b2:=FALSE, b3:=TRUE : BOOL; END_VARb := 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_VARw1 := 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)

Page 235: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

OVDDISABLE 223

TriStation 1131 Libraries Reference

OVDDISABLEDisables output voter diagnostics (OVD) for a selected Digital Output (DO) Module.

SyntaxMY_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.

ExampleVAR MY_OVDDISABLE : OVDDISABLE ; END_VAR(* Disable OVD for the module in chassis 9 slot 5. *)MY_OVDDISABLE( CI:=true, CHASSIS:=9, SLOT:=5 ) ;

Runtime Errors

Upon detection of a runtime error condition, the function block returns the indicated values and sets the error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function block.

Application Notes

• Can be used in Safety or Control applications.

• Space Saver: a single instance can be executed more than once per scan to reduce memory usage and increase performance. For directions, see Using a Space Saver Function Block on page 6.

Library

Tricon (TR1LIB/TX1LIB)

Table 234 Input Parameters

Name Data Type Description

CI BOOL Enables OVDDISABLE.

CHASSIS DINT The chassis number (1–15).

SLOT DINT The physical slot number.

Table 235 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

Page 236: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

224 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

OVDENABLEEnables output voter diagnostics (OVD) for a selected Digital Output (DO) Module.

SyntaxMY_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.

ExampleVAR MY_OVDENABLE : OVDENABLE ; END_VAR(* Enable OVD for the module in chassis 9 slot 5. *)MY_OVDENABLE( CI:=true, CHASSIS:=9, SLOT:=5 ) ;

Runtime Errors

Upon detection of a runtime error condition, the function block returns the indicated values and sets the error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function block.

Application Notes

• Can be used in Safety or Control applications.

• Space Saver: a single instance can be executed more than once per scan to reduce memory usage and increase performance. For directions, see Using a Space Saver Function Block on page 6.

Library

Tricon (TR1LIB/TX1LIB)

Table 236 Input Parameters

Name Data Type Description

CI BOOL Enables OVDENABLE.

CHASSIS DINT The chassis number (1–15).

SLOT DINT The physical slot number.

Table 237 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

Page 237: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

PACK16 225

TriStation 1131 Libraries Reference

PACK16Packs 16 bits into a DWORD.

Syntaxw := 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.

Examplew := 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 238 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 239 Return Value

Data Type Description

DWORD The packed result

Page 238: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

226 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

PACK32Packs 32 bits into a DWORD.

Syntaxw := 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.

Examplew := 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 240 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 241 Return Value

Data Type Description

DWORD The packed result

Page 239: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

PAGE_EJECT 227

TriStation 1131 Libraries Reference

PAGE_EJECTEjects paper (feeds the form) to the top of the next page.

SyntaxMY_PAGE_EJECT( CI:=b1, PRINTER:=n1 ) ;

Description

The PAGE_EJECT function block ejects paper (feeds the form) to the top of the next page.

CI is the control input. CI enables evaluation. If CI is true, then perform the print operation. If CI is false, then do nothing. The default initial value of CI is true.

PRINTER is a number that identifies the printer or print server. The valid range is different for different controllers. For the Tricon controller, all values are valid—however, the function block prints to port 5 if PRINTER=5, but prints to port 10 if PRINTER is any other number. For the Trident or Tri-GP controller, the valid range is 1 through 10.

CO is the control ouput. CO follows CI if no runtime error is detected. CO=true indicates that the function block was enabled and executed successfully, with no runtime error. CO=false and CI=true indicates a runtime error was detected. CO=false and CI=false indicates no operation.

ExampleVAR 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 242 Input Parameters

Name Data Type Description

CI BOOL Enables PAGE_EJECT.

PRINTER DINT Printer number.

Table 243 Output Parameters

Name Data Type Description

CO BOOL True if PAGE_EJECT executes successfully.

Condition Return Value Error Flags

If PRINTER is invalid. CO=false BADPARAM, ERROR

Page 240: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

228 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 6.

Library

• Tricon (TR1LIB/TX1LIB)

• Trident/Tri-GP (TRDLIB)

Page 241: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

PERDEV 229

TriStation 1131 Libraries Reference

PERDEVComputes percent deviation.

Syntaxb := 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.

ExampleVAR b: BOOL ; END_VARb := 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 244 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 245 Return Value

Data Type Description

BOOL True if measured ratio less than or equal toFRACTION.

Page 242: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

230 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

PIDPerforms the proportional integral derivative (PID) algorithm.

SyntaxMY_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 246 VAR_IN_OUT Parameters

Name Data Type Description

SP REAL The set point.

CV REAL The control variable.

Table 247 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 248 Output Parameters

Name Data Type Description

CO BOOL True if PID executes successfully.

Page 243: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

PID 231

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)

Page 244: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

232 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

PID_RPerforms the proportional integral derivative (PID) algorithm.

SyntaxMY_PID_R( SPIN:=x1, CVIN:=x2, CI:=b1, PV:=x3, AUTO_MAN:=b2, RATE:=x4, RESET:=x5, KPB:=x6, MAXCV:=x7, MINCV:=x8, MAXRATE:=x9, DLT:=x10 ) ;x1 := MY_PID_R.SPOUT ;x2 := MY_PID_R.CVOUT ;

Description

The PID_R function block performs the proportional integral derivative (PID) algorithm. PID provides for anti-reset windup, bumpless transfer, and limitation of the maximum rate of change for the control variable. Bumpless transfer is handled in the setpoint-tracking form.

Neither the SP nor the PV argument is limited in its dynamic range. To impose limitations, use the LIMIT function prior to calling PID. The control variable CV is typically scaled to range from 0 to 100 percent. KPB represents the proportional gain. For direct-acting control, PID is programmed for KPB to be positive (that is, increasing the control variable causes an increasing process variable).

For reverse-acting control (increasing the control variable causes a decreasing process variable), KPB should be negative. You should determine the value of KPB by making control changes and observing

Table 249 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 250 Output Parameters

Name Data Type Description

CO BOOL True if PID_R executes successfully.

SPOUT REAL Set point out.

CVOUT REAL Control variable out.

Page 245: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

PID_R 233

TriStation 1131 Libraries Reference

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)

Page 246: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

234 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

POLY4Returns the value of a polynomial with four coefficients.

Syntaxy := 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).

ExampleVAR x, y, c0, c1, c2, c3 : LREAL ; END_VARx := 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 251 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 252 Return Value

Data Type Description

LREAL The returned value (C0 + C1*X + C2*X*X + C3*X*X*X).

Page 247: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

POLY5 235

TriStation 1131 Libraries Reference

POLY5Returns the value of a polynomial with five coefficients.

Syntaxy := 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).

ExampleVAR x, y, c0, c1, c2, c3, c4 : LREAL ; END_VARx := 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 253 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 254 Return Value

Data Type Description

LREAL The returned value (C0 + C1*X + C2*X*X + C3*X*X*X + C4*X*X*X*X).

Page 248: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

236 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

PRINT_BOOLPrints a three-character field containing either Off or On.

SyntaxMY_PRINT_BOOL( CI:=b1, PRINTER:=n1, IN:=b2 ) ;

Description

The PRINT_BOOL function block prints a three-character field containing either Off or On. (On is left-justified in the field.) Prints Off if IN is false or 0. Prints On if IN is true or 1. When printed, each argument is preceded by a blank space.

CI is the control input. CI enables evaluation. If CI is true, then perform the print operation. If CI is false, then do nothing. The default initial value of CI is true.

PRINTER is a number that identifies the printer or print server. The valid range is different for different controllers.

• For the Tricon controller, all values are valid, however, the function block prints to port 10 if PRINTER=10, but prints to port 5 if PRINTER is any other number.

• For the Trident v1.x controller, the valid range is 1 through 10.

• For the Trident v2.x or Tri-GP controller, the PRINTER parameter must be 5 or 10. The Left and Right CM ports cannot have the same PRINTER parameter.

IN is the Boolean value to be printed. If IN=false, then print "Off". If IN=true, then print "On ".

CO is the control ouput. CO follows CI if no runtime error is detected. CO=true indicates that the function block was enabled and executed successfully, with no runtime error. CO=false and CI=true indicates a runtime error was detected. CO=false and CI=false indicates no operation.

ExampleVAR MY_PRINT_BOOL : PRINT_BOOL ; END_VAR(* Print "Off" on printer 5. *)MY_PRINT_BOOL( PRINTER:=5, IN:=FALSE ) ;

Table 255 Input Parameters

Name Data Type Description

CI BOOL Enables PRINT_BOOL.

PRINTER DINT Printer number.

IN BOOL The value to be printed.

Table 256 Output Parameters

Name Data Type Description

CO BOOL True if PRINT_BOOL executes successfully.

Page 249: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

PRINT_BOOL 237

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 6.

Library

• Tricon (TR1LIB/TX1LIB)

• Trident/Tri-GP (TRDLIB)

Condition Return Value Error Flags

If PRINTER is invalid. CO=false BADPARAM, ERROR

Page 250: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

238 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

PRINT_CDTPrints the current date and time of day.

SyntaxMY_PRINT_CDT( CI:=b1, PRINTER:=n1 ) ;

Description

The PRINT_CDT function block prints the current date and time of day in this format:

mm/dd/yy hh:mm:ss.msec

When printed, each argument is preceded by a blank space.

CI is the control input. CI enables evaluation. If CI is true, then perform the print operation. If CI is false, then do nothing. The default initial value of CI is true.

PRINTER is a number that identifies the printer or print server. The valid range is different for different controllers.

• For the Tricon controller, all values are valid, however, the function block prints to port 10 if PRINTER=10, but prints to port 5 if PRINTER is any other number.

• For the Trident v1.x controller, the valid range is 1 through 10.

• For the Trident v2.x or Tri-GP controller, the PRINTER parameter must be 5 or 10. The Left and Right CM ports cannot have the same PRINTER parameter.

CO is the control ouput. CO follows CI if no runtime error is detected. CO=true indicates that the function block was enabled and executed successfully, with no runtime error. CO=false and CI=true indicates a runtime error was detected. CO=false and CI=false indicates no operation.

ExampleVAR MY_PRINT_CDT : PRINT_CDT ; END_VAR(* Print current date and time on printer 5. *)MY_PRINT_CDT( PRINTER:=5 ) ;

Table 257 Input Parameters

Name Data Type Description

CI BOOL Enables PRINT_CDT.

PRINTER DINT Printer number.

Table 258 Output Parameters

Name Data Type Description

CO BOOL True if PRINT_CDT executes successfully.

Page 251: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

PRINT_CDT 239

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 6.

Library

• Tricon (TR1LIB/TX1LIB)

• Trident/Tri-GP (TRDLIB)

Condition Return Value Error FlagS

If PRINTER is invalid. CO=false BADPARAM, ERROR

Page 252: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

240 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

PRINT_CRLFPrints a new line (a carriage return and line feed).

SyntaxMY_PRINT_CRLF( CI:=b1, PRINTER:=n1 ) ;

Description

The PRINT_CRLF function block prints a new line (a carriage return and line feed).

CI is the control input. CI enables evaluation. If CI is true, then perform the print operation. If CI is false, then do nothing. The default initial value of CI is true.

PRINTER is a number that identifies the printer or print server. The valid range is different for different controllers.

• For the Tricon controller, all values are valid, however, the function block prints to port 10 if PRINTER=10, but prints to port 5 if PRINTER is any other number.

• For the Trident v1.x controller, the valid range is 1 through 10.

• For the Trident v2.x or Tri-GP controller, the PRINTER parameter must be 5 or 10. The Left and Right CM ports cannot have the same PRINTER parameter.

CO is the control ouput. CO follows CI if no runtime error is detected. CO=true indicates that the function block was enabled and executed successfully, with no runtime error. CO=false and CI=true indicates a runtime error was detected. CO=false and CI=false indicates no operation.

ExampleVAR MY_PRINT_CRLF : PRINT_CRLF ; END_VAR(* Print a carriage return and line feed on printer 5. *)MY_PRINT_CRLF( PRINTER:=5 ) ;

Table 259 Input Parameters

Name Data Type Description

CI BOOL Enables PRINT_CRLF.

PRINTER DINT Printer number.

Table 260 Output Parameters

Name Data Type Description

CO BOOL True if PRINT_CRLF executes successfully.

Page 253: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

PRINT_CRLF 241

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 6.

Library

• Tricon (TR1LIB/TX1LIB)

• Trident/Tri-GP (TRDLIB)

Condition Return Value Error Flags

If PRINTER is invalid. CO=false BADPARAM, ERROR

Page 254: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

242 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

PRINT_CTODPrints the current time of day.

SyntaxMY_PRINT_CTOD( CI:=b1, PRINTER:=n1 ) ;

Description

The PRINT_CTOD function block prints the current time of day in this format:

hh:mm:ss.msec

When printed, each argument is preceded by a blank space.

CI is the control input. CI enables evaluation. If CI is true, then perform the print operation. If CI is false, then do nothing. The default initial value of CI is true.

PRINTER is a number that identifies the printer or print server. The valid range is different for different controllers.

• For the Tricon controller, all values are valid, however, the function block prints to port 10 if PRINTER=10, but prints to port 5 if PRINTER is any other number.

• For the Trident v1.x controller, the valid range is 1 through 10.

• For the Trident v2.x or Tri-GP controller, the PRINTER parameter must be 5 or 10. The Left and Right CM ports cannot have the same PRINTER parameter.

CO is the control ouput. CO follows CI if no runtime error is detected. CO=true indicates that the function block was enabled and executed successfully, with no runtime error. CO=false and CI=true indicates a runtime error was detected. CO=false and CI=false indicates no operation.

ExampleVAR MY_PRINT_CTOD : PRINT_CTOD ; END_VAR(* Print the current time of day on printer 5. *)MY_PRINT_CTOD( PRINTER:=5 ) ;

Table 261 Input Parameters

Name Data Type Description

CI BOOL Enables PRINT_CTOD.

PRINTER DINT Printer number.

Table 262 Output Parameters

Name Data Type Description

CO BOOL True if PRINT_CTOD executes successfully.

Page 255: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

PRINT_CTOD 243

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 6.

Library

• Tricon (TR1LIB/TX1LIB)

• Trident/Tri-GP (TRDLIB)

Condition Return Value Error Flag

If PRINTER is invalid. CO=false BADPARAM, ERROR

Page 256: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

244 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

PRINT_DINTPrints a double integer right-justified in an eight-character field.

SyntaxMY_PRINT_DINT( CI:=b1, PRINTER:=n1, IN:=n2 ) ;

Description

The PRINT_DINT function block prints a double integer right-justified in an eight-character field. If the value is negative, the minus (–) sign immediately precedes the value. When printed, each argument is preceded by a blank space.

CI is the control input. CI enables evaluation. If CI is true, then perform the print operation. If CI is false, then do nothing. The default initial value of CI is true.

PRINTER is a number that identifies the printer or print server. The valid range is different for different controllers.

• For the Tricon controller, all values are valid, however, the function block prints to port 10 if PRINTER=10, but prints to port 5 if PRINTER is any other number.

• For the Trident v1.x controller, the valid range is 1 through 10.

• For the Trident v2.x or Tri-GP controller, the PRINTER parameter must be 5 or 10. The Left and Right CM ports cannot have the same PRINTER parameter.

IN represents the integer value to be printed, right-justified in an eight-character field. If the value is negative, the minus (–) sign immediately precedes the value. When printed, each argument is preceded by a blank space.

CO is the control ouput. CO follows CI if no runtime error is detected. CO=true indicates that the function block was enabled and executed successfully, with no runtime error. CO=false and CI=true indicates a runtime error was detected. CO=false and CI=false indicates no operation.

Table 263 Input Parameters

Name Data Type Description

CI BOOL Enables PRINT_DINT.

PRINTER DINT Printer number.

IN DINT The value to be printed.

Table 264 Output Parameters

Name Data Type Description

CO BOOL True if PRINT_DINT executes successfully.

Page 257: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

PRINT_DINT 245

TriStation 1131 Libraries Reference

ExampleVAR MY_PRINT_DINT : PRINT_DINT ; END_VAR(* Print " 999" on printer 5. *)MY_PRINT_DINT( PRINTER:=5, IN:=999 ) ;

Runtime Errors

Upon detection of a runtime error condition, the function block returns the indicated values and sets the error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function block.

If the PRINTER parameter is invalid, then the function block aborts the print operation.

Note that this function block simply adds the print operation to a buffer and does not check the status of the printer or print server. To read printer status (like printer ready, buffer overflow, bytes free, bytes used), see SYS_CM_STATUS or TR_PORT_STATUS.

Application Notes

• Can be used in Control applications.

• Space Saver: a single instance can be executed more than once per scan to reduce memory usage and increase performance. For directions, see Using a Space Saver Function Block on page 6.

Library

• Tricon (TR1LIB/TX1LIB)

• Trident/Tri-GP (TRDLIB)

Condition Return Value Error Flags

If PRINTER is invalid. CO=false BADPARAM, ERROR

Page 258: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

246 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

PRINT_REALPrints a real (floating-point) value right justified in an eight-character field.

SyntaxMY_PRINT_REAL( CI:=b1, PRINTER:=n1, IN:=x1, PRECISION:=n2 ) ;

Description

The PRINT_REAL function block prints a real (floating-point) value right justified in an eight-character field. If the value is negative, a minus (–) sign immediately precedes the first printed digit. The PRECISION argument specifies the number of decimal places. The default is 4 decimal places.

If a real number does not fit in the eight-character field, then significance to the right of the decimal point is reduced. If this fails, then the number is printed in scientific notation. When printed, each argument is preceded by a blank space.

CI is the control input. CI enables evaluation. If CI is true, then perform the print operation. If CI is false, then do nothing. The default initial value of CI is true.

PRINTER is a number that identifies the printer or print server. The valid range is different for different controllers.

• For the Tricon controller, all values are valid, however, the function block prints to port 10 if PRINTER=10, but prints to port 5 if PRINTER is any other number.

• For the Trident v1.x controller, the valid range is 1 through 10.

• For the Trident v2.x or Tri-GP controller, the PRINTER parameter must be 5 or 10. The Left and Right CM ports cannot have the same PRINTER parameter.

IN represents the real number to be printed, right-justified in an eight-character field. If the number is negative, a minus (–) sign immediately precedes the first printed digit. The PRECISION argument specifies the number of decimal places. The default is 4 decimal places.

CO is the control ouput. CO follows CI if no runtime error is detected. CO=true indicates that the function block was enabled and executed successfully, with no runtime error. CO=false and CI=true indicates a runtime error was detected. CO=false and CI=false indicates no operation.

Table 265 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 266 Output Parameters

Name Data Type Description

CO BOOL True if PRINT_REAL executes successfully.

Page 259: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

PRINT_REAL 247

TriStation 1131 Libraries Reference

ExampleVAR MY_PRINT_REAL : PRINT_REAL ; END_VAR(* Print " 1.0625" on printer 5. *)MY_PRINT_REAL( PRINTER:=5, IN:=1.0625 ) ;

Runtime Errors

Upon detection of a runtime error condition, the function block returns the indicated values and sets the error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function block.

If the PRINTER parameter is invalid, then the function block aborts the print operation.

Note that this function block simply adds the print operation to a buffer and does not check the status of the printer or print server. To read printer status (like printer ready, buffer overflow, bytes free, bytes used), see SYS_CM_STATUS or TR_PORT_STATUS.

Application Notes

• Can be used in Control applications.

• Space Saver: a single instance can be executed more than once per scan to reduce memory usage and increase performance. For directions, see Using a Space Saver Function Block on page 6.

Library

• Tricon (TR1LIB/TX1LIB)

• Trident/Tri-GP (TRDLIB)

Condition Return Value Error Flags

If PRINTER is invalid. CO=false BADPARAM, ERROR

Page 260: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

248 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

PRINT_STRINGPrints a string of text (not including quotation marks).

SyntaxMY_PRINT_STRING( CI:=b1, PRINTER:=n1, IN:=s1 ) ;

Description

The PRINT_STRING function block prints a string of text (not including quotation marks).

CI is the control input. CI enables evaluation. If CI is true, then perform the print operation. If CI is false, then do nothing. The default initial value of CI is true.

PRINTER is a number that identifies the printer or print server. The valid range is different for different controllers.

• For the Tricon controller, all values are valid, however, the function block prints to port 10 if PRINTER=10, but prints to port 5 if PRINTER is any other number.

• For the Trident v1.x controller, the valid range is 1 through 10.

• For the Trident v2.x or Tri-GP controller, the PRINTER parameter must be 5 or 10. The Left and Right CM ports cannot have the same PRINTER parameter.

IN represents the string to be printed.

CO is the control ouput. CO follows CI if no runtime error is detected. CO=true indicates that the function block was enabled and executed successfully, with no runtime error. CO=false and CI=true indicates a runtime error was detected. CO=false and CI=false indicates no operation.

ExampleVAR 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 267 Input Parameters

Name Data Type Description

CI BOOL Enables PRINT_STRING.

PRINTER DINT Printer number.

IN STRING The value to be printed.

Table 268 Output Parameters

Name Data Type Description

CO BOOL True if PRINT_STRING executes successfully.

Page 261: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

PRINT_STRING 249

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 6.

Library

• Tricon (TR1LIB/TX1LIB)

• Trident/Tri-GP (TRDLIB)

Condition Return Value Error Flags

If PRINTER is invalid. CO=false BADPARAM, ERROR

Page 262: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

250 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

PRNTR_FLUSHClears the print buffer for the specified printer without printing the contents of the buffer.

SyntaxMY_PRNTR_FLUSH( CI:=b1, PRINTER:=n1 ) ;

Description

The PRNTR_FLUSH function block clears the print buffer for the specified printer without printing the contents of the buffer.

CI is the control input. CI enables evaluation. If CI is true, then perform the print operation. If CI is false, then do nothing. The default initial value of CI is true.

PRINTER is a number that identifies the printer or print server. The valid range is different for different controllers.

• For the Tricon controller, all values are valid, however, the function block prints to port 10 if PRINTER=10, but prints to port 5 if PRINTER is any other number.

• For the Trident v1.x controller, the valid range is 1 through 10.

• For the Trident v2.x or Tri-GP controller, the PRINTER parameter must be 5 or 10. The Left and Right CM ports cannot have the same PRINTER parameter.

CO is the control ouput. CO follows CI if no runtime error is detected. CO=true indicates that the function block was enabled and executed successfully, with no runtime error. CO=false and CI=true indicates a runtime error was detected. CO=false and CI=false indicates no operation.

ExampleVAR MY_PRNTR_FLUSH : PRNTR_FLUSH ; END_VAR(* Clear the print buffer for printer 5. *)MY_PRNTR_FLUSH( PRINTER:=5 ) ;

Table 269 Input Parameters

Name Data Type Description

CI BOOL Enables PRNTR_FLUSH.

PRINTER DINT Printer number.

Table 270 Output Parameters

Name Data Type Description

CO BOOL True if PRNTR_FLUSH executes successfully.

Page 263: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

PRNTR_FLUSH 251

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 6.

Library

• Tricon (TR1LIB/TX1LIB)

• Trident/Tri-GP (TRDLIB)

Condition Return Value Error Flags

If PRINTER is invalid. CO=false BADPARAM, ERROR

Page 264: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

252 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

R_TRIGDetects a rising edge.

SyntaxMY_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.

ExampleVAR CHECK_FOR_RISING_EDGE : R_TRIG ; END_VARVAR b : BOOL ; END_VARb := 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 271 Input Parameters

Name Data Type Description

CLK BOOL Clock.

Table 272 Output Parameters

Name Data Type Description

Q BOOL True indicates rising edge detected.

Page 265: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

R_TRIG 253

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)

Page 266: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

254 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

REALA 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.401298464E–45.

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.

Page 267: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

REAL 255

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.5E–39 7 digits

1.5E–40 6 digits

1.5E–41 5 digits

1.5E–42 4 digits

1.5E–43 3 digits

1.5E–44 2 digits

1.5E–45 1 digits

0.0 0 digits

RangeMaximum Absolute Error

Maximum Relative Error

0 < |x| 2–150 |x| 1

2–150 < |x| 2–126 2–150 2–150 / |x|

2–126 |x| < 2128 – 2103 2–24 * |x| 2–24

Page 268: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

256 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

REAL_TO_DINTConverts a 32-bit real number to a 32-bit integer.

Syntaxk := 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.

ExampleVAR 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.

Table 273 Input Parameters

Name Data Type Description

x REAL The 32-bit number to be converted.

Table 274 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

Page 269: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

REAL_TO_DINT 257

TriStation 1131 Libraries Reference

Application Notes

Can be used in Safety or Control applications.

Library

Standard (STDLIB)

Page 270: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

258 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

REAL_TO_INTConverts a 32-bit real number to a 16-bit integer.

Syntaxk := 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.

ExampleVAR 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.

Table 275 Input Parameters

Name Data Type Description

x REAL The 32-bit number to be converted.

Table 276 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

Page 271: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

REAL_TO_INT 259

TriStation 1131 Libraries Reference

Application Notes

Can be used in Safety or Control applications.

Library

Standard (STDLIB)

Page 272: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

260 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

REAL_TO_LREALConverts a 32-bit real number to a 64-bit long real number.

Syntaxy := 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.

ExampleVAR 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 277 Input Parameters

Name Data Type Description

x REAL The 32-bit number to be converted.

Table 278 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

Page 273: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

ReportBadParam 261

TriStation 1131 Libraries Reference

ReportBadParamReports a bad parameter error.

Syntaxb1 := 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.

ExampleVAR NOT_USED, b1, b2 : BOOL ; STATUS : CHK_ERR ; END_VARENO := 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 279 Input Parameters

Name Data Type Description

I1 INT Not used.

Table 280 Return Value

Data Type Description

BOOL Not used, always false.

Page 274: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

262 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

ROLRotates left N bits, where N is the shift count.

Syntaxw := 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.

ExampleVAR w1, w2, w3 : DWORD; END_VARw1 := 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 281 Input Parameters

Name Data Type Description

IN ANY_BIT Operand

N ANY_INT Shift count.

Table 282 Return Value

Data Type Description

ANY_BIT IN rotated left N bits

Page 275: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

ROR 263

TriStation 1131 Libraries Reference

RORRotates right N bits, where N is the shift count.

Syntaxw := 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.

ExampleVAR w1, w2, w3 : DWORD; END_VARw1 := 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 283 Input Parameters

Name Data Type Description

IN ANY_BIT Operand.

N ANY_INT Shift count.

Table 284 Return Value

Data Type Description

ANY_BIT IN rotated left N bits

Page 276: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

264 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

RSRS is a bistable function block (reset dominant).

SyntaxRS( 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.

ExampleVAR MY_RS : RS ; END_VARMY_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 285 Input Parameters

Name Data Type Description

S BOOL Set.

R1 BOOL Reset.

Table 286 Output Parameters

Name Data Type Description

Q1 BOOL State

Table 287 Truth Table

S R1 Q1

false false no change

false true false

true false true

true true false

Page 277: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

RS 265

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)

Page 278: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

266 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

RTCProvides a real-time clock.

SyntaxMY_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.

ExampleVAR MY_RTC : RTC ; END_VARMY_RTC() ; (* Output CDT is the current date and time. *)

Runtime Errors

None.

Application Notes

• Can be used in Safety or Control applications.

• Space Saver: a single instance can be executed more than once per scan to reduce memory usage and increase performance. For directions, see Using a Space Saver Function Block on page 6.

Library

Standard (STDLIB)

Table 288 Input Parameters

Name Data Type Description

IN BOOL Enables RTC.

PDT DT Preset date and time.

Table 289 Output Parameters

Name Data Type Description

Q BOOL Copy of IN.

CDT DT The current date and time.

Page 279: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

SCALE 267

TriStation 1131 Libraries Reference

SCALEScales a value from one engineering unit to another.

Syntaxy := 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 ;

ExampleVAR y : REAL; END_VARy := 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 290 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 291 Return Value

Data Type Description

REAL The scaled output value.

Page 280: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

268 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

SELSelects one of two data values.

Syntaxv := 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.

Examplev := SEL( G, IN0, IN1 ) ;

Runtime Errors

None.

Application Notes

Can be used in Safety or Control applications.

Library

Standard (STDLIB)

Table 292 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 293 Return Value

Data Type Description

ANY The output value.

Page 281: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

SHL 269

TriStation 1131 Libraries Reference

SHLShifts left N bits, where N is the shift count.

Syntaxw := 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.

ExampleVAR w1, w2, w3 : DWORD; END_VARw1 := 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 294 Input Parameters

Name Data Type Description

IN ANY_BIT Operand

N ANY_INT Shift count.

Table 295 Return Value

Data Type Description

ANY_BIT IN shifted left N bits

Page 282: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

270 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

SHRShifts right N bits, where N is the shift count.

Syntaxw := 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.

ExampleVAR w1, w2, w3 : DWORD; END_VARw1 := 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 296 Input Parameters

Name Data Type Description

IN ANY_BIT Operand

N ANY_INT Shift count

Table 297 Return Value

Data Type Description

ANY_BIT IN shifted right N bits

Page 283: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

SIN 271

TriStation 1131 Libraries Reference

SINCalculates 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.

ExampleVAR y : REAL; END_VARy := 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 298 Input Parameters

Name Data Type Description

x ANY_REAL The angle, in radians.

Table 299 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

Page 284: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

272 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

SOECLRClears a sequence of events (SOE) block.

SyntaxMY_SOECLR( CI:=b1, BLOCK:=n1 ) ;

Description

The SOECLR function block clears a sequence of events (SOE) block. SOECLR removes all entries from the block and writes a SOECLR time stamp into the block. You must stop event collection (using SOESTOP) before clearing the block.

If the SOECLR operation is successful, the output status is 2, indicating that the block is cleared. If the event collection was not stopped before the SOECLR operation was attempted, the output status is 0, 1, or 3.

If CI is false, no operation occurs (no output changes).

Example

For examples of using SOE function blocks, see these SOE sample projects:

• ExSOE.pt2 (For Tricon controllers)

• TdSOE.pt2 (For Trident or Tri-GP controllers)

Note See Sample Projects on page 7 for information about where to find these projects on the PC where you installed TriStation 1131.

Table 300 Input Parameters

Name Data Type Description

CI BOOL Enables SOECLR.

BLOCK DINT The block number (1–16).

Table 301 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.

Page 285: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

SOECLR 273

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 6.

Library

• Tricon (TR1LIB/TX1LIB)

• Trident/Tri-GP (TRDLIB)

Condition Return Value Error Flags

If the block number is out of range

CO=false,

STAT=0

BADPARAM, ERROR

Page 286: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

274 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

SOESTATReturns status for a sequence of events (SOE) block.

SyntaxMY_SOESTAT( CI:=b1, BLOCK:=n1 ) ;

Description

The SOESTAT function block returns status for a sequence of events (SOE) block, including the number of 8-byte entries that are used, and the number of 8-byte entries that are free.

If CI is false, no operation occurs.

Example

For examples of using SOE function blocks, see these SOE sample projects:

• ExSOE.pt2 (For Tricon controllers)

• TdSOE.pt2 (For Trident or Tri-GP controllers)

Note See Sample Projects on page 7 for information about where to find these projects on the PC where you installed TriStation 1131.

Table 302 Input Parameters

Name Data Type Description

CI BOOL Enables SOESTAT.

BLOCK DINT The block number (1–16).

Table 303 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.

Page 287: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

SOESTAT 275

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 6.

Library

• Tricon (TR1LIB/TX1LIB)

• Trident/Tri-GP (TRDLIB)

Condition Return Value Error Flags

If the block number is out of range CO=false,

STAT=0,

FREE=0,

USED=0

BADPARAM, ERROR

Page 288: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

276 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

SOESTOPWrites a time stamp into a sequence of events (SOE) block, and changes the state of the block from collecting to stopped.

SyntaxMY_SOESTOP( CI:=b1, BLOCK:=n1 ) ;

Description

The SOESTOP function block writes a time stamp into a sequence of events (SOE) block, and changes the state of the block from collecting to stopped. Event collection stops until the next SOESTRT operation.

If the SOESTOP operation is successful, the output status is 2, indicating that the event collection is stopped. If CI is false, no operation occurs (no output changes).

Example

For examples of using SOE function blocks, see these SOE sample projects:

• ExSOE.pt2 (For Tricon controllers)

• TdSOE.pt2 (For Trident or Tri-GP controllers)

Note See Sample Projects on page 7 for information about where to find these projects on the PC where you installed TriStation 1131.

Runtime Errors

Table 304 Input Parameters

Name Data Type Description

CI BOOL Enables SOESTOP.

BLOCK DINT The block number (1–16).

Table 305 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

Page 289: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

SOESTOP 277

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 6.

Library

• Tricon (TR1LIB/TX1LIB)

• Trident/Tri-GP (TRDLIB)

Page 290: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

278 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

SOESTRTStarts sequence of events (SOE) collection for an SOE block.

SyntaxMY_SOESTRT( CI:=b1, BLOCK:=n1 ) ;

Description

The SOESTRT function block starts sequence of events (SOE) collection for an SOE block. The Main Processor writes an SOESTRT time stamp entry into the block and changes the state of the block from not started or stopped to collecting. If the SOESTRT operation is successful, the output status is 1, indicating that the block is collecting data.

If CI is false, no operation occurs (no output changes).

The SOESTRT function block must be executed for each SOE block you want to collect events from.

Note The SOESTRT function block is executed once per scan, which means the resulting STAT output is valid only for that scan.

Example

For examples of using SOE function blocks, see these SOE sample projects:

• ExSOE.pt2 (For Tricon controllers)

• TdSOE.pt2 (For Trident or Tri-GP controllers)

Note See Sample Projects on page 7 for information about where to find these projects on the PC where you installed TriStation 1131.

Table 306 Input Parameters

Name Data Type Description

CI BOOL Enables SOESTRT.

BLOCK DINT The block number (1–16).

Table 307 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.

Page 291: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

SOESTRT 279

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 6.

Library

• Tricon (TR1LIB/TX1LIB)

• Trident/Tri-GP (TRDLIB)

Condition Return Value Error Flags

If the block number is out of range CO=false,

STAT=0

BADPARAM, ERROR

Page 292: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

280 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

SQRTCalculates the square root of a number.

Syntaxy := SQRT( x ) ;

Description

The SQRT function returns the square root of a number.

ExampleVAR y : REAL; END_VARy := 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 308 Input Parameters

Name Data Type Description

x ANY_REAL A real number.

Table 309 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

Page 293: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

SR 281

TriStation 1131 Libraries Reference

SRSR is a bistable function block (set dominant).

SyntaxSR( 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.

ExampleVAR MY_SR : SR ; END_VARMY_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.

Table 310 Input Parameters

Name Data Type Description

S1 BOOL Set

R BOOL Reset

Table 311 Output Parameters

Name Data Type Description

Q1 BOOL State

Table 312 Truth Table

S1 R Q1

false false no change

false true false

true false true

true true true

Page 294: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

282 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.

Library

Standard (STDLIB)

Page 295: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

STRING 283

TriStation 1131 Libraries Reference

STRINGA 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

Page 296: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

284 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

SUBCalculates the difference between two operands.

Syntax for Subtracting a Number from Another Numberz := x - y ;

Syntax for Subtracting a Time from a Date and Timed2 := d1 - t ;

Syntax for Subtracting a Time from a Timet3 := t1 - t2 ;

Table 313 Input Parameters

Name Data Type Description

x ANY_NUM Minuend

y ANY_NUM Subtrahend

Table 314 Return Value

Data Type Description

ANY_NUM The difference x - y

Table 315 Input Parameters

Name Data Type Description

d1 DT Minuend

t TIME Subtrahend

Table 316 Return Value

Data Type Description

DT The difference d1 - t

Table 317 Input Parameters

Name Data Type Description

t1 TIME Minuend

t2 TIME Subtrahend

Table 318 Return Value

Data Type Description

TIME The difference t1 - t2

Page 297: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

SUB 285

TriStation 1131 Libraries Reference

Subtracting a Time from a Time of Daytod2 := 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_VARm := 1564 - 10; (* result is 1554 *)

Subtract a time from a date and time:

VAR d : DT; END_VARd := 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_VARt := T#11d22h33m - T#3h10m; (* result is T#11d19h23m *)

Subtract a time from a time of day:

VAR tod1 : TOD; END_VARtod1 := TOD#08:00:00 - T#3h30m45s; (* result is TOD#04:29:15 *)

Table 319 Input Parameters

Name Data Type Description

tod1 TIME OF DAY Minuend

t TIME Subtrahend

Table 320 Return Value

Data Type Description

TOD The difference tod1 - t

Page 298: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

286 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

Page 299: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

SYS_AI32_STATUS 287

TriStation 1131 Libraries Reference

SYS_AI32_STATUS

Gets the status of an Analog Input Module in a Trident or Tri-GP controller.

SyntaxMY_SYS_AI32_STATUS( CI:=b1, IOP:=n1, SLOT:=n2 ) ;

Table 321 Input Parameters

Name Data Type Description

CI BOOL Enables SYS_AI32_STATUS.

IOP DINT The I/O Processor (1).

SLOT DINT The baseplate number (0–32).

Table 322 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.

NO_FLD_FLTS BOOL No field faults detected.

Page 300: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

288 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 or Tri-GP controller.

ExampleVAR MY_AI : SYS_AI32_STATUS ; END_VARVAR AI_ACTIVE : BOOL ; END_VARMY_AI( CI:=TRUE, IOP:=1, SLOT:=5 ) ;AI_ACTIVE := MY_AI.LEFT_ACTIVE OR MY_AI.RIGHT_ACTIVE ;(* * Result : AI_ACTIVE is TRUE if there is * an active AI32 module in slot 5. *)

Runtime Errors

Upon detection of a runtime error condition, the function block returns the indicated values and sets the error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function block.

Application Notes

• Can be used in Safety or Control applications.

• Space Saver: a single instance can be executed more than once per scan to reduce memory usage and increase performance. For directions, see Using a Space Saver Function Block on page 6.

Library

Trident/Tri-GP (TRDLIB)

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 322 Output Parameters (continued)

Name Data Type Description

Page 301: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

SYS_AO04_STATUS 289

TriStation 1131 Libraries Reference

SYS_AO04_STATUSGets the status of an Analog Output Module.

SyntaxMY_SYS_AO04_STATUS( CI:=b1, IOP:=n1, SLOT:=n2 ) ;

Table 323 Input Parameters

Name Data Type Description

CI BOOL Enables SYS_AO04_STATUS.

IOP DINT The I/O Processor (1).

SLOT DINT The baseplate number (0–32).

Table 324 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.

NO_FLD_FLTS BOOL No field faults detected on module.

NO_VOTER_FLTS BOOL No voter faults detected on module.

Page 302: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

290 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.

ExampleVAR MY_AO : SYS_AO04_STATUS ; END_VARVAR AO_ACTIVE : BOOL ; END_VARMY_AO( CI:=TRUE, IOP:=1, SLOT:=5 ) ;AO_ACTIVE := MY_AO.LEFT_ACTIVE OR MY_AO.RIGHT_ACTIVE ;(* * Result : AO_ACTIVE is TRUE if there is * an active AO04 module in slot 5. *)

Runtime Errors

Upon detection of a runtime error condition, the function block returns the indicated values and sets the error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function block.

Application Notes

• Can be used in Safety or Control applications.

• Space Saver: a single instance can be executed more than once per scan to reduce memory usage and increase performance. For directions, see Using a Space Saver Function Block on page 6.

Library

Trident/Tri-GP (TRDLIB)

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 324 Output Parameters (continued)

Name Data Type Description

Page 303: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

SYS_APP_HALT 291

TriStation 1131 Libraries Reference

SYS_APP_HALTHalts the application.

Syntaxn1 := 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_VARn := 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.

Table 325 Input Parameters

Name Data Type Description

APP_HALT BOOL True means halt the application; false means do not halt.

Table 326 Return Value

Data Type Description

DINT Error Number:

• 0 =No error.

• –1 =The IOP is invalid.

• –2 =The slot is not valid.

• –3 =The module is not configured.

• –4 =The module is the wrong type.

Condition Return Value Error Flags

If error number is non-zero. Error number BADPARAM, ERROR

Page 304: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

292 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

Application Notes

Can be used in Safety or Control applications.

Library

Trident/Tri-GP (TRDLIB)

Page 305: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

SYS_CLEAR_FLTS 293

TriStation 1131 Libraries Reference

SYS_CLEAR_FLTSClear all faults in the system.

Syntaxn1 := 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_VARn := 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 327 Input Parameters

Name Data Type Description

CLEAR_FLTS BOOL True means clear faults; false means do not clear.

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

Page 306: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

294 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

Application Notes

Can be used in Safety or Control applications.

Library

Trident/Tri-GP (TRDLIB)

Page 307: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

SYS_CM_STATUS 295

TriStation 1131 Libraries Reference

SYS_CM_STATUSGets the status of a Trident or Tri-GP Communication Module (CM).

SyntaxMY_SYS_CM_STATUS( CI:=b1, IOP:=n1, SLOT:=n2 ) ;

Table 329 Input Parameters

Name Data Type Description

CI BOOL Enables SYS_CM_STATUS.

IOP DINT The I/O Processor (1).

SLOT DINT The baseplate number (2 or 3).

Table 330 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.

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.

Page 308: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

296 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

Description

The SYS_CM_STATUS function block gets the status of a Communications Module. The status information for serial ports only applies to ports used as Modbus slaves.

ExampleVAR MY_CM : SYS_CM_STATUS ; END_VARVAR CM_ACTIVE : BOOL ; END_VARMY_CM( CI:=TRUE, IOP:=0, SLOT:=2 ) ;CM_ACTIVE := MY_CM.ACTIVE ;(* * Result : CM_ACTIVE is TRUE if there is * an active CM module in slot 2. *)

Runtime Errors

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.

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.

Condition Return Value Error Flags

If ERROR_NUM is non-zero Reset all outputs except ERROR_NUM to zero. BADPARAM, ERROR

Table 330 Output Parameters (continued)

Name Data Type Description

Page 309: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

SYS_CM_STATUS 297

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 6.

Library

Trident/Tri-GP (TRDLIB)

Page 310: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

298 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

SYS_CRITICAL_IOAccumulates the status of safety-critical I/O modules.

SyntaxMY_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 Safety Considerations Guide for your controller.

Instructions for Use

To initialize, invoke once with RESET := TRUE.

To complete initialization, invoke again with these input settings:

• RESET := FALSE

• CI := TRUE

Table 331 Input Parameters

Name Data Type Description

CI BOOL Enables SYS_CRITICAL_IO.

RESET BOOL Resets.

IOP DINT The I/O Processor (1).

SLOT DINT The baseplate number (0–32).

APP DINT The application number (1-2).

RELAY_OK BOOL The relay is energized and not stuck.

Table 332 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.

Page 311: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

SYS_CRITICAL_IO 299

TriStation 1131 Libraries Reference

• APP := DE_ENERGIZED

• RELAY_OK := false

To get the status of a safety-critical I/O module:

• For each module, invoke specifying the input values:

— IOP

— SLOT

— APP

— RELAY_OK

For example, if IOP 1 SLOT 1 is a critical DO module with a relay, and SCIO is the function block instance name:

SCIO( IOP:=1, SLOT:=1, APP:=RELAY,RELAY_OK:=RELAY1_OK );

• Read the output values:

— CO

— TMR

— GE_DUAL

— GE_SINGLE

Example

For shutdown examples, see this sample project:

• TdTUV.pt2 (For Trident or Tri-GP controllers)

Note See Sample Projects on page 7 for information about where to find this project on the PC where you installed TriStation 1131.

Runtime Errors

Upon detection of a runtime error condition, the function block returns the indicated values and sets the error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function block.

Application Notes

Can be used in Safety or Control applications.

Library

Trident/Tri-GP (TRDLIB)

Condition Return Value Error Flags

If ERROR_NUM is non-zero Reset all BOOL outputs to false BADPARAM, ERROR

Page 312: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

300 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

SYS_DI16_AI16_STATUSGets the status of a combo AI/DI input module.

SyntaxMY_SYS_DI16_AI16_STATUS( CI:=b1, IOP:=n1, SLOT:=n2 ) ;

Table 333 Input Parameters

Name Data Type Description

CI BOOL Enables SYS_DI16_A16_STATUS.

IOP DINT The I/O Processor (1).

SLOT DINT The baseplate number (0–32).

Table 334 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.

Page 313: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

SYS_DI16_AI16_STATUS 301

TriStation 1131 Libraries Reference

Description

The SYS_DI16_A16_STATUS function block gets the status of a combo AI/DI input module.

ExampleVAR MY_AIDI : SYS_DI16_AI16_STATUS ; END_VARVAR AIDI_ACTIVE : BOOL ; END_VARMY_AIDI( CI:=TRUE, IOP:=1, SLOT:=5 ) ;AIDI_ACTIVE := MY_AIDI.LEFT_ACTIVE OR MY_AIDI.RIGHT_ACTIVE ;(* * Result : AIDI_ACTIVE is TRUE if there is * an active AI/DI combo module in slot 5. *)

Runtime Errors

Upon detection of a runtime error condition, the function block returns the indicated values and sets the error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function block.

Application Notes

• Can be used in Safety or Control applications.

• Space Saver: a single instance can be executed more than once per scan to reduce memory usage and increase performance. For directions, see Using a Space Saver Function Block on page 6.

Library

Trident/Tri-GP (TRDLIB)

This function was added to the library in v1.114 of TRDLIB, first released with TriStation 1131 v4.3.

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 334 Output Parameters (continued)

Name Data Type Description

Page 314: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

302 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

SYS_DI32_STATUSGets the status of a discrete input module.

SyntaxMY_SYS_DI32_STATUS( CI:=b1, IOP:=n1, SLOT:=n2 ) ;

Table 335 Input Parameters

Name Data Type Description

CI BOOL Enables SYS_DI32_STATUS.

IOP DINT The I/O Processor (1).

SLOT DINT The baseplate number (0–32).

Table 336 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.

Page 315: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

SYS_DI32_STATUS 303

TriStation 1131 Libraries Reference

Description

The SYS_DI32_STATUS function block gets the status of a discrete input module.

ExampleVAR MY_DI : SYS_DI32_STATUS ; END_VARVAR DI_ACTIVE : BOOL ; END_VARMY_DI( CI:=TRUE, IOP:=1, SLOT:=5 ) ;DI_ACTIVE := MY_DI.LEFT_ACTIVE OR MY_DI.RIGHT_ACTIVE ;(* * Result : DI_ACTIVE is TRUE if there is * an active DI32 module in slot 5. *)

Runtime Errors

Upon detection of a runtime error condition, the function block returns the indicated values and sets the error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function block.

Application Notes

• Can be used in Safety or Control applications.

• Space Saver: a single instance can be executed more than once per scan to reduce memory usage and increase performance. For directions, see Using a Space Saver Function Block on page 6.

Library

Trident/Tri-GP (TRDLIB)

NO_FLD_FLTS BOOL No field faults detected (always truea).

NO_VOTER_FLTS BOOL No voter faults detected (always truea).

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 336 Output Parameters (continued)

Name Data Type Description

Page 316: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

304 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

SYS_DO16_STATUSGets the status of a discrete output module.

SyntaxMY_SYS_DO16_STATUS( CI:=b1, IOP:=n1, SLOT:=n2 ) ;

Table 337 Input Parameters

Name Data Type Description

CI BOOL Enables SYS_DO16_STATUS.

IOP DINT The I/O Processor (1).

SLOT DINT The baseplate number (0–32).

Table 338 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.

NO_FLD_FLTS BOOL No field faults detected on module.

NO_VOTER_FLTS BOOL No voter faults detected on module.

Page 317: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

SYS_DO16_STATUS 305

TriStation 1131 Libraries Reference

Description

The SYS_DO16_STATUS function block gets the status of a discrete output module.

ExampleVAR MY_DO : SYS_DO16_STATUS ; END_VARVAR DO_ACTIVE : BOOL ; END_VARMY_DO( CI:=TRUE, IOP:=1, SLOT:=5 ) ;DO_ACTIVE := MY_DO.LEFT_ACTIVE OR MY_DO.RIGHT_ACTIVE ;(* * Result : DO_ACTIVE is TRUE if there is * an active DO16 module in slot 5. *)

Runtime Errors

Upon detection of a runtime error condition, the function block returns the indicated values and sets the error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function block.

Application Notes

• Can be used in Safety or Control applications.

• Space Saver: a single instance can be executed more than once per scan to reduce memory usage and increase performance. For directions, see Using a Space Saver Function Block on page 6.

Library

Trident/Tri-GP (TRDLIB)

OVD_RUNNING_01_16 DWORD OVD points 01–16 are OK.

FLD_OK_01_16 DWORD Field points 01–16 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 338 Output Parameters (continued)

Name Data Type Description

Page 318: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

306 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

SYS_HRDI32_STATUSGets the status of a high resolution discrete input module.

SyntaxMY_SYS_HRDI32_STATUS( CI:=b1, IOP:=n1, SLOT:=n2 ) ;

Table 339 Input Parameters

Name Data Type Description

CI BOOL Enables SYS_HRDI32_STATUS.

IOP DINT The I/O Processor (1).

SLOT DINT The baseplate number (0–32).

Table 340 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.

Page 319: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

SYS_HRDI32_STATUS 307

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.

ExampleVAR MY_HRDI : SYS_HRDI32_STATUS ; END_VARVAR HRDI_ACTIVE : BOOL ; END_VARMY_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 truea).

NO_VOTER_FLTS BOOL No voter faults detected (always truea).

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 340 Output Parameters (continued)

Name Data Type Description

Page 320: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

308 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 6.

Library

Trident/Tri-GP (TRDLIB)

This function was added to the library in v1.120 of TRDLIB, first released with TriStation 1131 v4.6.

Page 321: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

SYS_IO_STATUS 309

TriStation 1131 Libraries Reference

SYS_IO_STATUSGets the status of an I/O module.

SyntaxMY_SYS_IO_STATUS( CI:=b1, IOP:=n1, SLOT:=n2 ) ;

Table 341 Input Parameters

Name Data Type Description

CI BOOL Enables SYS_IO_STATUS.

IOP DINT The I/O Processor (1).

SLOT DINT The baseplate number (0–32).

Table 342 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.

NO_FLD_FLTS BOOL No field faults detected on module.

NO_VOTER_FLTS BOOL No voter faults detected on module.

Page 322: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

310 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

Description

The SYS_IO_STATUS function block gets the status of an I/O module.

ExampleVAR MY_IO : SYS_IO_STATUS ; END_VARVAR IO_ACTIVE : BOOL ; END_VARMY_IO( CI:=TRUE, IOP:=1, SLOT:=5 ) ;IO_ACTIVE := MY_IO.LEFT_ACTIVE OR MY_IO.RIGHT_ACTIVE ;(* * Result : IO_ACTIVE is TRUE if there is * an active IO module in slot 5. *)

Runtime Errors

Upon detection of a runtime error condition, the function block returns the indicated values and sets the error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function block.

Application Notes

• Can be used in Safety or Control applications.

• Space Saver: a single instance can be executed more than once per scan to reduce memory usage and increase performance. For directions, see Using a Space Saver Function Block on page 6.

Library

Trident/Tri-GP (TRDLIB)

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 342 Output Parameters (continued)

Name Data Type Description

Page 323: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

SYS_IOP_STATUS 311

TriStation 1131 Libraries Reference

SYS_IOP_STATUSGets the status of a Trident or Tri-GP I/O Processor.

SyntaxMY_SYS_IOP_STATUS( CI:=b1, IOP:=n1 ) ;

Table 343 Input Parameters

Name Data Type Description

CI BOOL Enables SYS_IOP_STATUS.

IOP DINT The I/O Processor (1).

Table 344 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.

IO_GE_Dual BOOL At least two channels are operating without fatal faults detected on the I/O string.

Page 324: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

312 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

Description

The SYS_IOP_STATUS function block gets the status of an I/O Processor.

ExampleVAR MY_IOP : SYS_IOP_STATUS ; END_VARVAR NO_IOP_FAULTS : BOOL ; END_VARMY_IOP( CI:=TRUE, IOP:=1 ) ;NO_IOP_FAULTS := MY_IOP.NO_FLTS ;(* * Result : NO_IOP_FAULTS is TRUE if there are * no failed modules detected on the IOP. *)

Runtime Errors

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.

Condition Return Value Error Flags

If ERROR_NUM is non-zero Reset all outputs except ERROR_NUM to zero. BADPARAM, ERROR

Table 344 Output Parameters (continued)

Name Data Type Description

Page 325: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

SYS_IOP_STATUS 313

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 6.

Library

Trident/Tri-GP (TRDLIB)

Page 326: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

314 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

SYS_MP_EXT_STATUS Gets the extended status of a Trident or Tri-GP Main Processor Module.

SyntaxMY_SYS_MP_EXT_STATUS( CI:=b1 ) ;

Table 345 Input Parameters

Name Data Type Description

CI BOOL Enables SYS_MP_STATUS.

Table 346 Output Parameters

Name Data Type Description

CO BOOL 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 in degrees Celsius.

TEMP_MID DINT The temperature of the middle MP in degrees Celsius.

TEMP_RIGHT DINT The temperature of the right MP in degrees Celsius.

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.

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.

Page 327: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

SYS_MP_EXT_STATUS 315

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.

ExampleVAR MY_MPX : SYS_MP_EXT_STATUS ; END_VARVAR DELTA : DINT ; END_VARMY_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.

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 346 Output Parameters (continued)

Name Data Type Description

Page 328: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

316 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 6.

Library

Trident/Tri-GP (TRDLIB)

Page 329: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

SYS_MP_RESET_PORTS 317

TriStation 1131 Libraries Reference

SYS_MP_RESET_PORTSReset statistics for Modbus ports on the MP.

Syntaxn1 := 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_VARn := 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 347 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 348 Return Value

Data Type Description

DINT Error Number:

• 0 =No error.

• –1 =The IOP is invalid.

• –2 =The slot is not valid.

• –3 =The module is not configured.

• –4 =The module is the wrong type.

Condition Return Value Error Flags

If error number is non-zero. Error number BADPARAM, ERROR

Page 330: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

318 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

Application Notes

Can be used in Safety or Control applications.

Library

Trident/Tri-GP (TRDLIB)

Page 331: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

SYS_MP_STATUS 319

TriStation 1131 Libraries Reference

SYS_MP_STATUS Gets the status of the Trident or Tri-GP Main Processor Modules.

SyntaxMY_SYS_MP_STATUS( CI:=b1 ) ;

Table 349 Input Parameters

Name Data Type Description

CI BOOL Enables SYS_MP_STATUS.

Table 350 Output Parameters

Name Data Type Description

CO BOOL 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.

BATT_OK_RIGHT BOOL The right module battery is OK.

Page 332: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

320 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

Description

The SYS_MP_STATUS function block gets the status of Trident or Tri-GP Main Processor modules. Use the SYS_MP_STATUS function block with BOOL MP status variables and the SYS_MP_EXT_STATUS function block with DINT MP status variables.

ExampleVAR MY_MP : SYS_MP_STATUS ; END_VARVAR MP_TEMPERATURE_OK : BOOL ; END_VARMY_MP( CI:=TRUE ) ;MP_TEMPERATURE_OK := MY_MP.TEMP_OK ;(* * Result : MP_TEMPERATURE_OK is TRUE if * the MP temperature is OK. *)

Runtime Errors

Upon detection of a runtime error condition, the function block returns the indicated values and sets the error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function block.

Application Notes

• Can be used in Safety or Control applications.

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 350 Output Parameters (continued)

Name Data Type Description

Page 333: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

SYS_MP_STATUS 321

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 6.

Library

Trident/Tri-GP (TRDLIB)

Page 334: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

322 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

SYS_OVD_INHIBITInhibits output voter diagnostics.

Syntaxn1 := SYS_OVD_INHIBIT( IOP, SLOT, IOVD_01_16 ) ;

Description

The SYS_OVD_INHIBIT function block turns output voter diagnostic inhibits on or off.

When enabled, the Trident or Tri-GP DO or SDO module runs output voter diagnostics on each output point. The application program can call SYS_OVD_INHIBIT to control the OVD inhibit for each point. Each bit 01..16 of IOVD_01_16 controls the running of OVD for the corresponding point on the output module. If the bit value is one, then inhibit diagnostics for that point. If the bit value is zero, then run the diagnostics for that point.

Invoke SYS_DO16_STATUS or SYS_SDO16_STATUS to read whether OVD is running for each point.

Table 351 Input Parameters

Name Data Type Description

IOP DINT I/O Processor (1).

SLOT DINT Baseplate number (0-32).

IOVD_01_16 DWORD Inhibit Output Voter Diagnostics points 01..16

Table 352 Return Value

Data Type Description

DINT Error Number:

• 0 =No error.

• –1 =The IOP is invalid.

• –2 =The slot is not valid.

• –3 =The module is not configured.

• –4 =The module is the wrong type.

WARNINGPoints on the Trident or Tri-GP SDO module are configured for supervision in TriStation 1131.

Using the SYS_OVD_INHIBIT function block to inhibit OVDs on an SDO point overrides the TriStation 1131 supervisory configuration and results in loss of supervision of that point.

See the TriStation 1131 Developer’s Guide for more information about configuring the Trident or Tri-GP SDO module.

Page 335: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

SYS_OVD_INHIBIT 323

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_VARn := SYS_OVD_INHIBIT( 1, 5, 2#00000000000000000000000000111111 );

Runtime Errors

Upon detection of a runtime error condition, the function returns the indicated value, sets the error flags to true, and resets ENO to false. For more information about error flags and runtime errors, see the CHK_ERR function block.

Application Notes

Can be used in Safety or Control applications.

Library

Trident/Tri-GP (TRDLIB)

Condition Return Value Error Flags

If error number is non-zero. Error number BADPARAM, ERROR

Page 336: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

324 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

SYS_PI06_STATUSGets the status of a Trident/Tri-GP Pulse Input or Enhanced Pulse Input Module.

SyntaxMY_SYS_PI06_STATUS( CI:=b1, IOP:=n1, SLOT:=n2 ) ;

Table 353 Input Parameters

Name Data Type Description

CI BOOL Enables SYS_PI06_STATUS.

IOP DINT The I/O Processor (1).

SLOT DINT The baseplate number (0–32).

Table 354 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.

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.

Page 337: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

SYS_PI06_STATUS 325

TriStation 1131 Libraries Reference

Description

The SYS_PI06_STATUS function block gets the status of a Trident or Tri-GP Pulse Input or Enhanced Pulse Input Module.

ExampleVAR MY_PI : SYS_PI06_STATUS ; END_VARVAR PI_ACTIVE : BOOL ; END_VARMY_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. *)

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 354 Output Parameters (continued)

Name Data Type Description

Page 338: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

326 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 6.

Library

Trident/Tri-GP (TRDLIB)

Condition Return Value Error Flags

If ERROR_NUM is non-zero Reset all BOOL outputs to false BADPARAM, ERROR

Page 339: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

SYS_RO32_STATUS 327

TriStation 1131 Libraries Reference

SYS_RO32_STATUSGets the status of a Trident/Tri-GP Relay Output Module.

SyntaxMY_SYS_RO32_STATUS( CI:=b1, IOP:=n1, SLOT:=n2 ) ;

Table 355 Input Parameters

Name Data Type Description

CI BOOL Enables SYS_RO32_STATUS.

IOP DINT The I/O Processor (1).

SLOT DINT The baseplate number (0–32).

Table 356 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.

NO_FLD_FLTS BOOL No field faults detected.

NO_VOTER_FLTS BOOL No voter faults detected.

Page 340: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

328 Chapter 2 Functions and Data Types

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).

ExampleVAR MY_RO : SYS_RO32_STATUS ; END_VARVAR RO_ACTIVE : BOOL ; END_VARMY_RO( CI:=TRUE, IOP:=1, SLOT:=5 ) ;RO_ACTIVE := MY_RO.LEFT_ACTIVE OR MY_RO.RIGHT_ACTIVE ;(* * Result : RO_ACTIVE is TRUE if there is * an active RO32 module in slot 5. *)

Runtime Errors

Upon detection of a runtime error condition, the function block returns the indicated values and sets the error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function block.

Application Notes

• Can be used in Safety or Control applications.

• Space Saver: a single instance can be executed more than once per scan to reduce memory usage and increase performance. For directions, see Using a Space Saver Function Block on page 6.

Library

Trident/Tri-GP (TRDLIB)

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 356 Output Parameters (continued)

Name Data Type Description

Page 341: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

SYS_SDO16_STATUS 329

TriStation 1131 Libraries Reference

SYS_SDO16_STATUSGets the status of a supervised discrete output module.

SyntaxMY_SYS_SDO16_STATUS( CI:=b1, IOP:=n1, SLOT:=n2 ) ;

Table 357 Input Parameters

Name Data Type Description

CI BOOL Enables SYS_SDO16_STATUS.

IOP DINT The I/O Processor (1).

SLOT DINT The baseplate number (0–32).

Table 358 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.

NO_FLD_FLTS BOOL No field faults detected on module.

NO_VOTER_FLTS BOOL No voter faults detected on module.

Page 342: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

330 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

Description

The SYS_SDO16_STATUS function block gets the status of a supervised discrete output module.

CO is the control ouput. CO follows CI if no runtime error is detected. CO=true indicates that the function block was enabled and executed successfully, with no runtime error. CO=false and CI=true indicates a runtime error was detected. CO=false and CI=false indicates no operation.

ExampleVAR MY_SDO : SYS_SDO16_STATUS ; END_VARVAR SDO_ACTIVE : BOOL ; END_VARMY_SDO( CI:=TRUE, IOP:=1, SLOT:=5 ) ;SDO_ACTIVE := MY_SDO.LEFT_ACTIVE OR MY_SDO.RIGHT_ACTIVE ;(* * Result : SDO_ACTIVE is TRUE if there * is an active SDO16 module in slot 5.*)

Runtime Errors

Upon detection of a runtime error condition, the function block returns the indicated values and sets the error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function block.

OVD_RUNNING_01_16 DWORD OVD points 01–16 are OK.

FLD_OK_01_16 DWORD Field points 01–16 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.

Condition Return Value Error Flags

If ERROR_NUM is non-zero Reset all BOOL outputs to false BADPARAM, ERROR

Table 358 Output Parameters (continued)

Name Data Type Description

Page 343: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

SYS_SDO16_STATUS 331

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 6.

Library

Trident/Tri-GP (TRDLIB)

This function was added to the library in v1.120 of TRDLIB, first released with TriStation 1131 v4.6.

Page 344: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

332 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

SYS_SERIAL_PORTResets statistics for one or more serial ports.

SyntaxMY_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 359 Input Parameters

Name Data Type Description

CI BOOL Enables SYS_SERIAL_PORT.

IOP DINT I/O Processor (1).

SLOT DINT Baseplate 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 360 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.

Page 345: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

SYS_SERIAL_PORT 333

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_VARMY_SYS_SERIAL_PORT( RESET_STATS_SERIAL_1:=TRUE, RESET_STATS_SERIAL_2:=TRUE, RESET_STATS_SERIAL_3:=TRUE );

Runtime Errors

Upon detection of a runtime error condition, the function block returns the indicated values and sets the error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function block.

Application Notes

• Can be used in Safety or Control applications.

• Exactly Once: each instance should be executed exactly once per scan.

Library

Trident/Tri-GP (TRDLIB)

Condition Return Value Error Flags

If ERROR_NUM is non-zero Reset all BOOL outputs to false BADPARAM, ERROR

Page 346: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

334 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

SYS_SET_APP_LOCKTurns the application lock on or off.

Syntaxn1 := SYS_SET_APP_LOCK( b1 ) ;

Description

The SYS_SET_APP_LOCK function turns the application lock on or off.

The application lock controls the TriStation 1131 permissions for performing application changes. When locked, TriStation 1131 cannot download changes, download all, set variable values, or disable points on a Trident or Tri-GP controller.

Invoke function block SYS_MP_STATUS to read APP_LOCKED.

Example(* Lock the application. *)

Table 361 Input Parameters

Name Data Type Description

VALUE BOOL True means locked; false means unlocked.

Table 362 Return Value

Data Type Description

DINT Error Number:

• 0 =No error.

• –1 =The IOP is invalid.

• –2 =The slot is not valid.

• –3 =The module is not configured.

• –4 =The module is the wrong type.

CAUTIONOnce 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.

Page 347: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

SYS_SET_APP_LOCK 335

TriStation 1131 Libraries Reference

VAR n : DINT; END_VARn := 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/Tri-GP (TRDLIB)

Condition Return Value Error Flags

If error number is non-zero. Error number BADPARAM, ERROR

Page 348: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

336 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

SYS_SET_PROG_ALARMTurns the programmable alarm on or off.

Syntaxn1 := 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 or Tri-GP MP module.

Invoke function block SYS_MP_STATUS to read PROG_ALARM_ON.

Example(* Turn the blue programmable alarm indicator on. *)VAR n : DINT; END_VARn := 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.

Table 363 Input Parameters

Name Data Type Description

VALUE BOOL True means alarm on; false means alarm off.

Table 364 Return Value

Data Type Description

DINT Error Number:

• 0 =No error.

• –1 =The IOP is invalid.

• –2 =The slot is not valid.

• –3 =The module is not configured.

• –4 =The module is the wrong type.

Condition Return Value Error Flags

If error number is non-zero. Error number BADPARAM, ERROR

Page 349: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

SYS_SET_PROG_ALARM 337

TriStation 1131 Libraries Reference

Application Notes

Can be used in Safety or Control applications.

Library

Trident/Tri-GP (TRDLIB)

Page 350: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

338 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

SYS_SET_REMOTE_WRT_ENBLTurns remote write enable on or off.

Syntaxn1 := 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 or Tri-GP controller.

Invoke function block SYS_MP_STATUS to read REMOTE_WRT_ENBL.

Example(* Allow writes from remote hosts. *)VAR n : DINT; END_VARn := 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.

Table 365 Input Parameters

Name Data Type Description

VALUE BOOL True means enable writes; false means disable writes.

Table 366 Return Value

Data Type Description

DINT Error Number:

• 0 =No error.

• –1 =The IOP is invalid.

• –2 =The slot is not valid.

• –3 =The module is not configured.

• –4 =The module is the wrong type.

Condition Return Value Error Flags

If error number is non-zero. Error number BADPARAM, ERROR

Page 351: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

SYS_SET_REMOTE_WRT_ENBL 339

TriStation 1131 Libraries Reference

Application Notes

Can be used in Safety or Control applications.

Library

Trident/Tri-GP (TRDLIB)

Page 352: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

340 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

SYS_SHUTDOWNEnables a system shutdown according to industry guidelines.

SyntaxMY_SYS_SHUTDOWN( CI:=b1, IO_CO:=b2, IO_TMR:=b3, IO_GE_DUAL:=b4, IO_GE_SINGLE:=b5, IO_NO_VOTER_FAULTS:=b6, MAX_TIME_DUAL:=t1, MAX_TIME_SINGLE:=t2, MAX_SCAN_TIME:=t3 ) ;

Table 367 Input Parameters

Name Data Type Description

CI BOOL Enables SYS_SHUTDOWN.

IO_CO BOOL 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 368 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

ALARM_PROGRAMMING_PERMITTED

BOOL True if application changes are permitted

ALARM_REMOTE_ACCESS BOOL True if remote-host writes are enabled

Page 353: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

SYS_SHUTDOWN 341

TriStation 1131 Libraries Reference

Description

The SYS_SHUTDOWN function block enables a system shutdown according to industry guidelines. For more information, see the Safety Considerations Guide for your controller.

Example

For shutdown examples, see this sample project:

• TdTUV.pt2 (For Trident or Tri-GP controllers)

Note See Sample Projects on page 7 for information about where to find this project on the PC where you installed TriStation 1131.

Runtime Errors

Upon detection of a runtime error condition, the function block returns the indicated values and sets the error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function block.

If a programming error or configuration error occurs, then CO is false and the error number is non-zero. For error numbers, see the description of the ERROR output.

Application Notes

Can be used in Safety or Control applications.

Library

Trident/Tri-GP (TRDLIB)

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 368 Output Parameters (continued)

Name Data Type Description

Page 354: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

342 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

SYS_SYSTEM_STATUSGets the status of an entire Trident or Tri-GP system, including Main Processors, I/O modules, communication, power, and time.

SyntaxMY_SYS_SYSTEM_STATUS( CI:=b1 ) ;

Table 369 Input Parameters

Name Data Type Description

CI BOOL Enables SYS_SYSTEM_STATUS.

Table 370 Output Parameters

Name Data Type Description

CO BOOL 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.

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.

Page 355: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

SYS_SYSTEM_STATUS 343

TriStation 1131 Libraries Reference

Description

The SYS_SYSTEM_STATUS function block gets the status of an entire Trident or Tri-GP system, including Main Processors, I/O modules, communication, power, and time.

If CI = false, then CO = false and no operation occurs (no output changes). If CI = true, then CO = true if no errors occur (ERROR_NUM=0).

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 (1–12)

DAY DINT The day of the month (1–31)

HOUR DINT The hour (0–23)

MINUTE DINT The minute (0–59)

SECOND DINT The second (0–59)

MILLISECOND DINT The millisecond (0–999)

MICROSECOND DINT The millisecond (0–999)

RELATIVE_SECONDS DINT The relative seconds since January 1, 1970

DAY_OF_WEEK DINT The current day of the week (0–6, 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 370 Output Parameters (continued)

Name Data Type Description

Page 356: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

344 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

Each digit of the DWORD for the NODE_OK... parameters corresponds to four nodes in the given range of the parameter. The following diagram illustrates which nodes each digit corresponds to:

For example, if the DWORD for NODE_OK_01_32 contains "5000," reading right to left indicates:

0 = 0000, Nodes 1-4 Not OK

0 = 0000, Nodes 5-8 Not OK

0 = 0000, Nodes 9-12 Not OK

5 = 0101, Nodes 13 and 15 OK, Nodes 14 and 16 Not OK

ExampleVAR MY_SYS : SYS_SYSTEM_STATUS ; END_VARVAR NO_SYSTEM_FAULTS : BOOL ; END_VARMY_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 6.

Library

Trident/Tri-GP (TRDLIB)

Condition Return Value Error Flags

If ERROR_NUM is non-zero Reset all outputs except ERROR_NUM to zero. BADPARAM, ERROR

32

31

30

29

28

27

26

25

24

23

21

22

20

19

18

17

16

15

14

13

12

11

10

09

08

07

06

05

04

03

02

01

1 2 3 4 5 6 7 8Digit

Node Number

NODE_OK_01_32 or NODE_REDUNDANT_01_32

Layout

64

63

62

61

60

59

58

57

56

55

53

54

52

51

50

49

48

47

46

45

44

43

42

41

40

39

38

37

36

35

34

33

1 2 3 4 5 6 7 8Digit

Node Number

NODE_OK_33_64 or NODE_REDUNDANT_33_64

Layout

Page 357: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

SYS_VOTE_MODE 345

TriStation 1131 Libraries Reference

SYS_VOTE_MODEConverts redundancy status.

SyntaxMY_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 371 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 372 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 373 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

Othera

a. If an error in the inputs occurs, then CO is false, the mode outputs are false, and the function block reports a bad parameter error (BADPARAM).

F F F F

Page 358: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

346 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

Example

For shutdown examples, see this sample project:

• TdTUV.pt2 (For Trident or Tri-GP controllers)

Note See Sample Projects on page 7 for information about where to find this project on the PC where you installed TriStation 1131.

Runtime Errors

Upon detection of a runtime error condition, the function block returns the indicated values and sets the error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function block.

Application Notes

• Can be used in Safety or Control applications.

• Space Saver: a single instance can be executed more than once per scan to reduce memory usage and increase performance. For directions, see Using a Space Saver Function Block on page 6.

Library

Trident/Tri-GP (TRDLIB)

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

Page 359: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TAN 347

TriStation 1131 Libraries Reference

TANCalculates the tangent of an angle.

Syntax

y := TAN( x ) ;

Description

The TAN function returns the tangent of an angle given in radians.

ExampleVAR y : REAL; END_VARy := 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 374 Input Parameters

Name Data Type Description

x ANY_REAL The angle, in radians.

Table 375 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

Page 360: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

348 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

TCJ_CONVConverts a Type J thermocouple input into degrees Celsius and returns the result.

Syntaxy := 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 376 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 377 Return Value

Data Type Description

REAL The temperature in degrees Celsius.

WARNINGThe 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.

Page 361: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TCJ_CONV 349

TriStation 1131 Libraries Reference

Application Notes

Can be used in Safety or Control applications.

Library

Triconex (TCXLIB)

Page 362: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

350 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

TCK_CONVConverts a Type K thermocouple input into degrees Celsius and returns the result.

Syntaxy := 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.

Runtime Errors

None.

Table 378 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 379 Return Value

Data Type Description

REAL The temperature in degrees Celsius.

WARNINGThe 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.

Page 363: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TCK_CONV 351

TriStation 1131 Libraries Reference

Application Notes

Can be used in Safety or Control applications.

Library

Triconex (TCXLIB)

Page 364: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

352 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

TDD_IProvides a time delay to de-energize.

SyntaxMY_TDD_I( I1:=b1, TGT:=n1 ) ;

Description

The TDD_I function block provides a time delay to de-energize. The delay time is given in integer milliseconds. If the input is true, then the output is true. After the input changes to false, the output remains true for the specified delay time, then the output changes to false.

Note If TGT is within one scan period of 2147483647 milliseconds (25 days), then the time accumulator can overflow to a negative value.

You must invoke an instance of TDD_I exactly once per scan.

ExampleVAR MY_TDD_I : TDD_I ; END_VARVAR b1, b2 : BOOL ; END_VARMY_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 380 Input Parameters

Name Data Type Description

I1 BOOL The input state.

TGT DINT The target delay time in integer milliseconds.

Table 381 Output Parameters

Name Data Type Description

Q1 BOOL The output state.

Page 365: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TDD_R 353

TriStation 1131 Libraries Reference

TDD_RProvides a time delay to de-energize.

SyntaxMY_TDD_R( I1:=b1, TGT:=x1 ) ;

Description

The TDD_R function block provides a time delay to de-energize. The delay time is given in real seconds. If the input is true, then the output is true. After the input changes to false, the output remains true for the specified delay time, then the output changes to false.

You must invoke an instance of TDD_R exactly once per scan.

Note The rounding error in the time accumulator increases with time until the accumulator eventually stops. The rounding error in seconds is less than ACC ACC (50,000,000 T), where ACC is the accumulated time in seconds and T is the scan period in seconds. The accumulator stops after ACC > 16,000,000 T. For example, if the scan period is 20 milliseconds, then after one hour, the rounding error is less than 13 seconds.

ExampleVAR MY_TDD_R : TDD_R ; END_VARVAR b1, b2 : BOOL ; END_VARMY_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.

Table 382 Input Parameters

Name Data Type Description

I1 BOOL The input state.

TGT REAL The target delay time in real seconds.

Table 383 Output Parameters

Name Data Type Description

Q1 BOOL The output state.

Page 366: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

354 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.

• Can be used in CEM Cause, Effect, and Intersection cells.

Library

Standard (STDLIB)

Page 367: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TDE_I 355

TriStation 1131 Libraries Reference

TDE_IProvides a time delay to energize.

SyntaxMY_TDE_I( I1:=b1, TGT:=n1 ) ;

Description

The TDE_I function block provides a time delay to energize. The delay time is given in integer milliseconds. If the input is false, then the output is false. After the input changes to true, the output remains false for the specified delay time, then the output changes to true.

Note If TGT is within one scan period of 2147483647 milliseconds (25 days), then the time accumulator can overflow to a negative value.

You must invoke an instance of TDE_I exactly once per scan.

ExampleVAR MY_TDE_I : TDE_I ; END_VARVAR b1, b2 : BOOL ; END_VARMY_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 384 Input Parameters

Name Data Type Description

I1 BOOL The input state.

TGT DINT The target delay time in integer milliseconds.

Table 385 Output Parameters

Name Data Type Description

Q1 BOOL The output state.

Page 368: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

356 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

TDE_RProvides a time delay to energize.

SyntaxMY_TDE_R( I1:=b1, TGT:=x1 ) ;

Description

The TDE_R function block provides a time delay to energize. The delay time is given in real seconds. If the input is false, then the output is false. After the input changes to true, the output remains false for the specified delay time, then the output changes to true.

You must invoke an instance of TDE_R exactly once per scan.

Note The rounding error in the time accumulator increases with time until the accumulator eventually stops. The rounding error in seconds is less than ACC ACC (50,000,000 T), where ACC is the accumulated time in seconds and T is the scan period in seconds. The accumulator stops after ACC > 16,000,000 T. For example, if the scan period is 20 milliseconds, then after one hour, the rounding error is less than 13 seconds.

ExampleVAR MY_TDE_R : TDE_R ; END_VARVAR b1, b2 : BOOL ; END_VARMY_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.

Table 386 Input Parameters

Name Data Type Description

I1 BOOL The input state.

TGT REAL The target delay time in real seconds.

Table 387 Output Parameters

Name Data Type Description

Q1 BOOL The output state.

Page 369: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TDE_R 357

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)

Page 370: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

358 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

TIMEA 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 In TriStation 1131 v4.4 and later, the syntax of the TIME data type is not case-sensitive.

Application Notes

• Can be used in Safety or Control applications.

• Can be used in CEM Cause, Effect, and Intersection cells.

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

Page 371: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TIME_TO_SECS 359

TriStation 1131 Libraries Reference

TIME_TO_SECSConverts time to number of seconds.

Syntaxy := TIME_TO_SECS( t ) ;

Description

The TIME_TO_SECS function converts time to number of seconds.

ExampleVAR t : TIME ; y : LREAL ; END_VARt := 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 388 Input Parameters

Name Data Type Description

t TIME The time.

Table 389 Return Value

Data Type Description

LREAL The number of seconds.

Condition Return Value Error Flags

If t is out of range. NAN BADPARAM, ERROR

Page 372: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

360 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

TIME_TO_SECS_REALConverts time to number of seconds.

Syntaxy := TIME_TO_SECS_REAL( t ) ;

Description

The TIME_TO_SECS_REAL function converts time to number of seconds.

ExampleVAR t : TIME ; y : REAL ; END_VARt := 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 390 Input Parameters

Name Data Type Description

t TIME The time.

Table 391 Return Value

Data Type Description

REAL The number of seconds.

Condition Return Value Error Flags

If t is out of range. NAN BADPARAM, ERROR

Page 373: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TIMEADJ 361

TriStation 1131 Libraries Reference

TIMEADJAdjusts the calendar clock.

SyntaxMY_TIMEADJ( CI:=b1, MS:=n1 ) ;

Description

The TIMEADJ function block adjusts the calendar clock.

CI is the control input. Call the function block with CI=true to adjust the clock. Then change CI to false for the next evaluation.

Note You must clear CI to 0 (False) after adjusting the clock.

MS is the number of milliseconds, positive or negative, by which the clock should be adjusted.

CO is the control output. The function block sets CO to true after the clock is adjusted. CO is false if CI is false or if an error is detected.

Example(* * Subtract 700 milliseconds from the clock. *)VAR MY_TIMEADJ : TIMEADJ ; END_VARVAR DO_ADJUST : BOOL ; END_VARMY_TIMEADJ( CI:=DO_ADJUST, MS:=-700 ) ;DO_ADJUST := false ;

Runtime Errors

Table 392 Input Parameters

Name Data Type Description

CI BOOL Enables TIMEADJ.

MS DINT The number of milliseconds, positive or negative, to adjust the clock.

Table 393 Output Parameters

Name Data Type Description

CO BOOL True if TIMEADJ executes successfully.

CAUTIONTriconex 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.

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

Page 374: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

362 Chapter 2 Functions and Data Types

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.

• Only Once: each instance should be executed only once per scan, but does not need to be executed every scan.

Library

Triconex (TCXLIB)

Page 375: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TIMESET 363

TriStation 1131 Libraries Reference

TIMESETSets the calendar clock.

SyntaxMY_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.

Note You must clear CI to 0 (False) after adjusting the clock.

GMT is the Greenwich mean time given in number of seconds elapsed since 00:00:00 on January 1, 1970. GMT must be a positive number.

MS is the number of milliseconds (0-999) past the time given in GMT.

CO is the control output. CO=true indicates that the time was successfully set. CO=false indicates that the time was not set. CO is false if an error is detected—for example, if MS is less than 0 or greater than 999.

As a general rule, do not set the time back to previous dates.

Table 394 Input Parameters

Name Data Type Description

CI BOOL Enables TIMESET.

GMT DINT The number of seconds elapsed since 00:00:00 Greenwich mean time, January 1, 1970. GMT must be a positive number.

MS DINT The number of milliseconds (0–999) past the time given in GMT.

Table 395 Output Parameters

Name Data Type Description

CO BOOL True if TIMESET executes successfully.

CAUTIONTriconex recommends using the TIMESET function no more than once a day. Using TIMESET more frequently can result in excessive time adjustments to a network and may result in Main Processor re-education. Tricon version 9 systems do not allow you to set the time to a date earlier than December 31, 1993.

Page 376: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

364 Chapter 2 Functions and Data Types

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_VARVAR SET_THE_TIME : BOOL ; END_VARMY_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

Page 377: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TMR 365

TriStation 1131 Libraries Reference

TMRProvides a timer to replace the functionality of the TMR coil in TriStation MSW.

SyntaxMY_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 396 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 397 Output Parameters

Name Data Type Description

Q BOOL The current state.

ET TIME The elapsed time accumulator.

Page 378: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

366 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

ExampleVAR MY_TMR : TMR ; END_VARVAR b1, b2 : BOOL ; END_VARMY_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)

Page 379: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TMR_I 367

TriStation 1131 Libraries Reference

TMR_IProvides a timer to replace the functionality of the TMR coil in TriStation MSW.

SyntaxMY_TMR_I( IN:=b1, RESET:=b2, PT:=n1 ) ;

Description

The TMR_I function block replaces the functionality of the TMR coil in TriStation MSW. It differs from TMR in that the time is in milliseconds.

While the input IN is true, the timer increments the elapsed time accumulator until its value is greater than or equal to the preset time (input PT). After the preset time is reached, the output Q remains true until reset.

RESET clears Q and resets ET to 0.

Input IN adds the previous scan period to ET. If IN is true and ET is greater than or equal to PT, then the function block copies PT to ET and sets Q. If IN is false, then ET holds its current value until reset

PT is the preset time in milliseconds which means the timer expires when ET is greater than or equal to PT.

Q indicates when the timer expires. Q is set to true when ET increases to PT or beyond. RESET clears Q.

ET accumulates the elapsed time in milliseconds while input IN is true. ET starts at 0 milliseconds. While input IN is true, the timer adds the previous scan period to ET until its value is greater than or equal to PT. After the preset time is reached, the timer sets ET equal to PT.

Note If PT is within one scan period of 2147483647 milliseconds (25 days), then the elapsed time accumulator can overflow to a negative value.

You must invoke an instance of TMR_I exactly once per scan.

Table 398 Input Parameters

Name Data Type Description

IN BOOL Enables TMR_I.

RESET BOOL Resets TMR_I.

PT DINT The preset time in milliseconds.

Table 399 Output Parameters

Name Data Type Description

Q BOOL The current state.

ET DINT The elapsed time accumulator in milliseconds.

Page 380: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

368 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

ExampleVAR MY_TMR_I : TMR_I ; END_VARVAR b1, b2 : BOOL ; END_VARMY_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)

Page 381: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TMR_R 369

TriStation 1131 Libraries Reference

TMR_RProvides a timer to replace the functionality of the TMR coil in TriStation MSW.

SyntaxMY_TMR_R( IN:=b1, RESET:=b2, PT:=x1 ) ;

Description

The TMR_R function block replaces the functionality of the TMR coil in TriStation MSW. It differs from TMR in that the time is in seconds.

While the input IN is true, the timer increments the elapsed time accumulator until its value is greater than or equal to the preset time (input PT). After the preset time is reached, the output Q remains true until reset.

RESET clears Q and resets ET to 0.0.

Input IN adds the previous scan period to ET. If IN is true and ET is greater than or equal to PT, then the function block copies PT to ET and sets Q. If IN is false, then ET holds its current value until reset

PT is the preset time in milliseconds which means the timer expires when ET is greater than or equal to PT.

Q indicates when the timer expires. Q is set to true when ET increases to PT or beyond. RESET clears Q.

ET accumulates the elapsed time in seconds while input IN is true. ET starts at 0.0 seconds. While input IN is true, the timer adds the previous scan period to ET until its value is greater than or equal to PT. After the preset time is reached, the timer sets ET equal to PT.

You must invoke an instance of TMR_R exactly once per scan.

Note The rounding error in the elapsed time accumulator increases with time until the accumulator eventually stops. The rounding error in seconds is less than ET ET (50,000,000 T), where ET is the elapsed time in seconds and T is the scan period in seconds. The elapsed time accumulator stops after ET > 16,000,000 T. For example, if the scan period is 20 milliseconds, then after one hour, the rounding error is less than 13 seconds.

Table 400 Input Parameters

Name Data Type Description

IN BOOL Enables TMR_I.

RESET BOOL Resets TMR_I.

PT REAL The preset time in seconds.

Table 401 Output Parameters

Name Data Type Description

Q BOOL The current state.

ET REAL The elapsed time accumulator in seconds.

Page 382: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

370 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

ExampleVAR MY_TMR_R : TMR_R ; END_VARVAR b1, b2 : BOOL ; END_VARMY_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)

Page 383: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TOD 371

TriStation 1131 Libraries Reference

TODA 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

Page 384: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

372 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

TOFDelays the falling edge of a pulse.

SyntaxMY_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 402 Input Parameters

Name Data Type Description

IN BOOL The input pulse.

PT TIME The pulse time.

Table 403 Output Parameters

Name Data Type Description

Q BOOL The output pulse.

ET TIME The elapsed time.

Page 385: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TOF 373

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.

Page 386: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

374 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

ExampleVAR MY_TOF : TOF ; END_VARVAR b1, b2 : BOOL ; END_VARMY_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)

Page 387: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TOGGLE 375

TriStation 1131 Libraries Reference

TOGGLEReplaces the functionality of the TGL coil in TriStation MSW.

SyntaxMY_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.

ExampleVAR MY_TOGGLE : TOGGLE ; END_VARMY_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 404 Input Parameters

Name Data Type Description

IN BOOL Enables TOGGLE.

RESET BOOL Resets TOGGLE.

Table 405 Output Parameters

Name Data Type Description

Q BOOL The current state.

Table 406 Truth Table

IN RESET Q

false false no change

false true false

true false not Q

true true false

Page 388: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

376 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, Effect, and Intersection cells.

Library

Triconex (TCXLIB)

Page 389: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TON 377

TriStation 1131 Libraries Reference

TONDelays the rising edge of a pulse.

SyntaxMY_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 407 Input Parameters

Name Data Type Description

IN BOOL The input pulse.

PT TIME The pulse time.

Table 408 Output Parameters

Name Data Type Description

Q BOOL The output pulse.

ET TIME The elapsed time.

Page 390: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

378 Chapter 2 Functions and Data Types

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.

ExampleVAR MY_TON : TON ; END_VARVAR b1, b2 : BOOL ; END_VARMY_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)

Page 391: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TP 379

TriStation 1131 Libraries Reference

TPGenerates a timed pulse.

SyntaxMY_TP( IN:=b1, PT:=t1 ) ;

Description

The TP function block generates a pulse of duration PT starting on the rising edge of input IN.

IN is an input pulse. The rising edge of IN starts the timer, setting Q to true. While Q is true, the timer ignores IN.

PT gives the requested duration of the pulse. When Q is true and ET is greater than or equal to PT, the timer resets Q to false.

Q is the output pulse. The timer sets Q true on the rising edge of IN. Q remains true for time PT, and then changes to false.

ET is the elapsed time from the rising edge of Q while Q is true. After the falling edge of Q, ET is equal to PT while input IN remains true. ET is zero if IN and Q are both false.

ExampleVAR MY_TP : TP ; END_VARVAR b1, b2 : BOOL ; END_VARMY_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 409 Input Parameters

Name Data Type Description

IN BOOL The input pulse.

PT TIME The pulse time.

Table 410 Output Parameters

Name Data Type Description

Q BOOL The output pulse.

ET TIME The elapsed time.

Page 392: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

380 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, Effect, and Intersection cells.

Library

Standard (STDLIB)

Page 393: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TP_I 381

TriStation 1131 Libraries Reference

TP_IGenerates a timed pulse.

SyntaxMY_TP_I( IN:=b1, PT:=n1 ) ;

Description

The TP_I function block generates a pulse of width PT milliseconds starting on the rising edge of input IN.

IN is an input pulse. The rising edge of IN starts the timer, setting Q to true. While Q is true, the timer ignores IN.

PT gives the requested duration of the pulse in milliseconds. When Q is true and the pulse width is greater than or equal to PT milliseconds, the timer resets Q to false.

Q is the output pulse. The timer sets Q true on the rising edge of IN. Q remains true for time PT milliseconds, and then changes to false.

Note If PT is within one scan period of 2147483647 milliseconds (25 days), then the time accumulator can overflow to a negative value.

You must invoke an instance of TP_I exactly once per scan.

ExampleVAR MY_TP_I : TP_I ; END_VARVAR b1, b2 : BOOL ; END_VARMY_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 411 Input Parameters

Name Data Type Description

IN BOOL The input pulse.

PT DINT The pulse time in milliseconds.

Table 412 Output Parameters

Name Data Type Description

Q BOOL The output pulse.

Page 394: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

382 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.

• Can be used in CEM Cause, Effect, and Intersection cells.

Library

Standard (STDLIB)

Page 395: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TP_R 383

TriStation 1131 Libraries Reference

TP_RGenerates a timed pulse.

SyntaxMY_TP_R( IN:=b1, PT:=x1 ) ;

Description

The TP_R function block generates a pulse of width PT seconds starting on the rising edge of input IN.

IN is an input pulse. The rising edge of IN starts the timer, setting Q to true. While Q is true, the timer ignores IN.

PT gives the requested duration of the pulse in seconds. When Q is true and the pulse width is greater than or equal to PT seconds, the timer resets Q to false.

Q is the output pulse. The timer sets Q true on the rising edge of IN. Q remains true for time PT seconds, and then changes to false.

You must invoke an instance of TP_R exactly once per scan.

Note The rounding error in the time accumulator increases with time until the accumulator eventually stops. The rounding error in seconds is less than ACC ACC (50,000,000 T), where ACC is the accumulated time in seconds and T is the scan period in seconds. The accumulator stops after ACC > 16,000,000 T. For example, if the scan period is 20 milliseconds, then after one hour, the rounding error is less than 13 seconds.

ExampleVAR MY_TP_R : TP_R ; END_VARVAR b1, b2 : BOOL ; END_VARMY_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 413 Input Parameters

Name Data Type Description

IN BOOL The input pulse.

PT REAL The pulse time in seconds.

Table 414 Output Parameters

Name Data Type Description

Q BOOL The output pulse.

Page 396: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

384 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.

• Can be used in CEM Cause, Effect, and Intersection cells.

Library

Standard (STDLIB)

Page 397: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TR_64_POINT_STATUS 385

TriStation 1131 Libraries Reference

TR_64_POINT_STATUSGets point information, specifically LOAD/FUSE and diagnostic status for up to 64 points, from a Tricon controller.

SyntaxMY_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 415 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 416 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).

Page 398: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

386 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

Example(* Get the status for chassis 1 slot 5. *)VAR MY_TR_64_POINT_STATUS : TR_64_POINT_STATUS ; END_VARMY_TR_64_POINT_STATUS( CI:=TRUE, CHASSIS:=1, SLOT:=5 ) ;

Runtime Errors

Upon detection of a runtime error condition, the function block returns the indicated values and sets the error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function block.

Application Notes

• Can be used in Safety or Control applications.

• Space Saver: a single instance can be executed more than once per scan to reduce memory usage and increase performance. For directions, Using a Space Saver Function Block on page 6.

Library

Tricon (TR1LIB/TX1LIB)

Condition Return Value Error Flags

If the chassis or slot is invalid. CO=false BADPARAM, ERROR

Page 399: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TR_CALENDAR 387

TriStation 1131 Libraries Reference

TR_CALENDARGets calendar values from a Tricon controller.

SyntaxMY_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_VARVAR TODAY : DINT ; END_VARNOW() ;TODAY := NOW.DAY

Runtime Errors

None.

Table 417 Input Parameters

Name Data Type Description

CI BOOL Enables TR_CALENDAR.

Table 418 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 (1–12).

DAY DINT The day of the month (1–31).

HOUR DINT The hour (0–23).

MINUTE DINT The minute (0–59).

SECOND DINT The second (0–59).

MILLISEC DINT The millisecond (0–999).

WEEKDAY DINT The day of the week (0–6, 0=Sunday).

RELSEC DINT The seconds since Jan 01 1970 00:00:00.

Page 400: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

388 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 6.

Library

Tricon (TR1LIB/TX1LIB)

Page 401: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TR_CHASSIS_STATUS 389

TriStation 1131 Libraries Reference

TR_CHASSIS_STATUSGets the chassis status from a Tricon controller.

SyntaxMY_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_VARMY_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 419 Input Parameters

Name Data Type Description

CI BOOL Enables TR_CHASSIS_STATUS.

CHASSIS DINT The chassis number.

Table 420 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

Page 402: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

390 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 6.

Library

Tricon (TR1LIB/TX1LIB)

Page 403: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TR_CLEAR_FLTS 391

TriStation 1131 Libraries Reference

TR_CLEAR_FLTSClears all faults in the system.

SyntaxERROR_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_VARERROR_NUMBER := TR_CLEAR_FLTS( CLEAR_FLTS := TRUE );

Runtime Errors

Upon detection of a runtime error, the function resets ENO and sets the BADPARAM status flag. For more information about error flags and runtime errors, see the CHK_ERR function block.

Application Notes

Can be used in Safety or Control applications.

Library

Tricon (TX1LIB)

This function was added to the library in v1.62 of TX1LIB, first released with TriStation 1131 v4.1.419.

Table 421 Input Parameters

Name Data Type Description

CLEAR_FLTS BOOL Clears fault alarms.

Table 422 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

Page 404: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

392 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

TR_CRITICAL_IOAccumulates the status of safety-critical I/O modules in a Tricon controller.

SyntaxMY_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 Safety Considerations Guide for Tricon Systems.

Instructions for Use

The following instructions for using the TR_CRITICAL_IO function block apply to the Structured Text (ST) language.

Table 423 Input Parameters

Name Data Type Description

CI BOOL Enables TR_CRITICAL_IO.

INIT BOOL Initializes TR_CRITICAL_IO.

CHASSIS DINT The chassis number (1–15).

SLOT DINT The physical slot number.

APP DINT The application number (1-2).

RELAY_OK BOOL The relay is energized and not stuck.

Table 424 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 1–15.

• –2 =Invalid chassis or slot.

• –3 =The module is not configured.

• –5 =An invalid application number is used.

• –6 =Not initialized.

Page 405: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TR_CRITICAL_IO 393

TriStation 1131 Libraries Reference

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:

• ExTUV.pt2 (For Tricon controllers)

Note See Sample Projects on page 7 for information about where to find this project on the PC where you installed TriStation 1131.

Runtime Errors

Upon detection of a runtime error condition, the function block returns the indicated values and sets the error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function block.

Condition Return Value Error Flags

If ERROR is non-zero Reset all BOOL outputs to false BADPARAM, ERROR

Page 406: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

394 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

Application Notes

Can be used in Safety or Control applications.

Library

Tricon (TR1LIB/TX1LIB)

Page 407: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TR_MP_STATUS 395

TriStation 1131 Libraries Reference

TR_MP_STATUSGets the status of the Main Processor.

SyntaxMY_TR_MP_STATUS( CI:=b1 ) ;

Description

The TR_MP_STATUS function block gets the status of the Main Processor.

Example(* Get the main processor status. *)VAR MY_TR_MP_STATUS : TR_MP_STATUS ; END_VARMY_TR_MP_STATUS() ;

Runtime Errors

None.

Table 425 Input Parameters

Name Data Type Description

CI BOOL Enables TR_MP_STATUS.

Table 426 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.

Page 408: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

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 6.

Library

Tricon (TR1LIB/TX1LIB)

Page 409: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TR_PEER_STATUS 397

TriStation 1131 Libraries Reference

TR_PEER_STATUSGets the Peer-to-Peer status of a node.

SyntaxMY_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:

• ExPeer.pt2 (For Tricon controllers)

• TdPeer.pt2 (For Trident or Tri-GP controllers)

Note See Sample Projects on page 7 for information about where to find these projects on the PC where you installed TriStation 1131.

Runtime Errors

Upon detection of a runtime error condition, the function block returns the indicated values and sets the error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function block.

Table 427 Input Parameters

Name Data Type Description

CI BOOL Enables TR_PEER_STATUS.

NODE DINT The node number.

Table 428 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

Page 410: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

398 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 6.

Library

Tricon (TR1LIB/TX1LIB)

Page 411: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TR_POINT_STATUS 399

TriStation 1131 Libraries Reference

TR_POINT_STATUSGets the status of a point from a Tricon controller.

SyntaxMY_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_VARMY_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 429 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 430 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

Page 412: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

400 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 6.

Library

Tricon (TR1LIB/TX1LIB)

Page 413: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TR_PORT_STATUS 401

TriStation 1131 Libraries Reference

TR_PORT_STATUSGets the status of a Tricon Communication Module (TCM), Network Communication Module (NCM), or an Advanced Communication Module (ACM).

SyntaxMY_TR_PORT_STATUS( CI:=b1 ) ;

Description

The TR_PORT_STATUS function block gets the status of aTricon Communication Module (TCM), Network Communication Module (NCM), or an Advanced Communication Module (ACM). The NET1 status is not used with the ACM. When there is more than one communication module installed, and both are in the same type of slot (left or right), the corresponding status (NET1L/NET2L, and NET1R/NET2R, respectively) are not defined.

Example(* Get the port status. *)VAR MY_TR_PORT_STATUS : TR_PORT_STATUS ; END_VARMY_TR_PORT_STATUS() ;

Runtime Errors

None.

Table 431 Input Parameters

Name Data Type Description

CI BOOL Enables TR_PORT_STATUS.

Table 432 Output Parameters

Name Data Type Description

CO BOOL True if TR_PORT_STATUS executes successfully.

ICM_P5_OVFL BOOL The printer on port 5 has a buffer overflow.

ICM_P10_OVFL BOOL The printer on port 10 has a buffer overflow.

ICM_P5_RDY BOOL The printer on port 5 is ready.

ICM_P10_RDY BOOL The printer on port 10 is ready.

NCM_NET1L_OK BOOL Port 1 of a communication module in the left slot is operational.

NCM_NET2L_OK BOOL Port 2 of a communication module in the left slot is operational.

NCM_NET1R_OK BOOL Port 1 of a communication module in the right slot is. operational.

NCM_NET2R_OK BOOL Port 2 of a communication module in the right slot is operational.

Page 414: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

402 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 6.

Library

Tricon (TR1LIB/TX1LIB)

Page 415: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TR_PROGRAM_STATUS 403

TriStation 1131 Libraries Reference

TR_PROGRAM_STATUSGets the status of a Tricon program.

SyntaxMY_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_VARMY_TR_PROGRAM_STATUS() ;

Runtime Errors

None.

Table 433 Input Parameters

Name Data Type Description

CI BOOL Enables TR_PROGRAM_STATUS.

Table 434 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.

Page 416: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

404 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 6.

Library

Tricon (TR1LIB/TX1LIB)

Page 417: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TR_SCAN_STATUS 405

TriStation 1131 Libraries Reference

TR_SCAN_STATUSGets the status of a scan.

SyntaxMY_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_VARMY_TR_SCAN_STATUS() ;

Runtime Errors

None.

Table 435 Input Parameters

Name Data Type Description

CI BOOL Enables TR_SCAN_STATUS.

Table 436 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

Page 418: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

406 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 6.

Library

Tricon (TR1LIB/TX1LIB)

Page 419: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TR_SHUTDOWN 407

TriStation 1131 Libraries Reference

TR_SHUTDOWNEnables a Tricon system shutdown according to industry guidelines.

SyntaxMY_TR_SHUTDOWN( CI:=b1, IO_CO:=b2, IO_TMR:=b3, IO_GE_DUAL:=b4, IO_GE_SINGLE:=b5, IO_NO_VOTER_FLTS:=b6, IO_ERROR:=n1, MAX_TIME_DUAL:=t1, MAX_TIME_SINGLE:=t2, MAX_SCAN_TIME:=t3 ) ;

Table 437 Input Parameters

Name Data Type Description

CI BOOL Enables TR_SHUTDOWN.

IO_CO BOOL 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 438 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.

ALARM_RESPONSE_TIME BOOL True if actual scan time is greater than or equal to MAX_SCAN_TIME.

Page 420: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

408 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 Safety Considerations Guide for Tricon v9-v10 Systems.

Example

For shutdown examples, see this sample project:

• ExTUV.pt2 (For Tricon controllers)

Note See Sample Projects on page 7 for information about where to find this project on the PC where you installed TriStation 1131.

Runtime Errors

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_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 438 Output Parameters (continued)

Name Data Type Description

Page 421: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TR_SLOT_STATUS 409

TriStation 1131 Libraries Reference

TR_SLOT_STATUSGets the status of a Tricon controller slot.

SyntaxMY_TR_SLOT_STATUS( CI:=b1, CHASSIS:=n1, SLOT:=n2 ) ;

Description

The TR_SLOT_STATUS function block gets the status of a Tricon controller slot.

Example(* Get the status for chassis 1 slot 5. *)VAR MY_TR_SLOT_STATUS : TR_SLOT_STATUS ; END_VARMY_TR_SLOT_STATUS( CI:=TRUE, CHASSIS:=1, SLOT:=5 ) ;

Table 439 Input Parameters

Name Data Type Description

CI BOOL Enables TR_SLOT_STATUS.

CHASSIS DINT The chassis number.

SLOT DINT The physical slot number.

Table 440 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.

Page 422: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

410 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 6.

Library

Tricon (TR1LIB/TX1LIB)

Condition Return Value Error Flags

If the chassis or slot is invalid. CO=false BADPARAM, ERROR

Page 423: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TR_URCV_BOOL 411

TriStation 1131 Libraries Reference

TR_URCV_BOOLReceives up to 20 data values from a matching TR_USEND_BOOL function block on another Triconex controller.

SyntaxMY_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 Developer’s Guide.

Table 441 Input Parameters

Name Data Type Description

CI BOOL Enables TR_URCV_BOOL.

RECVID DINT The unique identifier for a TR_URCV_BOOL function block (1–99).

SENDNODE DINT Specifies which node sends data to a TR_URCV_BOOL function block (1–63).

SENDID DINT The unique identifier for a matching TR_USEND_BOOL function block in a sending controller (1–99).

N DINT The number of values to receive (1–20).

Table 442 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.

Page 424: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

412 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

Example

For Peer-to-Peer examples, see these sample projects:

• ExPeer.pt2 (For Tricon controllers)

• TdPeer.pt2 (For Trident or Tri-GP controllers)

Note See Sample Projects on page 7 for information about where to find these projects on the PC where you installed TriStation 1131.

Runtime Errors

For error numbers, see the description for the STATUS output.

Application Notes

• Can be used in Safety or Control applications.

• Exactly Once: each instance should be executed exactly once per scan.

Library

Tricon (TR1LIB/TX1LIB)

Condition Return Value Error Flags

If STATUS is greater than or equal to 100. ERROR=true None

Page 425: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TR_URCV_DINT 413

TriStation 1131 Libraries Reference

TR_URCV_DINTReceives up to 20 data values from a matching TR_USEND_DINT function block on another Triconex controller.

SyntaxMY_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 Developer’s Guide.

Table 443 Input Parameters

Name Data Type Description

CI BOOL Enables TR_URCV_DINT.

RECVID DINT The unique identifier for a TR_URCV_DINT function block (1–99).

SENDNODE DINT Specifies which node sends data to a TR_URCV_DINT function block (1–63).

SENDID DINT The unique identifier for a matching TR_USEND_DINT function block in a sending controller (1–99).

N DINT The number of values to receive (1–20).

Table 444 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.

Page 426: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

414 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

Example

For Peer-to-Peer examples, see these sample projects:

• ExPeer.pt2 (For Tricon controllers)

• TdPeer.pt2 (For Trident or Tri-GP controllers)

Note See Sample Projects on page 7 for information about where to find these projects on the PC where you installed TriStation 1131.

Runtime Errors

For error numbers, see the description for the STATUS output.

Application Notes

• Can be used in Safety or Control applications.

• Exactly Once: each instance should be executed exactly once per scan.

Library

Tricon (TR1LIB/TX1LIB)

Condition Return Value Error Flags

If STATUS is greater than or equal to 100. ERROR=true None

Page 427: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TR_URCV_DINT_32 415

TriStation 1131 Libraries Reference

TR_URCV_DINT_32Receives up to 32 data values from a matching TR_USEND_DINT_32 function block on another Triconex controller.

SyntaxMY_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 Developer’s Guide.

Table 445 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 (1–99).

SENDNODE DINT Specifies which node sends data to a TR_URCV_DINT_32 function block (1–63).

SENDID DINT The unique identifier for a matching TR_USEND_DINT_32 function block in a sending controller (1–99).

N DINT The number of values to receive (1–32).

Table 446 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.

Page 428: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

416 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

Example

For Peer-to-Peer examples, see these sample projects:

• ExPeer.pt2 (For Tricon controllers)

• TdPeer.pt2 (For Trident or Tri-GP controllers)

Note See Sample Projects on page 7 for information about where to find these projects on the PC where you installed TriStation 1131.

Runtime Errors

For error numbers, see the description for the STATUS output.

Application Notes

• Can be used in Safety or Control applications.

• Exactly Once: each instance should be executed exactly once per scan.

Library

Tricon (TR1LIB/TX1LIB)

Condition Return Value Error Flags

If STATUS is greater than or equal to 100. ERROR=true None

Page 429: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TR_URCV_REAL 417

TriStation 1131 Libraries Reference

TR_URCV_REALReceives up to 20 data values from a matching TR_USEND_REAL function block on another Triconex controller.

SyntaxMY_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 Developer’s Guide.

Table 447 Input Parameters

Name Data Type Description

CI BOOL Enables TR_URCV_REAL.

RECVID DINT The unique identifier for a TR_URCV_REAL function block (1–99).

SENDNODE DINT Specifies which node sends data to a TR_URCV_REAL function block (1–63).

SENDID DINT The unique identifier for a matching TR_USEND_REAL function block in a sending controller (1–99).

N DINT The number of values to receive (1–20).

Table 448 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.

Page 430: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

418 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

Example

For Peer-to-Peer examples, see these sample projects:

• ExPeer.pt2 (For Tricon controllers)

• TdPeer.pt2 (For Trident or Tri-GP controllers)

Note See Sample Projects on page 7 for information about where to find these projects on the PC where you installed TriStation 1131.

Runtime Errors

For error numbers, see the description for the STATUS output.

Application Notes

• Can be used in Safety or Control applications.

• Exactly Once: each instance should be executed exactly once per scan.

Library

Tricon (TR1LIB/TX1LIB)

Condition Return Value Error Flags

If STATUS is greater than or equal to 100. ERROR=true None

Page 431: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TR_URCV_REAL_32 419

TriStation 1131 Libraries Reference

TR_URCV_REAL_32Receives up to 32 data values from a matching TR_USEND_REAL_32 function block on another Triconex controller.

SyntaxMY_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_32 function block on another Triconex controller. For detailed descriptions of the input and output parameters, see Appendix B, Peer-to-Peer Parameters.

For information about setting the number of send and receive functions and determining data transfer time, see the TriStation 1131 Developer’s Guide.

Table 449 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 (1–99).

SENDNODE DINT Specifies which node sends data to a TR_URCV_REAL_32 function block (1–63).

SENDID DINT The unique identifier for a matching TR_USEND_REAL_32 function block in a sending controller (1–99).

N DINT The number of values to receive (1–32).

Table 450 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.

Page 432: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

420 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

Example

For Peer-to-Peer examples, see these sample projects:

• ExPeer.pt2 (For Tricon controllers)

• TdPeer.pt2 (For Trident or Tri-GP controllers)

Note See Sample Projects on page 7 for information about where to find these projects on the PC where you installed TriStation 1131.

Runtime Errors

For error numbers, see the description for the STATUS output.

Application Notes

• Can be used in Safety or Control applications.

• Exactly Once: each instance should be executed exactly once per scan.

Library

Tricon (TR1LIB/TX1LIB)

Condition Return Value Error Flags

If STATUS is greater than or equal to 100. ERROR=true None

Page 433: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TR_USEND_BOOL 421

TriStation 1131 Libraries Reference

TR_USEND_BOOLSends up to 20 data values to a matching TR_URCV_BOOL function block on another Triconex controller.

SyntaxMY_TR_USEND_BOOL( SENDFLG:=b1, SENDID:=n1, RECVNODE:=n2, RECVID:=n3, N:=n4, SD_01:=d1, ..., SD_20:=d20 ) ;

Table 451 Input Parameters

Name Data Type Description

SENDFLG BOOL Enables TR_USEND_BOOL.

SENDID DINT The unique identifier for a TR_USEND_BOOL function block (1–99).

RECVNODE DINT Specifies which controller node receives data from a TR_USEND_BOOL function block (1–63).

RECVID DINT The unique identifier for a matching TR_URCV_BOOL function block in a receiving controller (1–99).

N DINT The number of values to send (1–20).

SD_01

.

.

.

SD_20

BOOL

.

.

.

BOOL

Send data 01.

.

.

.

Send data 20.

Table 452 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.

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.

Page 434: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

422 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 Developer’s Guide.

Example

For Peer-to-Peer examples, see these sample projects:

• ExPeer.pt2 (For Tricon controllers)

• TdPeer.pt2 (For Trident or Tri-GP controllers)

Note See Sample Projects on page 7 for information about where to find these projects on the PC where you installed TriStation 1131.

Runtime Errors

For error numbers, see the description for the STATUS output.

Application Notes

• Can be used in Safety or Control applications.

• Exactly Once: each instance should be executed exactly once per scan.

Library

Tricon (TR1LIB/TX1LIB)

Condition Return Value Error Flags

If STATUS is greater than or equal to 100. ERROR=true None

Page 435: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TR_USEND_DINT 423

TriStation 1131 Libraries Reference

TR_USEND_DINTSends up to 20 data values to a matching TR_URCV_DINT function block on another Triconex controller.

SyntaxMY_TR_USEND_DINT( SENDFLG:=b1, SENDID:=n1, RECVNODE:=n2, RECVID:=n3, N:=n4, SD_01:=d1, ..., SD_20:=d20 ) ;

Table 453 Input Parameters

Name Data Type Description

SENDFLG BOOL Enables TR_USEND_DINT.

SENDID DINT The unique identifier for a TR_USEND_DINT function block (1–99).

RECVNODE DINT Specifies which controller node receives data from a TR_USEND_DINT function block (1–63).

RECVID DINT The unique identifier for a matching TR_URCV_DINT function block in a receiving controller (1–99).

N DINT The number of values to send (1–20).

SD_01

.

.

.

SD_20

DINT

.

.

.

DINT

Send data 01.

.

.

.

Send data 20.

Table 454 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.

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.

Page 436: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

424 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 Developer’s Guide.

Example

For Peer-to-Peer examples, see these sample projects:

• ExPeer.pt2 (For Tricon controllers)

• TdPeer.pt2 (For Trident or Tri-GP controllers)

Note See Sample Projects on page 7 for information about where to find these projects on the PC where you installed TriStation 1131.

Runtime Errors

For error numbers, see the description for the STATUS output.

Application Notes

• Can be used in Safety or Control applications.

• Exactly Once: each instance should be executed exactly once per scan.

Library

Tricon (TR1LIB/TX1LIB)

Condition Return Value Error Flags

If STATUS is greater than or equal to 100. ERROR=true None

Page 437: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TR_USEND_DINT_32 425

TriStation 1131 Libraries Reference

TR_USEND_DINT_32Sends up to 32 data values to a matching TR_URCV_DINT_32 function block on another Triconex controller.

SyntaxMY_TR_USEND_DINT_32( SENDFLG:=b1, SENDID:=n1, RECVNODE:=n2, RECVID:=n3, N:=n4, SD_01:=d1, ..., SD_32:=d32 ) ;

Table 455 Input Parameters

Name Data Type Description

SENDFLG BOOL Enables TR_USEND_DINT_32.

SENDID DINT The unique identifier for a TR_USEND_DINT_32 function block (1–99).

RECVNODE DINT Specifies which controller node receives data from a TR_USEND_DINT_32 function block (1–63).

RECVID DINT The unique identifier for a matching TR_URCV_DINT_32 function block in a receiving controller (1–99).

N DINT The number of values to send (1–32).

SD_01

.

.

.

SD_32

DINT

.

.

.

DINT

Send data 01.

.

.

.

Send data 32.

Table 456 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.

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.

Page 438: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

426 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 Developer’s Guide.

Example

For Peer-to-Peer examples, see these sample projects:

• ExPeer.pt2 (For Tricon controllers)

• TdPeer.pt2 (For Trident or Tri-GP controllers)

Note See Sample Projects on page 7 for information about where to find these projects on the PC where you installed TriStation 1131.

Runtime Errors

For error numbers, see the description for the STATUS output.

Application Notes

• Can be used in Safety or Control applications.

• Exactly Once: each instance should be executed exactly once per scan.

Library

Tricon (TR1LIB/TX1LIB)

Condition Return Value Error Flags

If STATUS is greater than or equal to 100. ERROR=true None

Page 439: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TR_USEND_REAL 427

TriStation 1131 Libraries Reference

TR_USEND_REALSends up to 20 data values to a matching TR_URCV_REAL function block on another Triconex controller.

SyntaxMY_TR_USEND_REAL( SENDFLG:=b1, SENDID:=n1, RECVNODE:=n2, RECVID:=n3, N:=n4, SD_01:=d1, ..., SD_20:=d20 ) ;

Table 457 Input Parameters

Name Data Type Description

SENDFLG BOOL Enables TR_USEND_REAL.

SENDID DINT The unique identifier for a TR_USEND_REAL function block (1–99).

RECVNODE DINT Specifies which controller node receives data from a TR_USEND_REAL function block (1–63).

RECVID DINT The unique identifier for a matching TR_URCV_REAL function block in a receiving controller (1–99).

N DINT The number of values to send (1–20).

SD_01

.

.

.

SD_20

REAL

.

.

.

REAL

Send data 01.

.

.

.

Send data 20.

Table 458 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.

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.

Page 440: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

428 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 Developer’s Guide.

Example

For Peer-to-Peer examples, see these sample projects:

• ExPeer.pt2 (For Tricon controllers)

• TdPeer.pt2 (For Trident or Tri-GP controllers)

Note See Sample Projects on page 7 for information about where to find these projects on the PC where you installed TriStation 1131.

Runtime Errors

For error numbers, see the description for the STATUS output.

Application Notes

• Can be used in Safety or Control applications.

• Exactly Once: each instance should be executed exactly once per scan.

Library

Tricon (TR1LIB/TX1LIB)

Condition Return Value Error Flags

If STATUS is greater than or equal to 100. ERROR=true None

Page 441: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TR_USEND_REAL_32 429

TriStation 1131 Libraries Reference

TR_USEND_REAL_32Sends up to 32 data values to a matching TR_URCV_REAL_32 function block on another Triconex controller.

SyntaxMY_TR_USEND_REAL_32( SENDFLG:=b1, SENDID:=n1, RECVNODE:=n2, RECVID:=n3, N:=n4, SD_01:=d1, ..., SD_32:=d32 ) ;

Table 459 Input Parameters

Name Data Type Description

SENDFLG BOOL Enables TR_USEND_REAL_32.

SENDID DINT The unique identifier for a TR_USEND_REAL_32 function block (1-99).

RECVNODE DINT Specifies which controller node receives data from a TR_USEND_REAL_32 function block (1–63).

RECVID DINT The unique identifier for a matching TR_URCV_REAL_32 function block in a receiving controller (1–99).

N DINT The number of values to send (1–32).

SD_01

.

.

.

SD_32

REAL

.

.

.

REAL

Send data 01.

.

.

.

Send data 32.

Table 460 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.

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.

Page 442: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

430 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 Developer’s Guide.

Example

For Peer-to-Peer examples, see these sample projects:

• ExPeer.pt2 (For Tricon controllers)

• TdPeer.pt2 (For Trident or Tri-GP controllers)

Note See Sample Projects on page 7 for information about where to find these projects on the PC where you installed TriStation 1131.

Runtime Errors

For error numbers, see the description for the STATUS output.

Application Notes

• Can be used in Safety or Control applications.

• Exactly Once: each instance should be executed exactly once per scan.

Library

Tricon (TR1LIB/TX1LIB)

Condition Return Value Error Flags

If STATUS is greater than or equal to 100. ERROR=true None

Page 443: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TR_VOTE_MODE 431

TriStation 1131 Libraries Reference

TR_VOTE_MODEConverts redundancy status.

SyntaxMY_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 461 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 462 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 463 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

Othera

a. If an error in the inputs occurs, then CO is false, the mode outputs are false, and the function block reports a bad parameter error (BADPARAM).

F F F F

Page 444: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

432 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

Example

For shutdown examples, see this sample project:

• ExTUV.pt2 (For Tricon controllers)

Note See Sample Projects on page 7 for information about where to find this project on the PC where you installed TriStation 1131.

Runtime Errors

Upon detection of a runtime error condition, the function block returns the indicated values and sets the error flags to true. For more information about error flags and runtime errors, see the CHK_ERR function block.

Application Notes

• Can be used in Safety or Control applications.

• Space Saver: a single instance can be executed more than once per scan to reduce memory usage and increase performance. For directions, see Using a Space Saver Function Block on page 6.

Library

Tricon (TR1LIB/TX1LIB)

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

Page 445: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TRUNC_LREAL_TO_DINT 433

TriStation 1131 Libraries Reference

TRUNC_LREAL_TO_DINTTruncates a 64-bit long real number to a 32-bit integer.

Syntaxk := 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.

ExampleVAR 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 464 Input Parameters

Name Data Type Description

x LREAL A 64-bit long real number.

Table 465 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

Page 446: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

434 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

Application Notes

Can be used in Safety or Control applications.

Library

Standard (STDLIB)

Page 447: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TRUNC_LREAL_TO_INT 435

TriStation 1131 Libraries Reference

TRUNC_LREAL_TO_INTTruncates a 64-bit long real number to a 16-bit integer.

Syntaxk := 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.

ExampleVAR 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 466 Input Parameters

Name Data Type Description

x LREAL A 64-bit long real number.

Table 467 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

Page 448: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

436 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

Application Notes

Can be used in Safety or Control applications.

Library

Standard (STDLIB)

Page 449: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TRUNC_REAL_TO_DINT 437

TriStation 1131 Libraries Reference

TRUNC_REAL_TO_DINTTruncates a 32-bit real number to a 32-bit integer.

Syntaxk := 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.

ExampleVAR 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 468 Input Parameters

Name Data Type Description

x REAL A 32-bit real number.

Table 469 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

Page 450: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

438 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

Application Notes

Can be used in Safety or Control applications.

Library

Standard (STDLIB)

Page 451: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TRUNC_REAL_TO_INT 439

TriStation 1131 Libraries Reference

TRUNC_REAL_TO_INTTruncates a 32-bit real number to a 16-bit integer.

Syntaxk := 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.

ExampleVAR 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 470 Input Parameters

Name Data Type Description

x REAL A 32-bit real number.

Table 471 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

Page 452: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

440 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

Application Notes

Can be used in Safety or Control applications.

Library

Standard (STDLIB)

Page 453: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TSCHED 441

TriStation 1131 Libraries Reference

TSCHEDSchedules periodic execution.

SyntaxMY_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_VARVAR N : DINT ; END_VARMY_TSCHED( CI:=TRUE, PERIOD:=T#90s ) ;if MY_TSCHED.Q then N := N + 1 ;end_if ;

Runtime Errors

None.

Table 472 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 OFFSET < PERIOD).

Table 473 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.

Page 454: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

442 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)

Page 455: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TSCHED_I 443

TriStation 1131 Libraries Reference

TSCHED_ISchedules periodic execution.

SyntaxMY_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_VARVAR N : DINT ; END_VARMY_TSCHED_I( CI:=TRUE, PERIOD:=90000 ) ;if MY_TSCHED_I.Q then N := N + 1 ;end_if ;

Runtime Errors

None.

Table 474 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 475 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.

Page 456: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

444 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)

Page 457: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TSCHED_R 445

TriStation 1131 Libraries Reference

TSCHED_RSchedules periodic execution.

SyntaxMY_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_VARVAR N : DINT ; END_VARMY_TSCHED_R( CI:=TRUE, PERIOD:=90.0 ) ;if MY_TSCHED_R.Q then N := N + 1 ;end_if ;

Runtime Errors

None.

Table 476 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 477 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.

Page 458: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

446 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)

Page 459: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

UNPACK16 447

TriStation 1131 Libraries Reference

UNPACK16Unpacks a DWORD into 16 separate Boolean outputs.

SyntaxMY_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.

ExampleVAR MY_UNPACK16 : UNPACK16 ; END_VARMY_UNPACK16( CI:=TRUE, INPUT:=16#0000001F ) ;(* * Result on Q outputs of MY_UNPACK16: * Q16 Q01 * 0000000000011111 *)

Runtime Errors

None.

Table 478 Input Parameters

Name Data Type Description

CI BOOL Enables UNPACK16.

INPUT DWORD The input value.

Table 479 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).

Page 460: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

448 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 6.

Library

Triconex (TCXLIB)

Page 461: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

UNPACK32 449

TriStation 1131 Libraries Reference

UNPACK32Unpacks a DWORD into 32 separate Boolean outputs.

SyntaxMY_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.

ExampleVAR MY_UNPACK32 : UNPACK32 ; END_VARMY_UNPACK32( CI:=TRUE, INPUT:=16#0000001F ) ;(* * Result on Q outputs of MY_UNPACK32: * Q32 Q01 * 00000000000000000000000000011111 *)

Runtime Errors

None.

Table 480 Input Parameters

Name Data Type Description

CI BOOL Enables UNPACK32.

INPUT DWORD The input value.

Table 481 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).

Page 462: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

450 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 6.

Library

Triconex (TCXLIB)

Page 463: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

X_OF_N 451

TriStation 1131 Libraries Reference

X_OF_NDetermines whether at least X of the last N measurements exceeds a specified limit.

SyntaxMY_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.

ExampleVAR X3oo4 : X_OF_N ; END_VARX3oo4( CI:=FALSE, RESET:=TRUE, LMT:=0.5, X:=3, N:=4 ) ;X3oo4( VALUE:=0.7, CI:=TRUE, RESET:=FALSE ) ;X3oo4( VALUE:=0.8 ) ;X3oo4( VALUE:=0.4 ) ;X3oo4( VALUE:=0.9 ) ;(* * result : X3oo4.Q is true because 3 out of 4 values * are greater than or equal to 0.5. *)

Runtime Errors

Table 482 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 483 Output Parameters

Name Data Type Description

CO BOOL True if X of N executes successfully.

Q BOOL X of N values exceeding the limit.

Conditions Return Values Error Flags

If N is less than or equal to 0. CO=false, Q=false BADPARAM, ERROR

Page 464: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

452 Chapter 2 Functions and Data Types

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.

• 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)

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

Conditions Return Values Error Flags

Page 465: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

XOR 453

TriStation 1131 Libraries Reference

XORPerforms a logical exclusive OR of two or more Boolean operands or a bitwise exclusive OR of two or more bit-strings.

Syntaxb := 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 484 Input Parameters

Name Data Type Description

b1..bn ANY_BIT Operands

Table 485 Output Parameters

Data Type Description

ANY_BIT b1 XOR b2 XOR ... XOR bn

Table 486 Logical XOR

b1 b2 b1 XOR b2

FALSE FALSE FALSE

FALSE TRUE TRUE

TRUE FALSE TRUE

TRUE TRUE FALSE

Table 487 Bitwise XOR

w1 w2 w1 XOR w2

2#0011 2#0101 2#0110

Page 466: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

454 Chapter 2 Functions and Data Types

TriStation 1131 Libraries Reference

Example

Using Boolean Operands

VAR b, b1:=TRUE, b2:=TRUE, b3:=TRUE : BOOL; END_VARb := 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_VARw1 := 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)

Page 467: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TriStation 1131 Libraries Reference

AModbus Protocol

Overview 456

Message Response Time 457

Modbus Messages 459

Modbus Functions 465

Transmission Errors and Exception Conditions 476

Page 468: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

456 Appendix A Modbus Protocol

TriStation 1131 Libraries Reference

OverviewThis sppendix provides detailed information about Modbus protocol, which is a communication protocol used with serial ports to transmit data between a Modbus master and slave. Modbus protocol includes functions which define the message format for the query and response.

Query-Response Sessions

Modbus communication is a query-response session, in which the Modbus master initiates a query and a Modbus slave responds. In Modbus communication, a serial link transmits data in both directions, but in only one direction at a time.

A query-response session consists of these actions:

• The master sends a query to a slave.

• The master starts a fail-safe timer while it waits for the slave response. Typical slave response time is in hundreds of milliseconds.

• The slave returns a response to the master.

• The master waits until it has received the response from the slave before sending another query.

• If there is a slave response timeout, the master will retry the query. The number of retries and the timeout interval is configured by the MBCTRL function block (see page 178).

For information on configuring Modbus communication, see the Communication Guide for your controller.

Page 469: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

Message Response Time 457

TriStation 1131 Libraries Reference

Message Response TimeThis 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 457

• Modbus Functions and Scan Time on page 458

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 or Tri-GP MP slave:

Writes: 3 x Scan Time

Reads: 2 x Scan Time

Trident or Tri-GP 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 MBCTRL on page 178).

Message Response Time = the sum of all the results

Page 470: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

458 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 470

• Preset Single Register (Function Code 06) on page 471

• Force Multiple Coils (Function Code 15) on page 474

• Preset Multiple Registers (Function Code 16) on page 475

The functions least affected by scan time increases are:

• Read Coil Status Function (Function Code 01) on page 466

• Read Input Status (Function Code 02) on page 467

• Read Holding Registers (Function Code 03) on page 468

• Read Input Registers (Function Code 04) on page 469

Page 471: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

Modbus Messages 459

TriStation 1131 Libraries Reference

Modbus MessagesThis section describes the Modbus messages (query and response functions) supported by Triconex communication modules. The serial ports on Triconex communication modules support several Modbus message formats and functions (queries and responses).

Topics include:

• Communication Modes on page 459

• Function Names and Aliases on page 460

• Modbus Message Formats on page 461

• Sample Query and Response Messages on page 463

• Modbus Message Lengths on page 464

Communication Modes

A Modbus serial link must use either the Remote Terminal Unit (RTU) or ASCII mode of communication. If both modes are available, you should choose RTU because it is more efficient and robust than ASCII. Each serial port can use a different communication mode, assuming that each port is connected to a separate Modbus master or slave device. If you configure a port for combination Modbus master and slave operation, you must use RTU mode.

RTU Mode

In RTU mode, data is sent in 8-bit binary characters. Gaps between characters cannot exceed three character times (the time it takes to send a character). RTU mode uses a 16-bit cyclic redundancy check (CRC) to detect transmission errors.

ASCII Mode

In ASCII mode, data is transmitted in pairs of ASCII characters. The first character is the ASCII representation of the most significant 4 bits of the corresponding RTU character. The second character is the ASCII representation of the least significant 4 bits of the corresponding RTU character. For example, the RTU character 010011112 (4F16) is sent as the two ASCII characters 4 and F (3416 and 4616). Each ASCII message has a colon at the beginning and a carriage return and line feed at the end. Gaps between characters in an ASCII message are not significant.

Page 472: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

460 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 or Tri-GP 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

Page 473: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

Modbus Messages 461

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.

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:

x16 + x15 +x2 + 1

:

Page 474: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

462 Appendix A Modbus Protocol

TriStation 1131 Libraries Reference

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 two’s 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.

Table 488 LRC Checksum Sample Calculation

Message Field Message Content

Address 0x300x32

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 two’s complement. 0xB2

The resulting Error Check (LRC) 0x42 (‘B’)0x32 (‘2’)

Page 475: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

Modbus Messages 463

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 (2516) points starting at point 20 (1316 + 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

0010 0111

C 5

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 1100a 1101b

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

1111 1111

E 5

Trailer None CR LF

Page 476: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

464 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.

FunctionCode

QueryNumber of RTUCharacters

Number of ASCIICharacters

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)

FunctionCode

ResponseNumber of RTUCharacters

Number of ASCIICharacters

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

Page 477: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

Modbus Functions 465

TriStation 1131 Libraries Reference

Modbus FunctionsThis section includes details on Modbus functions.

Functions include:

• Read Coil Status Function (Function Code 01) on page 466

• Read Input Status (Function Code 02) on page 467

• Read Holding Registers (Function Code 03) on page 468

• Read Input Registers (Function Code 04) on page 469

• Force Single Coil (Function Code 05) on page 470

• Preset Single Register (Function Code 06) on page 471

• Read Exception Status (Function Code 07) on page 472

• Loop-Back Diagnostic Test (Function Code 08) on page 473

• Force Multiple Coils (Function Code 15) on page 474

• Preset Multiple Registers (Function Code 16) on page 475

Page 478: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

466 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.

:

:

Page 479: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

Modbus Functions 467

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

:

:

Page 480: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

468 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.

:

:

Page 481: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

Modbus Functions 469

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

:

:

Page 482: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

470 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 (FF0016) turns the coil On, and a coil value of zero (000016) 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

:

:

Page 483: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

Modbus Functions 471

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

:

:

Page 484: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

472 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

:

:

Page 485: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

Modbus Functions 473

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

:

Page 486: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

474 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

òò

òò

:

Page 487: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

Modbus Functions 475

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 or Tri-GP controllers). 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

:

:

Page 488: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

476 Appendix A Modbus Protocol

TriStation 1131 Libraries Reference

Transmission Errors and Exception ConditionsDuring 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 476

• Exception Conditions on page 477

• Exception Responses on page 478

• Exception Response Codes on page 479

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.

Page 489: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

Transmission Errors and Exception Conditions 477

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)

Page 490: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

478 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 slave’s station address, function code, error code, and error-check fields. To indicate that the message is an exception response, the slave sets the high-order bit of the function code to 1. This example shows an exception response to a Preset Multiple Registers (Function Code 16) query.

Sample Query

Sample Exception Response

Page 491: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

Transmission Errors and Exception Conditions 479

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 slave’s 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.

Page 492: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

480 Appendix A Modbus Protocol

TriStation 1131 Libraries Reference

Page 493: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

TriStation 1131 Libraries Reference

BPeer-to-Peer Parameters

Overview 482

Parameters of Send Function Blocks 483

Parameters of Receive Function Blocks 486

Peer-to-Peer Runtime Errors 488

Page 494: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

482 Appendix B Peer-to-Peer Parameters

TriStation 1131 Libraries Reference

OverviewThis appendix describes the input and output parameters for Peer-to-Peer function blocks, and runtime errors.

Topics include:

• Parameters of Send Function Blocks on page 483

• Parameters of Receive Function Blocks on page 486

• Peer-to-Peer Runtime Errors on page 488

Page 495: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

Parameters of Send Function Blocks 483

TriStation 1131 Libraries Reference

Parameters of Send Function BlocksThis 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 486.

A TriStation 1131 application must execute a Send function block unconditionally, exactly once per scan. The SENDFLG parameter should be zero for the first scan. If the value of SENDFLG is zero, no send operation takes place even though the function block is executed. When another application has new data to send, it should first check the result of the Send function block execution (in other words, the STATUS output). If the STATUS is zero, then set SENDFLG to true to initiate the send operation so that data can be transferred.

SENDID

The SENDID input parameter specifies a unique identifier for a Send function block. The legal range for identifiers is from 1 to the value specified for Maximum Number of Peer-to-Peer Send.

Each Send function block in a TriStation 1131 application must have a unique SENDID. If more than one Send function block has the same SENDID, the first Send function block in the application will work properly. Other Send function blocks with the same SENDID will generate an error status of 105.

RECVNODE

The RECVNODE input parameter specifies which controller will receive data from this Send function block. It should be set to the node number of the receiving Triconex controller. The range is 1 to 63. (Note: Nodes 32 to 63 are valid for Trident or Tri-GP controllers only.) If RECVNODE is out of range, calls to the function block set the STATUS output to 102.

RECVID

The RECVID input parameter specifies the unique Receive function block that receives data from this Send function block. A receive call with a matching RECVID must be defined in the receiving controller. The legal range for RECVID identifiers is from 1 to the value specified for Maximum Number of Peer-to-Peer Receive. If RECVID is out of range, calls to the function block set the STATUS output to 102.

Page 496: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

484 Appendix B Peer-to-Peer Parameters

TriStation 1131 Libraries Reference

N

The N input parameter specifies the number of data values to send (1 to 20 for TR_USEND function blocks and 1 to 32 for TR_USEND_32 function blocks). The receiving function block must specify the same value for the N output parameter.

SD_01...SD_nn

The SD_ input parameters send data values to the receiving controller. A TR_USEND function block can send up to 20 values and a TR_USEND_32 function block can send up to 32 values. These values can be BOOL, DINT, or REAL data types. There must be matching RD_ parameters in the Receive function block of the receiving controller.

SENT

The SENT output parameter of type BOOL indicates that a send was initiated and the STATUS parameter is set to 1 or 4. Instead of testing the STATUS output, you can use the SENT output to change the send data if you want to send it again, or reset the SENDFLG if you do not want to send the data again.

ACK

The ACK output parameter indicates that the receiving controller has acknowledged the send. In other words, the last send operation was completed successfully and the STATUS parameter is equal to 3 or 4.

ERROR

The ERROR output parameter indicates that an error has occurred and the STATUS parameter is greater than or equal to 100.

STATUS

The STATUS output parameter indicates the current state of communication with the receiving controller. The STATUS values described in the following table allow the TriStation 1131 application to perform an appropriate action when a problem occurs.

Table 489 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).

Page 497: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

Parameters of Send Function Blocks 485

TriStation 1131 Libraries Reference

3 The last send operation was completed successfully and the receiving controller sent an acknowledgment. STATUS = 3 only if SENDFLG was set to false after STATUS was equal to 1.

The sending controller gets an acknowledgment from the receiving controller for each successfully completed send (STATUS = 3). As soon as the acknowledgment is received, the sending controller initiates another send because SENDFLG is set to true. If SENDFLG is set to true all the time, the STATUS value oscillates between 2 and 4 unless a communication problem causes another type of error.

4 The last send was completed successfully and a new send was initiated. The receiving controller acknowledged that its TriStation 1131 application received the data. STATUS = 3 only if SENDFLG was set to false after STATUS was equal to 1.

The sending controller gets an acknowledgment from the receiving node for each successfully completed send (STATUS = 3). However, as soon as the acknowledgment is received, the sending controller initiates another send because SENDFLG is set to true. If SENDFLG is set to true all the time, the STATUS value oscillates between 2 and 4 unless a communication problem causes another type of error.

100 The controller is trying to recover or establish communication with the receiving controller. This can happen if there is no receiving controller connected to the network, or if there is no matching Receive function block in the TriStation 1131 application of the receiving controller. The sending controller will retry every 2 seconds to establish communication.

Make sure that the receiving controller is connected to the network. If the receiving controller is connected and running, verify that the TriStation 1131 application includes a Receive function block with parameters that exactly match those of the Send function block. If STATUS = 100, the application should inform the operator of communication loss with the receiving controller.

101 The last send operation that was initiated has failed. There is a communication problem or other problem in the receiving controller. The sending controller will retry every 2 seconds to establish communication with the receiving controller. If the retry fails, STATUS is set to 100, and the TriStation 1131 application should inform the operator of communication loss with the receiving controller.

102 Bad identifier. SENDID, RECVNODE, or RECVID is out of range, or the SENDID is greater than the Maximum Number of Peer-to-Peer Sends specified in the configuration.

103 The types or number of variables in the Send and Receive function block pair are mismatched. In other words, the parameters defined for the Send and Receive function block pair do not match exactly. This is a programming error—in one or both of the TriStation 1131 applications—that must be corrected.

104 Number of values (N parameter) is out of range. The allowable range is 1 to 20 for TR_USEND function blocks and 1 to 32 for TR_USEND_32 function blocks.

105 More than one Send function block has the same SENDID, or the same Send function block has been called twice. This is a programming error. Each Send function block in the TriStation 1131 application must have a unique SENDID. If there is more than one Send function block with the same SENDID, the first Send function block in the application will work properly. Other Send function blocks with the same SENDID will result in error status 105.

Send function blocks must be evaluated exactly once per scan. Error status 105 results if the application executes the same Send function block twice per scan. If the application does not execute the Send function block during every scan, results are unpredictable.

Table 489 Send Function Block STATUS Output Parameter Values (continued)

Status Meaning and Action

Page 498: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

486 Appendix B Peer-to-Peer Parameters

TriStation 1131 Libraries Reference

Parameters of Receive Function BlocksThis 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 63. (Note: Nodes 32 to 63 are valid for Trident or Tri-GP controllers only.) If SENDNODE is out of range, calling the function block sets the STATUS output to 102.

SENDID

The SENDID input parameter specifies which Send function block in the sending controller will send data to this Receive block. There must be a Send function block call in the sending controller with the same SENDID. The legal range is from 1 the value specified for the Maximum Number of Send. If SENDID is out of range, calling the function block sets the STATUS output to 102.

N

The N input parameter specifies the number of values to be received (1 to 20 for TR_URCV function blocks and 1 to 32 for TR_URCV_32 function blocks). The sending function block must specify the same value for its N input parameter.

NDR

The NDR (New Data Received) output parameter indicates that new data has been received and is available in the RD_01...RD_nn output parameters until new data is received again. NDR is true when the STATUS parameter has a value of 1.

ERROR

The ERROR output parameter indicates that an error has occurred. ERROR is true when the STATUS parameter is greater than or equal to 100.

STATUS

The STATUS output parameter allows the application to determine the status of communication with the sending controller. This table describes the STATUS values.

Page 499: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

Parameters of Receive Function Blocks 487

TriStation 1131 Libraries Reference

RD_01...RD_nn

The RD_ input parameters receive data values from the sending controller. A TR_URCV function block can receive up to 20 values and a TR_URCV_32 function block can receive up to 32 values. These parameters must match the number and type of the parameters specified in the corresponding Send function block.

Table 490 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.

Page 500: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

488 Appendix B Peer-to-Peer Parameters

TriStation 1131 Libraries Reference

Peer-to-Peer Runtime ErrorsThe 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.

Table 491 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.

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.

Page 501: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

Peer-to-Peer Runtime Errors 489

TriStation 1131 Libraries Reference

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.

Table 491 Peer-to-Peer Runtime Error Descriptions (continued)

Error Description Detection Suggested Action

Page 502: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

490 Appendix B Peer-to-Peer Parameters

TriStation 1131 Libraries Reference

Page 503: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

Index

Symbols* operator 209** operator 115/ operator 101+ operator 12= operator 109> operator 136>= operator 126

Numerics-1.#INF 205, 206

AABS function 10absolute value 10ACK output parameter 484ACOS function 11ADD function 12AIN function 14AIN_BP function 15AIN_BP12 function 17AIN_HR function 19alarm functions

BYPASS_BOOL 69BYPASS_DINT 71BYPASS_REAL 73DEVIATION_ALARM_DINT 21DEVIATION_ALARM_REAL 25LEVEL_ALARM_DINT 29LEVEL_ALARM_REAL 33ROC_ALARM_DINT 37ROC_ALARM_REAL 41TRIP_ALARM 45

analog input 14, 15, 17, 19analog output 50, 51AND function 48AND operator 48AOUT function 50AOUT_BP12 function 51

arc cosine 11arc sine 59arc tangent 60array 53, 55, 57ARRAY32_BOOL function block 53ARRAY32_DINT function block 55ARRAY32_REAL function block 57ARRAYERR error flag 76ASCII mode

characters in station address 461defined 459

ASIN function 59ATAN function 60

BBADCONV error flag 76BADPARAM error flag 76BADPARAM status flag 261base ten logarithm 163bistable 264, 281bitwise AND 48bitwise complement 217bitwise NOT 217bitwise OR 221bitwise XOR 453BLINK function block 61BLINK_I function block 63BLINK_R function block 65BOOL data type 67BOOL_TO_DWORD function 68BYPASS_BOOL function 69BYPASS_DINT function 71BYPASS_REAL function 73

Ccalendar clock

adjusting 361setting 363

Page 504: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

492 Index

TriStation 1131 Libraries Reference

CEIL function 75ceiling 75checksum field, in Modbus message format 461CHK_ERR function block 76CLR_ERR function block 80CONCAT_DT function 82concatenate 82COS function 83cosine 83count down 89count up 91count up-down 93counting bits 219, 220CR field 462CRC error check 461CSCHED function block 84CSCHED_I function block 86CSCHED_R function block 88CTD function block 89CTU function block 91CTUD function block 93

Ddata types

BOOL 67DATE 95DINT 96DT 103DWORD 106INT 140LREAL 166REAL 254STRING 283TIME 358TOD 371

date and time 104, 105data type 103

DATE data type 95deviation 229DEVIATION_ALARM_DINT function 21DEVIATION_ALARM_REAL function 25differential bipolar analog input 15, 17DINT data type 96DINT_TO_DWORD function 97DINT_TO_INT function 98DINT_TO_LREAL function 99

DINT_TO_REAL function 100DIV function 101DIVBYZERO error flag 76down counter 89DT data type 103DT_TO_DATE function 104DT_TO_TOD function 105DWORD data type 106DWORD_TO_BOOL function 107DWORD_TO_DINT function 108

Eedge detector 117

rising 252EQ function 109error flags 76ERROR output parameter 484, 486errors 76errors, Modbus data transmission 476event collection 272, 274, 276, 278exception conditions, Modbus 477exception responses, Modbus 478, 479exclusive OR 453execution scheduling 84, 86, 88, 441, 443, 445EXP function 111EXPFLTR function block 113exponential 111exponential filter 113exponentiation 115EXPT function 115

FF_TRIG function block 117falling edge 117faults, clear faults function 391flags 76flipflop 264, 281floating-point underflow

for LREAL data types 166for REAL data types 254

FLOOR function 119Force Multiple Coils function 474Force Single Coil function 470

Page 505: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

Index 493

TriStation 1131 Libraries Reference

Ggas detector 120GASDETR function block 120GATDIS function block 123gate disable 123gate enable 124GATENB function block 124GE function 126GetDelta_DINT function 128GetDelta_REAL function 130GetDeltaT function 132GetTimer function 134gradual underflow

effect on absolute and relative error 167, 255for LREAL data types 166for REAL data types 254

GT function 136

Hhigh-resolution analog input 19

Ii.LREAL numbers, precision when approaching

zero 167I/O modules, status 392IEC-559 Standard Floating-Point format 254inclusive OR 221-INF 205, 206INFINITY_LREAL function 138INFINITY_REAL function 139INT data type 140INT_TO_DINT function 141INT_TO_LREAL function 142INT_TO_REAL function 143integration 144, 146INTERNALERR error flag 76INTGTOR function block 144INTGTOR_R function block 146IsFinite_LREAL function 148IsFinite_REAL function 149IsNan_LREAL function 150IsNan_REAL function 151

Llatch 264, 281

LE function 152lead-lag compensation 154, 156LEADLAG function block 154LEADLAG_R function block 156less than or equal to operator 152, 174LEVEL_ALARM_DINT function 29LEVEL_ALARM_REAL function 33LF field 462LIMIT function 158line monitor 160LINEMNTR function block 160LN function 162LOG function 163logarithm

base ten 163natural 162

logical AND 48logical NOT 217logical OR 221logical XOR 453long reals, precision when approaching zero 167longitudinal redundancy check. See LRC checksum.loop detector 164Loop-Back Diagnostic Test function 473LOOPDETR function block 164LRC checksum, calculation 462LREAL data type 166LREAL_TO_DINT function 168LREAL_TO_INT function 170LREAL_TO_REAL function 172LT function 174

MMAX function 176MBCTRL function block 178MBREAD_BOOL function block 180MBREAD_DINT function block 182MBREAD_REAL function block 184MBREAD_REAL_TRD function block 188MBWRITE_BOOL function block 191MBWRITE_DINT function block 193MBWRITE_REAL function block 195MBWRITE_REAL_TRD function block 198median 201

Page 506: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

494 Index

TriStation 1131 Libraries Reference

MEDSEL function 201message response time 457MIN function 203MINUS_INFINITY_LREAL function 205MINUS_INFINITY_REAL function 206MOD function 207Modbus, alias mapping 184, 195Modbus communication, noise sources 476Modbus devices, RTU and ASCII modes 459Modbus functions

list of names and codes 459supported by serial ports 459

Modbus masterreading values from a slave 180, 182, 184, 188setting timeout and retry values 178writing values to a slave 191, 193, 195, 198

Modbus protocolchecksum field 461exception conditions 477exception responses 478, 479function code field, described 461message format 461message header 461message lengths 464overview 456performance considerations 458query and response 463station address field 461

modulo 207monitoring analog current loops 160MOVE function 208MUL function 209MUX function 211

NN input parameter 484, 486NAN 150, 151, 213, 214NAN_LREAL function 213NAN_REAL function 214natural exponential 111natural logarithm 162NDR output parameter 486NE function 215noise sources, Modbus communication 476not a number (NAN) 150, 151, 213, 214NOT function 217NOT operator 217

NUMBITS function 219NUMBITS_DWORD function 220

OOR function 221OR operator 221OTHER error flag 76output voter diagnostics 223, 224OVDDISABLE function block 223OVDENABLE function block 224OVERFLOW error flag 76

PPACK16 function 225PACK32 function 226packing bits 225, 226, 447, 449PAGE_EJECT function block 227parity checking, Modbus transmission errors 476Peer-to-Peer

receive 411, 413, 415, 417, 419runtime errors 488send 421, 423, 425, 427, 429

percent deviation 229PERDEV function 229performance, Modbus functions 458PID function block 230PID_R function block 232Poly4 function 234POLY5 function 235

polynomial 234, 235power 115Preset Multiple Registers function 475Preset Single Register function 471PRINT_BOOL function block 236PRINT_CDT function block 238PRINT_CRLF function block 240PRINT_CTOD function block 242PRINT_DINT function block 244PRINT_REAL function block 246PRINT_STRING function block 248PRNTR_FLUSH function block 250proportional integral derivative (PID) 230, 232

RR_TRIG function block 252

Page 507: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

Index 495

TriStation 1131 Libraries Reference

RANGE error flag 76RD_nn 487Read Coil Status function 466Read Exception Status function 472Read Holding Registers function 468Read Input Registers function 469Read Input Status function 467REAL data type 254real number, precision when approaching zero 255real time clock 266REAL_TO_DINT function 256REAL_TO_INT function 258REAL_TO_LREAL function 260RECVID input parameter 483, 486RECVNODE input parameter 483remainder 207remote access 124remote write access 123ReportBadParam function 261reset set 264rising edge detector 252rising edge trigger 252ROC_ALARM_DINT function 37ROC_ALARM_REAL function 41ROL function 262ROR function 263RS function block 264RTC function block 266RTU mode 459runtime error flags 76runtime errors, Peer-to-Peer 488

SSCALE function 267scan time, effect on Modbus performance 458scheduling execution 84, 86, 88, 441, 443, 445SD_nn input parameters 484SEL function 268select 268SENDFLG input parameter 483SENDID input parameter 483, 486SENDNODE input parameter 486SENT output parameter 484sequence of events 272, 274, 276, 278

set reset 281shift left 269shift right 270SHL function 269SHR function 270shutdown 298, 309, 340, 345, 392, 407, 431SIN function 271sine 271SOECLR function block 272SOESTAT function block 274SOESTOP function block 276SOESTRT function block 278special numbers 138, 139, 148, 149, 150, 151SQRT function 280square root 280SR function block 281station address field, Modbus message 461status

critical I/O modules 392safety-critical I/O modules 298Tricon 64 point 385Tricon chassis 389Tricon main processor 395Tricon Peer-to-Peer 397Tricon points 399Tricon port 401Tricon program 403Tricon scan 405Tricon slot 409Trident analog input module 287Trident analog output module 289Trident combo AI/DI input module 300Trident communication module 295Trident discrete input module 302Trident discrete output module 304Trident high resolution discrete input module 306Trident I/O module 309Trident I/O processor 311Trident main processor 314, 319Trident pulse input module 324Trident relay output module 327Trident supervised discrete output module 329Trident system 342Tri-GP analog input module 287Tri-GP analog output module 289Tri-GP combo AI/DI input module 300Tri-GP communication module 295Tri-GP discrete input module 302Tri-GP discrete output module 304Tri-GP high resolution discrete input module 306

Page 508: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

496 Index

TriStation 1131 Libraries Reference

status (continued)Tri-GP I/O module 309Tri-GP I/O processor 311Tri-GP main processor 314, 319Tri-GP pulse input module 324Tri-GP relay output module 327Tri-GP supervised discrete output module 329Tri-GP system 342

status flags 76STATUS output parameter 484STATUS output values 486STRING data type 283STRLEN error flag 76SUB function 284subtraction operator 284SYS_AI32_STATUS function block 287SYS_AO04_STATUS function block 289SYS_APP_HALT function 291SYS_CLEAR_FLTS function 293SYS_CM_STATUS function block 295SYS_CRITICAL_IO function block 298SYS_DI16_AI16_STATUS function block 300SYS_DI32_STATUS function block 302SYS_DO16_STATUS function block 304SYS_HRDI32_STATUS function block 306SYS_IO_STATUS function block 309SYS_IOP_STATUS function block 311SYS_MP_EXT_STATUS function block 314SYS_MP_RESET_PORTS function 317SYS_MP_STATUS function block 319SYS_OVD_INHIBIT function 322SYS_PI06_STATUS function block 324SYS_RO32_STATUS function block 327SYS_SDO16_STATUS function block 329SYS_SERIAL_PORT function block 332SYS_SET_APP_LOCK function 334SYS_SET_PROG_ALARM function 336SYS_SET_REMOTE_WRT_ENBL function 338SYS_SHUTDOWN function block 340SYS_SYSTEM_STATUS function block 342SYS_VOTE_MODE function block 345

TTAN function 347tangent 347

TCJ_CONV function 348TCK_CONV function 350TDD_I function block 352TDD_R function block 353TDE_I function block 355TDE_R function block 356TGL coil 375thermocouple 348, 350TIME data type 358time of day 105TIME_TO_SECS function 359, 360TIMEADJ function block 361TIMESET function block 363TMR function block 365TMR_I function block 367TMR_R function block 369TOD data type 371TOF function block 372TOGGLE function block 375TON function block 377TP function block 379TP_I function block 381TP_R function block 383TR_64_POINT_STATUS function block 385TR_CALENDAR function block 387TR_CHASSIS_STATUS function block 389TR_CLEAR_FLTS 391TR_CRITICAL_IO function block 392TR_MP_STATUS function block 395TR_PEER_STATUS function block 397TR_POINT_STATUS function block 399TR_PORT_STATUS function block 401TR_PROGRAM_STATUS function block 403TR_SCAN_STATUS function block 405TR_SHUTDOWN function block 407TR_SLOT_STATUS function block 409TR_URCV_BOOL function block 411TR_URCV_DINT function block 413TR_URCV_DINT_32 function block 415TR_URCV_REAL function block 417TR_URCV_REAL_32 function block 419TR_USEND_BOOL function block 421TR_USEND_DINT function block 423TR_USEND_DINT_32 function block 425

Page 509: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

Index 497

TriStation 1131 Libraries Reference

TR_USEND_REAL function block 427TR_USEND_REAL_32 function block 429TR_VOTE_MODE function block 431training xtransmission errors, Modbus 476Triconex contact information xtrigger 117

rising edge 252TRIP_ALARM function 45TRUNC_LREAL_TO_DINT function 433TRUNC_LREAL_TO_INT function 435TRUNC_REAL_TO_DINT function 437TRUNC_REAL_TO_INT function 439TSCHED function block 441TSCHED_I function block 443TSCHED_R function block 445Type J thermocouple 348Type K thermocouple 350

Uunderflow

gradual for LREAL data types 166gradual for REAL data types 254

UNDERFLOW error flag 76UNPACK16 function block 447UNPACK32 function block 449up counter 91up-down counter 93

Wwrite access 123

XX_OF_N function block 451XOR function 453XOR operator 453

Page 510: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

498 Index

TriStation 1131 Libraries Reference

Page 511: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each
Page 512: TriStation 1131 Libraries Reference, v4.8 Infi90 Documentation... · TriStation™ 1131 Developer’s Workbench software. This reference guide provides detailed descriptions of each

Invensys Operations Management5601 Granite Parkway Suite 1000Plano, TX 75024United States of Americahttp://iom.invensys.com

Global Customer SupportInside U.S.: 1-866-746-6477Outside U.S.: 1-508-549-2424 or contact your local Invensys representative.Email: [email protected]: http://support.ips.invensys.com