Archive for the ‘Quadcopter’ Category

IMU potting in gel

Monday, January 4th, 2010

I got quite a few questions on what get I used to encapsulate the IMU. The gel is the Dow Corning Sylgard 527, the consistency of the gel is controlled by the proportion of part A vs. part B. I used 70% part B and 30% part A. After you mix the two parts you need to heat the mix (and the board in it) in order to cure. I put it in an oven at about 70 degC for 2 hours. It will also cure at room temperature but it may take several days.

Quad-rotor demo with CHR-6D IMU and DCM algorithm

Wednesday, December 30th, 2009

After implementing the DCM algorithm on the CHR-6D IMU it was time to flight test it on my quad-copter. I used the same controller I developed last year but instead of using the onboard 5DOF IMU, I connected a serial port to the CHR-6D IMU. The filters and DCM algorithm was executed on the STM32 of the CHR-6D, the direction matrix was sent to the control board through the serial port. Only a few minor modifications were made on the control software to use the angles from the direction matrix, the rest remained the same.

I spent a few hours tuning the PID gains, filter cut-off frequencies and DCM parameters and the results look very promising. Occasionally, small corrections are still needed to keep the quad-rotor in one spot but that was expected. With a GPS and altimeter it should be possible to control the position and altitude fairly accurately.

The main reasons for the improved performance are:

  • Encapsulating the IMU sensors in gel to reduce vibration
  • High speed sampling and extensive filtering of raw sensor data
  • Direction Cosine Matrix using a 6DOF IMU (3 accels and 3 gyros) – although a Kalman filter should also have worked

The ESCs are still controlled using PWM, stability should improve by using a I2C ESCs and a higher update rate (>100Hz). Stability is not as good as in some more high-end setups but I can comfortably fly the quad-rotor outdoors, in fact it is easier than flying a heli. I still need to test the effect of large acceleration on the stabilization e.g. fast ascent, descent or turns (can be easily corrected by calculating and subtracting the centripetal acceleration).

Direction Cosine Matrix implementation for the CHR-6d IMU

Sunday, December 20th, 2009

I recently got the CHR-6d IMU from CH Robotics, I needed a 6DOF (3 gyros and 3 accelerometers) for my quad-rotor. In my last attempt I used a 5DOF IMU and did all processing in the control board. Although I was able to get it to hover fairly well with only minor manual corrections I had two main limitations. Processing power and sensitivity to vibration from the frame. The CHR-6d has a powerful ARM Cortex processor with plenty of processing power available for filtering and additional signal processing. I was able to drastically reduce the effect of vibration by complete potting the IMU in dielectric gel.

The board comes with open source software the implements the digital filters and serial communication. I needed to extend this functionality to calculate the actual Euler angles (or equivalent) that would be used to stabilize the quad-rotor. I have tried a Kalman filter in my last attempt so I wanted to try out something different. I found an excellent paper from William Premerlani that very clearly explains the theory behind the Direction Cosine Matrix. I prototyped the implementation in Matlab and tested it using data from the actual IMU, I also did a few vibration tests by mounting it on my quad-rotor and powering up the motors while holding it fixed on the ground. With the dielectric gel I was able to reduce the effect of vibration to about 1-2 degrees of error when the motors are running at 65% throttle (typical hover is 55%). The ultimate test will of course be a flight test.

The following video is a ground test of the complete setup. The implementation is not yet completed, I have a 3-axis  magnetometer break-out board for the HMC5843 from SparkFun. It will be connected through the I2C bus to the CHR-6d IMU and will be used to correct the drift of the yaw gyro.

You can download the latest version of the DCM implementation and Matlab scripts from the DCM page.

IMU stabilizer design files

Friday, February 20th, 2009

Even though the IMU stabilized quadcopter is not yet complete, there have been enough requests for the source code to justify releasing it as it is. Please let me know if you try it out on your design and especially if you  make any improvements. As soon as the weather improves around here, I am planning to try the stabilizer on my EasyStar. I will likely have more improvements at this time.

Download the source code from here.

First indoor flight

