Roadrunner technical documentation Buy
Tested on Linux Kernel: 4.19.78
Up to 12 ADC lines are available on the RoadRunner SOM. Some of them are available also on Fox Board D27
Signal | Description | Line | FOX D27 |
---|---|---|---|
3.3V | 3.3 volt power line | ||
AVDD | Clean 3.24V out for A/D circuitry | ||
VREF | A/D voltage reference input | ||
AGND | Analog GND | ||
AD0 | Analog input 0 | PD19 | J2-09 |
AD1 | Analog input 1 | PD20 | J2-10 |
AD2 | Analog input 2 | PD21 | J2-11 |
AD3 | Analog input 3 | PD22 | J2-12 |
AD4 | Analog input 4 | PD23 | J1-13 |
AD5 | Analog input 5 | PD24 | J1-10 |
AD6 | Analog input 6 | PD25 | J1-12 |
AD7 | Analog input 7 | PD26 | |
AD8 | Analog input 8 | PD27 | |
AD9 | Analog input 9 | PD28 | |
AD10 | Analog input 10 | PD29 | J1-15 |
AD11 | Analog input 11 | PD30 | |
GND | Digital GND |
To enable the ADC Linux driver and the IIO user space interface inside make ARCH=arm menuconfig
:
Device Drivers --->
<*> Industrial I/O support --->
<*> Enable software IIO device support
<*> Enable software triggers support
Analog to digital converters --->
<*> Atmel AT91 ADC
<*> Atmel AT91 SAMA5D2 ADC
Follow this article to compile the Linux Kernel, enable the right drivers and use the right device tree definitions.
Edit the device tree source at arch/arm/boot/dts/at91-sama5d2_roadrunner.dts
of your board adding these lines:
Insert this definition to enable the driver:
vddin_3v3: fixed-regulator-vddin_3v3 {
compatible = "regulator-fixed";
regulator-name = "VDDIN_3V3";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
regulator-always-on;
regulator-boot-on;
status = "okay";
};
vddana: fixed-regulator-vddana {
compatible = "regulator-fixed";
regulator-name = "VDDANA";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
regulator-always-on;
regulator-boot-on;
vin-supply = <&vddin_3v3>;
status = "okay";
};
advref: fixed-regulator-advref {
compatible = "regulator-fixed";
regulator-name = "advref";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
regulator-always-on;
regulator-boot-on;
vin-supply = <&vddana>;
status = "okay";
};
adc: adc@fc030000 {
vddana-supply = <&vddana>;
vref-supply = <&vddana>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_adc_default>;
status = "okay";
};
Insert this definition to select the pin to use:
pinctrl_adc_default: adc_default {
pinmux = <PIN_PD19__GPIO>,
<PIN_PD20__GPIO>,
<PIN_PD21__GPIO>,
<PIN_PD22__GPIO>,
<PIN_PD23__GPIO>,
<PIN_PD24__GPIO>,
<PIN_PD25__GPIO>,
<PIN_PD26__GPIO>,
<PIN_PD27__GPIO>,
<PIN_PD28__GPIO>,
<PIN_PD29__GPIO>,
<PIN_PD30__GPIO>;
bias-disable;
};
Generate the at91-sama5d2_roadrunner.dtb
:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- at91-sama5d2_roadrunner.dtb
Rename it in acme-roadrunner.dtb
and save it inside boot partition.
cat /sys/bus/iio/devices/iio\:device0/in_voltage0_raw
cat /sys/bus/iio/devices/iio\:device0/in_voltage1_raw
...
cat /sys/bus/iio/devices/iio\:device0/in_voltage11_raw
More in-depth examples are available from Microchip at:
Without using mpio library:
import time
def get_adc(id):
with open("/sys/bus/iio/devices/iio:device0/in_voltage%d_raw" % id) as f:
value=int(f.read())
return value
while True:
print "ADC value: %d" % get_adc(0)
time.sleep(1)
Using mpio library:
from mpio import ADC
import time
while True:
adc = ADC(0)
print "ADC value: %d" % adc.value(0)
time.sleep(1)