ACR BASICS
112
ACR
Programmer’s Guide
The
IF
portion is the condition to test; if the condition proves true, the
THEN
portion of the statement executes.
If instead the condition proves false, the
THEN
statement is ignored and program execution moves on to the next
statement.
NOTE: Enclose the condition being tested in parentheses.
Though the
IF/THEN
statement provides a single-line test, it can execute multiple statements when the condition
proves true. All the statements must appear on a single line and be separated by a delimiter (space, colon, and
another space).
When using an
IF/THEN
statement, users can nest
GOTO
and
GOSUB
statements.
IF (BIT 24) THEN P0 = P0+1
IF (P0 < 2) THEN GOSUB LoadParts : P0 = 100
Or, from the previous program sample, check if the drive did not enable. If it did not enable, print a message and
end the program:
IF (NOT BIT8465) THEN ? "DRIVE DIDN'T ENABLE" : END
IF/ELSE/ENDIF
The
IF/ELSE
statement provides a powerful tool for program branching and program flow control. The
IF/ELSE
statement allows you to run one set of code if the condition is true, and another set of code if the
condition is false. The
IF/ELSE
statement must end with
ENDIF
.
When using an
IF/ELSE
statement, observe the following:
•
You can nest
GOSUB
statements in an
IF/ELSE
statement. The
GOSUB
provides a return into the
IF/ELSE
statement.
•
Do not nest
GOTO
statements in
IF/ELSE
statements. The
GOTO
statement exits the
IF/ELSE
statements and does not provide any link back inside.
•
Do not nest
IF/THEN
statements in
IF/ELSE
statements
—
the logic may not provide the results you
expect.
Tip: When troubleshooting programs, use the
LIST
command to view the program stored on the controller. In
recognizing
IF/ELSE
statements, the controller indents the statements under the
IF
including the
ENDIF
. If any
statements in the
IF/ELSE
are not indented but should be, check the code in the program editor and re-
download.
The following demonstrates different actions based on conditions being true or false. If the input (bit 24) is true,
the long array increments and axis X moves an incremental distance of 25 units. If false, the long array decrements
and axis Y moves to an absolute position of 5.
IF (BIT 24)
LA0(1) = LA0(1)+ 1
X/25
ELSE
LA0(1) = LA0(1)- 1
Y5
Summary of Contents for ACR7000 Series
Page 1: ...Effective June 2021 Document Number 88 028698 01E Programmer s Guide ACR Series Controllers ...
Page 23: ...PARKER MOTION MANAGER ACR Programmer s Guide 23 CHAPTER 1 Parker Motion Manager ...
Page 69: ...PARKER MOTION MANAGER ACR Programmer s Guide 69 ...
Page 101: ...ACR BASICS ACR Programmer s Guide 101 CHAPTER 2 ACR Basics ...
Page 153: ...MAKING MOTION ACR Programmer s Guide 153 CHAPTER 3 Making Motion ...
Page 207: ...WRITING ACROBASIC PROGRAMS ACR Programmer s Guide 207 CHAPTER 4 Writing AcroBASIC Programs ...
Page 233: ...WRITING ACROBASIC PROGRAMS ACR Programmer s Guide 233 ...
Page 238: ...BINARY HOST INTERFACE 238 ACR Programmer s Guide CHAPTER 5 Binary Host Interface ...
Page 269: ...TROUBLESHOOTING ACR Programmer s Guide 269 CHAPTER 6 Troubleshooting ...
Page 288: ...APPENDIX B ETHERNET BASICS 288 ACR Programmer s Guide APPENDIX B Ethernet Basics ...
Page 293: ...APPENDIX C SERVO PID TUNING ACR Programmer s Guide 293 APPENDIX C Servo PID Tuning ...
Page 296: ...APPENDIX C SERVO PID TUNING 296 ACR Programmer s Guide ...