SysFS

The SysFS driver is part of the kernel module for all Unipi units with inputs and outputs (except Unipi 1.1) and provides easy file-based access to all inputs and outputs.

Patron
Neuron
Axon


To use 1-Wire on a Unipi unit with OpenSource OS, you must install and configure OWFS. In the case of an OS with EVOK, OWFS is already installed.

Do not install OWFS for Mervis OS! It uses an alternative method to work with 1-Wire and collisions could occur.


Check the following examples of reading and writing I/O to get started:
All files within SysFS can be accessed in the same way.

DO status reading:

cat /run/unipi/io_group1/do_1_01/do_value

Setting the DO to the closed state:

echo 1 > /run/unipi/io_group1/do_1_01/do_value

DI status reading:

cat /run/unipi/io_group1/di_1_01/di_value

Status reading of all first section DI's:

cat /run/unipi/io_group1/di_[1-3]_[0-9][0-9]/di_value

Status reading of all available DI units:

cat /run/unipi/io_group[1-3]/di_[1-3]_[0-9][0-9]/di_value

General information

I/O board name

The file is read-only and contains the name of the input and output board of the Unipi unit, with the number in the range [1-3] corresponding to the unit section.

Returns an error if it is a board with an unknown device ID and the corresponding board name cannot be obtained.

/run/unipi/io_group[1-3]/sys_board_name

I/O board serial number

The file is read-only and contains the serial number of the input and output board of the Unipi unit, with a number in the range [1-3] corresponding to the unit section.

If the serial number is not valid, it returns zero.

/run/unipi/io_group[1-3]/sys_board_serial

Firmware version

The file is read-only and contains the firmware version designation of the input and output board of the Unipi unit, with a number in the range [1-3] corresponding to the unit section. The firmware version number uses the following format: [0-9,A-F].[0-9,A-F][0-9,A-F].

If the version number is invalid, it returns an error.

/run/unipi/io_group[1-3]/firmware_version

UART configuration

The file allows both reading and writing and contains the settings of the serial ports available on the I/O board, with a number in the range [1-3] corresponding to the unit section.

If the I/O board does not have a serial port, the file is empty.

/run/unipi/io_group[1-3]/uart_config

UART queue length

The file is read-only and contains the number of received characters in the serial port buffer on the I/O board, with a number in the range [1-3] corresponding to the unit section.

If the I/O board does not have a serial port, the file is empty.

/run/unipi/io_group[1-3]/uart_queue_length

Storage life status

Files are read-only and contain storage status information.

The first file indicates the number of memory erase cycles used compared to the maximum [%].

/run/unipi_stats/cycles_used

The second file indicates the number of blocks [%] that are all right.

/run/unipi_stats/good_blocks

A third file is available for Neuron units indicating the number of power cycles with the current SD card.

/run/unipi_stats/power_cycles

If you have a supported SD card in Neuron unit, you can use the following files to find out the card manufacturer.

/run/unipi_stats/vendor_1
/run/unipi_stats/vendor_2
/run/unipi_stats/vendor_3

Inputs and outputs (I/O)

Digital inputs

Used to read the status of the selected input in the given section [1-3] of the unit. For more information, including voltage levels for log.0/1 detection, see the article on digital inputs.

The file is read-only and if it contains the value 0, a logic value of 0 is detected on the digital input. If it contains the value 1, a logic value of 1 is detected.

/run/unipi/io_group[1-3]/di_[1-3]_[0-9][0-9]/di_value

Digital outputs

Used to read/set the status of the selected transistor output in the given section [1-3] of the unit. For more information see the article on digital outputs.

The file allows both reading and writing and if it contains the value 0, the digital output is open. If it contains the value 1, it is closed. Writing a value to this file will change the state (closed/open) of the output according to the given rule.

/run/unipi/io_group[1-3]/do_[1-3]_[0-9][0-9]/do_value

Relay outputs

Used to read/set the status of the selected output relay in the given section [1-3] of the unit. For more information see the article on relay outputs.

The file allows both reading and writing and if it contains the value 0, the relay output is open. If it contains the value 1, it is closed. Writing a value to this file will change the state (open/closed) of the output according to the given rule.

/run/unipi/io_group[1-3]/ro_[1-3]_[0-9][0-9]/ro_value

User LEDs

Used to read/set the status of the selected user LED of the given section [1-3] of the unit.

The file allows both reading and writing and if it contains the value 0, the LED is off. If it contains a value greater than or equal to 1, the LED is lit. Writing a value to this file will change the state (on/off) of the LED according to the given rule.

