RIO Commands Flashcards
(29 cards)
#
Label Designator
The # denotes the name of a program label, for example, #move. Labels are often used to implement subroutines or loops. Labels are either user-defined or are reserved names, called “automatic subroutines”, that automatically execute when a particular event occurs.
‘A sample FOR loop
‘Routine will run 10 times and sum all integers 1 through 10
sum=0; ‘ variable to hold sum of integers
i=1; ‘ create a counter
#for
sum=sum+i; ‘ add counter to sum
i=i+1; ‘ increment counter
JP#for,(i<=10)
EN
#AUTO
Subroutine to Run Automatically on Power-Up
Defines the automatic entry point of embedded DMC code. When power is applied to the controller, or after the controller is reset, the program will automatically begin executing at this label. When no host software is used with the controller, #AUTO is required to run an application program on the controller stand-alone.
‘On startup, this code will create a 50% duty cycle square wave
‘on output 1 with a period of 1 second
#AUTO; ‘ start on powerup
SB 1; ‘ set bit 1
WT 500; ‘ wait 500msec
CB 1; ‘ clear bit 1
WT 500; ‘ wait 500msec
JP #AUTO; ‘ jump back to #AUTO
@AN
Analog Input Query
The @AN[] operator returns the value of the given analog input in volts.
:MG @AN[1] ; ‘print analog input 1 value
1.7883
:x = @AN[1] ; ‘assign analog input 1 state to a variable
@AO
Analog Output Query
The @AO[n] operator is used to query the value of an Analog Output.
:MG@AO[1]; ‘ Displays status of Analog output 1
2.5000
:temp=@AO[1]; ‘ Sets variable temp to the value of Analog output 1
@IN
Read Digital Input
The @IN operand returns the value of the given digital input (either 0 or 1).
:MG @IN[1]
1.0000
:x = @IN[1]
:x = ?; ‘ print digital Input 1
1.000
@OUT
Read Digital Output
Returns the value of the given digital output (either 0 or 1)
:MG @OUT[1]; ‘ print state of digital output 1
1.0000
:x = @OUT[1]; ‘ assign state of digital output 1 to a variable
AI
After Input
The AI command is a trippoint used in motion programs to wait until after a specified input has changed state. This command can be configured such that the controller will wait until the input goes high or the input goes low.
AI 8;’ Wait until input 8 is high
#A;’ Begin Program
AI 7&15&-1&-12;’ Wait until inputs 7 & 15 are high, and inputs 1 & 12 are low
MG “DONE”;’ Send message ‘DONE’ when conditions are satisfied
EN;’ End Program
AT
ex
At Time
The AT command is a trippoint which is used to hold up execution of the next command until after the specified time has elapsed. The time is measured with respect to a defined reference time. AT 0 establishes the initial reference.
AT 0;’ Establishes reference time 0 as current time
AT 50;’ Waits 50 msec from reference 0
AT 100;’ Waits 100 msec from reference 0
AT -150;’Waits 150 msec from reference 0 and sets new reference at 150
AT 80;’ Waits 80 msec from new reference (total elapsed time is 230 msec)
EN
BN
Burn Parameters
The BN command saves certain board parameters in non-volatile EEPROM memory. Once written to the memory, all parameters which can be burned will persist through a software reset (RS command), hardware reset (reset button) or power cycle. This command typically takes 1 second to execute and must not be interrupted. The controller returns a colon (:) when the Burn is complete. All parameters which have been burned into memory can be restored to their factory defaults through a master reset.
SB1; ‘ set bit 1
CB2; ‘clear bit 2
CW1; ‘ set data adjustment bit
BN; ‘ burn all parameter states
BP
Burn Program
The BP command saves the application program in non-volatile EEPROM memory. This command may take several seconds to execute and must not be interrupted. The controller returns a : (colon) when the Burn is complete.
:BP; ‘ burn in program to controller
: //get colon response when done
BV
Burn Variables and Arrays
The BV command saves the controller variables and arrays in non-volatile EEPROM memory. This command typically takes up to 2 seconds to execute and must not be interrupted. The controller returns a : when the Burn is complete.
:BV;’ burn in variables
: //controller returns a colon when Burn is complete
CB
Clear Bit
The CB command clears a particular digital output. The SB and CB (Clear Bit) instructions can be used to control the state of output lines.
When an output has been cleared, current will cease flowing through the optocoupler for that output.
SB 5; ‘ Set digital output 5
SB 1; ‘ Set digital output 1
CB 5; ‘ Clear digital output 5
CB 1; ‘ Clear digital output 1
EN
IQ
Digital Input Configuration
The IQ command sets the bitwise active level for each of the digital inputs. The input for IQ is a bitmask representing the inputs of the controller. When bit n of IQ is 0, then current flowing through the opto of input n returns a 0. When bit n is 1, current flow returns a 1.
:IQ255; ‘This sets inputs 0-7 such that current flowing results in logic 1
:
:IQ192;’ Current flowing on inputs 6 and 7 results in logic 1 - current flowing on 0-5 and 8-15 are logic 0
IF
input
IF Conditional Statement
The IF command is used in conjunction with an ENDIF command to form an IF conditional statement. The arguments consist of one or more conditional statements and each condition must be enclosed with parenthesis (). If the conditional statement(s) evaluates true, the command interpreter will continue executing commands which follow the IF command. If the conditional statement evaluates false, the controller will ignore commands until the associated ENDIF command or an ELSE command occurs in the program.
IF (@IN[1]=0);’ IF conditional statement based on input 1
MG “Input 1 is Low”;’ Message to be executed if “IF” statement is true
ENDIF;’ End of IF conditional statement
EN
v1=@AN[1]*5;’ some calculation for variable v1
IF((v1>25)&(@IN[4]=1));’ Conditions based on V1 variable and input 4 status
MG “Conditions met”;’ Message to be executed if “IF” statement is true
ENDIF;’ End of IF statement
EN
ENDIF
End of IF Conditional Statement
The ENDIF command is used to designate the end of an IF conditional statement. An IF conditional statement is formed by the combination of an IF and ENDIF command. An ENDIF command must always be executed for every IF command that has been executed. It is recommended that the user not include jump commands inside IF conditional statements since this causes re-direction of command execution. In this case, the command interpreter may not execute an ENDIF command.
IF (@IN[1]=0);’ IF conditional statement based on input 1
IF (@IN[2]=0);’ 2nd IF conditional statement executed if 1st IF conditional true
MG “IN1 AND IN2 ARE ACTIVE”;’ Message if 2nd IF conditional is true
ELSE;’ ELSE command for 2nd IF conditional statement
MG “ONLY IN1 IS ACTIVE”;’ Message if 2nd IF conditional is false
ENDIF;’ End of 2nd conditional statement
ELSE;’ ELSE command for 1st IF conditional statement
IF (@IN[2]=0);’ 3rd IF conditional statement executed if 1st IF conditional false
MG “ONLY IN2 IS ACTIVE”;’ Message if 3rd IF conditional statement is true
ELSE;’ ELSE command for 3rd conditional statement
MG “IN1 AND IN2 INACTIVE”;’Message if 3rd IF conditional statement is false
ENDIF;’ End of 3rd conditional statement
ENDIF;’ End of 1st conditional statement
ELSE
ELSE Function for Conditional IF Statement
The ELSE command is an optional part of an IF conditional statement. The ELSE command must occur after an IF command and it has no arguments. It allows for the execution of a command only when the argument of the IF command evaluates False. If the argument of the IF command evaluates false, the controller will skip commands until the ELSE command. If the argument for the IF command evaluates true, the controller will execute the commands between the IF and ELSE command.
IF (@IN[1]=0);’ IF conditional statement based on input 1
IF (@IN[2]=0);’ 2nd IF conditional statement executed if 1st IF conditional true
MG “IN1 AND IN2 ARE ACTIVE”;’ Message if 2nd IF conditional is true
ELSE;’ ELSE command for 2nd IF conditional statement
MG “ONLY IN1 IS ACTIVE”;’ Message if 2nd IF conditional is false
ENDIF;’ End of 2nd conditional statement
ELSE;’ ELSE command for 1st IF conditional statement
IF (@IN[2]=0);’ 3rd IF conditional statement executed if 1st IF conditional false
MG “ONLY IN2 IS ACTIVE”;’ Message if 3rd IF conditional statement is true
ELSE;’ ELSE command for 3rd conditional statement
MG “IN1 AND IN2 INACTIVE”;’Message if 3rd IF conditional statement is false
ENDIF;’ End of 3rd conditional statement
ENDIF;’ End of 1st conditional statement
KP
Proportional Gain Constant
KP designates the proportional constant in the controller filter. The proportional gain outputs a control signal proportional to the amount of error.
:KP 12,14;’ Implicit notation to set channel A and B term
:KPB= 14;’ Explicit notation to set channel A only
:KP ,8;’ Implicit notation to set B
:KP ?,?;’ Return A,B values
12, 14
:KPB= ?;’ Return B value
14
:MG _KPA;’ Message the operand for the A channel
12
:
LZ
Omit Leading Zeroes
The LZ command is used for formatting the values returned from interrogation commands, variables, and arrays. By enabling the LZ function, all leading zeros of returned values will be removed.
- _LZ contains the state of the LZ function. ‘0’ is disabled and ‘1’ is enabled.
:LZ 0; ‘disable the LZ function
:TB; ‘tell status bits
001
:LZ 1; ‘inhibit leading zeros
:TB; ‘tell status
NO
A; ‘Program A
No Operation
The NO (or ‘) command performs no action in a sequence and can be used as a comment in a program. NO (or ‘) command lines are downloaded to the controller and do take some execution time.
NO; ‘ No operation
NO This Program; ‘ No operation
NO Does Absolutely; ‘ No operation
NO Nothing; ‘ No operation
EN; ‘End of program
OB
Output Bit
The OB command allows variable control of an output bit based on logical expressions. The OB command defines output bit n as either 0 or 1 depending on the result from the logical expression.
OB 1, pos; ‘ If pos<>0, Bit 1 is high. If pos=0, Bit 1 is low
OB 2, @IN[1]&@IN[2]; ‘ If Input 1 and Input 2 are both high, then Output 2 is set high
OB 3, count[1]; ‘ If the element 1 in the array is zero, clear bit 3
OB n, count[1]; ‘ If element 1 in the array is zero, clear bit n
OP
Output Port
The OP command sets the output ports of the controller in a bank using bitmasks. Arguments to the OP command are bit patterns (decimal or hex) to set entire banks (bytes) of digital outputs. Use SB, CB or OB to set bits individually..
OP $85;’ Set outputs 1,3,8 and clear the others
OP 0;’ Clear all bits
PW
Password
The PW command sets the password used to lock the controller. Locking the controller prevents interrogation of the controller program space.
- The password can only be changed when the controller is in the unlocked state. See the ^L^K for more details.
- The password is burnable but cannot be interrogated. If you forget the password and the controller is locked you must master reset the controller to gain access.
- Quotes are not used to frame the password string. If quotes are used, they are part of the password.
:PWapple,orange
?
:TC1
138 Passwords not identical
:PWapple,apple
:^L^K apple,1
REM
Remark
REM is used for comment lines. The REM statement is NOT a controller command. Rather, it is recognized by Galil PC software, which strips away the REM lines before downloading the DMC file to the controller.
REM differs from NO (or ‘) in the following ways:
- NO (or ‘) comments are downloaded to the controller and REM comments are not.
- NO (or ‘) comments take up execution time and REM comments don’t; therefore, REM should be used for code that needs to run fast.
- REM comments cannot be recovered when uploading a program but NO (or ‘) comments are recovered. Thus the uploaded program is less readable with REM.
- NO (or ‘) comments take up program line space and REM lines do not.
- REM comments must be the first and only thing on a line, whereas NO (or ‘) can be used to place comments to the right of code (after a semicolon) on the same line.
REM This comment will be stripped when downloaded to the controller
‘This comment will be downloaded and takes some execution time
SB1 ;’this comment is to the right of the code and will be downloaded to the controller
RS
Reset
The RS command resets the state of the processor to its power-on condition. The previously saved state of the hardware, along with parameter values and saved program, are restored.
:RS; ‘ reset the hardware
:RS-1; ‘ perform a soft master reset