Out Statement

Simultaneously sets 8 output bits.

Syntax
Out portNumber, outData [, Forced]

Parameters

portNumber
Specify the output byte of I/O. The portnum selection corresponds to the following outputs:

Port Number Outputs
0 0-7
1 8-15
... ...
outData
Specify the output pattern for the output group specified by port number as an integer value from 0 to 255. If represented in hexadecimal form the range is from &H0 to &HFF. The lower digit represents the least significant digits (or the 1st 4 outputs) and the upper digit represents the most significant digits (or the 2nd 4 outputs).
Forced
Optional. Usually omitted.

Description
Out simultaneously sets 8 output lines using the combination of the portNumber and outdata values specified by the user to determine which outputs will be set. The portNumber parameter 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 portnum is selected (i.e. a group of 8 outputs has be selected), a specific output pattern must be defined. This is done using the outData parameter. The outData parameter may have a value between 0 to 255 and may be represented in Hexadecimal or Integer format. (i.e. &H0 to &HFF or 0 to 255)

The table below shows some of the possible I/O combinations and their associated outData values assuming that portNumber is “0”, and “1” accordingly.

Output Settings When portNumber=0 (Output number)

OutData 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 Off On Off On Off
11 Off Off Off Off On Off On On
99 Off On On Off Off Off On On
255 On On On On On On On On

Output Settings When portNumber=1 (Output number)

OutData Value 15 14 13 12 11 10 9 8
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 Off On Off On Off
11 Off Off Off Off On Off On On
99 Off On On Off Off Off On On
255 On On On On On On On On

Notes


  • Difference between OpBCD and Out

    The Out and OpBCD 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.
  • 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, MemOut, MemSw, Off, On, Oport, Sw, Wait

Out Statement Example
The example below shows main task starting a background task called “iotask”. The “iotask” is a simple task to flip flop between turning output bits 0 to 3 On and then Off. The Out instruction makes this possible using only 1 command rather than turning each output On and Off individually.

Function main

  Xqt iotask
  Do
    Go P1
    Go P2
  Loop
Fend

Function iotask

  Do
    Out 0, &H0F
    Out 0, &H00
    Wait 10
  Loop
Fend

Other simple examples are as follows from the command window:

> Out 1,6  	'Turns on Outputs 9 & 10
> Out 2,1  	'Turns on Output 8
> Out 3,91   'Turns on Outputs 24, 25, 27, 28, and 30