How to read ADC values in IMX6ULL sysfs userspace ?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to read ADC values in IMX6ULL sysfs userspace ?

Jump to solution
2,677 Views
_ZZ_
Contributor II

Hi, 

How do I read the  ADC values in IMX6ULL userspace?

for your information reference voltage is 3.3v

in /sys/bus/iio/devices/iio:device0/ I have the following itemsimg_x.pngsome communities say it is done as below 

 awk "BEGIN{printf (\"%d\n\", (in_voltage0_raw + in_voltage_offset) * in_voltage_scale)}" 

but in my case, there is no  in_voltage_offset 

if I choose the in_voltage_offset as 0 , only one of the readings make sense 

Labels (2)
0 Kudos
Reply
1 Solution
2,546 Views
Sanket_Parekh
NXP TechSupport
NXP TechSupport

Hi @_ZZ_,

 
I hope you are doing well.
 

 

One can try adding the below property in the adc node in the device tree.
 
vref-supply = <&reg_vref_3v3>;
 
& below node in dts.
 
reg_vref_3v3: regulator-adc-verf {
     compatible = "regulator-fixed";
     regulator-name = "vref-3v3";
     regulator-min-microvolt = <3300000>;
     regulator-max-microvolt = <3300000>;
};
 
 
Please mention linux BSP version & share the device tree file.
 
Please share the actual voltage present at ADC channel pin and RAW input data for it.
 
Please try to measure the output of Vref regulator & make sure it is exactly around 3.3v.

 

 
Thanks & Regards,

Sanket Parekh

View solution in original post

0 Kudos
Reply
4 Replies
2,613 Views
Sanket_Parekh
NXP TechSupport
NXP TechSupport
Hi @_ZZ_,
 
I hope you are doing well.
 
Could please please share more information regarding which channel and pin is used to read ADC values & sampling frequency?
 
Thanks & Regards,
Sanket Parekh
0 Kudos
Reply
2,597 Views
_ZZ_
Contributor II

Hi @Sanket_Parekh 

According to the i.MX 6ULL Applications Processor Reference Manual section 13.2

ADC1_IN0 Analog channel 1 input 0 GPIO1_IO00

Also vf610 ADC driver in my Linux firmware and 12 bit resolution is used.  

in my Linux user space, it is in_voltage0_raw is the corresponding sysfs file to read the value. 

in_voltage_scale is 1048.575927734 (I am not sure how it has been calculated as I have not build the firmware myself).

58098 is my default sampling frequency and available sampling frequencies are below:

206250, 58098, 29676, 15000, 7541

Reference voltage is 3.3v which is an actual regulator. however, every time after I power up my board and run "dmesg" Linux command, I see few kernel warning messages related to the ADC and the reference voltage as below:

[    2.568224] vf610-adc 2198000.adc: 2198000.adc supply vref not found, using dummy regulator
[    2.569165] vf610-adc 2198000.adc: Linked as a consumer to regulator.0

Thanks,

 

 

 

 

0 Kudos
Reply
2,547 Views
Sanket_Parekh
NXP TechSupport
NXP TechSupport

Hi @_ZZ_,

 
I hope you are doing well.
 

 

One can try adding the below property in the adc node in the device tree.
 
vref-supply = <&reg_vref_3v3>;
 
& below node in dts.
 
reg_vref_3v3: regulator-adc-verf {
     compatible = "regulator-fixed";
     regulator-name = "vref-3v3";
     regulator-min-microvolt = <3300000>;
     regulator-max-microvolt = <3300000>;
};
 
 
Please mention linux BSP version & share the device tree file.
 
Please share the actual voltage present at ADC channel pin and RAW input data for it.
 
Please try to measure the output of Vref regulator & make sure it is exactly around 3.3v.

 

 
Thanks & Regards,

Sanket Parekh

0 Kudos
Reply
2,391 Views
_ZZ_
Contributor II

@Sanket_Parekh  Thanks for your reply,

Modified the device tree as instructed and resolved issue. 

0 Kudos
Reply