Wednesday, February 4th, 2009

I was at last able to have the first successful indoor flight! Hover seems to be very stable, with only a slight drift. Small corrections are still needed to keep the quad in one spot, however much less input was needed to hover compared to a helicopter (I am flying a TRex 450).

Development took a bit more effort than I originally anticipated, due to the effect of vibration on the accelerometers. Having four (unbalanced) motors does produce quite a bit of vibration. I had to spend some time trying to understand the vibration and its effect on the accels. Given the constrains I have on the Propeller, I opted for a moving average filter on the accelerometer channels and I noticed a big improvement on the IMU response. The vibration would basically make the roll and pitch output of the Kalman filter drift by up to 15 degrees. With the filters I was able to keep any error below 3-4 degrees. Some more tuning on the filter length and Kalman parameters is possible, however I am quite satisfied with the performance of the IMU stabilizer so far. The results can be seen in the video above, during the flight some small corrections were needed but nothing major.

I would not declare victory just yet, there is still some room for improvement and more testing is needed on outdoor flights (for example the effect of centripetal force during a turn). However I am quite satisfied with the performance of the controller, considering that low cost gyros and accelerometers are used.

As soon as the weather improves I will also try it on my EasyStar. I will post the source code and design files on this blog soon, stay tuned!

Update on IMU controller progress

Wednesday, January 7th, 2009

The IMU development is coming along but a number of modifications had to be made to get it to work more reliably:

  • The original design was updating both IMU and PID loops every 20 ms. I found that this was not fast enough to react to the fast attitude changes of the Quad. To achieve a faster update rate I had to re-write the IMU code and Kalman filters from scratch to allow them to run at a 5 ms update rate.
  • The gyro conversion from the raw ADC sample to rad/sec (or deg/sec) was wrong by a factor of two resulting in an error in the short term estimate of the pitch and roll angles (the accels did eventually correct the angle). Fixing the conversion factor considerably improved the the angle response and allowed to tune the Kalman filter to rely on the gyro more than the accels. That results in a much faster IMU response to attitude changes. That can also be seen in the video below. Keep in mind that the artificial horizon is only updated every 100ms through the debug port so there is a noticeable lag in the UI.
  • The PID loops now run at a 10 ms rate, the motor ESCs are updated at the same rate however I am not sure how often the input is actually read by the ESC. In any case an improvement was seen with the faster update rate.
  • Some more progress was also done on the Windows application that is used to record and display data from the IMU controller in real-time. The update rate is a bit slow (100 ms) due to the large number of channels that are transmitted through the debug port.
  • Preliminary flight tests show that a large amount of derivative control is needed in the PID loops to minimize the oscillation. The PID loops were also modified to use the un-biased rates that are calculated by the Kalman filters as the input to the derivative part of the PID loops (rate of change). That allows the loops to quickly react to changes in attitude before the Quad starts oscillating out of control.
  • The GY401 Heli gyro works pretty well, in heading hold mode it keeps the Quad steady in the yaw axis. There is a slow drift but this is expected since there is no sensor to measure the absolute yaw. A magnetic compass could be added in the future for that purpose.

More work is needed on the tuning of the PID loops and Kalman filters and this is the next step. Preliminary tests show that stable flight is possible with the current setup!

Quadcopter assembly completed

Wednesday, January 7th, 2009

The Quadcopter assembly has been finally completed. The design is based on the Kquad design as described in the RCGroups thread. There are many different frame designs mentioned in the thread but I went for Rusty’s Rev 7 fiberglass frame. It is a bit heavier than the other options but it can take a lot of punishment (which will be needed while testing the IMU based controller!). Of course I am not using the controller that most use in the Kquad since the IMU I am developing will do all of the work. Assembly was very easy, wiring was a bit tricky but it worked out great. The video camera, transmitter, OSD and eLogger will be installed after IMU stabilized flight is achieved.

img_1

