Professional Documents
Culture Documents
Release 1.1
User Manual
Summary of Changes
Whats New
See:
chapter 1
chapter 1
chapter 2
chapter 2
chapter 3
appendix C
chapter 3
chapter 3
chapter 4
chapter 4
chapter 4
appendix A
appendix A
appendix B
Preface
Structured Text User Manual
Figure 1
Enhanced PLC-5 Programmable Controller Documentation
HARDWARE
SOFTWARE
Software Configuration
and Maintenance
Installing 6200
programming software
Defining data table files
Configuring processor
Processor/channel status
Clearing faults
Printing reports
6200-6.4.6
1785-6.5.12
Enhanced PLC-5
Programmable
Controllers
Installation Instructions
Ethernet PLC-5
Programmable
Controllers
Installation Instructions
1785-2.38
1785-2.30
I/O Configuration
Software
Configuring intelligent
I/O modules
6200-6.4.12
1785 PLC-5
Programmable Controllers
Quick Reference
Quick access to switches,
status bits, indicators,
instructions, software screens
1785-7.1
Structured Text
User Manual
Program considerations
Program examples
Mnemonic explanations
Using PowerTextt
Instruction parameters
and syntax
6200-6.4.18
Programming
Creating/managing files
Saving/restoring files
Importing/exporting
Creating/editing SFCs
Creating/editing/
documenting ladder
logic programs
6200-6.4.7
Instruction Set
Reference
Instruction execution,
parameters, status
bits and examples
6200-6.4.11
Preface
Structured Text User Manual
Where to Start
Conventions
ii
Preface
Structured Text User Manual
Pictures of keys and/or screens represent actual keys that you press or screens
that you see. For example, in the procedure for creating a structured text file,
you see:
Program
Directory
Proc Functions
F1
Create File
F6
Create STxt Fl
F8
Press
Press
Esc
to return to
Program
Directory
What the procedure shows is that from the program directory, press [F1] and
then [F6] to display this screen. Then press [F8] to create a structured text
file and enter the file number. Press [Esc] to return to the program directory.
Words in square brackets represent actual keys that you press. For example:
[Enter] or [F1] Online Programming/Documentation
Words that describe information that you have to provide are shown in
italics. For example, if you have to type a file name, this is shown as:
filename
Messages and prompts that the terminal displays are shown as:
Press a function key
iii
Table of Contents
Structured Text User Manual
Chapter 1
Chapter Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Using Structured Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Installing the Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Writing Structured Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Rules for Writing Structured Text . . . . . . . . . . . . . . . . . . . . . . . . . . .
1-1
1-1
1-1
1-3
1-6
Chapter 2
Chapter Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Variable Assignment (:=) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Non-Retentive Bit Assignments (:=) . . . . . . . . . . . . . . . . . . . . . . . . .
Retentive Bit Assignments (RETAIN) . . . . . . . . . . . . . . . . . . . . . . .
IF-ELSIF-ELSE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
CASE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
FOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
WHILE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
REPEAT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
EXIT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
;; . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Ladder Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Memory Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2-1
2-2
2-2
2-3
2-4
2-5
2-6
2-7
2-8
2-9
2-10
2-10
2-12
Chapter 3
Chapter Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Creating a Structured Text File . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Configuring the Structured Text Editor . . . . . . . . . . . . . . . . . . . . . . .
Defining Addresses and Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . .
Entering Structured Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Editing Structured Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Creating Documentation Reports . . . . . . . . . . . . . . . . . . . . . . . . . . .
3-1
3-1
3-2
3-3
3-5
3-7
3-10
Chapter 4
Chapter Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Using PowerText . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Creating a Configurable Data Monitor . . . . . . . . . . . . . . . . . . . . . . .
4-1
4-1
4-4
iv
Structured Text User Manual
Table of Contents
Structured Text User Manual
Application Example
Instruction Reference
Appendix A
Appendix Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Programming a Free Running Timer . . . . . . . . . . . . . . . . . . . . . . . . .
Programming a Sort Routine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Debugging Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A-1
A-1
A-2
A-2
Appendix B
Instruction Operands and Valid Data Types . . . . . . . . . . . . . . . . . . .
B-1
Appendix C
ASCII Structured Text Processor Memory File Example . . . . . . . . .
Structured Text Syntax for Above ASCII File . . . . . . . . . . . . . . . . .
C-1
C-9
v
Structured Text User Manual
Chapter
Chapter Objectives
Use this chapter to learn what structured text is and how you can use it as
an alternative to or in conjunction with ladder logic or Sequential Function
Charts (SFCs).
1.
2.
When the DOS prompt appears, insert the structured text disk into the
disk drive. Type:
A:
Return
INSTALL C:
Return
1-1
Chapter 1
Writing Structured Text
You see:
Press
Return
Press ENTER to continue with the installation
3
Enter your company name and address.
You can find the serial number on the front
of the product box. Format is AA0AA0AA.
Contents:
PLC-5 Prog Structured Text Programming Option
Catalog Number: 6203-ST5
Product Registration Information
Part Number:
XXXXXX-XX
Release Number:
2.0 Name:
Quantity 1 Disk
Company
Address:
:
Serial Number:
F9
Instructions
Enter product registration info and press F9
1-2
Chapter 1
Writing Structured Text
Contents:
Catalog Number:
Part Number:
Release Number:
98% Complete
0%
25%
50%
75%
100%
Instructions
1-3
Chapter 1
Writing Structured Text
Function:
Operator:
Function:
/
*
modulo (MOD)
SQR
FRD
TOD
NOT
NEG
add
subtract
divide
multiply
returns the remainder of an integer divide
square root
convert from BCD
convert to BCD
logical NOT
negate
LN
LOG
DEG
RAD
SIN
COS
TAN
ASN
ACS
ATN
natural log
log to the base 10
degree (convert radians to degrees)
radian (convert degrees to radians)
sine
cosine
tangent
arc sine
arc cosine
arc tangent
Function:
<
>
=
<=
>=
<>
less than
greater than
equal
less than or equal
greater than or equal
not equal
input instruction any valid ladder input instruction (excluding LBL and SBR) or compare
expression. You can examine the state of a bit by specifying the address of
the bit you want (i.e. I:0/0). This operand or expression is true if the
specified bit is a logical 1. To invert the logic (the operand or expression is
true if the bit is a logical 0) precede the bit address with a ! (i.e. !I:0/0).
For example, XIC (I:0/0).
1-4
Chapter 1
Writing Structured Text
input expression a sequence of input instructions separated by boolean AND, OR, or XOR.
(You can only use XOR with bit operands and compare expressions. You
can implement a ladder function extension by assigning the logic state to a
bit and using the bit address in the XOR expression).
Precedence in an expression is evaluated according to the following list
(from highest to lowest priority):
1.
!(bit inversion)
2.
parentheses
3.
4.
5.
*, / , MOD
6.
+,
7.
8.
9.
1-5
Chapter 1
Writing Structured Text
1-6
Chapter 1
Writing Structured Text
{
ELSIF
AND (boolean)
OR (boolean)
} (no semicolon
required)
DO, THEN, OF
ELSE_IF, ELSEIF
&&, &
||
END_FOR;, END_CASE;, ENDIF;,
ENDWHILE;, ENDREPEAT;,
END_WHILE;, END_REPEAT;,
ENDFOR;, ENDCASE;, END_IF;
Important: Although you can use braces ({}) when writing or entering
a program, the syntax of structured text is different than that used in the
standard C programming language. In the following comparison, the
original program version does not have matching pairs of braces. In
structured text, this is correct syntax.
Standard Format:
Original Program:
IF (N7:0 = 1) THEN
Structured Text
ELSIF (N7:3 = 27) THEN
Structured Text
ELSE
Structured Text
ENDIF ;
IF (N7:0 = 1) {
Structured Text
else_if (N7:3 = 27) {
Structured Text
ELSE
Structured Text
}
The following words are reserved and you should not use them
as symbols:
- any ladder instruction mnemonic (i.e. LOG, DEG)
- any structured text keyword or equivalent (i.e. CASE, FOR)
- START, DATA, PROJECT, SFC, SFC2, LADDER, I/O, ASCII,
CAR, FORCE, PLC2, CONFIG, INC, ALL, YES, NO,
STRUCTURED TEXT
1-7
Chapter 1
Writing Structured Text
no line
End
End Construct
no line
Blank Line 2
XX := YY;
Blank Line 3
XX := YY;
Blank Line 4
1-8
Chapter
Chapter Objectives
After you prepare your design specification and, if applicable, enter your
sequential function chart (SFC), you are ready to enter the structured text
that runs your application. Use this chapter to learn about the structured
text constructs that you can use. The following table lists page references
for each construct.
If You Want to:
Use this:
See Page:
variable assignment
2-2
non-retentive bit
assignment
retentive bit
assignment
IF-ELSIF-ELSE
CASE
2-2
FOR
2-6
WHILE
2-7
REPEAT
2-8
EXIT
2-9
;;
2-10
ladder functions
2-10
2-3
2-4
2-5
The last section in this chapter provides guidelines for the memory
requirements for the constructs.
2-1
Chapter 2
Structured Text Constructs
Format:
Examples:
operand := immediate ;
N7:0 := 10;
operand := operand ;
N7:0 := N7:10;
N7:0 := R6:0.LEN;
N30:0
N30:1 := N30:0
Destination
Non-Retentive Bit
Assignments (:=)
N30:1
Use this construct to make binary assignments to a storage bit. These bit
addresses are non-retentive (they are cleared to 0 when the processor mode
changes from Program to Run or when an SFC step with the structured text
file as an action is postscanned). See the following formats and examples:
Format:
Examples:
bit_operand := 0;
B3/0 := 0;
bit_operand := 1;
N7:0/0 := 1;
bit_operand := bit_operand;
O:0/0 := N7:0/0;
bit_operand := compare_expr;
1
0
2-2
Chapter 2
Structured Text Constructs
Use this construct to make binary assignments to a storage bit. These bit
addresses are made retentive (they are not cleared to 0 when the processor
mode changes from Program to Run or when the SFC step is postscanned)
using the RETAIN function. See the following formats and examples.
Formats:
Examples:
B3:0 is set to 0.
N7:0/0 is set to 1.
If N7:0/0 is set to 1
then O:0/0 is set
to 1. If N7:0/0 is
set to 0, then O:0/0
is set to 0.
If the Compare
Expression Is:
The Assignment
Value Is:
true
false
1
0
2-3
Chapter 2
Structured Text Constructs
IF-ELSIF-ELSE
code section
Format:
Examples:
IF I:000/0 THEN
N7:0 := N7:1 + N7:2;
END_IF ;
2-4
nested IF
end of nested IF
Chapter 2
Structured Text Constructs
CASE
single value
list of values
range of values
mixed list and range
default case
Format:
Examples:
CASE N7:0 OF
0:
N7:1 :=
1,9:
N7:1 :=
2..4:
N7:1 :=
10,5..8:
N7:1 :=
ELSE
N7:1 :=
END_CASE;
IF N7:0 = 0
1;
2;
IF N7:0 = 1 or 9
IF 2 <= N7:0 <= 4
3
IF N7:0 = 10 OR 5 <= N7:0 <= 8
4;
5;
Default
CASE F8:0 OF
recommended range check
5.001 .. 5.625:
N7:1 := 3;
N7:0 , N7:5 .. F8:5 :
mixed mode
N7:1 := 4;
ELSE
N7:1 := 5;
Default
END_CASE;
2-5
Chapter 2
Structured Text Constructs
FOR
default: increment by 1
Format:
Examples:
FOR N7:0 := 10 TO 0 BY -1 DO
N7:4 := N7:4 + 1;
END_FOR;
FOR N7:0 := 0 To 10 DO
N7:1 := N7:1 + 1;
END_FOR;
= 1.
2-6
Chapter 2
Structured Text Constructs
WHILE
Method:
Examples:
IIN instruction
FOR N7:0 := 10 TO 0 BY -1 DO
N7:4 := N7:4 + 1;
IIN (000);
IF (I:000/00) THEN
EXIT;
END_IF;
END_FOR;
EXIT construct
FOR N7:0 ;+ 0 TO 20 DO
N7:1 := N8:0 + N8:1;
IF (B3:0/0 = 1) THEN
EXIT;
END_IF;
END_FOR;
Examples:
2-7
Chapter 2
Structured Text Constructs
Examples:
IIN instruction
WHILE (I:000/000) DO
N7:0 := N7:0 + 1;
IIN (000);
END_WHILE;
WHILE (N7:0/0 = 1) DO
N7:3 := (N7:1 + N7:2);
IF (N7:19/2) THEN
EXIT;
END_IF;
END_WHILE;
EXIT construct
REPEAT
Examples:
REPEAT
Structured Text
UNTIL input expression
END_REPEAT;
REPEAT
N7:0 := N7:0 + 1;
UNTIL N7:0 > (N7:10 / 10)
END_REPEAT;
N7:0 increments by 1
until N7:0 is greater than N7:10
divided by 10
2-8
Chapter 2
Structured Text Constructs
Examples:
IIN instruction
REPEAT
N7:0 := N7:0 +1;
IIN (000);
IF (I:000/07) THEN
EXIT;
END_IF;
UNTIL (N7:0 > 25)
END_REPEAT;
REPEAT
N7:0 := N7:0 +1;
IF (B3:0/0 = 1 ) THEN
EXIT;
END_IF;
UNTIL (N7:0 > (N7:10 /10)
END_REPEAT;
EXIT construct
EXIT
Examples:
EXIT;
FOR N7:0 := 0 TO 10 DO
WHILE N7:1/0 DO
N7:10:=(N7:10 + 10) / (SIN(F8:0));
IF N7:5 < 4 THEN
exit the WHILE loop early
EXIT;
END_IF;
END_WHILE;
execution continues here
N7:11 := N7:12 + 1;
END_FOR;
2-9
Chapter 2
Structured Text Constructs
;;
Ladder Functions
Format:
Examples:
;;
IF N7:0/0 THEN
;;
no effect on program scan
ELSE
time
N7:2 := N7:5 +10;
END_IF;
Format:
Examples:
FAL(R6:0,10,0,ALL,#N7:0,#N7:1+#N7:2);
Some input instructions require output instructions for correct syntax (see
the DTR example above). Appendix B identifies which instructions
require output instructions.
In general, enter ladder functions exactly as they are displayed in the
ladder editor. You must specify all fields, even those that are display-only
fields in the ladder editor. Any field that accepts a word (i.e. Yes or
No in a block transfer) must be fully specified (Y or N is invalid.)
2-10
Chapter 2
Structured Text Constructs
Structured text has equivalents to OTL, OTU, OTE, CPT, FOR, NXT,
BRK, AND, and OR instructions. See the following table for page
references for these functions. Structured text has no direct equivalent to
the JMP instruction. Use the CASE and WHILE constructs instead.
For an Equivalent to
these Constructs:
OTE
OTL, OTU
CPT
FOR, NXT, BRK
AND, OR
Important: OTL, OTU, OTE, and CPT are valid output instructions in
structured text. However, they will be displayed as their structured text
counterparts after you accept the logic.
Important: In ladder programming, the SBR instruction is an input
instruction. This instruction must be the first instruction in a program file
and must be followed by an output instruction. In structured text
programming, however, no output instruction is required, but the SBR
instruction still must be the first instruction in the program file.
2-11
Chapter 2
Structured Text Constructs
Memory Requirements
Memory Requirement:
IF
ELSIF
ELSE
END_IF
END_FOR
END_WHILE
END_REPEAT
END_CASE
2 words
2 words
2 words
2 words
2 words
WHILE
REPEAT
EXIT
EMPTY
CASE
case item
discrete
range
expressions = 14 words
10 to 12 words
(3 to 6 words) * number of items
6 to 12 words
2-12
Chapter
Chapter Objectives
This chapter explains how to use the structured text editor. Use the
following table to find specific topics.
For this Topic:
See Page:
3-1
3-2
3-5
3-7
3-10
Important: If you create a structured text program file, you can only
monitor or restore that file with programming software that supports
structured text.
Creating a Structured
Text File
Program
Directory
Proc Functions
F1
Create File
F6
Create STxt Fl
F8
Press
Press
Esc
to return to
Program
Directory
3-1
Chapter 3
Using the Structured Text Editor
After you create the file, you can enter your structured text. Follow the
steps on the left:
Program
Directory
cursor to
structured text file
Monitor File
F8
SFC
Main Menu
General
Utility
F7
Configure
Display
F2
Act/Cnd
Window
F8
3-2
Chapter 3
Using the Structured Text Editor
Defining Addresses
and Symbols
To:
ke toggles
les between
e ee displaying
s la
ess
Thiss key
or ssuppressing
address symbols. The default is to display symbols.
[Esc]
Any addresses and symbols that you want to use in your structured text
files must be assigned before you edit the file. You cannot save a
structured text file that references any addresses or symbols that do not
exist in the database.
You can access the documentation database and the data table monitor
through the structured text editor. You must still define the symbols you
need prior to editing a structured text file. To access the documentation
database or the data table monitor, follow these steps:
3-3
Chapter 3
Using the Structured Text Editor
6200
Main Menu
Online Prog
F1
6200
Main Menu
Offline Prog
or
F3
Program
Directory
Cursor to a
structured text file or
enter file number
Online Prog
F1
Offline Prog
or
F3
Program
Directory
Cursor to a
structured text file or
enter file number
Monitor File
Monitor File
F8
F8
Edit
DBASE
Data
Monitor
F5
F8
For more information about using the documentation database, see the
PLC-5 Programming Manual, publication 6200-6.4.7. For more
information about using the data monitor, see the PLC-5 Configuration and
Maintenance Manual, publication 6200-6.4.6.
3-4
Chapter 3
Using the Structured Text Editor
6200
Main Menu
Online Prog
F1
Offline Prog
or
Cursor to a
structured text file or
enter file number
F8
Edit
IF (!T4:0.DN) THEN
TON (T4:0, 0.01, 100, 0);
ELSIF (T4:0.DN) THEN
RES (T4:0);
END_IF;
F3
Program
Directory
Monitor File
You can enter structured text as an MCP, subroutine, fault routine, STI
routine, or as an action or transition in an SFC file. To enter structured text
as an MCP, subroutine, fault routine, or STI routine follow the steps on
the left:
WHILE (TIMER1) DO
FOR (N7:10 := 0 TO 10) DO
CASE (N7:20) OF
0:
N7:100 := TIMER8;
1:
N7:101 := TIMER9;
END_CASE;
END_FOR;
END_WHILE;
If you havent entered logic (structured text) into the program file yet,
this window is blank.
F10
3-5
Chapter 3
Using the Structured Text Editor
Edit
F10
START
+++
+=====+=====+
# MIXER
#
+=====+=====+
+
|
|
+++
SFC
Edit Selections
Append
Step/Trn
Insert
Step/Trn
or
F3
F4
Step
Trans
Actions
*
F1
F2
PLC5/40 Ser C
Step
Timer
F4
Rev C
Step
Name
F8
Step Actions
a If you press
F1
Rem Prog
SFCFrc:Disabled
Select
Edit
Append
Insert
Remove
File
Text
Action
Action
Action
F1
F2
F3
F4
F6
F2
Trans
b If you press
F2
Rem Prog
SFCFrc:Disabled
Select Edit
Copy
Remove
File
Cond
Cond
F1
Text
F2
F3
F2
3-6
F6
Chapter 3
Using the Structured Text Editor
The editing keys for a structured text file used within an SFC (as an action
or transition) and a structured text file used as an MCP or subroutine are
identical, but the ways to get to the editor are different. To edit structured
text, either in an SFC or as an MCP or subroutine, follow the steps on
the left:
Important: You must be offline or in Program or Remote Program mode
to edit structured text. If you change the processor mode from Program or
Remote Program, all of your edits are lost. The system displays an error
message Processor has changed to Run or Test mode, edit
aborted. The system returns to the SFC main menu (if you are using an
SFC) or the Structured Text View screen (if you are entering structured text
as an MCP or subroutine).
Within an SFC
MCP or Subroutine
SFC
Main Menu
Ladder Editor
Main Menu
Online Prog
F1
Edit
Offline Prog
or
F3
F10
SFC
Main Menu
SFC
Edit Selections
Prog Dir
F4
Modify Stp/Trn
F5
Cursor to a
structured text file or
enter file number
Step Actions
F1
Trans
or
F2
Monitor File
F8
F10
Use these editing keys to edit the structured text. For more
information on how the editor works, see chapter 17 in the
PLC-5 Programming manual, 6200-6.4.7.
3-7
Chapter 3
Using the Structured Text Editor
When you load a structured text program into a processor, the processor
converts the program to IEC standard 1131-3 format. Therefore, if you
monitor or save a program, it is converted to standard format, regardless of
the format in which you wrote it. (For example, if you used semicolons in
place of colons in your program, the semicolons are replaced by colons
when you load the program into the processor.) If you want to keep the
program as you originally entered it, save the original program as a paste
file using the Advanced Editing cut, copy, and paste features.
Accepting Edits
When you finishing entering or editing structured text, press F8 Accept
Edits to accept the edits. The software checks the edits to make sure the
syntax is correct before saving the file. If there is an error in the structured
text, the software displays an error message explaining the error. You must
correct the error before you can accept edits again.
TIP
If there are syntax errors and you want to temporarily save the incorrect
structured text file, use the advanced editing functions to copy the file to a
disk file. You can then later paste the file into an empty structured text file
and correct the syntax errors. Follow the steps below.
To select the structured
text to save to disk file:
ST Editor
ST Editor
Advanced Editing
Cut
F7
F2
Copy to Disk
Select
F1
3-8
F7
Chapter 3
Using the Structured Text Editor
3-9
Chapter 3
Using the Structured Text Editor
Creating Documentation
Reports
6200
Main Menu
Reports
F8
Create Offline
F3
Create Online
or
F1
Create Select
Reports
All
F1
F2
Toggle
Report
F3
Report Options
F5
Create Reports
F1
3-10
Title
F8
Save
Config
F9
current
processor
memory
file
Chapter 3
Using the Structured Text Editor
Proc File:
Output:
Phase:
Abort Utility
F3
+========================================+
|
ALLENBRADLEY COMPANY
|
|
6200 SERIES SOFTWARE
|
|
PLC5 DOCUMENTATION SOFTWARE
|
+========================================+
LIMIT
Report:
Structured Text Listing
LIMIT.TXR
Config:
Files 1 999
GENERATE ST. TXT. LISTING Status:
File: 2
+==============================================================================+
|** OPEN PROCESSOR MEMORY FILE **
|
|** GENERATE STRUCTURED TEXT LISTING REPORT **
|
|** GENERATE LISTING FOR FILE 2 **
|
|
|
|
|
|
|
|
|
|
|
|
|
+==============================================================================+
Press F3 to abort
Abort
Utility
F3
For more information about reports, including how to print a report, see the
PLC-5 Configuration and Maintenance Manual, publication 6200-6.4.6.
To View the Report:
6200
Main Menu
Reports
F8
Print/View
F8
PLC5/40
Addr 68
Page 1
File 2
IF (!T4:0.DN) THEN
TON (T4:0, 0.01, 100, 0);
ELSEIF (T4:0.DN) THEN
RES (T4:0);
END_IF;
WHILE (TIMER1) DO
FOR (N7:10 := 0 TO 10) DO
CASE (N7:20) OF
0:
N7:100 := TIMER8;
1:
N7:101 := TIMER9;
END_CASE;
END_FOR;
END_WHILE;
R6:6.DN AND
Select
F3
A structured text listing looks similar to the above screen. The structured text
listing file has a .TXR extension and resides in the IPDS\TEXT\PLC5 directory.
View File
F10
3-11
Chapter
Chapter Objectives
Use this chapter to learn how to use the Structured Text View window and
the PowerText feature as monitoring tools for structured text.
Using PowerText
Program
Directory
cursor to
structured text file
Monitor File
F8
TIP
Alt
F7
to toggle between
4-1
Chapter 4
Monitoring Structured Text
MCP or Subroutine
Within an SFC:
SFC
Main Menu
6200
Main Menu
Online Prog
F1
Offline Prog
or
F3
Alt
Program
Directory
Cursor to a
structured text file or
enter file number
If you have not created a structured text file,
you need to do so. See page 3-1.
Monitor File
F8
PowerText values
289}))) THEN
If you havent entered logic (structured text) into the program file yet,
this window says only: Empty Structured Text File
If the processor is not in Run mode, the view window displays the
structured text that you entered.
4-2
Chapter 4
Monitoring Structured Text
Software
Config
F6
Color
Selection
F3
+========================= PLC-5
PROGRAMMING SOFTWARE =======================+
|
|
|
A 6200 Series Software Product
|
| += COLOR SELECTION MONOCHROME =========================================+ |
| | + Main Displays
+
Informational Messages
| |
| | | True Logic
|
Errors
| |
| | | Forces
|
User Prompts
| |
| | | Rung/Step Comments
|
User Input
| |
| | | Address Comments
|
Processor Status
| |
| | | Instruction Comments
|
Program Modes
| |
| | | Symbols
|
Test Modes
| |
| | | Instruction Cursor
|
Run Modes
| |
| | ++
Faults
| |
| |
Logo/Processor Directory
Function Keys
| |
| |
Processor Dir. Cursor
Data Entry Windows
| |
| |
Selection Windows
Option Windows
| |
| |
Selection Cursor
Who
| |
+==+= ESC exits/ALTU aborts changes =======================================+==+
Press a function key
Mono/ Recall
DfltClr LastClr
F1
F2
Bakgrnd Forgrnd
Color
Color
F5
F6
Save
Config
F9
This Selection:
Applies to:
Displays in:
True Logic
False Logic
Forces
Option Windows
4-3
Chapter 4
Monitoring Structured Text
Toggle between a black and white display or a display that uses the
default colors.
Restore the last color selections that were saved before the current
programming session. This restores color for all display options.
Configurations saved during the current session are not recalled.
Cancel any changes you made on this screen for the current editing session.
Creating a Configurable
Data Monitor
With the PowerText feature, you can create custom data table monitoring
screens using structured text assignments. This is a convenient way to
monitor non-adjacent data table values.
The processor updates PowertText values on the screen when the processor
is in Run mode. To see these values, create a structured text file that is not
executing as an MCP, subroutine, or an action or transition within an SFC
file. Because the structured text file is not executing, the logic in the file is
not executed. Data table values for these variables, however, are
accurately updated.
To create a monitoring screen, follow these steps:
1.
4-4
Chapter 4
Monitoring Structured Text
3.
Accept the edits and change the processor mode to Run. The
PowerText values update. For example:
IF (0 = 1) THEN
FLOW_RATE1{
N10:0{
326.07} := FLOW_RATE2{
4095} := N10:1{
119.923};
4095};
4095} := N10:1{
4095} + N31:231 {
1413} + N26:34{
57};
N10:10 {
2000} := F8:10 {
2000.00};
END_IF;
Field Widths
The width of each data type field displayed by the PowerText feature
varies. For the width of a particular data type field, see the following table.
Data Type:
Field Width:
integer
decimal
float
ASCII
Binary (word)
6
4
14
6
19
4-5
Appendix
Application Examples
Appendix Objectives
Programming a Free
Running Timer
You can program the logic in this example in several ways using structured text.
Method A uses 3 words of memory, the same as the ladder example. Method B
uses 24 words, and method C uses 34 words.
Example: Free Running Timer
T4:0
TIMER ON DELAY
LADDER:
DN
STRUCTURED TEXT:
TON
EN
Timer
T4:0
Time base
0.01
Preset
100
Accum
DN
METHOD A:
!T4:0.DN TON (T4:0, 0.01, 100, 0);
METHOD B:
IF (!T4:0.DN) THEN
TON (T4:0, 0.01, 100, 0);
ELSE
RES (T4:0);
END_IF;
METHOD C:
IF (!T4:0.DN) THEN
TON (T4:0, 0.01, 100, 0);
ELSIF (T4:0.DN) THEN
RES (T4:0);
END_IF;
All of the programming examples execute the timer until the preset equals the
accumulated value. The timer is then reset and begins timing again.
A-1
Appendix A
Application Examples
Programming a Sort Routine The following program sorts numbers in ascending order.
MAX_INDEX := MIN_INDEX + MAX_LOTS;
UNSORTED := 0;
START_I := MIN_INDEX + 1;
FOR (UNSORTED := START_I TO MAX_INDEX) DO
NEW_LOT := N7:[N7:301];
LOCATION := UNSORTED;
PREVIOUS_LOCATION := LOCATION 1;
WHILE (LOCATION > MIN_INDEX) AND (N7:[N7:[N7:309] > NEW_LOT) DO
N7:[N7:303] := N7:[N7:309];
LOCATION := LOCATION 1;
PREVIOUS_LOCATION := LOCATION 1;
END_WHILE;
N7:[N7:303] := NEW_LOT;
END_FOR;
Debugging Programs
To help locate and trace the execution of a structured text program, set a
variable at the beginning of each program file and store the file number. Then
in various locations throughout the structured text program, update a state
variable. For example:
FILE := 3;
STATE := 0;
structured text code
.
.
.
STATE := 1;
structured text code
.
.
.
STATE := 2;
structured text code
.
.
.
STATE := 3;
Use PowerText to monitor the structured text file to determine where the
processor is executing. You can also use your operator interface to monitor the
FILE and STATE values to determine where the processor is executing.
A-2
Appendix
Appendix Objectives
This appendix lists the available ladder instructions for structured text and their
operands and the data types/values that are valid for each operand.
The following table explains each valid data type/value:
This Data Type/Value:
immediate
(program constant)
integer
float
block transfer
PID
string
SFC status
Accepts:
any value between -32768 and 32767
any integer data type: integer, timer, counter, status, bit, input, output,
ASCII, BCD, control (e.g. N7:0, C4:0, etc.)
any floating point data type (valid range is + 1.1754944e-38 to
+3.4028237e +38). Note that the 1784-T50 may round or truncate the
number based on the number of significant digits and the size of the
floating point number.
any block transfer data type (e.g. BT14:0) or integer data type (e.g. N7:0)
any PID data type (e.g. PD16:0) or integer data type (e.g. N7:0)
any string data type (e.g. ST12:0)
any SFC status data type (e.g. SC17:0)
Table B.A shows the PLC-5 instructions you can program in structured text, the
syntax, and the operands for those instructions. Some ladder functions are
transitional and do not operate properly if not scanned with a false rung status.
Table B.A also lists whether a false-to-true transition is required for execution.
Structured text is only supported on enhanced PLC-5 series C, revision C and
later processors.
Important: This appendix lists the instructions you can use in structured text
programs. There are additional instructions that you can use in ladder logic
programs. For a complete list of instructions, see the PLC-5 Instruction Set
Reference, publication 6200-6.4.11.
B-1
Appendix B
Ladder Functions Reference
Table B.A
Programming Instructions and Operands
Instruction Description
Operand
Valid Value
Require
False-to-True
Transition
channel
immediate, 04 integer
yes
control
control address
characters
integer
structured-text syntax
ABL
channel
immediate, integer
control
control address
characters
integer
yes
yes
ACN
ACS
source
string
destination
integer
source A
string
source B
string
Arc Cosine
source
destination
ADD
source A
source B
destination
integer, float
String Extract
source
string
index
number
destination
string
ADD
AEX
AFI
Always False
no
no
no
no
no
no
AFI
AHL
AIC
channel
handshake OR mask
control
control
source
immediate, integer
destination
string
B-2
yes
no
Appendix B
Ladder Functions Reference
Instruction Description
Operand
Valid Value
Require
False-to-True
Transition
channel
yes
destination
string
control
control address
string length
0 82
characters read
integer
structured-text syntax
ARD
channel
destination
string
control
control address
string length
0 82
characters read
integer
yes
ASN
ASR
ATN
AVE
AWA
source
string
index
search
string
result
integer
Arc Sine
source
destination
source A
string
source B
string
Arc Tangent
source
destination
Average File
file
integer, float
AVE (fil
(file, d
destination,
i
i
control,
l
length, position)
destination
integer, float
control
control address
length
1 1000
position
0 999
channel
source
string
control
control address
string length
0 82
characters sent
integer
no
no
no
no
yes
yes
B-3
Appendix B
Ladder Functions Reference
Instruction Description
Operand
Valid Value
Require
False-to-True
Transition
ASCII Write
channel
immediate, integer
yes
source
string
control
control address
length
0 82
characters sent
integer
structured-text syntax
AWT
BSR
BTD
file
binary
control
control address
bit address
bit
length
file
binary
control
control address
bit address
bit
length
Bit Distribute
source
immediate, integer
source bit
destination
integer
destination bit
immediate (0 15)
length
immediate (1 16)
B-4
yes
yes
no
Appendix B
Ladder Functions Reference
Instruction Description
Operand
Valid Value
Require
False-to-True
Transition
rack
00-277 octal
yes
group
0-7
module
0-1
control block
BT address
structured-text syntax
BTR
integer address
BTW
data file
integer
length
0, 1-64
continuous
YES, NO
rack
00-277 octal
group
0-7
module
0-1
control block
BT address
yes
integer address
CLR
Clear
data file
integer
length
0, 1-64
continuous
YES, NO
destination
integer, float
no
CLR destination
CMP
Compare
expression, relative
expression using values or
expression, expression addresses with evaluators
no
File Copy
source
array
no
destination
array
length
immediate (1 1000)
Cosine
source
destination
Compute
destination
integer, float
math expression
Count Down
counter
counter
PRE
32768 +32767
ACC
32768 +32767
COS
CPT
CTD
no
no
yes
In non-continuous mode, BTR and BTW ladder functions requires a false-to-true transition to execute. In continuous mode, once the rung goes true, BTR and BTW functions continue to
execute regardless of rung condition.
B-5
Appendix B
Ladder Functions Reference
Instruction Description
Operand
Valid Value
Require
False-to-True
Transition
Count Up
counter
counter
yes
PRE
32768 +32767
ACC
32768 +32767
Diagnostic Detect
source array
binary
reference array
binary
result array
integer
compare control
control address
length
position
0 15999
result control
control address
length
1 1000
position
0 999
source
destination
Divide
source A
source B
destination
integer, float
Data Transitional
source
immediate, integer
(source mask,
mask reference) output
DTR (source,
instruction
mask
immediate, integer
structured-text syntax
CTU
DDT
DEG
DIV
DTR
thiss instruction
must
s
s bee followed
ll e by an
a output instruction
s
reference
to compile correctly
EOT
yes
no
no
no
integer
End of Transition
no
EOT
EQU
source A
source B
File Arithmetic/Logical
control
control address
length
1 1000
position
0 999
mode
destination
integer, float
expression
Equal
no
B-6
yes
Appendix B
Ladder Functions Reference
Instruction Description
Operand
Valid Value
Require
False-to-True
Transition
source array
binary
yes
reference array
binary
result array
integer
compare control
control address
length
position
0 15999
result control
control address
length
1 1000
position
0 999
FIFO Load
source
FIFO array
indexed, integer
control
control address
length
1 1000
position
0 999
FIFO Unload
FIFO array
indexed, integer
destination
indexed, integer
control
control address
length
1 1000
position
0 999
Fill File
source
destination array
array
length
immediate (1 1000)
From BCD
source
immediate, integer
destination
integer
control
length
1 1000
structured-text syntax
FBC
FFL
FFU
FLL
FRD
FSC
position
thiss instruction
s
must
s bee followed
ll e by aan output instruction
s
to compile correctly
mode
GEQ
yes
yes
no
no
yes
0 999
immediate, integer (0, INC,
11000, ALL)
expression
source A
source B
no
B-7
Appendix B
Ladder Functions Reference
Instruction Description
Operand
Valid Value
Require
False-to-True
Transition
source A
no
source B
I (input word)
immediate, integer
PLC-5/10, 11, 12 15, 20, 25,
30: 000-077
PLC-5/40, 40L: 000-157
PLC-5/60, 60L, 80, :000-237
no
O (output word)
immediate, integer
PLC-5/40, 40L: 000-157
PLC-5/60, 60L, 80: 000-237
no
Jump to Subroutine
no
JSR (file_number,
number_of_input_parameters,
input parameter list
input_parameter_list,
_p
_
)
return_parameter_list)
number of input
parameters
immediate, integer
integer, float
source A
source B
source A
source B
Limit
low limit
test
structured-text syntax
GRT
Greater Than
GRT (source_a, source_B) output
instruction
Immediate Input
IIN input_word
IOT
Immediate Output
IOT output_word
JSR
LEQ
no
Less Than
no
thiss instruction
must
s
s bee followed
ll e by an
a output instruction
s
high limit
to compile correctly
LFL
LIFO Load
source
LIFO array
indexed, integer
control
control address
length
1 1000
position
0 999
B-8
no
yes
Appendix B
Ladder Functions Reference
Instruction Description
Operand
Valid Value
Require
False-to-True
Transition
LIFO Unload
LIFO array
indexed, integer
yes
destination
indexed, integer
control
control address
length
1 1000
position
0 999
Natural Log
source
LN (source, destination)
destination
float
source
destination
float
source operand
immediate, integer
MEQ (source,
(source mask,
mask compare) output
instruction
source mask
immediate, integer
structured-text syntax
LFU
LN
LOG
MEQ
thiss instruction
s
must
s bee followed
ll e by an
a output instruction
s
compare operand
to compile correctly
MOV
MUL
MVM
NEG
NEQ
no
no
no
immediate, integer
Move
source
destination
integer, float
Multiply
source A
source B
destination
integer, float
Masked Move
source operand
immediate, integer
source mask
destination
integer
Negate
source
destination
integer, float
Not Equal To
source A
source B
Logical NOT
source
immediate, integer
destination
integer
One Shot
source bit
bit
no
no
no
no
no
ONS
no
yes
B-9
Appendix B
Ladder Functions Reference
Instruction Description
Operand
Valid Value
Require
False-to-True
Transition
storage bit
bit
yes
OSF (storage
bit output
bit
(storage_bit,
output_bit,
output_word) output instruction
output bit
immediate
structured-text syntax
OSF
thiss instruction
s
must
s bee followed
ll e by an
a output instruction
s
output word
to compile correctly
OSR
OTE
word
storage bit
bit
OSR (storage
(storage_bit,
bit output
output_bit,
bit
output_word) output instruction
output bit
immediate
yes
thiss instruction
s
must
s bee followed
ll e by an
a output instruction
s
output word
to compile correctly
word
Output Energize
destination bit
bit
no
destination bit
bit
no
destination bit
bit
no
PID
control
PD address
no
control
integer address
yes
process variable
integer
tieback
immediate, integer
control variable
integer
source
destination
Timer/Counter Reset
address
timer, counter, or
control address
no
no
Retentive Timer On
time base
yes
PRE
0 32767
ACC
0 32767
integer, float
no
SFC reset
immediate (1 999)
no
restart at step
immediate, integer
OTE bit
OTL
Output Latch
OTL bit
OTU
Output Unlatch
OTU bit
PID
RAD
RES
RES address
RET
Return
no
RET (return_parameter_list)
RTO
SBR
Subroutine
SBR (input_parameter_list)
SFR
B-10
Appendix B
Ladder Functions Reference
Instruction Description
Operand
Valid Value
Require
False-to-True
Transition
Sine
source
no
destination
Sequencer Input
file
integer, indexed
mask
structured-text syntax
SIN
SQI
thiss instruction
s
must
s bee followed
ll e by an
a output instruction
s
source
to compile
le correctly
e l
control
SQL
SQO
SQR
SRT
STD
SUB
no
length
1 1000
position
0 999
Sequencer Load
file
integer, indexed
source
control
control address
length
1 1000
position
0 999
Sequencer Output
file
integer, indexed
mask
destination
indexed, integer
control
control address
length
1 1000
position
0 999
Square Root
source
destination
integer, float
Sort
sort file
integer, float
control
control address
length
1 1000
position
0 999
Standard Deviation
integer, float
destination
integer, float
control
control address
length
1 1000
position
0 999
Subtract
source A
source B
destination
integer, float
yes
yes
no
yes
yes
no
B-11
Appendix B
Ladder Functions Reference
Instruction Description
Operand
Valid Value
Require
False-to-True
Transition
Tangent
source
no
destination
To BCD
source
immediate, integer
destination
integer
timer
timer
time base
PRE
0 32767
ACC
0 32767
Timer On Delay
timer
timer
time base
PRE
0 32767
ACC
0 32767
structured-text syntax
TAN
TOD
TOF
TON
UID
no
yes: requires
a
truetofalse
transition
a s
to
e e e
execute
yes
no
UID
UIE
no
UIE
XIC
Examine On
source bit
bit
no
source bit
bit
no
X to the Power of Y
source A
immediate, integer
no
source B
immediate, integer
destination
integer
Examine Off
XIO bit output instruction
B-12
Appendix
This programming example is an ASCII structured text file that you can import
into 6200 using the import/export functions. For more information about
importing ASCII files, see the PLC-5 Programming Manual,
publication 6200-6.4.7.
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
DATA I:277
0X0000 0X0000
0X0000 0X0000
0X0000 0X0000
0X0000 0X0000
0X0000 0X0000
0X0000 0X0000
0X0000 0X0000
0X0000 0X0000
0X0000 0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
0X0000
DATA S:127
%
STATUS FILE COMMENT
DH+ station: 33
Mode: ADAPTER
Local hardware addressing: 1SLOT
Ram backup: DISABLEDMemory: UNPROTECTED EEPROM: TRANSFER DISABLED
Arithmetic flags
S:0 Z:0 V:0 C:0 CHECKSUM: 12912
User control bits
00000000 00000000
RESTART FIRST STEP
Processor status
00100000 10001000
MODE SWITCH IN REMOTE
Minor fault
00000000 00000010
DH+ TABLE CHANGE
Minor fault2
00000000 00000000
Major fault
00000000 00000000
Fault code
23
FILE NUMBER OUT OF RANGE
Where faulted
prog file:
2
rung:
0
Fault routine
prog file:
0
watchdog:
500
Select. timed inter.prog file:
0
setpoint:
0
Select. scan [msec] last:
0
max:
0
Program input inter.prog file:
0
input word:
00
C-1
Appendix C
ASCII Structured Text Programming Example
PII scan
[msec] last:
0
max:
0
PII input mask: 0000000000000000
preset:
0
accum:
0
PII in polarity: 0000000000000000
return mask: 0000000000000000
Program scan [msec] last:
7
max:
284
Date/time 00000406 23:53:17Indexed addressing offset
0
Adapter Image file:
0
I/O Status File:
0
VME status file:
Active node list
0
10
20
30
40
50
60
70
00000000 00000000 00000000 00010000 00001000 00000000 00000000 00000000
0
00000000
reset:
00000000
reset:
00000000
reset:
rack fault
00000000
rack fault
00000000
rack fault
00000000
MCP
MCP
MCP
MCP
MCP
MCP
MCP
MCP
MCP
MCP
MCP
MCP
MCP
MCP
MCP
MCP
MCP
last:
last:
last:
last:
last:
last:
last:
last:
last:
last:
last:
last:
last:
last:
last:
last:
3
4
0
0
0
0
0
0
0
0
0
0
0
0
0
0
inhibit: 0000000000000000
prog file:
2
prog file:
3
prog file:
0
prog file:
0
prog file:
0
prog file:
0
prog file:
0
prog file:
0
prog file:
0
prog file:
0
prog file:
0
prog file:
0
prog file:
0
prog file:
0
prog file:
0
prog file:
0
max:
max:
max:
max:
max:
max:
max:
max:
max:
max:
max:
max:
max:
max:
max:
max:
00000000
inhibit: 00000000
00000000
inhibit: 00000000
00000000
inhibit: 00000000
9
281
0
0
0
0
0
0
0
0
0
0
0
0
0
0
%
0
2
6
0
0
0
0
0
2
0
0
0
0
8328 13797
0
23
23
53
0
0
0
0
0
0
0
0
0
0
3
9
0
0
0
0
0
0
0
0
DATA B3:1
0
0
2
17
0
0
0
0
0
3
0
0
0
0
2048
0
0
0
0
0
0
0
4
0
0
0
0
16
0
0
0
0
0
0
0
281
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
12912
0
0
0
0
0
0
0
C-2
7
0
500
0
0
0
0
0
0
0
0
0
284
4
0
0
0
0
0
0
0
0
0
0
Appendix C
ASCII Structured Text Programming Example
DATA T4:3
0X026f
0X020a
0X02a5
0X02fa
2
2
34
2
0
0
0
0
DATA C5:2
0X0000
1
0X2000
100
0X0000
100
0
188
41
DATA R6:0
0X0000
DATA N7:50
0
1
0
0
20
0
2
500
0
0
17
1
0
0
1
0
DATA F8:25
1
0
0
0
2
1
0
0
0
0
0
3 1.7320508
0
0
0
0
0
0
5
3
0
0
0
0
0
0
0
0
7
0
601
0
0
31
0
5
0
0
0
1
5
0
0
0
1.5
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
PROJECT P80NEW
3 text1
LADDER 2
SOR XIC I:001/004 CTU C5:2 100 41 EOR
SOR MOV N7:46 N7:36 EOR
ST_TEXT 3
IF (I:001/007) THEN
F8:23 := ((1.0 * F8:21)+( SQR ((F8:21 * F8:21)((4.0 * F8:20)* F8:22))))/(2.0 * F8:20);
F8:24 := ((1.0 * F8:21)(SQR((F8:21 * F8:21)((4.0 * F8:20)* F8:22))))/ (2.0 * F8:20);
END_IF;
F8:25 := ((1.0 * F8:21)+( SQR ((F8:21 * F8:21)((4.0 * F8:20)* F8:22))))/ (2.0 * F8:20);
IF (I:001/007) THEN
SQR (F8:1, F8:2);
NEG (F8:3, F8:4);
END_IF;
AFI () CTU (C5:1, 100, 188);
IF (I:001/004) THEN
CTU (C5:1, 100, 188);
END_IF;
N7:35 := 7;
N7:36 := 31;
IF (I:001/000) THEN
TON (T4:0, 1.0, 2, 0);
END_IF;
C-3
Appendix C
ASCII Structured Text Programming Example
IF (T4:0.DN) THEN
O:001/000 := 1;
O:001/001 := 1;
O:001/002 := 1;
O:001/003 := 1;
O:001/004 := 1;
O:001/005 := 1;
O:001/006 := 1;
O:001/007 := 1;
END_IF;
IF (T4:0.DN) THEN
TON (T4:1, 1.0, 2, 0);
END_IF;
IF (T4:1.DN) THEN
O:001/000 := 0;
O:001/001 := 0;
O:001/002 := 0;
O:001/003 := 0;
O:001/004 := 0;
O:001/005 := 0;
O:001/006 := 0;
O:001/007 := 0;
RES (T4:0);
RES (T4:1);
END_IF;
IF (I:001/001 AND !I:001/000) THEN
TON (T4:2, 1.0, 34, 0);
END_IF;
IF ((T4:2.ACC > 2) AND I:001/001) THEN
O:001/000 := 1;
END_IF;
IF ((T4:2.ACC > 4) AND I:001/001) THEN
O:001/001 := 1;
END_IF;
IF ((T4:2.ACC > 6) AND I:001/001) THEN
O:001/002 := 1;
END_IF;
IF ((T4:2.ACC > 8) AND I:001/001) THEN
O:001/003 := 1;
END_IF;
IF ((T4:2.ACC > 10) AND I:001/001) THEN
O:001/004 := 1;
END_IF;
IF ((T4:2.ACC > 12) AND I:001/001) THEN
O:001/005 := 1;
END_IF;
IF ((T4:2.ACC > 14) AND I:001/001) THEN
O:001/006 := 1;
END_IF;
C-4
Appendix C
ASCII Structured Text Programming Example
1;
1;
1;
1;
1;
1;
1;
1;
0;
C-5
Appendix C
ASCII Structured Text Programming Example
10 :
O:001/001
11 :
O:001/002
12 :
O:001/003
13 :
O:001/004
14 :
O:001/005
15 :
O:001/006
16 :
O:001/007
:= 0;
:= 0;
:= 0;
:= 0;
:= 0;
:= 0;
:= 0;
END_CASE;
IF (I:001/003) THEN
TON (T4:3, 1.0, 2, 0);
END_IF;
IF (T4:3.DN) THEN
N7:50 := N7:50 + 1;
END_IF;
IF (N7:50 > 17) THEN
N7:50 := 0;
END_IF;
IF (T4:3.DN) THEN
RES (T4:3);
END_IF;
IF (I:001/004) THEN
N7:31 := 500;
N7:32 := 0;
N7:35 := 7;
N7:36 := 31;
N7:6 := 0;
N7:7 := 0;
N7:8 := 0;
FOR (N7:30 := 2 TO N7:35 BY 2) DO
N7:32 := N7:32 + 1;
REPEAT
N7:6 := N7:6 + 1;
UNTIL (N7:6 > 600) END_REPEAT;
IF (N7:6 > 550) THEN
EXIT;
END_IF;
END_FOR;
END_IF;
SFC2 4
FORCE FO:277
0X0000 0X0000
0X0000 0X0000
0X0000 0X0000 . . .
C-6
Appendix C
ASCII Structured Text Programming Example
FORCE FI:277
0X0000 0X0000
0X0000 0X0000
0X0000 0X0000
0X0000 0X0000 . . .
PLC2 $3:0:47
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
PLC2 $3:1:47
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
PLC2 $3:2:47
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
PLC2 $3:3:47
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
PLC2 $3:4:47
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
PLC2 $3:5:47
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
C-7
Appendix C
ASCII Structured Text Programming Example
CONFIG $4:0
CONFIG $4:1:411
1
1 32574
8224
8224
1
28207
7175 18954
0
0
0
3335
4097
7717
0
18954
8224
257
0
CONFIG $4:2:17
8192
6995 21826
1536
0
0
1024
781
CONFIG $4:3:17
8192
6995 21826
1536
0
0
7717
8224
260
0
1
8224
257
0
4097
8224
0
0
8224
1
0
0
8224
5121
0
0 . . .
0
243
0 28672
2560
0
50
1000
771
768
1024
781
0
243
0 28672
2560
0
50
1000
771
768
CONFIG $4:4:71
130
0
0
0
0
0
8
0
0
27
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
CONFIG $4:5:71
129
0
0
0
0
0
8
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
CONFIG $4:6:71
127
0
0
0
0
0
8
0
0
3264
0
0
0
0
0
24
0
0
1
0
0
24
0
0
0
0
0
0
0
0
CONFIG $4:7:71
127
0
0
0
8
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
C-8
Appendix C
ASCII Structured Text Programming Example
The actual structured text for the preceding ASCII processor memory file is
shown below.
IF (I:001/007) THEN
F8:23 := ((1.0 * F8:21) + ( SQR ((F8:21 * F8:21) ((4.0 * F8:20) * F8:22)))) / (2.0 * F8:20);
F8:24 := ((1.0 * F8:21) ( SQR ((F8:21 * F8:21) ((4.0 * F8:20) * F8:22)))) / (2.0 * F8:20);
END_IF;
F8:25 := ((1.0 * F8:21) + ( SQR ((F8:21 * F8:21) ((4.0 * F8:20) * F8:22)))) / (2.0 * F8:20);
IF (I:001/007) THEN
SQR (F8:1, F8:2);
NEG (F8:3, F8:4);
END_IF;
AFI () CTU (C5:1, 100, 188);
IF (I:001/004) THEN
CTU (C5:1, 100, 188);
END_IF;
N7:35 := 7;
N7:36 := 31;
IF (I:001/000) THEN
TON (T4:0, 1.0, 2, 0);
END_IF;
IF (T4:0.DN) THEN
O:001/000 := 1;
O:001/001 := 1;
O:001/002 := 1;
O:001/003 := 1;
O:001/004 := 1;
O:001/005 := 1;
O:001/006 := 1;
O:001/007 := 1;
END_IF;
IF (T4:0.DN) THEN
TON (T4:1, 1.0, 2, 0);
END_IF;
IF (T4:1.DN) THEN
O:001/000 := 0;
O:001/001 := 0;
O:001/002 := 0;
O:001/003 := 0;
O:001/004 := 0;
O:001/005 := 0;
O:001/006 := 0;
O:001/007 := 0;
RES (T4:0);
RES (T4:1);
END_IF;
C-9
Appendix C
ASCII Structured Text Programming Example
C-10
Appendix C
ASCII Structured Text Programming Example
1;
1;
1;
1;
1;
1;
1;
1;
0;
:= 0;
:= 0;
:= 0;
:= 0;
:= 0;
:= 0;
:= 0;
END_CASE;
IF (I:001/003) THEN
TON (T4:3, 1.0, 2, 0);
END_IF;
IF (T4:3.DN) THEN
N7:50 := N7:50 + 1;
END_IF;
IF (N7:50 > 17) THEN
N7:50 := 0;
END_IF;
C-11
Appendix C
ASCII Structured Text Programming Example
IF (T4:3.DN) THEN
RES (T4:3);
END_IF;
IF (I:001/004) THEN
N7:31 := 500;
N7:32 := 0;
N7:35 := 7;
N7:36 := 31;
N7:6 := 0;
N7:7 := 0;
N7:8 := 0;
FOR (N7:30 := 2 TO N7:35 BY 2) DO
N7:32 := N7:32 + 1;
REPEAT
N7:6 := N7:6 + 1;
UNTIL (N7:6 > 600) END_REPEAT;
IF (N7:6 > 550) THEN
EXIT;
END_IF;
END_FOR;
END_IF;
C-12
Index
A
accepting edits, 3-8
addresses, 3-3
application example, sort routine, A-2
application examples
debugging programs, A-2
free running timer, A-1
ASCII files, 3-9, C-1
Attention
modifying programming examples, 2-1, A-1
sub-element values, 2-11
B
bit operands, 1-3
C
CASE, 2-5
compare expressions, 1-4
conditional iterative loops
EXIT, 2-9
REPEAT, 2-8
WHILE, 2-7
conditional loops
CASE, 2-5
IF-ELSIF-ELSE, 2-4
configuring
PowerText display colors, 4-3
structured text, 3-2
constructs, 1-3, 1-7, 2-1
creating
configurable data monitor, 4-4
structured text files, 3-1
D
data monitor, configurable, 4-4
data types, B-1
debugging programs, A-2
defining
addresses, 3-3
symbols, 3-3
display characteristics, configuring, 3-2
documentation reports, 3-10
E
editing
accepting edits, 3-8
ASCII files, 3-9
in Windows, 3-9
online, 3-9
structured text, 3-1, 3-7
EMPTY (;;), 2-10
entering
accepting edits, 3-8
structured text, 3-1, 3-5
equivalents to ladder functions, 2-11
EXIT, 2-9
F
false-to-true transitions, B-1
field widths, 4-5
FOR, 2-6
I
IF-ELSIF-ELSE, 2-4
immediates, 1-3
Important
creating a monitoring screen, 4-4
editing online in Program or Remote
Program mode, 3-9
exiting FOR loops, 2-7
exiting REPEAT loops, 2-9
exiting WHILE loops, 2-8
floating point values, 2-5
I/O addresses in iterative constructs, 2-7, 2-8
installing structured text, 1-1
line length, 1-6
multiple CASE values, 2-5
PowerText intensification, 4-1
processor modes, 3-7
removing previous versions of software, 1-1
software products, 3-1
supported ladder instructions, B-1
using % characters, 1-6
using braces ({ }), 1-7
Index
P
PowerText
configurable data monitor, 4-4
configuring display colors, 4-3
field widths, 4-5
line length, 1-6
monitoring structured text, 4-1
programming examples
ASCII structured text, C-1
debugging, A-2
free running timer, A-1
sort routine, A-2
R
reference, instructions, B-1
REPEAT, 2-8
reports, generating, 3-10
reserved words, 1-7
retentive bit assignments, 2-3
rules, 1-6
S
sort routine, A-2
string data types, 1-6
structured text
accepting edits, 3-8
application examples, A-1
ASCII files, 3-9
bit operands, 1-3
CASE, 2-5
compare expressions, 1-4
comparison to C, 1-7
configurable data monitor, 4-4
constructs, 1-3, 1-7, 2-1
definition, 1-1
editing, 3-1, 3-7
Index
rules, 1-6
support, 1-1
variable assignments, 2-2
WHILE, 2-7
whitespace, 1-5, 1-8
writing, 1-1
symbols, 3-3
T
Tip
[AltF7] key toggles documentation display,
4-1
saving files with syntax errors, 3-8
V
variable assignments, 2-2
W
WHILE, 2-7
whitespace, 1-5, 1-8
writing, structured text, 1-1
Customer Support
519-623-1810
414-382-2000
44-908 838800
31-2975 43500
(33-1) 4778 1402
(49) 2104 6900
(39-2) 4830 0381
(852) 873-1342
Allen-Bradley, a Rockwell Automation Business, has been helping its customers improve
productivity and quality for 90 years. We design, manufacture, and support a broad range of
control and automation products worldwide. They include logic processors, power and motion
control devices, man-machine interfaces, sensors, and a variety of software. Rockwell is one
of the worlds leading technology companies.
Worldwide representation.
Algeria Argentina Australia Austria Bahrain Belgium Brazil Bulgaria Canada Chile China, PRC Colombia Costa Rica Croatia Cyprus Czech Republic
Denmark Ecuador Egypt El Salvador Finland France Germany Greece Guatemala Honduras Hong Kong Hungary Iceland India Indonesia Israel Italy
Jamaica Japan Jordan Korea Kuwait Lebanon Malaysia Mexico New Zealand Norway Oman Pakistan Peru Philippines Poland Portugal Puerto Rico
Qatar Romania RussiaCIS Saudi Arabia Singapore Slovakia Slovenia South Africa, Republic Spain Switzerland Taiwan Thailand The Netherlands Turkey
United Arab Emirates United Kingdom United States Uruguay Venezuela Yugoslavia
Allen-Bradley Headquarters, 1201 South Second Street, Milwaukee, WI 53204 USA, Tel: (1) 414 382-2000 Fax: (1) 414 382-4444
PN 955116-95
Copyright 1995 Allen-Bradley Company, Inc. Printed in USA