I’m having issues with analog reading on a FX30.
In order to read the ADC value I’m using /sys/class/hwmon/hwmon0/device/mpp_05.
Firstly, I’m unable to select the range between 0-5V or 0-10V.
From the documentation “41110030_FX30 Hardware User Guide_r1.pdf” (page 38), it should be possible to select the ADC range through AT commands but running these commands fails:
modem /dev/ttyAT 230400 “AT!FWD=GPIOCFG,25,OUT”
returns:
ERROR
Same for modem /dev/ttyAT 230400 “AT!BSGPIO=25,1,0”
The document 41110030_FX30 User Guide_r2.pdf may be a better more up to date version but it describes the range without indicating how to set it.
I also tried to manually configure GPIO25 this way:
echo out > /sys/class/gpio/gpio25/direction
echo 1 > /sys/class/gpio/gpio25/value
This gives no error, but there’s no change in what /sys/class/hwmon/hwmon0/device/mpp_05 reports.
A second issue is that the range of raw values seems to be compressed: at 0V the raw value is 24808, while at 5V the raw value is 42750. This makes a range of 17942, which is quite far from the theoretical range of 32768 (15 bits).
At page 22 of the user guide, the table says that the analog input is connected on I/O 2 on the power connector, together with GPIO21. Manually disabling pull up on GPIO21 didn’t change anything (echo down > /sys/class/gpio/gpio21/pull)
My apologies, the ADC select output has not been implemented in software at this time. The User Guide incorrectly states that the input range can be controlled.
Did you ensure the internal pull-up on ext IO2 is disabled?
From this I understand that the selected range is 5v.
The “Result” corresponds to the modem returned value with more precision.
But I do not find the 15bits ADC resolution… the “Result” could correspond to a part of a 21 bits precision ADC…
What is really the precision of the ADC?
What is the “Raw” value returned by the reading of the SYS device?
Hi Christian,
The voltage range on the ADC is 0-1.8V and the Result is actually the voltage. The precision should be 15 bits, and I agree the Raw doesn’t correspond to this, could be a bug… will examine this.
For sysfs the reading is in uV while the AT command reports in mV.