Rockwell Automation Logix5000 Controllers Structured Text Programming Manual User Manual

Page 5

Advertising
background image

5

Publication 1756-PM007D-EN-P - November 2012

5

Table of Contents

Preface

Studio 5000 Engineering and Design Environment and
Logix Designer Application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
In This Manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
How to Use this Manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

Chapter 1

Program Structured Text

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Assignments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

Specify a Non-retentive Assignment. . . . . . . . . . . . . . . . . . . . . . . . 12
Assign an ASCII Character to a String . . . . . . . . . . . . . . . . . . . . . . 13

Expressions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

Use Arithmetic Operators and Functions . . . . . . . . . . . . . . . . . . . 15
Use Relational Operators. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Use Logical Operators. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Use Bitwise Operators. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Determine the Order of Execution . . . . . . . . . . . . . . . . . . . . . . . . 19

Instructions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Constructs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

Some Key Words Are Reserved for Future Use . . . . . . . . . . . . . . 21

IF...THEN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
CASE...OF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
FOR…DO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
WHILE…DO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
REPEAT…UNTIL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

Advertising