Local Formatting of Variables
VF command is a global format command that affects the format of all relevant returned values and
variables. Variables may also be formatted locally. To format locally, use the command, {Fn.m} or {$n.m}
following the variable name and the ‘=’ symbol. F specifies decimal and $ specifies hexadecimal. n is the
number of digits to the left of the decimal, and m is the number of digits to the right of the decimal. For
example:
Examples:
:V1=10 Assign
V1
:V1= Return
V1
0000000010.0000 Default
Format
:V1={F4.2} Specify local format
0010.00 New
format
:V1={$4.2} Specify
hex
format
$000A.00 Hex
value
:V1="ALPHA"
Assign string "ALPHA" to V1
:V1={S4}
Specify string format first 4 characters
ALPH
The local format is also used with the MG command (see page 70).
Programmable I/O
As described earlier, the RIO has 16 digital inputs, 16 digital outputs, 8 analog inputs and 8 analog outputs.
The paragraphs below describe the commands that are used for I/O manipulation and interrogation.
Digital Outputs
The most common method of changing the state of digital outputs is by using the set bit ‘SB’ and clear bit
‘CB’ commands. The following table shows an example of the SB and CB commands.
Instruction
Interpretation
SB2 Sets
bit
2
CB1
Clears bit 1
The Output Bit (OB) instruction is useful for setting or clearing outputs depending on the value of a variable,
array, input or expression. Any non-zero value results in a set bit.
Instruction
Interpretation
OB1,POS
Set Output 1 if the variable POS is non-zero. Clear Output 1 if
POS equals 0.
OB2,@IN [1]
Set Output 2 if Input 1 is high. If Input 1 is low, clear Output 2.
OB3,@IN [1]&@IN [2]
Set Output 3 only if Input 1 and Input 2 are high.
OB2,COUNT [1]
Set Output 2 if element 1 in array COUNT is non-zero.
The output port can be set by specifying the OP (Output Port) command. This instruction allows a single
command to define the state of the entire output bank, where 20 is bit 0, 21 is bit 1 and so on. A 1 designates
that the output is on.
72 Chapter 5 Programming
RIO-47xxx