I'm getting only 130 kCycles/sec on the Nano RP2040 Connect using this program. With a Signal gererator driving at 10kHz shows 13 samples between nulls in the output. But when the same code runs on the Metro RP2040 I get 20 samples between nulls giving 200 kCycles/sec. The Metro requires the Philhower core and I selected 133 mHz cpu rate. I assume the Nano RP2040 is also running at 133 mHz so what is the cause. More important to me is how to get the Nano to 200 kCycles/sec. I need that rate on the Nano for my ultrasonic sampling project.
#define BUFFER 1024
void setup() {
// open a serial connection
Serial.begin(115200);
delay(1000);
// change the resolution to 12 bits and read A0
analogReadResolution(12);
int data[BUFFER];
for (int i = 1; i<BUFFER; i++)
{
data[i] = analogRead(A0);
}
for (int i = BUFFER-30; i<BUFFER; i++)
{
Serial.print(i);
Serial.print(" ");
Serial.println(data[i]);
delay(10); // a little delay to not hog Serial Monitor
}
}
void loop() {
}
You probably need to set up the ADC with a higher clock rate and perhaps lower resolution. analogRead() uses some arbitrary defaults chosen by the people who wrote the Arduino cores.
The processor data sheet explains all the possibilities.
To detect a 100 kHz signal, 200 kHz sample rate is the absolute minimum. If you are interested to measure the amplitude of the 100 kHz signal, most people would sample at 10x, or 1 MHz.
Note that this processor has a very bad noise response, something the chip designers admit. The problem is mainly with the design of the chip, but you can make modest improvements with averaging and adding capacitors at various places. But note that this will slow down the achievable sample rate.
Yes, I was getting 500 KCycles/sec using Pico Visual Studio but that system is really difficult to jump right in and I suppose they are increasing the ADC clock. Arduino is so much easier to use and I'm switching over to the Philhower core. Does anyone have an Arduino example increasing the ADC clock?
I installed the latest Philhower core, but the Win11 port disappeared and wouldn't return. I found an old note that said to backload the core. I uninstalled the latest core and reinstalled Ver: 2.6.1. I also exited and reloaded the IDE between each move as suggested. Everything works now and getting 190 kCycle/sec. I still hope to get some help increasing the ADC clock to achieve my goal. Thank You.