Collect ADC sensor values at high frequency
-
Hi all,
I'd like to ask your opinion about having the possibility to stream data at high frequency from a generic ADC sensor (connected to an expansion board) to a CSV file (similar to what the M956 is doing with the accelerometer). I have this need because the CAN frequency at which the sensors are updating is too low for some of the custom calibrations I'm doing. I have something working based on the AccelerometerHandle, but I'd like to see if it is of interest to do a proper refactor and open a pull request from that.
My idea would be to have something like: M956.1 Pbb.nn Snnn F"" (board.pin name, number of samples, filename). The implementation would be similar to how the accelerometer works, so:
- add two CAN messages, one for the start request and one for the data structure (or somehow use the accelerometer messages?)
- an AdcStreamHandler: to be initialized from the pin name and have a task to collect the raw data and build/send the CAN messages
- modify AveragingFilter.h to return all the collected samples (without interfering with the average)
Side question: I'm not quite sure at which frequency the ADC is updating the filter queue: from a comment "Readings will be taken and about every 'ticksPerCall' milliseconds the callback function will be called with the specified parameter and ADC reading.". It seems like the analog ports are configured with 1, does this mean the adcFilter queue is filling up at 1ms rate?
BTW, what do you think about this feature? The main goal is to get values at high frequency (buffered, not necessarily in real-time, but with a known time interval between the samples). Do you see other approaches that could be followed to have the same functionality?
Thank you in advance.
-
@leone what sampling rate do you need?
-
@dc42 about 200-250Hz is good for what I'm doing now. If higher is possible, it is even better for future uses.