Previous Posts
Application Information
http://www.element14.com/community/community/design-challenges/sci-fi-your-pi/blog/2015/04/22/some-information-from-my-application
ChipKit Pi Vs Arduino Pro Mini
http://www.element14.com/community/community/design-challenges/sci-fi-your-pi/blog/2015/05/01/quick-update-on-the-quadcop-and-the-chipkit-pi
Quadcopter Assembled (You call that a Quadcopter?)
http://www.element14.com/community/community/design-challenges/sci-fi-your-pi/blog/2015/05/06/quadcopter-assembled
QuadCop -The Control Switch
http://www.element14.com/community/videos/16202/l/control-switch-explanation
The Control Switch
I've been using the ChipKit Pi and have really enjoyed learning its abilities. I originally thought it was an Arduino clone of some sort, but I realized quickly this is not the case. It does have some Arduino type libraries but it quickly diverges into its own paradigm.
Here is a video to show what I am doing followed by a more in depth explanation below.
In this video:
- Demonstration of the control switch
- QuadCopter Test platform
- How to power Raspberry Pi with a 6.6V battery
- Overall powering of all equipment
- Test flight plan with Raspberry Pi model B+ and Camera
- Rambling!
My original design called for Arduino Pro Minis, however I have decided instead to use the ChipKit Pi to replace the functionality of the minis. One such functionality is called the "Control Switch".
From my application:
"This is a custom configured Arduino Mini that is connected to both the Radio receiver (Rx) and The Rasberry Pie Flight System (RPFS). It is used to generate PWM signals to the flight controller either by reading the RPFS or the Rx depending on if the flight mode is manual or auto. It is responsible for switching signals when it detects mode changes between auto and manual. All PWM input from the Rx and PWM outputs to the flight controller are done with the control switch. Digital output is fed back to the RPFS to indicate the modes read off the Rx. This relieves the RPFs from having to detect pulse widths from the Rx as well have having the Rx connected to two different systems."
So what this entails at a high level is that I can control the QuadCop Manually, and then I can tell it to start flying in automode. This means that my manual control must be overridden. Further, I can take back control at any time. This requires the reading of PWM signals, and the generation of PWM signals. Both of these are done differently on the ChipKit Pi than they are done on the Arduino. However because the Pic32 is so much faster, the Interrupt Service Routines (ISR) are much faster, and have less overhead. This means a smoother signal can be generated when generating multiple signals.
The Control Switch is reading 7 PWM Signals and writing 5 PWM signals to control the QuadCop when in manual flying mode.
There are several pieces of code out there that do the above, but I wanted to write my own from scratch using C. I prefer to understand everything that is going on under the hood with not black box concepts.
When in autoflight mode, the RPFS takes over. The RPFS will be described more later, but at a high level it is reading the GPS, and executing the waypoint macros. It does this by sending a "control byte" to the control switch via I2C. The control switch reads and parses the control byte out and then moves in the desired directions.
There are 8 movements a quadcopter can do:
Forward
Reverse
Left
Right
Climb
Dive
Rotate left
Rotate right
These motions can be represented in 1 byte, each bit representing a direction. Of course we cant request both forwards and backwards motion at the same time and such a condition is checked for validation of the control byte that is received. The RPFS sends a control byte, a register command, and a Control Byte Check (CBC) over the I2C bus. The CBC is simply the remainder when dividing the control byte by 17 (control byte mod 17).
One thing that is missing is speed information. Per my initial design, speed will be ignored and the Quad will move at a constant slow speed. The RPFS has a command available to increase the speed in any direction in the case of a strong wind not allowing the QuadCop to move in a certain direction at the set speed.
The control switch will be powered by the RPFS which is turn controlled by a 5V linear regulator attached to a 6.6V LIFE pack commonly used in Radio Control applications.
Top Comments