RIO Commands Flashcards
#
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