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 mckelbo
#234311
I'm interested in using the Artemis Nano for a project since it is straightforward to implement, low profile, and accessible; the issue, however, is that I can't figure out a way to change the ADC settings so that I can get better results. I have been testing out different microcontrollers for my project, and one of them has been a Teensy board. The Teensy board allows me to easily adjust the ADC settings to configure settings like the sampling speed, acquisition speed, and resolution. Optimizing these settings helps me get the best results for my project. To my knowledge, there is no way to configure these settings on the Artemis Nano, so I was wondering if there was a way to do this or possibly implement this in a future update.
User avatar
By mckelbo
#234372
@TS_Russell, I'm not too familiar with the Artemis Nano board, so can you (or anybody else reading this) guide me through how that would work.
By paulvha
#234409
Unlike some processors where you can control most the hardware and port settings directly, the Artemis processor (like others) has modules. These modules can be configured to a certain extent to perform the task.

The Apollo3 ADC driver that configures and controls the ADC module works well. But indeed provides limited ability to make full use of the configuration options. When performing analogRead() the configuration will be set to a hardcoded / default "middle of the road" config, which is good enough for most solutions. From the user/sketch level, you can change the resolution with analogReadResolution() to a lower value than the default 14 bits but that is it.

Hardcoded are :
  • The ADC sampling speed defaults to a maximum (48Mhz). The Apollo3 also allows being configured to 24 Mhz, taking more time to take the sample. Especially in high (external) impedance circuits, this could help.
  • The acquisition average is set to ONE while the Apollo 3 can provide an average based on up to 128 samples in a single shot.
  • It is NOT in continuous reading, it performs a one-shot reading every time an analogRead() is performed.
  • As can be seen in other posts the overhead time for a single analogRead() from the driver is high as it configures the whole setup with every analogRead(). Making it slow.(see viewtopic.php?f=169&t=56770&hilit=ADC)
  • The Apollo3 has 8 'slots' in the module to make an ADC measurement. Sparkfun has chosen slot0, which has an impedance to the external circuit of 720K ohm. Much better would have been slots 1 to 7 which have 3600M ohm impact.
Now, all that said: the accuracy is not only dependent on the Artemis board but also on the sensor.

If you want to get a change .. better would be to try to ask on github (https://github.com/sparkfun/Arduino_Apollo3/issues)
User avatar
By mckelbo
#234446
Thanks for the detailed explanation, @paulvha. Sorry, but could you explain how changing the modules would work and how to go about hardcoding the desired changes (like is there a list of functions). The goal of my project is to read constantly changing data as fast as possible.
By paulvha
#234449
Expect the answer is not a straight forward as you may hope. But to help you to get started :

From a sketch the analog functions that can be called in
~/.arduino15/packages/SparkFun/hardware/apollo3/2.2.1/cores/arduino/mbed-bridge/core-implement/CommonAnalog.cpp
and
~/.arduino15/packages/SparkFun/hardware/apollo3/2.2.1/cores/arduino/sdk/core-implement/CommonAnalog.cpp

From these files the hardware layer functions (hal) are called, which are defined in :
~/.arduino15/packages/SparkFun/hardware/apollo3/2.2.1/cores/mbed-os/targets/TARGET_Ambiq_Micro/TARGET_Apollo3/sdk/mcu/apollo3/hal

if you want to make changes to the functions , best to study the Apollo3 datasheet
https://cdn.sparkfun.com/assets/1/5/c/6 ... 0_15_0.pdf
User avatar
By mckelbo
#234510
@paulvha, is it possible to change the hard-coded characteristics you mentioned in your earlier comment? If so, can you give an example?
By paulvha
#234515
Hi,

Given that I am busy on other projects and have no plans to re-write the analog driver, I am not going to spend a lot of time on this.

The short answer is YES, they can be changed and most of them in the file:
~/.arduino15/packages/SparkFun/hardware/apollo3/2.2.1/cores/arduino/sdk/core-implement/CommonAnalog.cpp

Functions like initializeADC() and ap3_config_channel() are the primary targets to change based on the datasheet information.
 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

long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]