This is an old revision of the document!
Direct Switch
This function works only for following Inputs & Outputs:
- digital inputs
- digital outputs
- relay outputs
This function allows logical connection of digital input to digital output or relay output to automatically perform one of the available operation. DirectSwitch is independent on the control software running on unit and is suitable for control of lighting or any other time-critical applications (typically, the output response time matches the input response).
Attention:
If DirectSwitch is applied to an output, it is not possible to write onto output (DO) in a regular way. Instead, you need to set the ForceOutput register to TRUE for approx. 1 second.
The software detection of changes is far from being instantaneous. And there are applications, where even 20 ms delay can cause problems, or represent some discomfort at least. A typical example is a switch controlling a light. What we expect from the behaviour is the instant change of the lighting upon pressing the switch. That, as demonstrated above, is not possible to achieve in the software by simple wiring the DI to DO.
The direct switch is the configuration of digital input in a way it will directly control digital or relay output of the same name. The wiring of the input and output is fixed and cannot be changed, only turned on or off. On Group 1, the DIs are wired to DOs. On other Groups, the DIs are wired to ROs.
DirectSwitch function can be configured only for the corresponding input and output, ie. only for DIy.x input and DOy.x (ROy.x) output, where x and y (if the y is given) numbers must match. It is not possible to use DirectSwitch simultaneously for input and output with mismatched labels, eg. DIx.y and DOv.z. It is also not possible to use the function for a single input and multiple outputs at the same time.
Please note:
The Direct switch depends on the Debounce settings. To have an instant change, you need to set the Debounce to value which doesn't deny the purpose of the Direct switch and yet to value, which doesn't deny the purpose of the Debouncing. 5-10 ms should be OK.
Enabling the Direct Switch
In the left panel, right-click on the name of your Unipi controller under the Modbus TCP channel and select Open editor.
Write DI_ in the search bar and select the DI_1.01, click on it and in the Properties panel find the Direct Switch field.
By selecting more than one digital inputs you can change the direct switch settings on multiple inputs at once.
As you can see, the option has a dropdown menu with different modes.
- Disabled: the direct switch is disabled. This option is selected by default.
- Copy: The status of the DI is copied to the DO/RO. So when the DI is
TRUE, the DO isTRUEand when the DI isFALSEthe DO is alsoFALSE - Copy (Invert): Same as above but inverted. When the DI is
TRUEthe DO isFALSEand vice versa. - Toggle: This mode toggles the DO on the rising edge of the DI. Handy for controlling light with a momentary switch for example
Demonstration on how the LED will look while Direct Switch is enabled on Patron units is here.
Select the copy option.
Important:
We just changed the configuration of the PLC modules, which is not applicable by simply uploading the solution. To save the configuration, follow the UniPi - Configure Module tutorial.
Now, that the DI_1.01 input is linked to DO_1.01 you can try to changing states of DI_1.01 with wired switch or button. You should see the output DO_1.01 changing to same state as input you are changing.

