Signal Processing at high frequencies

Firmware/software/electronics/mechanics
Post Reply
rampudia
Beginner
Posts: 20
Joined: Fri Mar 26, 2021 4:21 pm

Signal Processing at high frequencies

Post by rampudia »

Hi! I would like to sample data from the ADC at a frequency of ~2kHz and process it internally before logging the result at the regular 10-100Hz with the python client. I am having a hard time accommodating this functionality in the firmware with an APP or a deck driver and for this reason I would like your advice. Is this the right way to go, should I create a task or some other way?
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Signal Processing at high frequencies

Post by arnaud »

2KHz using a task is complicated since the FreeRTOS scheduler is setup to work on a 1KHz tick, this means that sleep can only be setup in steps of 1ms and be >1ms. So the easy solution of having a loop in a task with delay is not possible. It is possible to change the tick time of the OS but this risks to break random things in the firmware.

One way forward I can think about would be to use a timer and interrups: use a timer to trigger the adc at 2KHz (either directly or from an interrupt) and from the ADC interrupt push measurement in a freertos queue, this queue can be read from your app task and the data can be processed there. To do that you will need to read the stm32F405 reference manual and to use the ST drivers directly in your app.
rampudia
Beginner
Posts: 20
Joined: Fri Mar 26, 2021 4:21 pm

Re: Signal Processing at high frequencies

Post by rampudia »

Ok thanks for the advice, if I succeed I will post the solution here.
Post Reply