PDA

View Full Version : Minimal Signal Processing



drew
01-25-2013, 03:57 PM
I have an application where I need minimal digital signal processing.

Everytime the analog input crosses zere I recalculate the gain as a function of time and output a pwm d/a signal. Hmm, it would be really cool to log the signal to sdcard, too.

Can the teensies handle an 80+ KHz sample rate? (40 KHz sonar echo)

I thought I saw some a/d and pwm d/a libraries and/or examples, but I can't find any of them at the moment.

Teensy 3.0 hardware looks much more capable, but it's not clear what a/d and d/a libraries the 3.0 software currently include.

PaulStoffregen
01-27-2013, 04:25 PM
Teensy 3.0 might be able to do this. I haven't done much speed testing yet, but it is much faster than 2.0.

You'll want to use analogReadResolution(8) to set for the fastest mode, and analogReadAveraging(1) so there's no built-in averaging happening. That should give the fastest possible results with analogRead().

Jp3141
01-27-2013, 08:08 PM
I have an application where I need minimal digital signal processing.

Everytime the analog input crosses zere I recalculate the gain as a function of time and output a pwm d/a signal. Hmm, it would be really cool to log the signal to sdcard, too.

Can the teensies handle an 80+ KHz sample rate? (40 KHz sonar echo)

I thought I saw some a/d and pwm d/a libraries and/or examples, but I can't find any of them at the moment.

Teensy 3.0 hardware looks much more capable, but it's not clear what a/d and d/a libraries the 3.0 software currently include.

I'm running at about 125 kHz sample rate -- there is minimal processing on the interrupt loop (record value, accumulate value, increment counter), and that leaves about 50 % of the CPU time for processing.

When I go over ~150 kHz, I miss some interrupts (about 0.1 % of them) -- this is a function of the FlexTimer Module -- if other, higher priority processing takes more than 6 us, my interrupt gets missed. I haven't figured out if I am setting the interrupt priorities correctly yet, but I think it is the USB that is messing it up.

PaulStoffregen
01-27-2013, 08:36 PM
You could write to the NVIC registers to reduce the USB interrupt priority.

Jp3141
01-27-2013, 10:39 PM
You could write to the NVIC registers to reduce the USB interrupt priority.
I tried to do that -- set the FTM interrupt priority to 0, but it didn't work for me (maybe the USB is already set to 0 ?).

I have to read the manual more -- I'm not sure I did it correctly.

PaulStoffregen
01-27-2013, 10:46 PM
I believe they all default to zero. If you want to have your interrupt able to interrupt others, you probably need to lower their priority. I have not personally played with the priority levels and nesting interrupts yet.....