Re: enabling a regulator before doing an ADC measurement

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 19 Feb 2020 11:32:35 +0100
Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxxxx> wrote:

> Hello,
> 
> I have a hardware setup that looks as follows:
> 
>                                 ,-------------------.
>  ,---------.       ,---/ -------| current-regulator |
>  |  ADC    |       |            `-------------------'
>  |      CH0--------+
>  |         |       |
>  `.........'    ,-----.
>                 |PT100|
> 		`-----'
> 		   |
>
> 
> So the idea is that I enable the regulator and then measure the adc's
> input to determine the resistance of the PT100 and so its temperature.
> 
> I wonder if/how I should represent that in my device's device tree. I
> discussed this already a bit with Geert on irc and he came up with
> something like:
> 
> 	adc {
> 		...
> 		channel@0 {
> 			reg = <0>;
> 			supply = <&myregulator>;
> 		};
> 	};
> 
> with the intention that the adc driver enables myregulator before
> starting a measurement on channel 0.
> 
> Does this sound sensible? Does something like this maybe even already
> exist and I missed it?

> 
> What is a bit special here is that usually a regulator is used to supply
> a device and it's just enabled at probe time (or when the device is
> started to be used) and disabled when done. Here the regulator is
> supposed to be enabled only during a measurement[1] to yield the reference
> current and doesn't supply a device. So maybe better use another
> property name instead of plain "supply", maybe "reference-supply"?


There are similar cases though they tend to be wrapped
up in runtime pm rather than enable and disable each time.
Note this tends not to be the case in 'first' posts of drivers, because
it's a bit fiddly to do.  Hence it gets added later if relevant.  Often
the regulator being disabled is the reference voltage rather than
the primary power supply.

For this particular case, I'd rather see the pt100 fully represented
(with a tiny driver).   That would be a consumer of the ADC channel
and present it's own temperature channel.  We do this for things
like analog accelerometers.   Then you can control the regulator
either every time.

That way it looks just like a normal device with simple bindings.
The oddity being the necessity to turn the power off after a reading
(and I guess keep it off for some minimum time?)

Thanks,

Jonathan

> 
> Best regards
> Uwe
> 
> [1] When the current measurement is done, the regulator must be swiched
> off again to not warm up the PT100 and so fudge future measurements.
> 





[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux