PDA

View Full Version : Threading in Teensy3



Pedro
04-16-2013, 07:10 PM
Hi all,

have anyone tried to use threading in Teensy3? Specifically a library called protothreads (http://waynemay.com/threading-in-arduino/)?

I am trying to make a program that integrates IMU and GPS data. The GPS has an update rate of 5Hz and the IMU 200Hz, so for me threading seems to be a great solution, although I am opened to other suggestions. The sensors data is then used by a control algorithm.

Thanks,
Pedro

linuxgeek
04-16-2013, 08:52 PM
This is something like what I've been working on.
You could do an interrupt at 200Hz for the IMU, and within the interrupt every 40 counts, you would capture the GPS data.
You'd have your control algorithm in the main loop.

swarfrat
04-17-2013, 12:54 AM
In the microcontroller world this is usually done with interrupts, but its not a 1:1 translation from multithreading. I'm looking at rewriting my arduino app to be driven off the IntervalTimer library, something like: 10ms timer for things that fade between values, 100ms for scanning inputs looking for fault conditions, and 1s for logging to serial. Since you currently only get 3 timers, things that happen more frequently than the next bigger timer just count.

This way, stuff that happens on the highest resolution timer is dirt simple stuff. I think in my app these would all be simple linear interpolations. Thinking in terms without synchronization primitives is frustrating if you're used to just throwing a scoped boost::shared_lock in there.

npashine
07-16-2016, 11:20 AM
Can we include the RTOS in Teensy 3.2?.

Constantin
07-16-2016, 11:50 AM
Multiple RTOS' have been ported by Bill Greiman, the author of the SDFat library. ChibiOS and FreeRTOS, among others. I'd Google his work and go from there.