Hi
I am trying to get the ADC configured so I can use it in a CPP app.
I am monitoring the voltage of a battery so speed and precision are not major requirements.
I have found various articles but I suspect they are not up to date and so I get stuck trying to follow them.
The articles show testing the ADC from the CLI so I thought I would start with this and then progress to my CPP app.
Here is the contents of my BB-ADC-00A0.dts file
> // SPDX-License-Identifier: GPL-2.0-only
> /*
> * Copyright (C) 2012 Texas Instruments Incorporated - https://www.ti.com/
> */
>
> /dts-v1/;
> /plugin/;
>
> /*
> * Helper to show loaded overlays under: /proc/device-tree/chosen/overlays/
> */
> &{/chosen} {
> overlays {
> BB-ADC-00A0.bb.org-overlays = __TIMESTAMP__;
> };
> };
>
> &tscadc {
> status = "okay";
> adc {
> ti,adc-channels = <0 1 2 3 4 5 6 7>;
> ti,chan-step-avg = <16 16 16 16 16 16 16 16>;
> ti,chan-step-opendelay = <0x98 0x98 0x98 0x98 0x98 0x98 0x98 0x98>;
> ti,chan-step-sampledelay = <0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0>;
> };
> };
Comparing to the source in Beaglebone Black ADC: Reading Analog Voltages | Microcontroller Tutorials there are some differences. Should I make these changes or are they redundant now as the AINx pins are not configurable with the modes?
I also note there is no AIN5, is this correct? (I only need two analog inputs).
Following another link I added into /boot/uEnv.txt:
cape_enable=bone_capemgr.enable_partno=BB-ADC
and rebooted
In my case should this be set to BB-ADC-00A0?
I ran: sudo find / -type d -name scan_elements
and found : /sys/devices/platform/ocp/44e0d000.tscadc/TI-am335x-adc.0.auto/iio:device0/scan_elements
inside this directory I have the following files:
in_voltage0_en in_voltage1_type in_voltage3_index in_voltage5_en in_voltage6_type
in_voltage0_index in_voltage2_en in_voltage3_type in_voltage5_index in_voltage7_en
in_voltage0_type in_voltage2_index in_voltage4_en in_voltage5_type in_voltage7_index
in_voltage1_en in_voltage2_type in_voltage4_index in_voltage6_en in_voltage7_type
in_voltage1_index in_voltage3_en in_voltage4_type in_voltage6_index
I haven’t connected up a pot to an input yet but I am not sure which file type to read; _en, _index, _type
sudo cat in_voltage1_index
1
sudo cat in_voltage1_type
le:u12/16>>0
sudo cat in_voltage1_en
0
Can you please correct / confirm the above or point me to an up to date article on this.
Also an example of a CPP app reading the ADC without needing root access would be much appreciated.
Thanks
Michael