Skip to main content

Comedi

Prerequisites

This node-type requires comedilib (>= 0.11.0).

Implementation

The source code of the node-type is available here: https://github.com/VILLASframework/node/blob/master/lib/nodes/comedi.cpp

Configuration

subdevice
integer
bufsize
integer
Default: 16
required
Array of objects (comedi_signal)
rate
required
integer
object (Input configuration (received by VILLASnode))
vectorize
integer
Default: 1

This setting allows to send multiple samples in a single message to the destination nodes.

The value of this setting determines how many samples will be combined into one packet.

Array of Hook Object (object) or Hook Name (string) (hook_list)
builtin
boolean (Builtin hook functions)
Default: true

By default, each node and paths has a couple of default hooks attached to them. With this setting the attachment of built-in hooks can be disabled.

object (Output configuration (sent out by VILLASnode))
{
  • "subdevice": 0,
  • "bufsize": 16,
  • "signals": [
    ],
  • "rate": 0,
  • "in": {
    },
  • "vectorize": 1,
  • "hooks": [
    ],
  • "builtin": true,
  • "out": {
    }
}

Example

node/etc/examples/nodes/comedi.conf
nodes = {
pcie6259 = {
type = "comedi"

device = "/dev/comedi0"
in = {
subdevice = 0
rate = 1000

signals = (
# Note: order in this array defines order in villas sample
{ channel = 0, range = 0, aref = 0, name = "temperature_int" },
{ channel = 1, range = 0, aref = 0, name = "loopback_ao0" },
{ channel = 2, range = 0, aref = 0, name = "loopback_ao1" },
{ channel = 3, range = 0, aref = 0, name = "bnc_ext" }
)
}
out = {
subdevice = 1
# Note: buffer size and rate shouldn't be changed at the moment
# output sample rate
rate = 40000
# Comedi write buffer in kilobytes
bufsize = 24

signals = (
# Note: order in this array corresponds to order in villas sample
{ name = "ao0", channel = 0, range = 0, aref = 0 },
{ name = "ao1", channel = 1, range = 0, aref = 0 },
{ name = "ao2", channel = 2, range = 0, aref = 0 },
{ name = "ao3", channel = 3, range = 0, aref = 0 }
)
}
}

remote = {
type = "socket"
layer = "udp"
format = "protobuf"

in = {
address = "*:12000"
}

out = {
address = "134.130.169.32:12000"
}
}

sine1 = {
type = "signal"

signal = "sine"
values = 1
frequency = 50
rate = 10000
}

sine2 = {
type = "signal"

signal = "sine"
values = 1
frequency = 100
rate = 10000
}
}

paths = (
# 2-ch sine
# {
# in = [ "sine1.data[0]", "sine2.data[0]" ]
# out = "pcie6259"
# rate = 10000
# mask = ()
# }

# Remote data via UDP
{
in = "remote.data[0-3]"
out = "pcie6259"
rate = 40000
mask = ()
}
)

Further reading

Linux Control and measurement device interface

The Comedi project develops open-source drivers, tools, and libraries for data acquisition.