ISO-SENSOR-KIT2 IO Card Setup
Card Description
The Sensor-Kit IO card provides multiple interfaces for common sensors, 8 x 4-20mA Analogue sensors and dual RS485 Interfaces.
OS Configuration
To configure the ADC interfaces run the script below to configure the OS for direct access
root@raspberrypi:~# ./sensorkit2-config.sh [info] Configuring MyPi ISO-SENSORKIT-2 Card [info] Creating ADC /dev shortcuts
This can be made permanent and executed during the init startup sequence via the below command sequence :
# chmod +x ./sensorkit2-config.sh # mv ./sensorkit2-config.sh /etc/init.d # systemctl enable sensorkit2-config.sh # reboot
root@raspberrypi:~# i2cdetect -y 1 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- UU -- 6a -- -- -- 6e -- 70: -- -- -- -- -- -- -- --
68 = System RTC
6a = ADC 1 (Left hand side ADC)
6e = ADC 2 (Right hand side ADC)
4-20mA Analogue Inputs
Once the setup script has run the ADCs can be read directly
/dev/i2cadc1 /dev/i2cadc1/in_voltage0_raw /dev/i2cadc1/in_voltage0_scale /dev/i2cadc1/in_voltage1_raw /dev/i2cadc1/in_voltage1_scale /dev/i2cadc1/in_voltage2_raw /dev/i2cadc1/in_voltage2_scale /dev/i2cadc1/in_voltage3_raw /dev/i2cadc1/in_voltage3_scale /dev/i2cadc2 /dev/i2cadc2/in_voltage0_raw /dev/i2cadc2/in_voltage0_scale /dev/i2cadc2/in_voltage1_raw /dev/i2cadc2/in_voltage1_scale /dev/i2cadc2/in_voltage2_raw /dev/i2cadc2/in_voltage2_scale /dev/i2cadc2/in_voltage3_raw /dev/i2cadc2/in_voltage3_scale
The ADC Interface uses precision 0.1% 100R shunt resistor to convert 0-20mA to 0-2V signal suiable for reading by the ADC.The inputs are protected by a 33V TVS diode and a TPS26610 4-20mA line protection device.
Current loop sensors can be attached in either "High Side" or "Low Side" configuration. For our card we use Low Side configuration as shown this proved to be the best accuracy and has less scope for problems.
Note that The sensor requires an external power supply (usually +24V) to drive the 4-20mA current loop - the card only measures the current, it does not power the sensor.
Low Side 4-20mA configuration
Using a current loop calibrator setup in positon of the blue sensor in the above diagram we cycle through the settings and get results
$ cat /dev/i2cadc1/in_voltage0_raw 399 $ cat /dev/i2cadc1/in_voltage0_raw 799 $ cat /dev/i2cadc1/in_voltage0_raw 1199 $ cat /dev/i2cadc1/in_voltage0_raw 1599 $ cat /dev/i2cadc1/in_voltage0_raw 1997
Dividing these values by 100 gives the results for 4/8/16 & 20mA inputs with approx ±20µA accuracy to source, the shunt resistor has a ±25ppm/°C temperature coefficient so will give stable values over a wide temperature range.
Note that you do not need to be root user to read these values, but only the root user can alter the sample or scaling factors
RS485
The board uses a MAX13487 RS485 line driver, this has transparent automatic hardware flow control and so does not require any additional code to supervise flow control.
Channel 1 is connected to the UART connected on Pins 20/22 of the IO card
Board | Hardware UART | Linux Serial Port |
---|---|---|
NT/XT | UART0 / UART1 | ttyS0 / ttyAMA0 |
SE | UART4 | ttyAMA3 |
Channel 0 is connected to the UART connected on Pins 23/25 of the IO card
Board | Hardware UART | Linux Serial Port |
---|---|---|
NT | UART0 / UART1 | ttyS0 / ttyAMA0 |
XT/SE | UART 2 | tyAMA2 |
The following lines need to be added to /boot/config.txt to enable the hardware UART to appear on the correct pins for the adapter card, these are dependant on carrier board type used used.
Note that depending on the OS version uses these may appear as different tty ports as those stated below
# Integrator Board XT enable_uart=1 # Enables UART1 (ttyS0) on GPIO14/15 dtoverlay=disable-bt # Moves UART0 (ttyAMA0) to being on GPIO14/15 (if required) dtoverlay=uart2 # Enables UART2 (ttyAMA2) # Integrator Board NT dtoverlay=uart0,txd0_pin=32,rxd0_pin=33,pin_func=7 # Enables UART0 onto GPIO32/33 dtoverlay=uart1,txd1_pin=14,rxd1_pin=15 # Enables UART1 onto GPIO14/15 # Integrator board SE dtoverlay=uart4 # Enables UART4 (ttyAMA3) dtoverlay=uart2 # Enables UART2 (ttyAMA2)
Our RS485 Modbus app note will be a useful read at this point.
Board Pin out
Numbering left to right :
Left Connector (10way 3.5mm) - Left ADC (0x6A)
Pin | Function |
---|---|
1 | NC |
2 | NC |
3 | CH3+ (IN) |
4 | CH3- (OUT) |
5 | CH4+ (IN) |
6 | CH4- (OUT) |
7 | CH1+ (IN) |
8 | CH1- (OUT) |
9 | CH2+ (IN) |
10 | CH2- (OUT) |
Right Connector (8way 3.81mm) - Right ADC (0x6E)
Pin | Function |
---|---|
1 | CH3+ (IN) |
2 | CH3- (OUT) |
3 | CH4+ (IN) |
4 | CH4- (OUT) |
5 | CH1+ (IN) |
6 | CH1- (OUT) |
7 | CH2+ (IN) |
8 | CH2- (OUT) |
Main Board (8Way 3.5mm) - Digital Bus
Pin | Function |
---|---|
1 | 0V |
2 | RS485-0 A |
3 | RS485-0 B |
4 | 0V |
5 | RS485-1 A |
6 | RS485-1 B |
7 | 0V |
8 | 0V |