ID : 365
Set
Function
To turn I/O type variable Bit to ON.
Syntax
Set I/O type variable name[, output time[, Mode = Asynchronous mode]]
Guaranteed Entry
- I/O type variable name
- Designate an I/O type variable name.
- Output time
- Designate an output (ON) period by integer type data. This is an optional value. If this is omitted, ON I/O is not turned OFF.
- Asynchronous mode
- Designate mode by integer type. If the Mode option is specified, the system will perform OFF-signal output processing instead of PAC. This entry is available in Ver.1.8.* or higher.
- In the case of designating Asynchronous mode, use Global variable, I/O type variable. If you use Local variable, it causes Syntax error.
(Example) -
Set IO[24], 100, Mode = 2 'Due to I/O type Gloval variables, 'it can be used with the Mode designated.
DefIO aaa = Bit, 24
Set aaa, 100, Mode = 2 'Due to I/O type Local variables, 'it cannot be used with the Mode designated. (Syntax error)
Description
All Bits of I/O type variable designated by I/O type variable name are turned ON. If some are masked at the time of I/O type local variable declaration (DefIO), only Bits that are not masked are turned ON.
I/O of consecutive Index numbers can be turned ON at one time.
Set IO[128 To 160] 'Turn all of I/O ports 128-160 ON
DefIO aaa(3) = Byte, 128
Set aaa(0 To 3) 'I/O type local variable aaa is all 255
Designated "To" expressions that can be stated for consecutive variables are Set and Reset only.
Specifying Output Time
If output time is specified, the designated I/O is turned OFF once the specified time has passed.
The following is the same statement.
Set IO[10], 1000
Set IO[10]
Delay 1000
Reset IO[10]
Mode Option (This option is available Var.1.8.* or later)
When the Mode option is specified, PAC will turn ON an I/O and then immediately go on to the next step's execution.
In asynchronous with PAC, the system monitors the elapsed time, and then the I/O will turn OFF once the elapsed time reaches the output time.
Unless the Mode option is specified, the next step will not be executed until the output time has arrived.
Depending on the behavior at the task suspension, there are two types of Mode options.
Value | Mode | Description |
---|---|---|
1 | Keep turning ON while the task is suspended. | The elapsed time keeps counting up during the suspension; however the signal will not turn OFF even if the output time arrives during the suspension.
|
2 | Turn OFF immediately after the detection of the task suspension. | The signal is automatically and compulsory reset immediately after the task is suspended. Select this mode if you want to reset asynchronous I/O succeeding to the suspended stop under the protective stop.
|
- If the task stops before the output time arrives, any I/Os issuing ON signal at the applicable task will be reset compulsory.
- I/Os which were compulsory reset will not turn ON automatically, even if the task resumes after the suspended stop.
- If "-1" is specified as the output time while the Mode option is used, the I/O is set to the infinite wait state. If the output time is specified as "-1" during Mode 1 (see the table above), the I/O will turn OFF only when the task ends; as a result, it will behave as a signal that informs the end of the task.
- If the same I/O is specified in several SET commands that include Move option, the setting of the latest command precedes in other settings.
- I/Os which are under asynchronous processing can be turned OFF by Reset command, or turned ON by Set command that does not include Move option. However, the system keeps counting up the elapsed time, and the signal will be turned OFF once the elapsed time reaches the output time.
Related Terms
Attention
- There may be an error in specified output time due to task loading, etc. Moreover, an error occurs if the specified time is very short.
- Output time elapses even during pausing or step stop.
Example
'!TITLE "Switching I/O Ports"
' If the I/O port number "240" is ON, set the I/O port number "241," and "220" through "225" to OFF
Sub Sample_Set
' Set the I/O port number "240" to ON
Set IO[240]
' Set the I/O port number "241" to ON
Set IO[241]
' Set the I/O port numbers "220" through "225" to ON
Set IO[220 To 225]
' If the I/O port number "240" is ON
If IO[240] Then
' Set the I/O port number "241" to OFF
Reset IO[241]
' Set the I/O port numbers "220" through "225" to OFF
Reset IO[220 To 225]
End If
End Sub
ID : 365