ACR BASICS
ACR Programmer’s Guide
121
Local variables need to be dimensioned within program. Place a
CLEAR
command prior to a
DIM
statement to
clear out any previously dimensioned variables.
Below is a sample program that extends and retracts and actuator to feed out material, printing the number of
cycles, the length and the motor position.
PROGRAM
CLEAR
: REM Clear any dimensioned variables.
DIM LV(1)
: REM Dimension 1 long variable.
DIM DV(2)
: REM Dimension 2 double variables.
LV0=0
: REM Initialize cycle counter.
DV0=3.1412
: REM Set material feed distance.
_LABEL1
PRINT "Cycles=",LV0
: REM Comma inserts a tab character between.
PRINT "Length=";DV1
: REM Semicolon indicates there is no space.
PRINT "X",(P12290/P12375)
X(DV0)
: REM Feed out material.
X0
: REM Retract actuator.
LV0=LV0+1
: REM Increment the cycle count.
DV1=DV0*LV0
: REM Update the total length fed out.
GOTO LABEL1
ENDP
Use
LRUN
to execute the program in the Terminal Emulator and listen to
commands. A
statement that does not end with either a comma or a semicolon produces a carriage return and linefeed
combination.
Defines
From examples up to this point, AcroBASIC extensively uses bits, parameters and variables. These bits and
parameters can be for controller status or the
programmer’s user data
in programs. Alternative names, called
defines, can be assigned to parameters, bits, constants and variables to make program code more readable.
Defines are recognized globally (across user programs).
Observe the following rules when creating and using defines:
•
Use a maximum of 23 letters.
•
Defines are case sensitive.
•
The first character must be a letter, but numbers can be used after that.
•
Do not use spaces or special characters (such as _ and @).
•
Use caution when using defines with local variables.
A define is recognized across programs, while local variables are limited to the program in which they are created.
This can cause problems if you have created similar local variables in different programs. For example, if long
variables are dimensioned in three programs, then the define
“counter”
is assigned to
LV1
(long variable 1), the
controller recognizes “counter” as
a define in all three programs, though it represents a counter in only one
program.
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 ...