Oport Function
Returns the state of the specified output.
Syntax
Oport(outnum)
Parameters
- outnum
- Specify the output bits of I/O.
Return Values
Returns the specified output bit status as either 0 or 1.
- 0: Off status
- 1: On status
Description
Oport provides a status check for the outputs. It functions much in the same way as the Sw instruction does for inputs. Oport is most commonly used to check the status of one of the outputs which could be connected to a feeder, conveyor, gripper solenoid, or a host of other devices which works via discrete I/O. Obviously the output checked with the Oport instruction has 2 states (1 or 0). These indicate whether the specified output is On or Off.
Note
Difference between Oport and Sw
It is very important for the user to understand the difference between the Oport and Sw instructions. Both instructions are used to get the status of I/O. However, the type of I/O is different between the two. The Sw instruction works inputs. The Oport instruction works with the standard and expansion hardware outputs. These hardware ports are discrete outputs which interact with devices external to the controller.
See Also
In, InBCD, MemIn, MemOn, MemOff, MemOut, MemSw, Off, On, OpBCD, Out, Sw, Wait
OPort Function Example
The example shown below turns on output 5, then checks to make sure it is on before continuing.
Function main
TMOut 10
OnErr errchk
Integer errnum
On 5 'Turn on output 5
Wait Oport(5)
Call mkpart1
Exit Function
errchk:
errnum = Err(0)
If errnum = 94 Then
Print "TIME Out Error Occurred during period"
Print "waiting for Oport to come on. Check"
Print "Output #5 for proper operation. Then"
Print "restart this program."
Else
Print "ERROR number ", errnum, "Occurred"
Print "Program stopped due to errors!"
EndIf
Exit Function
Fend
Other simple examples are as follows from the command window:
> On 1
> Print Oport(1)
1
> Off 1
> Print Oport(1)
0
>