Jake13535
Posts: 1
Joined: Tue May 20, 2014 5:03 am

Raspberry pi quadcopter

Tue May 20, 2014 5:07 am

I really want to make a quadcopter out of my raspberry pi. I want to do so by using two h-bridge boards and the pi's gpio pins. How could I control the 4 motor speeds within my python program (without turning knob)?

recurry
Posts: 6
Joined: Wed May 07, 2014 11:34 pm

Re: Raspberry pi quadcopter

Sun May 25, 2014 12:54 am

Raspberry pi will make a terrible quadcopter controller for a number of reasons. First, it's I/O is terribly slow and latencies are very high. Second, it's VERY heavy. Unless you are making a very large quad it will have a hard time getting off the ground. The broadcom SOC was designed primarily for things like IP Cameras and similar embedded appliances and has plenty of compute performance but the GPIO's are just not optimized for high-speed bit twiddling.

It's not clear from your post whether you intend to run Linux for this little experiment. If so that's a major roadblock. Standard Linux as RPI runs is not suitable for realtime applications. You need an OS which can support pre-emptive task scheduling and is deterministic (meaning you can count on a specific response time to a given event). Without that it's near impossible to implement the kind of control loops necessary for something like a quad copter. There are versions of Linux that have been patched to be more suitable for real-time applications but Rasperian isn't one of them. If you want to build a quadcopter you will be best served buying an Arduino (still big and heavy though) or one of the many inexpensive multicopter controller boards using something like a Cortex3 or 4 ARM processor with some open source software to make it run.

Good luck!

User avatar
aTao
Posts: 1093
Joined: Wed Dec 12, 2012 10:41 am
Location: Howlin Eigg

Re: Raspberry pi quadcopter

Sun May 25, 2014 5:05 am

Going to have to disagree with recurry on the RPi's control abilities here.
Sure, if you bit-bash a GPIO pin then you will suffer from using a non real time OS (although RISC does quite well here, and then there is always your own OS option). But that would be a daft approach. Some GPIO pins on the RPi have hardware PWM capabilities and there is a library to provide fast, reliable PWM on all GPIOs.
So, how fast is the RPi? Using Java on Raspbian with no overclocking I have bit-bashed a GPIO at 3MHz, C++ has got 7MHz. Having taken the PWM timing away from the CPU you then have bags of time and response to control the motors faster than they could respond anyway.

As for payload weight, well that depends on your 'copter.
>)))'><'(((<

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

Re: Raspberry pi quadcopter

Sun May 25, 2014 7:08 am

Quadcopters use specialised motors. I don't think they are (usefully) controllable from H-bridges. Look up ESC and quadcopter.

recurry
Posts: 6
Joined: Wed May 07, 2014 11:34 pm

Re: Raspberry pi quadcopter

Sun May 25, 2014 7:12 pm

aTao wrote:Going to have to disagree with recurry on the RPi's control abilities here.
Sure, if you bit-bash a GPIO pin then you will suffer from using a non real time OS (although RISC does quite well here, and then there is always your own OS option). But that would be a daft approach. Some GPIO pins on the RPi have hardware PWM capabilities and there is a library to provide fast, reliable PWM on all GPIOs.
So, how fast is the RPi? Using Java on Raspbian with no overclocking I have bit-bashed a GPIO at 3MHz, C++ has got 7MHz. Having taken the PWM timing away from the CPU you then have bags of time and response to control the motors faster than they could respond anyway.

As for payload weight, well that depends on your 'copter.
The points you make don't really disagree with me - they actually support points that I made about performance/speed and weight. You seemed to have missed the points about "latency" and "determinism" though. It's not about how fast you can toggle an I/O or whether you can generate PWM. It's about whether you can guarantee that you'll always be able to respond to events in a deterministic fashion with sufficiently low event->response latency. As I stated the RPI is PLENTY fast enough and has probably 10x the compute power needed but it's I/O's aren't designed for that and standard Linux isn't either. There are versions of Linux that have been optimized for real-time applications that you could use perhaps.

Having built probably 20+ multi-copters personally on as many controller designs as well as having been part of the dev team for the Arducopter I can tell you there is much more to having a multi-copter flying than just speed and compute performance. Just getting something off the ground and hovering in calm air for more than a few secondes is an accomplishment in itself but it's not the same as having a stable, useful platform that can actually maneuver reliably without crashing in reasonable, real-world conditions.

As far as weight, you said the same thing I did which is the multi-copter will need to be large enough to be able to carry the weight of a RPI and alls the other stuff you have to add to it to make it a multi-copter controller.

Hey, one can experiment and try anything one wishes and likely even get an RPI based multi-copter off the ground for a short period of time. You'd definitely have a shot at it if you can find a way to make your control loops absolutely the highest priority task such that they are reliably deterministic and the latency between sensor change event and system response are short enough. I don't know how you do that using Linux without a substantially modified kernel. It might be fun to try if you wish but trying to claim the RPI is well-suited for multi-copter applications just denies the technical facts.

One approach might be to buy one of the Arduino plates and run the control loops on that with the RPI providing the other functions but it's way overly complex and over-kill.

Anyway, if you want to disagree credibly you need to address the determinism and latency issues because it's not an I/O or processor speed issue at all.

Good luck though and post a video when you get it working!

Cheers...

User avatar
aTao
Posts: 1093
Joined: Wed Dec 12, 2012 10:41 am
Location: Howlin Eigg

Re: Raspberry pi quadcopter

Mon May 26, 2014 4:43 pm

[quote="recurry"I don't know how you do that using Linux without a substantially modified kernel.[/quote]

Its called interrupts.

edit:

And lookup tables.
>)))'><'(((<

Return to “Beginners”