OpBCD Statement
Simultaneously sets 8 output lines using BCD format. (Binary Coded Decimal)
Syntax
OpBCD portNumber, outData [, Forced]
Parameters
- Portnum
- Specify the output byte of I/O. Where the portNumber selection corresponds to the following outputs:
Portnum Outputs 0 0-7 1 8-15 2 16-23 3 24-31 ... ... - Outputs
- Specify the output pattern for the output group specified by port number as an integer value from 0 to 99. The 2nd digit (called the 1's digit) represents the lower 4 outputs in the selected group and the 1st digit (called the 10's digit) represents the upper 4 outputs in the selected group.
- Forced
- This value is optional. Usually omitted.
Description
OpBCD simultaneously sets 8 output lines using the BCD format. The standard and expansion user outputs are broken into groups of 8. The portNumber parameter for the OpBCD instruction defines which group of 8 outputs to use where portNumber = 0 means outputs 0 to 7, portNumber = 1 means outputs 8 to 15, etc.
Once a port number is selected (i.e. a group of 8 outputs has be selected), a specific output pattern must be defined. This is done in Binary Coded Decimal format using the outdata parameter. The outdata parameter may have 1 or 2 digits. (Valid entries range from 0 to 99.) The 1st digit (or 10's digit) corresponds to the upper 4 outputs of the group of 8 outputs selected by portNumber. The 2nd digit (or 1's digit) corresponds to the lower 4 outputs of the group of 8 outputs selected by portNumber.
Since valid entries in BCD format range from 0 to 9 for each digit, every I/O combination cannot be met. The table below shows some of the possible I/O combinations and their associated outnum values assuming that portNumber is 0.
Output Settings (Output number)
Outnum Value | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
---|---|---|---|---|---|---|---|---|
01 | Off | Off | Off | Off | Off | Off | Off | On |
02 | Off | Off | Off | Off | Off | Off | On | Off |
03 | Off | Off | Off | Off | Off | Off | On | On |
08 | Off | Off | Off | Off | On | Off | Off | Off |
09 | Off | Off | Off | Off | On | Off | Off | On |
10 | Off | Off | Off | On | Off | Off | Off | Off |
11 | Off | Off | Off | On | Off | Off | Off | On |
99 | On | Off | Off | On | On | Off | Off | On |
Note that the Binary Coded Decimal format only allows decimal values to be specified. This means that through using Binary Coded Decimal format it is impossible to turn on all outputs with the OpBCD instruction. Please note that the maximum value for either digit for outnum is “9”. This means that the largest value possible to use with OpBCD is “99”. In the table above it is easy to see that “99” does not turn all Outputs on. Instead it turns outputs 0, 3, 4, and 7 On and all the others off.
Notes
Difference between OpBCD and Out
The OpBCD and Out instructions are very similar in the SPEL+ language. However, there is one major difference between the two. This difference is shown below:
- The OpBCD instruction uses the Binary Coded Decimal format for specifying an 8 bit value to use for turning the outputs on or off. Since Binary Coded Decimal format precludes the values of &HA, &HB, &HC, &HD, &HE or &HF from being used, all combinations for setting the 8 output group cannot be satisfied.
- The Out instruction works very similarly to the OpBCD instruction except that Out allows the range for the 8 bit value to use for turning outputs on or off to be between 0 and 255 (0 to 99 for OpBCD). This allows all possible combinations for the 8 bit output groups to be initiated according to the users specifications.
Output bits Configured as Remote:
If an output bit which was set up as remote is specified to be turned on by OpBCD, an error will occur. Remote output bits are turned On or Off automatically according to system status. For more information regarding remote, refer to the following manual:
"Epson RC+ User’s Guide"The individual bits for the remote connector can be set as remote or I/O from [Setup]-[System Configuration]-[Controller]-[Remote Control] panel.
Outputs and When an Emergency Stop Occurs:
The Controller has a feature which causes all outputs to go off when an E-Stop occurs. This feature is set or disabled from the [Outputs Off during emergency stop] checkbox in the [Setup]-[System Configuration]-[Controller]-[Preferences].
Forced Flag
This flag is used to turn On the I/O output at Emergency Stop and Safety Door Open from NoPause task, NoEmgAbort task (special task using NoPause or NoEmgAbort at Xqt), or background tasks.
Be sure that the I/O outputs change by Emergency Stop and Safety Door Open when designing the system.
See Also
In, InBCD, MemOff, MemOn, MemSw, Off, On, Oport, Out, Sw, Wait
OpBCD Function Example
The example below shows main task starting a background task called “iotask”. The “iotask” is a simple task to flip flop between turning outputs 1 & 2 on and then outputs 0 and 3 on. When 1 & 2 are turned on, then 0 & 3 are also turned off and vice versa.
Function main
Xqt 2, iotask
Go P1
.
.
.
Fend
Function iotask
Do
OpBCD 0, 6
OpBCD 0, 9
Wait 10
Loop
Fend
Other simple examples from the command window are as follows:
> OpBCD 1,6 'Turns on Outputs 1 and 2
> OpBCD 2,1 'Turns on Output 8
> OpBCD 3, 91 'Turns on Output 24, 28, and 31