Quick Start Guide
In this quick-start guide we will sample one input channel of the IOU09.
Prerequisites
Hardware
- A Moducop Edge Computer with a IOU09 installed
-
A development PC (Windows or Linux), connected via Network to the Moducop
-
A laboratory power supply to stimulate the analog inputs
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 IOU09
Io4Edge Devices are usually addressed by their service address, which is a name in the network.
The IOU09's service name depends on the ModuCop's slot and is usually
S101-IOU09-USB-EXT-<slot-number>[-<function>], i.e. if the IOU09 is in the slot next to ModuCops CPU01, we have the following service names:
| Service Name | Description |
|---|---|
| S101-IOU09-USB-EXT-1 | Core function |
| S101-IOU09-USB-EXT-1-anain | Analog input function |
We need this service address in the demo programs to address the module, for example S101-IOU09-USB-EXT-1-anain.
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 IOU09 is in the slot next to the CPU, the output should be:
DEVICE ID SERVICE TYPE SERVICE NAME IP:PORT
S101-IOU09-USB-EXT-1 _io4edge-core._tcp S101-IOU09-USB-EXT-1 192.168.201.1:9999
_io4edge_analogInTypeB._tcp S101-IOU09-USB-EXT-1-anain 192.168.201.1:10000
Analog Input Demo
The Analog Input demo will sample one analog input of the IOU09 for 10 seconds, with the sample rate you specify on the command line. The sampled values are printed.
Connecting
Plug a mating connector to the 1st connector from the top of the IOU09.
Mating connectors for IOU09:
- Wuerth Electronic P/N 691381030006
Connect the GND and U1 pins to your laboratory power supply which is set to a voltage of 5 V.
Demo Software
Compile Demo
Run this in a powershell console
cd examples\analogInTypeB\stream
$Env:GOOS = "linux"
$Env:GOARCH = "arm64"
go build
cd examples/analogInTypeB/stream
GOOS=linux GOARCH=arm64 go build
This produces the binary file stream 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 stream 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 IOU09 is not in the slot next to the CPU, use a different address, e.g. S101-IOU09-USB-EXT-2-anain
/data/stream S101-IOU09-USB-EXT-1-anain 100 | more
Channel groups:
Group 0: channels=[0 1] sampleRates=[61.035156 122.07031 244.14062 488.28125 976.5625 1953.125 3906.25] gains=[1 2 4 8 16 32 64 128]
Group 1: channels=[2 3] sampleRates=[61.035156 122.07031 244.14062 488.28125 976.5625 1953.125 3906.25] gains=[1 2 4 8 16 32 64 128]
Group 2: channels=[4 5] sampleRates=[61.035156 122.07031 244.14062 488.28125 976.5625 1953.125 3906.25] gains=[1 2 4 8 16 32 64 128]
Group 3: channels=[6 7] sampleRates=[61.035156 122.07031 244.14062 488.28125 976.5625 1953.125 3906.25] gains=[1 2 4 8 16 32 64 128]
Total channels: 8
Current configuration:
Channel 0: sampleRate=122.1 gain=1
Channel 1: sampleRate=122.1 gain=1
Channel 2: sampleRate=122.1 gain=1
Channel 3: sampleRate=122.1 gain=1
Channel 4: sampleRate=122.1 gain=1
Channel 5: sampleRate=122.1 gain=1
Channel 6: sampleRate=122.1 gain=1
Channel 7: sampleRate=122.1 gain=1
Started stream
got stream data seq=1 ts=231943759
#0: ts=231129483 ch 0 0.5000 0.0002
#1: ts=231129686 ch 2 0.0000 0.0000
#2: ts=231129891 ch 4 0.0000 0.0000
#3: ts=231130053 ch 6 0.0000 0.0000
#4: ts=231137642 ch 0 0.5000 0.0002
#5: ts=231137884 ch 2 0.0000 0.0000
#6: ts=231138085 ch 4 0.0000 0.0000
#7: ts=231138253 ch 6 0.0000 0.0000
What does the output mean?
First, the capabilities of channel groups are printed. Each group has two channels. The supported sample rates and gains are listed.
Then the current configuration is printed, which shows that all channels are configured with a sample rate of 122.1 samples per second (which is the closest samples rate to the requested rate of 100 Hz) and a gain of 1.
Then the stream starts, and the sampled values are printed. Each line shows the timestamp (ts), the channel number (ch), and the sampled values. You see that the two channels of a group are printed in the same line, as they have the same timestamp - they are sampled simultaneously.
The sampled values are normalized, so the value 1.0 represents full-scale, i.e. 10 Volts.
The timestamps are expressed in microseconds since the start of the IOU09.