Replaying analog signals

justinfrench

New member
Hey everyone, I’m looking for ideas and suggestions on how to replay or reproduce specific signals coming through analog pins to speed up the fine tuning of my algorithms and filters.

I’m working on an electronic drum project that has multiple piezo sensors, different surface areas and ways of hitting the drum with a stick (velocity, position, etc). This makes it hard to reproduce a specific kind of hit (or a series of hits), which in turn makes it slow to fine tune the settings and algorithms that translate this into MIDI.

My first idea is to read in the values at a specific sample rate, print those to the serial, save them into arrays and then replay them back at the same rate. Any other approaches I should consider or tutorials I should dig into?
 
I'm going to assume you've already worked out the analog circuitry for handing your piezo signals (amplification, impedance) and that you're simply working on capturing and "replaying" incoming signals to help on the firmware processing side.

First, use pedvide's enhanced ADC library. This will allow much more control over the Teensy's ADC(s). Next determine the necessary duration of each capture along with the needed resolution. This will help determine your memory requirement for these captures. To save memory, consider packing multiple readings together by shifting bits. For example, a signal 12-bit resolution sample would require 2 bytes (16 bits) of storage memory, and a pair of 12-bit samples would require 4 bytes (32 bits) but these same two 12-bit samples could also be more efficiently packed into 3 bytes (24 bits) with some simple bit shifting which is extremely fast and therefore won't impact your overall sample speed. Don't attempt to export your samples over serial/USB in real time. Instead, start the ADC in continuous mode, wait for a trigger (maybe an incoming reading over a predetermined threshold) then begin shifting and packing these ADC readings into an array until the necessary sample duration is reached or available RAM is filled. At that point you can simply point your filter functions toward this array and test away. Don't dump these values over serial until AFTER captured. This cuts down on digital noise and prevents any bottlenecks at high sample speeds.
I'd actually recommend switching over to serial monitor plotter and dumping the raw array samples to your monitor then processing the array data and dumping it to the plotter for quick and easy comparison.

In order to save and "replay" these samples, I'd recommend additional high speed, non-volatile memory such as a FRAM chip. I use this exact setup myself to shuffle several hundred thousand high speed ADC readings off into an external FRAM over SPI then process and filter them once the sample is completed. Just pull the samples from FRAM back into your RAM array to test out different filter methods while still maintaining a copy of the original unfiltered sample data that can be reloaded for testing other filters.

Depending on your hardware setup and the sensitivity of your analog measurements you may also be able to move samples over to FRAM in real time. I wouldn't recommend doing this with an SD card storage solution because the current draw can quite easily influence ADC readings.
 
Back
Top