Binary Outputs
In this quick-start guide we run demo programs to stimulate the IOU06 binary outputs and verify the behaviour.
Prerequisites
Hardware
- A Moducop Edge Computer with a IOU06 installed
-
A development PC (Windows or Linux), connected via Network to the Moducop
-
A laboratory power supply capable of supplying 24V/100mA
Tools on Development PC
The examples are written in programming language Go, we download the go sources and compile them. Therefore we need some tools on your development PC:
Get Demo Software
Clone the repository containing the examples to a folder of your choise (here myworkdir).
c:
cd \myworkdir
git clone https://github.com/ci4rail/io4edge-client-go.git
cd io4edge-client-go
cd ~/myworkdir
git clone https://github.com/ci4rail/io4edge-client-go.git
cd io4edge-client-go
Determine the Service Address of your IOU06
Io4Edge Devices are usually addressed by their service address, which is a name in the network.
The IOU06's service name depends on the ModuCop's slot and is usually
S101-IOU06-USB-EXT-<slot-number>[-<function>], i.e. if the IOU06 is in the slot next to ModuCops CPU01, we have the following service names:
| Service Name | Description | Port |
|---|---|---|
| S101-IOU06-USB-EXT-1 | Core function | 9999 |
| S101-IOU06-USB-EXT-1-ibis | IBIS | 10000 |
| S101-IOU06-USB-EXT-1-com | COM (mutually exclusive with CAN) | 10001 |
| S101-IOU06-USB-EXT-1-can | CAN (mutually exclusive with COM) | 10001 |
| S101-IOU06-USB-EXT-1-gpio | Binary outputs | 10002 |
We need this service address in the demo programs to address the module. For example, to address the binary output function we use S101-IOU06-USB-EXT-1-gpio.
If you are unsure, you can also browse the available devices:
ssh root@<moducop-ip>
Once logged in into the Moducop Shell:
io4edge-cli scan -f
If your IOU06 is in the slot next to the CPU, the output should be:
S101-IOU01-USB-EXT-1, 192.168.201.1, S101-IOU01, <serial-number>
+-----------------------------+-------------------------------------+-------+
| SERVICE TYPE | SERVICE NAME | PORT |
+-----------------------------+-------------------------------------+-------+
| _ttynvt._tcp | S101-IOU06-USB-EXT-1-ibis | 10000 |
| _ttynvt._tcp | S101-IOU06-USB-EXT-1-com | 10001 |
| _io4edge_binaryIoTypeB._tcp | S101-IOU06-USB-EXT-1-gpio | 10002 |
+-----------------------------+-------------------------------------+-------+
Binary Output Demo
The binary output demo stimulates the binary outputs of the IOU06. Connect separate loads (for example 1 kΩ resistors) so that when the output switch turns on, the binary output closes the circuit and current flows through the load.
Connecting
Connect the binary output pins BIN_OUT1 and BIN_OUT2 to different loads supplied with 24V. Connect the ground to the common ground pin COMMON_GND.
Compile Demo
Run this in a powershell console
cd examples\gpio\set_outputs
$Env:GOOS = "linux"
$Env:GOARCH = "arm64"
go build
cd examples/gpio/set_outputs
GOOS=linux GOARCH=arm64 go build
This produces the binary file set_outputs in the current folder.
Copy Demo to Moducop
Transfer the compiled binary. Replace <target-ip> with the IP address of your Moducop.
We copy the binary to the /data folder of ModuCop, as this is a writeable, whereas the rest of the filesystem is write protected.
scp set_outputs root@<target-ip>:/data
Running the Demo
Login into your Moducop over SSH:
ssh root@<target-ip>
Once logged in into the Moducop's Shell, run the demo.
In case your IOU06 is not in the slot next to the CPU, use a different address, e.g. S101-IOU06-USB-EXT-2-gpio