Increasing ADC reading speed

I am working on porting an application from an Arduino Mega to a Teensy 4.1. One of the most important requirments is to monitor several ADC inputs and react as fast as possible if one of them exceeds a preset level.

When I did the Arduino Mega sketch I found some information in Simon Monk's book on increasing the ADC speed. This is what he recommended:

ADCSRA &= ~PS_128;//remove prescale of 128
ADCSRA |= PS_16;// add prescale of 16 (1MHZ)

This software has been in use for several years and has provided the protection that I needed, I have not measured the reaction time but from my experience it is fast enough. I see that the ADC read speed is natively faster in the Teensy 4.1 when compared to an Arduino Mega but I don't know how much Monk's recommendation increased the default speed.

Will the Teensy 4.1 still be faster or are their comparable settings to increase the speed?

Thanks for your help,

Don
 
The Teensy 4.1's ADC is much faster than the Arduino Mega's, reaching up to 1.2 MSPS versus the Mega's 15-20K samples per second. It doesn't need manual tweaks like the Mega did, as it's fast by default. For even better performance, you can use analogReadFast(), lower the resolution, or adjust ADC settings, though the default speed is usually more than enough.
 
Is there a library that I need to include for the analogReadFast?

Don
To use analogReadFast() on the Teensy 4.1, install the ADC library by Pieter P from the Arduino Library Manager and include it with #include <ADC.h>. After that, you can call analogReadFast(pin) for fast analog readings. The library also lets you tweak settings like resolution and speed if needed, but the default performance is usually more than enough.
 
To use analogReadFast() on the Teensy 4.1, install the ADC library by Pieter P from the Arduino Library Manager and include it with #include <ADC.h>. After that, you can call analogReadFast(pin) for fast analog readings. The library also lets you tweak settings like resolution and speed if needed, but the default performance is usually more than enough.
I can't seem to find this library. Can you provide a link?
 
Back
Top