tuskiomi
Posts: 9
Joined: Wed Jan 21, 2015 2:43 am

Raspberry pi 3 RTOSes

Tue Jan 16, 2018 1:17 am

Hello, Has anyone gotten an RTOS working on the raspberry pi 3? I'm trying to make a flight system for a hexacopter, and I need the Real time precision that comes with an RTOS to make accurate calculations.

Heater
Posts: 9955
Joined: Tue Jul 17, 2012 3:02 pm

Re: Raspberry pi 3 RTOSes

Tue Jan 16, 2018 9:11 am

What are your real-time deadlines exactly? It's meaningless to state real-time without specifying that.

If you happen to be using a four core Pi you can isolate one or more cores from any Linux kernel scheduling activity and dedicate it to doing nothing but your real time task.

With these techniques I can eliminate all kernel action on a core except an interrupt that fires off every few ms and eats only 5us of time.

There is a discussion of these techniques here : viewtopic.php?f=63&t=200793&start=25#p1252388 and in the rest of that thread.

tuskiomi
Posts: 9
Joined: Wed Jan 21, 2015 2:43 am

Re: Raspberry pi 3 RTOSes

Tue Jan 16, 2018 7:17 pm

I need real time precision on PWM output (if the Pi does not have an internal PWM controller) I need real time monitoring on pwm input from the radio. I need real time, deterministic timing in my loop function so my delay functions can be held more or less constant.

User avatar
joan
Posts: 13578
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Raspberry pi 3 RTOSes

Tue Jan 16, 2018 7:32 pm

The term real-time doesn't mean much. You need to specify the real-time constraints. Have you looked at the Pi specs?

tuskiomi
Posts: 9
Joined: Wed Jan 21, 2015 2:43 am

Re: Raspberry pi 3 RTOSes

Tue Jan 16, 2018 10:33 pm

joan wrote:
Tue Jan 16, 2018 7:32 pm
The term real-time doesn't mean much. You need to specify the real-time constraints. Have you looked at the Pi specs?
Of course, I own a good number of them.

There's a good reason that you can't get any flight system running Linux certified

Heater
Posts: 9955
Joined: Tue Jul 17, 2012 3:02 pm

Re: Raspberry pi 3 RTOSes

Wed Jan 17, 2018 8:18 am

More or less what?

Real-time performance is possible on a pi running Raspbian. For some definition of "real-time". Discussion I linked to above.

Personally if I were messing with a lot of PWM and other high speed real-time signals I would consider using a separate MCU to do that. In particular the 8 core, 32 bit Propeller MCU from Parallax Inc. A perfect device for such real-time, deterministic timing. Very easy to program in C or the SPIN language from Parallax. Or even the assembly language is very easy on that device. Heck the Propeller has been used to control Quad copters all my itself!

I'm sure main high speed control loop can then be run at, say, 100Hz on the Raspberry Pi under Raspbian, with real-time guarantees. Provided you run it on a specific core that is isolated from the Linux kernel scheduler. See discussion above.

Meanwhile, lesser tasks can be run in regular Linux processes/threads. Communications for example, or any user interface.

davethomaspilot
Posts: 79
Joined: Tue Apr 29, 2014 6:18 pm

Re: Raspberry pi 3 RTOSes

Mon Oct 29, 2018 12:56 pm

I have a similar question. Here's my attempt to define "how realtime" my project needs. I'd appreciate any comments on how feasible it is on an RPI 3B+ running stretch. Do I need to dedicate a core? Is even that sufficient, or do I need a separate, dedicated processor?

An "event queue" will exist that will include events that have :
  • a timestamp for when the event was posted
  • a delay for when the associated action should be started
I was thinking I could use pigpio C I/F to get a timestamp on a GPIO transition that coincides with completion of a message from a UART. I think this timestamp accuracy could be a few usecs (or maybe better)? @joan?

The event_queue will be read every 1 msec. The code at that point will have to get a "now" time and will run the action code if current time is greater than the event time + delay.

Can I expect to get at least +/- 1 msec accuracy for when the action code runs?

Once the action code starts running, can interrupts be disabled until the code completes? Is there a limit on how long the interrupts can be disabled?

Thanks!

Return to “Other”