Reading a signal at 40kHz

Status
Not open for further replies.

youngibby

New member
Hello, I am working on a project and I am trying to obtain the phase and amplitude of a 40kHz using my teensy.I am generating the wave with a function generator. The serial plotter gives a good sine wave figure for 4kHz but when I increase the frequency to 40kHz the shape is distorted. I am new to microcontrollers, so I don't really know how to improve it because I know the teensy should be able to read 40kHz.
my code
int val;
void setup() {
// put your setup code here, to run once:
Serial.begin(2000000);

}

void loop() {
// put your main code here, to run repeatedly:
val = analogRead(A9);

Serial.println(val);
}
Please any suggestions on what to do will be appreciated
 
To get more out of the ADCs you probably want to go for cyclic reading using
https://forum.pjrc.com/threads/25532-ADC-library-update-now-with-support-for-Teensy-3-1
Possibly on a pin that can be read by both ADCs

Dropping the resolution will decrease the time taken if you want to stick with your current loop https://www.arduino.cc/reference/en/language/functions/zero-due-mkr-family/analogreadresolution/

Thank you so much, I reduced the resolution and I have started to get better results, I will read over cyclic reading , but thank you for your help
 
Status
Not open for further replies.
Back
Top