We have some hard time working with the ADC of the Apalis iMX8QM module (with the Ixora carrierboard): the values seems to have an offset.
The ADC values are lower than the one measured with a voltmeter.
The first solution that comes to our minds was to lower the sampling frequency by modifying the
assigned-clock-rate in the device tree. And it worked partially:
- The lower the frequency is, the better the measurement is.
- But on the other side, we have sometimes timeout occurring while reading the raw values through the Linux sysfs interface.
Do you have any ideas or solutions ?
I had a similar problem on a NXP iMXRT1050 board. Reason simply was, that keeper feature of the analog GPIO was enabled.
Details on how to disable keeper (set PKE to 0) can be found here: https://developer.toradex.com/device-tree-customization
Hello @s.steiger and thanks for your answer,
What we have for an iMX8 is only those settings
Currently, PULL (6-5) is set to 0b11 so I guess it is the right configuration.
The register definition
The ADC inputs of the Apalis IMX8 are protected by a 1kOhm serial resistor. Maybe your source has a to high Impedance.
The ADC has a sample and hold cap after the multiplexer, which is loaded with the present voltage. If the source Impedance is to high the cap is not loading fast enough which causes that a to low voltage is measured.
We are trying to read the voltage of a simple voltage divider. It seems fine to me:
If it is really a problem of impedance and we have to lower the sampling frequency (which isn’t a real problem for our application), what can we do against the timeout on ADC reading ? (cat on sysfs interface)
do you have some log from when you experience timeouts ?
So this is what I get when I set the sampling frequency to 1.6Mhz (
assigned-clock-rate = <4800000>) and I
cat the adc channels:
When the command is executed multiple times (with
watch for example), sometimes the command return the value and sometime it got a timeout error:
Obviously, the behavior occurs with libraries such as the C libiio, too.
What else are you doing in parallel on the module? Do you run many other tasks? what is you CPU load?
For the test, we are doing nothing with the module:
Another weird behavior if I
cat manually all the channels:
- The first channel printed timed out and not the following.
- It is always the first one as we can see in the following example
(Printing ADC values and swapping their order)
we tried on our side and it works
Hello @matthias.tx ,
have you tried with another sampling frequency ? Like the one I’ve taken in the older post ?
ok we have to check at different frequencies. please check with our frequency and give us a feedback. That we we will know that there is not another issue.
On the default clock (8Mhz) I don’t have any timeout while reading the values.
The tests I performed earlier were on a 1.6Mhz clock.
@henrique.tx can we check again at the same sampling freq?