/run/unipi/io_group[1-3]/leds/unipi:green:uled-x[0-9]/brightness

Specil I/O functions

Counter

A counter function is available for each digital input of Unipi units. See the article on digital inputs for more information on this function.

The file allows reading and writing and contains the total number of pulses in the range 0-4294967295 detected by the digital input of the given section [1-3] of the unit. Writing a value to a file sets the selected counter to the desired value. You can reset the counter by entering the value 0.

/run/unipi/io_group[1-3]/di_[1-3]_[0-9][0-9]/counter

Debounce

The Debounce function is used for input flash repression on the digital input. This file contains time in hundreds of µs (if its value is 10, it corresponds to 1 ms). During this set time, the response to a change in the value at the input is ignored to prevent accidental switching of the input due to induction on the cabling, etc. The setting is available for each individual input of the selected section [1-3] of the unit.

The file allows both reading and writing. It contains the value 50 at the factory settings, which corresponds to a time of 5 ms. A value of 0 means that the debounce function is disabled.

/run/unipi/io_group[1-3]/di_[1-3]_[0-9][0-9]/debounce

DirectSwitch

The DirectSwitch function is set on digital inputs, but its function is also linked to digital or relay outputs with the same designation. All DirectSwitch parameters can be set individually for each digital input of the selected section [1-3] of the unit. See the article on digital inputs for more information on this function.

DirectSwitch enable

The file allows both reading and writing and if it contains the value 0, the DirectSwitch function is disabled. If it contains the value 1, the function is enabled. Writing a value to this file will change the state (enabled/disabled) of the DirectSwitch function according to the given rule.

/run/unipi/io_group[1-3]/di_[1-3]_[0-9][0-9]/direct_switch_enable
DirectSwitch polarity

The file allows both reading and writing and if it contains the value 1, the DirectSwitch function (if enabled) sets the output to the state corresponding to the negated value of the input. If it contains the value 0, the state of the output is the same as the value at the input. Writing a value to this file sets the polarity (match/negation) of the DirectSwitch function according to the given rule.

/run/unipi/io_group[1-3]/di_[1-3]_[0-9][0-9]/direct_switch_polarity
DirectSwitch toggle

The file allows both reading and writing and if it contains the value 1, the DirectSwitch function (if enabled) changes the state of the output with each rising edge on the input, while the DirectSwitch polarity setting is ignored. If it contains the value 0, the toggle function is disabled. Writing a value to this file will change the state (enabled/disabled) of the toggle function according to the given rule.

/run/unipi/io_group[1-3]/di_[1-3]_[0-9][0-9]/direct_switch_toggle

PWM - pulse width modulation

PWM can only be set for digital outputs. In order to use the PWM function, the digital output value must be set to 0. See the article on digital outputs the article on digital outputs for more information on this function.


The length of one Tc cycle is set using the PWM Prescale and PWM Cycle values. The calculation is described by the following formula:

The PWM cycle value has a direct effect on the resolution of the PWM cycle according to the following formula:

resolution = PWM_cycle + 2

It follows that if the value of the PWM cycle is 1, the resolution is equal to 3. So we can set three values of the duty cycle - 0%, 50%, and 100%. Where the calculation allows it, it is advisable to set the PWM cycle to the highest possible value.

The PWM clock runs at 48 MHz by default, so the permissible PWM frequencies range from 24 MHz to ~ 0.0111 Hz. It should be noted that in the upper level of this range, the PWM square wave will be relatively irregular, due to the time for which the transistors change their state.

PWM duty cycle

The PWM duty-cycle setting is available individually for each digital output of the selected section [1-3] of the unit.

The file allows both reading and writing and values in the range 0-65535 can be written to it. However, the correct duty cycle values are in the range 0-100 [%], the setting of the higher value will always be evaluated as 100 [%].

/run/unipi/io_group[1-3]/do_[1-3]_[0-9][0-9]/pwm_duty_cycle
PWM cycle

The PWM cycle frequency setting is common to all digital outputs of the selected section [1-3] of the unit, and changing the setting of one output will affect all files.

The file allows both reading and writing and may contain values in the range 0-65535.

/run/unipi/io_group[1-3]/do_[1-3]_[0-9][0-9]/pwm_frequency_cycle
PWM prescale

The PWM prescale setting is common to all digital outputs of the selected section [1-3] of the unit, and changing the setting of one output will affect all files.

The file allows both reading and writing and may contain values in the range 0-65535.

/run/unipi/io_group[1-3]/do_[1-3]_[0-9][0-9]/pwm_prescale