How do I increase the default A/D conversion speed on an Artemis ATP Redboard when using the Arduino IDE? On an Arduino Mega I increase it to approximately 55 KHz using:
//ADCSRA |= (1 << ADPS2) | (1 << ADPS0); // 32 prescaler for 38.5 KHz
ADCSRA |= (1 << ADPS2); // 16 prescaler for 76.9 KHz
//ADCSRA |= (1 << ADPS1) | (1 << ADPS0); // 8 prescaler for 153.8 KHz
On the Artemis ATP Redboard the default is approximately 11 KHz. The above Arduino registers on the redboard give me an error when I compile and give me a suggestion to use PINADC but I don’t know what to set it to.
Please provide sample code if possible. I am not the best programmer and I usually copy and paste pieces of other people’s code.
Thanks,
Jerry
I am not clear what you really want to achieve with increasing conversion speed.
From the datasheet :
19.3.2 ADC Sample-and-Hold Time
The ADC on the Apollo3 Blue is a successive approximation register (SAR) ADC with 4 pF input capacitance. If there is large input impedance to the ADC input, then the sample-and-hold time must be increased to ensure the 4 pF sampling capacitor has time to settle.
The Apollo3 Blue ADC sample-and-hold time is fixed at 5 ADC clock cycles. The ADC has two options for ADC sampling clock, HFRC or HFRC/2. This results in a sample-and-hold time of approximately 0.2 µs for 24 MHz HFRC/2 ADC clock or about 0.1 µs for the default 48 MHz HFRC ADC clock.
For high impedance signal sources, the maximum 0.2 µs sample time may not be long enough to charge the internal sampling capacitor. One option for working with large impedance sources such as a large resistor divider is to add a 100 nF or larger cap to the ADC pin. This cap will buffer the voltage level so that the ADC sampling cap will take its charge from this cap. A 100 nF cap is large enough that the 4pF sampling cap should not perturb the voltage on the cap in any significant way. This is effective for measuring stable or slow changing signals such as battery voltage. For fast signals, the 100 nF capacitor will work with the source impedance to act as an RC filter which will limit the effective input frequency.
Another option for measuring high impedance source is to add an external buffer.
So the amount of sample time taken is depending on the ADC frequency, which is already 48MhZ by default. BUT the correct reading is depending on the impedance of the source. For the later there is a good post where an additional capacitor was added as it was a slow changing source. (viewtopic.php?f=169&t=54907&hilit=ADC)
If you want to increase the analogRead() turn-around time.
That mostly does not depend on the sample rate. There is a big overhead due to a large number of checks and settings that happens every time. See post viewtopic.php?f=169&t=56770&hilit=ADC for a answer
Maybe I missed out to address your issue, please explain a bit more.
Your link to the analog read speed is what I needed. Thanks much. I will try what paulvha - Mon Nov 22, 2021 10:25 am mentioned it that post. If I get the same speed that will solve my problem. Thanks much! Jerry