Avionics and Homemade RC Electronics

NightOwl Gyros | Drag Rudders | Servo Driver | HK 2.1 | Draganfly FETs

Many of these projects include a PIC 12C508 as the brains. The source code for each project is included, and the pinouts for the PIC are listed in the comments in the source code for each project.  See my PIC development page for links to the necessary PIC compiler and PIC programmer software packages, both of which are is free. All you will need to buy is an inexpensive PIC programmer interface which connects to a serial port on your computer, and of course the PIC, wiring, resistors, and capacitors that make up each project.

NightOwl - Stabilizing 3-Axis Gyros

NightOwl versions 4 and 5 each have a 3-axis rate gyro stabilizer.  There are four control surfaces on each NightOwl.  Two horizontal surfaces move together and control pitch.  Two vertical surfaces move together and control yaw.  All four surfaces together and control roll.   The gyro stabilizers installed to versions 4 and 5 of the NightOwl are made from disassembled HK 401B rate gyros.  These photos shows the gyro and mixer setup for NightOwl version 4.

Three HK 401B gyros were taken apart, removed from their original boxes, and hot-melt glued together into a smaller package with each gyro rotated to the correct angle for its sensing axis.  Gyro #1 senses roll, gyro #2 senses pitch, and gyro #3 senses yaw.  The outputs of each gyro is routed to mixers.  The first mixer is used for the horizontal control surfaces, for roll and pitch. The second mixer is used for the vertical control surfaces, for roll and yaw. 

Rx aileron output --> roll gyro --> roll stabilized PWM
Rx elevator output --> pitch gyro --> pitch stabilized PWM
Rx rudder output --> yaw gyro --> yaw stabilized PWM

roll stabilized PWM + pitch stablized PWM --> mixer #1 --> left horizontal surface + right horizontal surface
roll stabilized PWM + yaw stabilized PWM --> mixer #2 --> top vertical surface + bottom vertical surface

NightOwl version 5 was actually the first NightOwl to receive stabilization with gyros.  Because of the inherent slight variability of the timing circuits in all gyros, the use of three HK 401 gyros meant that the input to the mixers would slowly walk apart from each other, as each gyro's timer was not EXACTLY the same as the other gyros.  The timing oscillator output on one gyro was connected to the other two gyros, and their timing oscillators were disconnected and overridden. This kept all three gyros on the exact same timing, and allowed the output of the gyros to be connected into two standard commercial mixers, which are the yellow objects in the photo.

NightOwl version 4 received special home-made mixers were made from PICS with custom code that ignored the inherent timing problems that occur with separate timing circuits in independent gyros.  This required that one mixing input come from a gyro set to high-speed digital output at 3 ms frame rate, and one mixing input come from a gyro set to normal speed output at 20 ms frame rate.  The 20 ms frame rate was the master for input, and was also used for the output frame rate. The PIC source code for the timing independent mixers is here. 

Both versions worked great; these separate setups were done to test if both methods would work.

