I'm trying to monitor some 4-20mA current loops and 0-10V generators with a RPi 3. I found these modules which would do the job:
https://widgetlords.com/products/pi-spi-2a0-raspberry-pi-analog-output-ma-vdc-interface for the 0-10V and 4-20mA generator
https://widgetlords.com/collections/pi-spi-din-series/products/raspberry-pi-din-rail-analog-input-interface for the inputs.
The problem is that both devices use different libraries, and these libraries use different 'dtoverlays'. They say on the web site to activate in the '/boot/config.txt'
dtoverlay = pi-spi
for the output device
dtoverlay = vpe-2701c
for the input device
I put the code of the overlays down
I don't know if I can uncomment both lines at the same time so I can run a script that takes input and generates outputs ...
I took a look on the net but the device trees are quiet difficult to understand for me.
Would it be a problem to have 2 device tree overlays used by the same script ?
pi-spi overlay:
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2835", "brcm,bcm2836", "brcm,bcm2708", "brcm,bcm2709";
fragment@0 {
target = <&spi0>;
frag0: __overlay__ {
#address-cells = <1>;
#size-cells = <0>;
pinctrl-0 = <&spi0_pins &spi0_cs_pins>;
status = "okay";
cs-gpios = <&gpio 8 1>, /* 8KO */
<&gpio 7 1>, /* 8AI */
<&gpio 4 1>, /* 2AO */
<&gpio 17 1>, /* 8DI */
<&gpio 22 1>; /* SPARE */
spidev@2{
compatible = "spidev";
reg = <2>; /* CE2 */
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <1000000>;
};
spidev@3{
compatible = "spidev";
reg = <3>; /* CE3 */
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <1000000>;
};
spidev@4{
compatible = "spidev";
reg = <4>; /* CE4 */
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <1000000>;
};
};
};
fragment@1 {
target = <&spi0_cs_pins>;
frag1: __overlay__ {
brcm,pins = <8 7 4 17 22>;
brcm,function = <1>; /* out */
};
};
};
vpe-2701c overlay:
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2835", "brcm,bcm2836", "brcm,bcm2708", "brcm,bcm2709";
fragment@0 {
target = <&spi0>;
frag0: __overlay__ {
#address-cells = <1>;
#size-cells = <0>;
pinctrl-0 = <&spi0_pins &spi0_cs_pins>;
status = "okay";
cs-gpios = <&gpio 8 1>, /* CE0 */
<&gpio 7 1>, /* CE1 */
<&gpio 24 1>, /* CE2 */
<&gpio 23 1>, /* CE3 */
<&gpio 18 1>; /* CE4 */
spidev@2{
compatible = "spidev";
reg = <2>; /* CE2 */
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <1000000>;
};
spidev@3{
compatible = "spidev";
reg = <3>; /* CE3 */
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <1000000>;
};
spidev@4{
compatible = "spidev";
reg = <4>; /* CE4 */
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <1000000>;
};
};
};
fragment@1 {
target = <&spi0_cs_pins>;
frag1: __overlay__ {
brcm,pins = <8 7 18 23 24>;
brcm,function = <1>; /* out */
};
};
fragment@2 {
target = <&i2c_arm>;
__overlay__ {
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
mcp7941x: mcp7941x@6f {
compatible = "microchip,mcp7941x";
reg = <0x6f>;
status = "okay";
};
};
};
};