A number of lessons were learned during assembly and initial flight tests:

  • Motor spacing plays a big role on stability and yaw control. I found that when the spacing was about 800mm (shaft to shaft) the yaw was nearly impossible to control, also the Quad was impossible to control because any slight change in the motor speed will result in a large change in attitude. The solution was to move the motors in as much as possible for a spacing of 460mm. With that spacing the yaw authority was much better, however yaw became more sensitive to motor alignment so it took a few tries to get the yaw to be stable.
  • To my surprise, even at the reduced motor spacing it is nearly impossible to control the quad without active IMU stabilization. Especially when the yaw gyro is in heading-hold mode, the changes in motor speed tend to also affect pitch and roll. This is likely due to slight differences in the motor performance and position. My reflexes are not fast enough to manually compensate in time so I was not able to hover more than a foot from the ground.
  • The tennis balls are too heavy but I will temporary use them until I find something better.
  • Total weight is 1082 grams (38.2 oz) including the tennis balls (200 grams) but not the battery.

img_2

The next step is to work on the controller, tune the PID loops and Kalman filters for IMU stabilized flight. More details in the next post.

Successful bench test

Saturday, December 6th, 2008

After some tweaking with the Kalman filter I was able to get a decent response. I also started working on a Windows application that I will use to display IMU data in real time, dump the recording memory and play back recordings. The Artificial Horizon component from Tom’s web site came in very handy for the Windows application!

As you can see from the video the response if pretty good, some more tuning of the Kalman filter parameters is required. I started working on a Matlab model that will help me test adjustments a bit faster (it is also easier to quantify any improvements).

The Quadcopter parts are on order.

IMU board assembled

Saturday, December 6th, 2008

The boards have been received and ready for testing. The software is also coming together, I was able to find quite a few objects in the Propeller Object Exchange.

The following COGs are used (COG is a the 32-bit processing unit in the Propeller chip, there are a total of eight available)

  • [1 COG] Servo output using the Servo32v3 object.
  • [1 COG[ Servo input using the ServoInput object.
  • [2 COG] Floating point math using the Float32Full object.
  • [2 COG] Logger and high speed UART for real-time debugging. This is only used for testing, if more COGs are needed in the future it can be easily disabled.
  • [1 COG] ADC driver using the MCP3208 object. I had to make quite a few modifications on this one to get it to average samples between IMU updates.
  • [1 COG] The main loop with the IMU code, Kalman filters, PID loops etc. It executes every 20ms. For the Kalman filter I started with an implementation found in the object exchange but I had to make quite a few modifications to speed it up and get it to work using all three accelerometers.

Schematics and layout completed

Friday, December 5th, 2008

The schematics and layout of the boards has been completed. I decided to use ExpressPCB, they provide the schematics and layout software and their mini-board service is fairly cheap. The mini-board service is limited to a fixed size board of 3.8 x 2.5 inches, so I decided to fit both the IMU and OSD boards in the same fab. I decided to have two separate Propeller chips, one for the IMU and the motor/servo control and the other for the artificial horizon and OSD. They are connected using an I2C bus.

The IMU board consists of the following:

  • Controller: Spin Stamp board. This board includes 3.3V regulator, boot EEPROM and the Propeller chip. To avoid using an extra regulator for the ADC, IMU and EEPROM, I had to add one jumper wire to the Spin Stamp in order to get the 3.3V out on pin 24. The regulator is rated at 500mA so it can easily handle the load of the complete board. The servos are powered directly from the 5V input to the board.
  • IMU:The 5 DOF IMU from SparkFun is used, to save some space I was able to fit the ADC right under the IMU. The ADC should also help mechanically support the IMU.
  • ADC: The 12bit MCP3208 from Microchip is used, the ADC has a standard SPI interface.
  • Memory: The 24LC256 32KB EEPROM from Microchip. Not much memory but since it will only be used during development I did not want to compromise the size of the board. It should allow to store data for a few minutes.

The OSD is fairly simple and based on the HC-OSD, Terry was kind enough to also supply the Propeller driver code for the OSD. The OSD will communicate with the IMU using an I2C bus, spare pins are also routed to the connector for future expansion.

The layout is completed. The boards could be made a bit smaller but having a bit more space between components made the layout easier.