The phyCORE-i.MX7 SOM brings out four 12-bit ADC input channels (ADC_IN[0:3]). On the development kit, you can access these signals through the PEB-D-RPI Expansion Board via the X13 header. This guide provides a walk-through for connecting a bench-top power supply to test all four channels. In order to follow this guide, you will need a Philips Head Screw Driver, 2x M-F jumper cables, soldering equipment, 5x 2.54 mm pitch pin headers, 2x power supply leads, and power supply.
- VREF for ADC channels is 1.8V
- Since there isn't any 1.8V rails accessible on the Expansion Board a power supply or voltage divider + potentiometer will be necessary to create a ~1.8V supply.
- The connector X13 on the Expansion Board is not populated with header pins out of the box. 5 header pins will need to be soldered to the expansion board for ease of use.
- Once pin headers are populated some Raspberry Pi Hats may no longer seat correctly.
Connect to the ADC
ADC_IN0 through ADC_IN3 can be accessed on the PEB-D-RPI Expansion Board of the development kit through the X13 connector at pins 35, 37, 39 and 41 respectively. However, since the ADC channels are all referenced to 1.8V it will be necessary procure or create a 1.8V supply in order to properly test these interfaces.
First, we will need to populate some pin headers to allow access to the ADC channels.
- With the phyBOARD-Zeta powered off and with the power supply removed, remove the 2 bolts securing the PEB-D-RPI Expansion Board with a Phillips Head Screw Driver.
- Take care when removing this Expansion Board from the Carrier Board, as too much torque will bend the connector pins. Gently rock the connector back and forth and slowly lift it up as vertically as possible.
- With the PEB-D-RPI Expansion Board removed, solder the 5x 2.54 mm pitch pin headers to the #35-43 pins at X13.
- Now reassemble the phyBOARD-Zeta by re-securing the PEB-D-RPI Expansion Board to the Carrier Board.
- With the bench-top power supply disconnected from the phyBOARD-Zeta, set the voltage to something within the range 0V to 1.8V and set a current limit of 200 mA.
- Now boot the phyCORE-i.MX7 into Linux and connect the power supply to pins 35 and 43 on the PEB-D-RPI's X13 header. See the below circuit diagram for reference.
Read the ADC
You will be able to read each channel from the Linux command line. Below is a mapping of the ADC channel and corresponding device in Linux.
|ADC Channel||Signal Name|
This example shows how to read incoming data on ADC_IN0 (pin 35). Use of a different ADC channel can be accomplished by replacing the "in_voltage0_raw" with the corresponding signal name of the desired channel:
The ADC registers are 12 bits which will read from 0 to 4095. From the ADC reading you can calculate the voltage at the pin with the following formula:
By adjusting the output of the bench-top power supply (do not exceed 1.8V) and using the above command we can see that the voltage read on the ADC channel is changing from 0V to 1.8V.
The power supply was adjusted and a few readings were taken from Linux to calculate the voltage.
root@imx7d-phyboard-zeta-004:~# cat /sys/bus/iio/devices/iio\:device0/in_voltage0_raw 4 root@imx7d-phyboard-zeta-004:~# cat /sys/bus/iio/devices/iio\:device0/in_voltage0_raw 926 root@imx7d-phyboard-zeta-004:~# cat /sys/bus/iio/devices/iio\:device0/in_voltage0_raw 1581 root@imx7d-phyboard-zeta-004:~# cat /sys/bus/iio/devices/iio\:device0/in_voltage0_raw 2209 root@imx7d-phyboard-zeta-004:~# cat /sys/bus/iio/devices/iio\:device0/in_voltage0_raw 3199 root@imx7d-phyboard-zeta-004:~# cat /sys/bus/iio/devices/iio\:device0/in_voltage0_raw 4094
See the code block below for the command that corresponds to reading the ADC on each channel (the words following "#" are comments and will be ignored by your Kernel):
cat /sys/bus/iio/devices/iio\:device0/in_voltage0_raw # To read ADC_IN0 cat /sys/bus/iio/devices/iio\:device0/in_voltage1_raw # To read ADC_IN1 cat /sys/bus/iio/devices/iio\:device0/in_voltage2_raw # To read ADC_IN2 cat /sys/bus/iio/devices/iio\:device0/in_voltage3_raw # To read ADC_IN3