A final, smaller version of stability was completed on both NightOwl #4 and #5 via the use a 3-axis gyro stabilized receiver from Hobby King.  The outputs of the receiver, already having gone through the receiver's internal gyro on each axis, are fed into the same commercial mixers originally used for NightOwl #5.  Because all three internal gyros are already on the same timing circuit, no additional modifications are needed.
This reduced the components from (receiver + 3 gyros + 2 mixers + special wiring : on the right in photo #2) to (receiver + 2 mixers + less wiring : on the left in photo #2).  If you want to build a similar aircraft with three control surfaces (two elevons and a single rudder), as NightOwl's #1 through #3 were configured, you could even eliminate the 2 mixers, as the 3-axis stabilized receiver has the built-in ability to control elevon aircraft.

PIC 12C508 Drag Rudder Controller

The PIC reads the rudder PWM output from the receiver, and extracts out the left and right commands to send to the separate servos on each wing tip.  1 - 1.5 ms = left rudder, 1.5 - 2 ms = right rudder.  Since the left drag rudder only needs to move for left rudder command, and vice versa for the right rudder command, the PIC code translates all of this to individual commands for each servo.  The PIC source code for the drag rudder controller is here. 

1.0 to 1.5 ms --> left yaw command from receiver
    2.0 to 1.5 ms from Rx  = no left command               --> PWM output = 1 ms to left drag rudder servo
    1.5 ms from Rx            = no left command               --> PWM output = 1 ms to left drag rudder servo
    1.5 to 1.0 ms from Rx  = increasing left command    --> PWM output = 1 ms - 2 ms to left drag rudder servo
    1.0 ms from Rx            = full left command               --> PWM output = 2 ms to left drag rudder servo

1.5 to 2.0 ms --> right yaw command from receiver
    1.0 to 1.5 ms from Rx  = no right command              --> PWM output = 1 ms to right drag rudder servo
    1.5 ms from Rx            = no right command              --> PWM output = 1 ms to right drag rudder servo
    1.5 to 2.0 ms from Rx  = increasing right command   --> PWM output = 1 ms - 2 ms to right drag rudder servo
    2.0 ms from Rx            = full right command              --> PWM output = 2 ms to right drag rudder servo

PIC 12C508 Servo PWM Driver

The PIC reads three momentary pushbuttons as inputs, and drives three outputs:  a PWM for the servo, and two LEDS for status. The PIC starts at 1.50 ms output, and has 100 positions available for output from 1.0 ms to 2.0 ms.   One pushbutton increases the output by .01 ms, and one pushbutton decreases the output by .01 ms, with safety bounds at 1.0 ms and 2.0 ms to avoid overdriving the servo connected to the PWM output.  The third pushbutton puts the PIC into status display, with one LED showing the current PWM  / 10, and the second LED showing the single digit remainder, starting at 1.00 ms.   The PIC source code for the servo driver is here.

Example of status display:
At 1.01 ms, push the status button and the LEDs will flash : #1 for 0 flashes, #2 for 1 flash.
At 1.59 ms, push the status button and the LEDs will flash : #1 for 5 flashes, #2 for 9 flashes. 
At 2.00 ms, push the status button and the LEDs will flash : #1 for 10 flashes, #2 for 0 flashes.

HK Multi-Copter 2.1 Flight Controller

The HK 2.1 rate gyro board was one of the first purpose-built boards designed for multicopters. Before these simple rate boards, multicopters were stabilized by independent rate gyros set up on separate axis and controlling separate ESC or servos, directly or via mixers. These boards have since been made obsolete by the newer HK KK 2.0 and later flight controllers, but they still work fine for other uses.  OpenAero software 1.14.1 is available to install to these boards, and this software allows them to act as 3 axis rate gyro stabilizers.  The source code is available here.

If you wish to modify this base software, you will need AVR Studio 4 or later (version 4.19 works well), available here.  You will also need WinAVR, available here.  Finally, you will need to modify a couple settings in AVR Studio to point to the correct locations for the toolchain and compiler.  Instructions for those settings are available here I have also posted all of these setup instructions to RC Groups.

One modification I made to the stock OpenAero firmware was to increase the required timeout period before entering programming mode via the optional LCD.  This default period was about 2 seconds, which would enable the programming option.  During acrobatics, it is possible to command the correct combination of stick inputs to get into this mode, which disables outputs.  I discovered this accidentally while flying an acrobatic plane through a series of snaps.  I just happened to hit the correct stick combination and held it for more than 2 seconds.  Once the controller had entered programming mode (unknown to me), the plane kept the same control outputs and snapped up, over, and down, right into the ground.  I increased the timeout to 20 seconds so this would never happen again. The source software can also be compiled for various wing types: normal, flying wing, and flaperons.  I have a flying wing version with the programmable period bumped to 20 seconds in one of my flying wings for stability.  Take a look at the source code and experiment with possibilities; many other modifications can be done.


Draganfly FET Interface PIC

The original Draganfly quadcopter and its control board has been around for 20+ years. It uses three rate gyros, a custom circuit board with a PIC running custom code, and four FETS to drive four brushed motors.  It was expensive, but it was all that was available to fly commercially for a long time.  You can get orders of magnitude more performance now out of inexpensive brushless motors, BESCs, and off the shelf flight controllers, but it is still fun to play with these older electronics. 

Experimenting with this hardware, I traced the wiring on the board and O-scoped the inputs to the FET gates to see the range of signals they receive.  The PPM pulses going to the FETs last from 0 ms to 5.8 ms.  It was a simple matter to solder onto that connection, and use a PIC to scale the 0.0 ms - 5.8 ms pulse to a standard 1 ms - 2 ms PWM pulse that is used to control servos and ESCs.  I built four of these converters and tested them to drive four servos from the Draganfly board.

The PIC source code for the Draganfly FET to PWM converter is here.

I then used the Draganfly board and the converters to drive brushless ESCs and motors on a home-made quadcopter of similar size to the Draganfly.  This worked fine electronically, but the gains were vastly different between the original brushed Draganfly setup and the brushless setup of the new quadcopter.  A modification to the code in the PIC converters would allow variable gains (scaling of 0.0 ms - 5.8 ms --> 1 ms - 2 ms) via a separate PWM input, but I have not gone back to make that addition to the code yet.  It is still something to be done when I have the time.  The original Draganfly board and converter board with four PICS, mounted to a simple frame, is shown the first photo. The original Draganfly frame with its brushed motors, and the new brushless motor frame with the adapted electronics is shown in the second photo.