lkml.org 
[lkml]   [2024]   [May]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectSupporting a Device with Switchable Current/Voltage Measurement
Hello all,

We need to support a hardware that can measure current and voltage on
the same differential analog input, similar to a multimeter. The mode
of measurement is controlled by a GPIO switch and goes to different
ADC inputs depending on the mode. If the switch is enabled, a current
loop with a shunt is enabled for current measurement; otherwise, voltage
is measured. From the software point of view, we are considering using
the iio-rescale driver as a consumer of an ADC IIO parent device. One
of the problems is that we need to change the mode of measurement at
runtime, but we are trying to avoid using some userspace "hack". The
other is that for a minimal solution to enable the mode from boot, we
can use a gpio-hog and control it with overlays. However,
still would be better that this was done by the kernel. Do you know
or have some guidance on how to properly support this in the kernel?

For the in kernel gpio solution, this is a draft of DT we are thinking:

current-sense {
compatible = "current-sense-shunt";
io-channels = <&adc 0>;
gpio = <&main_gpio0 29 GPIO_ACTIVE_HIGH>;
shunt-resistor-micro-ohms = <3300000>;
};

voltage-sense {
compatible = "voltage-divider";
io-channels = <&adc 1>;
gpio = <&main_gpio0 29 GPIO_ACTIVE_LOW>;
output-ohms = <22>;
full-ohms = <222>;
};

Regards,
João Paulo Gonçalves


\
 
 \ /
  Last update: 2024-05-02 01:39    [W:0.128 / U:0.616 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site