Skip to content

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:

Connect the GND and U1 pins to your laboratory power supply which is set to a voltage of 5 V.

Connection for Analog Input Demo

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
You should see now the sampled values together with the timestamp:
Channel groups:
 Group 0: channels=[0 1] sampleRates=[61.015297 121.99088 243.82315 487.013 971.50256 1932.9897 3826.5305] gains=[1 2 4 8 16 32 64 128]
 Group 1: channels=[2 3] sampleRates=[61.015297 121.99088 243.82315 487.013 971.50256 1932.9897 3826.5305] gains=[1 2 4 8 16 32 64 128]
 Group 2: channels=[4 5] sampleRates=[61.015297 121.99088 243.82315 487.013 971.50256 1932.9897 3826.5305] gains=[1 2 4 8 16 32 64 128]
 Group 3: channels=[6 7] sampleRates=[61.015297 121.99088 243.82315 487.013 971.50256 1932.9897 3826.5305] gains=[1 2 4 8 16 32 64 128]
 Total channels: 8
Current configuration:
 Channel 0: sampleRate=122.0 gain=1
 Channel 1: sampleRate=122.0 gain=1
 Channel 2: sampleRate=122.0 gain=1
 Channel 3: sampleRate=122.0 gain=1
 Channel 4: sampleRate=122.0 gain=1
 Channel 5: sampleRate=122.0 gain=1
 Channel 6: sampleRate=122.0 gain=1
 Channel 7: sampleRate=122.0 gain=1
Started stream
got stream data seq=1 ts=5861632006
  #0: ts=5860760119 ch 0 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006
  #1: ts=5860768316 ch 0 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006
  #2: ts=5860776505 ch 0 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006
  #3: ts=5860784703 ch 0 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006
  #4: ts=5860792903 ch 0 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006
  #5: ts=5860801100 ch 0 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006
  #6: ts=5860809300 ch 0 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006
  #7: ts=5860817497 ch 0 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006
  #8: ts=5860825688 ch 0 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006
  #9: ts=5860833886 ch 0 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006
  #10: ts=5860842076 ch 0 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006
  #11: ts=5860850273 ch 0 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006
  #12: ts=5860858474 ch 0 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006
  #13: ts=5860866671 ch 0 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006
  #14: ts=5860874869 ch 0 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0007 -0.0007 -0.0006
  #15: ts=5860883067 ch 0 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0007 -0.0006 -0.0006
  #16: ts=5860891263 ch 0 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006

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.0 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 all channels 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.