Teensy 4, how to store ADC readings in buffers

Status
Not open for further replies.

frankzappa

Well-known member
Noob here.

I'm planning to do an electronic drum project and I'm thinking about the best way to get fast ACD readings from multiple piezos. Is there a way to do readings as fast as possible cycling through the different piezos and store the last reading from each piezo into buffers?

I could then read the last buffer value in stead of doing an ADC reading from one piezo, do some calculations, do the next etc.

That way the ADC readings would not be slowed down. Will this even matter with a teensy 4 BTW? Maybe it's so fast it's negligible. I need to read 10 sensors at the same time and would prefer to get at least 10 readings from each every millisecond. Preferably 20 or more because I want to try to read timing differences between them etc.

I'm planning to use the ADC library to get faster ADC readings but my coding knowledge is not yet good enough to understand much of the examples in the ADC library. Can anyone guide me in the right direction how to implement this? Or maybe tell me what specific topics I need to study to understand this.

Thank you
 
would you like to store 10 last values of ADC readings for each sensor and read them later? you can use a circular_buffer for that
 
https://github.com/tonton81/Circular_Buffer

you can use this to setup as many buffers as you like, but they must be a power of 2, so if you want 10 you'll need to use 16 instead. you can then indefinately write new ADC values to their buffers and the older ones will be overridden, giving you the last 16 values only, if you are planning to use averaging, it's there too
 
Status
Not open for further replies.
Back
Top