Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

6
  • I do not see how the RTOS is a problem in the situation described. It's actually sort of typical (and, frankly, very annoying/disappointing) that 2 or more libraries contend the use of the same timer. I'd rather patch them, drop the meddling with the timer and let the RTOS call them when appropriate. If anything, this shows a shortcoming of the Arduino libraries, where there is no standardized way to do timed stuff and the author of each library is let alone to figure out what HW timer to use. Commented Aug 5, 2015 at 0:30
  • It's not a problem that has an easy solution. Things like pin-change interrupts, for example, used by SoftwareSerial. Once you add one of the interrupt handlers you are committed to handling 8 pins. And how do you handle when one library wants timer 2 for timing an event, and another one wants it to do PWM? Commented Aug 5, 2015 at 1:11
  • As I said: let the RTOS replace the direct use of the timer. If a library just needs a periodic signal, most likely the RTOS can replace the timer handler with a thread. Same goes for PWM. Of course it depends on the time resolution and precision required. But I think in most cases it would be sufficiently accurate. Software Serial is something beyond redemption, as it busy loops in interrupt context. It's ok for a simple project, but in a serious application, I would definitely not use it, as the delay is not even fixed, but depends on the baud rate. Commented Aug 5, 2015 at 1:19
  • For the pin change interrupt, I think that's another short coming of the standard Arduino library. IMHO there should be a default, standard, way of running timed tasks and to get the OS to handle inputs/outputs, like providing the first/last time an input line changed or generate a pwm by sw on an arbitrary pin. I moved away from the Arduino standard libraries after noticing that thy make it harder to do apparently simple tasks. Commented Aug 5, 2015 at 1:26
  • That horse has probably well and truly left the stable by now. A lot of libraries assume you are only going to use their library (or at least not another one with conflicting requirements). To have imposed a RTOS during the early days of design would probably have been too hard, and now it is too late. The other issue is memory. To have multiple threads you need multiple stacks, and probably multiple heaps. It's going to get rather hard to manage all this when you only have 2 KB of RAM to start with. Commented Aug 5, 2015 at 1:45