Difference between revisions of "I.MX6UL internal ADC"

From ArmadeusWiki
Jump to: navigation, search
(Created page with "== Introduction == This description uses Linux kernel > 3.7. i.MX6UL (processor of OPOS6UL has an integrated 12 bits 16 channels Analog to Digital Converter. Only chann...")
 
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
== Introduction ==
 
== Introduction ==
  
This description uses Linux kernel > 3.7.
+
This description uses Linux kernel >= 4.8.
  
 
i.MX6UL (processor of [[OPOS6UL]] has an integrated 12 bits 16 channels Analog to Digital Converter.
 
i.MX6UL (processor of [[OPOS6UL]] has an integrated 12 bits 16 channels Analog to Digital Converter.
Line 7: Line 7:
 
Only channels 0-6 may be used to generic conversions and channels 2, 3, 4, 5 are used for the touchscreen on [[OPOS6ULDev]].
 
Only channels 0-6 may be used to generic conversions and channels 2, 3, 4, 5 are used for the touchscreen on [[OPOS6ULDev]].
  
* Channel 0 is available on J10 pin 38 of [[APF28Dev]]
+
* Channel 1 is available on J21 pin 40 of [[OPOS6ULDev]] (AIN1/YNLR: muxed with touchscreen)
* Channel 1 is available on J10 pin 36 of [[APF28Dev]]
+
* Channel 2 is available on J21 pin 38 of [[OPOS6ULDev]] (AIN2/YPLL: muxed with touchscreen)
* Channel 6 is available on J10 pin 35 of [[APF28Dev]]
+
* Channel 3 is available on J21 pin 39 of [[OPOS6ULDev]] (AIN3/XNUR: muxed with touchscreen)
 +
* Channel 4 is available on J21 pin 37 of [[OPOS6ULDev]] (AIN4/XPUL: muxed with touchscreen)
 +
* Channel 8 is available on J3 pin 12 of [[OPOS6ULDev]] (AIN8)
 +
* Channel 9 is available on J3 pin 7 of [[OPOS6ULDev]] (AIN9)
  
 
== Driver ==
 
== Driver ==
Line 42: Line 45:
 
# cd /sys/bus/iio/devices/iio:device0
 
# cd /sys/bus/iio/devices/iio:device0
 
# ls
 
# ls
buffer                   in_voltage11_raw in_voltage2_raw  name
+
buffer                         in_voltage5_raw
dev                      in_voltage12_raw in_voltage3_raw  power
+
current_timestamp_clock        in_voltage6_raw
in_temp8_raw      in_voltage13_raw in_voltage4_raw  scan_elements
+
dev                            in_voltage7_raw
in_temp9_raw      in_voltage14_raw in_voltage5_raw  subsystem
+
in_conversion_mode            in_voltage8_raw
in_voltage0_raw  in_voltage15_raw in_voltage6_raw  trigger
+
in_temp_input                  in_voltage9_raw
in_voltage10_raw in_voltage1_raw   in_voltage7_raw  uevent
+
in_voltage0_raw                in_voltage_sampling_frequency
 +
in_voltage10_raw              in_voltage_scale
 +
in_voltage11_raw               name
 +
in_voltage12_raw               of_node
 +
in_voltage13_raw               power
 +
in_voltage14_raw               sampling_frequency_available
 +
in_voltage15_raw               scan_elements
 +
in_voltage1_raw               subsystem
 +
in_voltage2_raw                trigger
 +
in_voltage3_raw                uevent
 +
in_voltage4_raw
 
</pre>
 
</pre>
  
 
To read ADC value just «cat» the corresponding input file:
 
To read ADC value just «cat» the corresponding input file:
 
<pre class="apf">
 
<pre class="apf">
# cat in_voltage0_raw       for channel 0
+
# cat in_voltage1_raw       for channel 1 (ADC1_IN1)
 
4095
 
4095
 
</pre>
 
</pre>
  
All values are not converted (ie. directly show the register content). To have the mV value, you must doi: value_mV = read_value * 1850/4095  
+
All values are not converted (ie. directly show the register content). To have the mV value, you must do: value_mV = read_value * 3300/4095
 +
 
 +
==AsDevices==
 +
* You can access this device from your C/C++ application using ''as_adc_xxx_iio'' functions from [[AsDevices]]
 +
* ''target/demos/oscillo'' is a "good" example to start with...
  
 
==Links==
 
==Links==

Latest revision as of 10:52, 18 May 2017

Introduction

This description uses Linux kernel >= 4.8.

i.MX6UL (processor of OPOS6UL has an integrated 12 bits 16 channels Analog to Digital Converter.

Only channels 0-6 may be used to generic conversions and channels 2, 3, 4, 5 are used for the touchscreen on OPOS6ULDev.

  • Channel 1 is available on J21 pin 40 of OPOS6ULDev (AIN1/YNLR: muxed with touchscreen)
  • Channel 2 is available on J21 pin 38 of OPOS6ULDev (AIN2/YPLL: muxed with touchscreen)
  • Channel 3 is available on J21 pin 39 of OPOS6ULDev (AIN3/XNUR: muxed with touchscreen)
  • Channel 4 is available on J21 pin 37 of OPOS6ULDev (AIN4/XPUL: muxed with touchscreen)
  • Channel 8 is available on J3 pin 12 of OPOS6ULDev (AIN8)
  • Channel 9 is available on J3 pin 7 of OPOS6ULDev (AIN9)

Driver

Driver is by default included if you choose an OPOS6UL as target.

Otherwise, you can select it that way:

[  ] $ make linux-menuconfig
Device Drivers  --->
    ...
    <*> Industrial I/O support  --->
            ...
            Analog to digital converters
                ...
                <*> Freescale vf610 ADC driver

Then compile the distribution :

[  ] $ make linux && make

Use it

Read channels value

# cd /sys/bus/iio/devices/iio:device0
# ls
buffer                         in_voltage5_raw
current_timestamp_clock        in_voltage6_raw
dev                            in_voltage7_raw
in_conversion_mode             in_voltage8_raw
in_temp_input                  in_voltage9_raw
in_voltage0_raw                in_voltage_sampling_frequency
in_voltage10_raw               in_voltage_scale
in_voltage11_raw               name
in_voltage12_raw               of_node
in_voltage13_raw               power
in_voltage14_raw               sampling_frequency_available
in_voltage15_raw               scan_elements
in_voltage1_raw                subsystem
in_voltage2_raw                trigger
in_voltage3_raw                uevent
in_voltage4_raw

To read ADC value just «cat» the corresponding input file:

# cat in_voltage1_raw       for channel 1 (ADC1_IN1)
4095

All values are not converted (ie. directly show the register content). To have the mV value, you must do: value_mV = read_value * 3300/4095

AsDevices

  • You can access this device from your C/C++ application using as_adc_xxx_iio functions from AsDevices
  • target/demos/oscillo is a "good" example to start with...

Links