Introduction to Industrial IO (sensor framework for Linux)

introduciton to Industrial IO


  • overview of industrial IO. In short, SPI and I2C sensor framework for Linux
  • sensor categories: “ADC, DAC, light, accel(erometer), gyro, magnetometer, humidity, temperature, amplifier, frequency, orientation, health”, etc
  • merged to mainline kernel 3.14, used by beagleBone, sysfs and char device based, see the IIO architecture

related projects/libs


  • DAQmx base for linux: commercial lib from national instrument
  • comedi: PCI/PCIe, USB devices for data acquisition
  • hwmon: very low speed,traditionally for CPU temperature monitoring
  • HID: like mouse, keyboard, generally low speed input device
  • bluetooth smart:

user space IIO API


user space library libiio (https://wiki.analog.com/resources/tools-software/linux-software/libiio)

  • #include <iio.h> four basic classes: iio_contex, iio_device, iio_channel and iio_buffer
  • iio_trigger is kind of iio_device without channel but with name inc “trigger”
  • iio_context has internal operation functions structure, kernel driver
  • windows user can use libiio to access network iiod
  • python and cshaprt wrapping for user space API: python-iio libiio-cil-dev
  • XML context: attributes calibration data, scale, etc.

detailed

(http://events.linuxfoundation.org/sites/events/files/slides/lceu15_baluta.pdf) + scan_element(), iio_channel_is_scan_element(): elements in buffer is called scan /sys/bus/iio/devices/iio:devices/scan elements

  • read_raw() from register (possible 12bit) to integer in memory. NO integer to physical quantity (with unit) like comedilib?

trigger readings based on an external interrupt source hardware interrupt (IRQ pins) software interrupts (periodic timers, sysfs triggers)

design of IIO


  • modes: DIRECT,BUFFER SOFTWARE,BUFFER HARDWARE,BUFFER TRIGGERED
  • iio_triggered_buffer iio_events only found in kernel mode iio_core, see(linux/iio/triggered_buffer.h);trigger are software trigger, not hardware TTL signal in DAQ terminology?

documentation for IIO


source code


supported hardware list


About 200 device drivers by the time of kernel 4.4; many drivers supports a varierty of models.

see/search kernel source tree linux/iio, there are a few subfolders corresponds to sensor categories: “ADC, DAC, light, accel(erometer), gyro, magnetometer, humidity, temperature, amplifier, frequency, orientation, health”, etc

test of IIO dummy device on ubuntu 16.04


“dummy” a virtual sensor for testing

sudo apt-get install libiio libiio-dev libiio-python libiio-utils
#all trigger related function need kernel module to support
sudo modprobe iio_dummy
iio_info
ls /sys/bus/iio/devices/iio\:device0
cat /sys/bus/iio/devices/iio\:device0/name
#no need to enable?
cat /sys/bus/iio/devices/iio\:device0/in_accel_x_raw

python-iio example

desired feature of IIO


  1. user space tool to expose sensors to webUI?
  2. devicetree: platform device support is supported such as beaglebone.
  3. standardisation calibration data in XML attribute file to simulate: IEEE 1451.4 Plug and Play Sensors (TEDS)
  4. possiblity of user space driver development based on user space SPI, i2c and libusb?
  5. physical value conversion “The functions comedi_to_physical, comedi_to_phys, comedi_from_physical and comedi_from_phys are used to convert between Comedi’s integer data and floating point numbers corresponding to physical values (voltages, etc.). ”
This entry was posted in Linux, Sensor. Bookmark the permalink.