Offloading the burdened drone

My drone code is a hard loop (no sleeps or other time blocking commands). Due to being written in interpreted Python, currently each loop around the code, checking the sensors, running the PIDs and updating the PWM takes about 0.015s. That seems pretty fast but I’m starting to wonder if it’s fast enough – the integrations, particularly of the accelerometer, are drifting. So what to do?

  • One step is to not run any irrelevant daemons – trouble is I have no idea how to find them
  • Another is to move from interpreted Python to compiled Python – for this I have to wait unti PyPy comes out of alpha release
  • Yet another would be to bring the PWM driving the motor ESCs away from the PWM I2C breakout board, and instead use RPIOs RPi DMA (direct memory access) PWM – but again, that’s in beta.

So for the moment, I think I’ll stick with what I’m doing, and assume there’s a bug in my integrals or PIDs – fingers crossed (again!).

4 thoughts on “Offloading the burdened drone

  1. Quick question: Why would using software generated PWM (with RPIO) be faster than hardware PWM with breakout board? Naively, I’d think the later is faster and more reliable…. More than happy to be proved wrong though?

    • RPIO _is_ hardware PWM provided by the Raspberry Pi hardware using DMA to program the PWM registers / channels. So in fact RPIO is likely to be faster and more reliable than the i2c Adafruit PWM. I swapped because there‚Äôs a weight loss and space gain on the breadboard by not using the Adafruit board

      • “RPIO _is_ hardware PWM”… oh ok – My bad!

        As a library, I assumed it was emulated as it is with Wiringpi or RPi.GPIO… but clearly not!

        Good to know!

        • The only reason I can be so sure is because I looked at the ‘C’ code – there’s only about 50 lines, and all it does it set up registers and DMA. The rest of the library is the Python mappings.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.