Difference between revisions of "LRADC"

From ArmadeusWiki
Jump to: navigation, search
(Read channels value)
(Use it)
 
(6 intermediate revisions by 2 users not shown)
Line 3: Line 3:
 
This description uses Linux kernel > 3.7.
 
This description uses Linux kernel > 3.7.
  
LRADC is a 12 bits 16 channels Analog to Digital Converter integrated into the iMX28 processor.
+
LRADC is a 12 bits 16 channels Analog to Digital Converter integrated into the i.MX28 processor.
  
Only channels 0-6 may be used to generic conversions and channels 2, 3, 4, 5 are used to the touchscreen.
+
Only channels 0-6 may be used to generic conversions and channels 2, 3, 4, 5 are used for the touchscreen on [[APF28Dev]].
  
* Channel 0 is available on pin J10 p.38;
+
* Channel 0 is available on J10 pin 38 of [[APF28Dev]]
* Channel 1 is available on pin J10 p.36;
+
* Channel 1 is available on J10 pin 36 of [[APF28Dev]]
* Channel 6 is available on pin J10 p.35;
+
* Channel 6 is available on J10 pin 35 of [[APF28Dev]]
  
 
== Driver ==
 
== Driver ==
Line 36: Line 36:
  
 
=== Load driver ===
 
=== Load driver ===
To use the LRADC, first load ''lradc'' module:
+
To use the LRADC, first load ''mxs-lradc'' module:
  
 
<pre class="apf">
 
<pre class="apf">
# modprobe lradc
+
# modprobe mxs-lradc
 
</pre>
 
</pre>
  
Line 55: Line 55:
 
</pre>
 
</pre>
  
To read adc value just «cat» an input :
+
To read ADC value just «cat» the corresponding input file:
 
<pre class="apf">
 
<pre class="apf">
# cat in_voltage0_raw  
+
# cat in_voltage0_raw       for channel 0
 
4095
 
4095
 
</pre>
 
</pre>
  
All values are not converted (ie. directly the register content). To have the mV value, you must doing: 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 = in_voltageX_raw * 1850/4095
 +
 
 +
===Temperature===
 +
* LRADC is also able to give us i.MX28 die temp:
 +
 
 +
<pre class="apf">
 +
TEMP_RAW=`cat /sys/bus/iio/devices/iio:device0/in_temp8_raw`
 +
TEMP_OFFSET=`cat /sys/bus/iio/devices/iio:device0/in_temp8_offset`
 +
TEMP_SCALE=`cat /sys/bus/iio/devices/iio:device0/in_temp8_scale`
 +
 
 +
TEMP=`echo "${TEMP_RAW} ${TEMP_OFFSET} + ${TEMP_SCALE} * p" | dc`
 +
echo ${TEMP}
 +
</pre>
 +
 
 +
==Links==
 +
* http://www.at91.com/linux4sam/bin/view/Linux4SAM/IioAdcDriver
  
 
[[Category:Linux drivers]]
 
[[Category:Linux drivers]]
 
[[Category:Analog to Digital Converter]]
 
[[Category:Analog to Digital Converter]]
 +
[[Category:Industrial Input Output]]

Latest revision as of 15:15, 25 November 2019

Introduction

This description uses Linux kernel > 3.7.

LRADC is a 12 bits 16 channels Analog to Digital Converter integrated into the i.MX28 processor.

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

  • Channel 0 is available on J10 pin 38 of APF28Dev
  • Channel 1 is available on J10 pin 36 of APF28Dev
  • Channel 6 is available on J10 pin 35 of APF28Dev

Driver

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

Otherwise, you can select it that way:

[  ] $ make linux-menuconfig
Device Drivers  --->
    <M> Staging drivers  --->
         IIO staging drivers
            Analog to digital converters
                <M>   Freescale i.MX28 LRADC

Then compile the distribution :

[  ] $ make linux && make

Use it

Load driver

To use the LRADC, first load mxs-lradc module:

# modprobe mxs-lradc

Read channels value

# cd /sys/bus/iio/devices/iio:device0
# ls
buffer                   in_voltage11_raw  in_voltage2_raw   name
dev                       in_voltage12_raw  in_voltage3_raw   power
in_temp8_raw      in_voltage13_raw  in_voltage4_raw   scan_elements
in_temp9_raw      in_voltage14_raw  in_voltage5_raw   subsystem
in_voltage0_raw   in_voltage15_raw  in_voltage6_raw   trigger
in_voltage10_raw in_voltage1_raw   in_voltage7_raw   uevent

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

# cat in_voltage0_raw       for channel 0
4095

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

Temperature

  • LRADC is also able to give us i.MX28 die temp:
TEMP_RAW=`cat /sys/bus/iio/devices/iio:device0/in_temp8_raw`
TEMP_OFFSET=`cat /sys/bus/iio/devices/iio:device0/in_temp8_offset`
TEMP_SCALE=`cat /sys/bus/iio/devices/iio:device0/in_temp8_scale`

TEMP=`echo "${TEMP_RAW} ${TEMP_OFFSET} + ${TEMP_SCALE} * p" | dc`
echo ${TEMP}

Links