Add gyroscopic yaw control to a cheap RC helicopter
This post shows you how to add a gyroscopic controller to a RC helicopter for yaw control. The remote control protocol was reverse engineered and the helicopter electronics replaced by a home-made version.
Not so long ago very cheap RC helicopters began to get quite popular. One prominent example of those is the PicooZ. It comes together with an infrared RC which is also responsible for charging the battery of the helicopter.
The PicooZ is a classical helicopter design with a main rotor for lift and a tail rotor for counteracting the momentum of the main rotor. In other words the tail rotor is responsible for avoiding that the helicopter spins around its yaw axis. And exactly there lies the problem of these cheap RC helicopters: The do spin around anyway.
The reason for this spinning is that they do not have a closed-loop control system. They just power the tail rotor proportional to the main rotors power. The only way for you as a user to avoid spinning is to counteract by steering command. So ok, maybe there is a closed-loop control system. Your eyes are the sensor, your brain is the controller and your finger is the first part of the actuator… phew, quite complicated.
The idea of this post is to replace the electronics of the helicopter with a homemade version. This version will be able to measure the yaw angular velocity by using a piezoelectric gyroscope. The gyroscope signal is fed into an AVR executing a PID controller which controls the tail rotor.
Lets take a look at the home-made helicopter PCB:
On the picture you see hanging on the left the battery. The big black component on the bottom is the IR receiver with two small SMD transistors left to it for controlling the two motors. The central part is the AVR and on the right side is a potentiometer for setting the gyro zero position. As you see, the PCB itself is very simple. Unfortunately I lost the design files of the board during the move to a new PC (does Eagle nowadays still has that “projects” folder as its default file save location? How many times I have forgotten to copy that dir… ). But by using the pin out in source code you should be able to rebuild such a board with no problem. Just remember to use the thinnest possible PCB material for saving weight.
The gyroscope (ENBC-03JA) was mounted on the back of the PCB (I’ve had this one lying around. You’d probably want to use a lighter one):
As modeling the dynamics of the system would be a bit too complicated, I’ve created a little test stand by the use of my desk lamp and some rubber band:
The main rotor is fixed to the desk lamp. The rubber band is fixed to the helicopter and by spinning the band a few turns, a constant torque can be applied to the helicopter. This torque emulates the torque of the running main rotor during flight. This setup allowed me to tune the PID controller until it was stable enough.
After the controller was working, I had to reverse engineer the RC protocol. Therefore I attached the IR receiver to my good old HP1630G logic analyzer and tried to figure out the meaning of the protocol. It took me a while until I found out the checksum function but from there on the rest was relatively easy.
The last thing to do was to combine RC input and PID controller for having a working helicopter. The following video shows you how the helicopter performs. Note how stable the helicopter keeps the yaw angle when it comes near to the camera. At that moment no yaw command came from the RC, thus the angle kept constant.
You find the source code for the ATTINY45 in one of my repositories. Just execute
hg clone https://bitbucket.org/befi/picooz