SparkFun Forums 

Where electronics enthusiasts find answers.

Topics pertaining to the Arduino Core & software used with the Artemis module and Artemis development boards.
User avatar
By tomcshop
#211000
I was trying to do some simple ADC's using the Redboard Artermis and I can't get my results to match my meter. I took into account the 2.0VDC reference and the 10 bit ADC. The Meter reads 1.4V and the redboard is giving me 1.3V. I am trying to read an NTC style thermocouple with a 100K in series resistor so I know that I have a high impedance load.

I found an app note in their documentation for the Apollo2 ( a little outdated) about setting up the ADC settling time. The problem is that I can't figure out what register or HAL command is used to control the settling time.
https://www.ambiqmicro.com/static/mcu/f ... rev1_1.pdf

Here is my read:
Code: Select all
double voltage = analogRead(A0)*2.0/1024;
Just wondering if anyone else has run into this issue. If I plug a traditional atmel style redboard in, and change the reference to 5.0, all works well and the voltages match.

I looked through the

am_hal_adc.c file

and could not find what I was looking for.

Thanks,

Tom
By paulvha
#211009
no.. you can not change that fixed number. You can only adjust the clock speed in ap3_analog.cpp, function ap3_adc_setup(). You can try to set the clock to AM_HAL_ADC_CLKSEL_HFRC_DIV2 instead of AM_HAL_ADC_CLKSEL_HFRC to reduce to clock speed to half. On a quick test reading the VDD I do not see a difference however. Measuring the VDD with a digital Fluke multimeter gives 3.137. The ADC reading gives a voltage of is 3.146 in both cases on 10bit. Alternative you can try to increase / decrease the resolution with the call analogReadResolution(uint8_t bits)
User avatar
By tomcshop
#211044
I did some more experiments to see what was going on since I was inspired by someone's quick reply to my problem. I got rid of the thermocouple and just used a breadboard to build some voltage dividers. I used a 4.7K and 4.7K for one with a 3.3 V supply, and results:

Fluke Meter: 1.651V
ADC as packaged: 1.625V
After clock adjust: 1.656V

Then I built a 100K and 100K to give a higher impedance on the input.

Fluke Meter: 1.643V
ADC as packaged: 1.316V
After clock change: 1.357V
Change from 10 bit to 14 bit: 1.373V

Then I researched hal to see if I could find clock with even more division but they do not exist.

My theory is the super quick sample rate capability comes with the drawback of not being able to have enough time to charge to the cap in the ADC with high impedance loads. Kind of a bummer for this project as I was excited to use the tensorflow aspect with a control system that depended on a 100K thermo couple.

https://cdn.sparkfun.com/assets/d/a/7/c ... v0_9_1.pdf

In here on page 780/909 it shows the dynamics of the sampling. Not 100% sure what this means but it sounds like a 14 bit ADC allows for 40 cycles of settling time whereas the 8 bit allows for 18 cycles. That would explain why the results above for the 100K were better at 14 bit but will way off.

TSNGLSLOT_SC
NCMP_PM14
Delay from scan start to scan
complete, precision mode 14
40 cycles

TSNGLSLOT_SC
NCMP_PM8
Delay from scan start to scan
complete, precision mode 8
18 cycles
By paulvha
#211052
Actually the Arduino Artemis library is always using 14 bit (set in ap3_analog.cpp, function ap3_change_channel()). When a read is performed at the end of analogRead() it will scale down the result to the requested bits. I did a change to hard code 10-bits to test but it does not bring a difference.

I suspect the timing could the issue but also interesting to me is the impedance difference in the datasheet (page 780) between ADC channel 0 and channel 1-7. The channel 0 is typical 720K where channel 1-7 is 3600M ohm. Channel 0 is connected to pad 16, where the 1 - 7 are connected to 29,11,31,32,33,34,35. Not sure which channel you have used for your test, but maybe try another.
 Topic permissions

You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum