Older blog entries for hudson (starting at number 8)

Another day lost to a dead glow plug ignitor... I met Mike Pearson to fly his Eco 8 electric and my 10cc prototype, but was unable to get the large prototype engine started. I believe the problem is that my glow plug driver needed to be charged.

So, in a fit of frustration I build a new field box that incorporates a "Power Panel" with step down circuitry to drive the glowplug from my 20 AH gel cell. It required a new case to fit properly, but on the plus side the fuel bottle is now stored upright and the transmitter is better protected.

I also tried to characterize the errors in the accelerometer sampling code. There is a plot of data readings for ten minutes of the IMU (image) on a stationary workbench.

I'm working this evening on tuning the PID loop with a static leveling test. It is no where near as difficult as the actual helicopter stabilization system, but a good workout for the IMU boards, the servo controlls, the accelerometer sampling and PID tuning.

So I built a small "level bot"(click for an image) that has one servo to control its roll axis. Based on the accelerometer readings fed into the PID code, the servo rotates to adjust the angle of the board. The HS-81 micro-servo has an allen wrench for the lever-arm since the servo arm barely reaches to ground...

You can see a textual graph of the leveling action in my post to the autopilot-devel mailing list.

15 Jan 2002 (updated 17 Jan 2002 at 03:41 UTC) »

Last night's all night hacking session has produced an iMac styled case for the autopilot. I also installed magnets in the fan disc for the N1 engine tach. The Hal effect sensor does not seem sensitive enough. I might have to purchase different ones. More details are in my post to the mailing list.

I also made Release 2.0 available over the weekend. This release is named "fly-by-wire" and is the first to support the Mega163 on the custom PCB. It has support for the servo outputs, sampling the gyros and accelerometer data as well as reading commands from the serial port.

My goal for the next release is to have the engine tach functioning and the PID loop governing the engine speed. I don't know much about control loop tuning, but I'll figure it out as I go...

I made good progress today on the realtime board. First, the good news:

  • Crystal clock problems have been resolved.

    Rather than frying another chip with uisp, I tried PonyProg2000. It's an IDE style programmer for just about every serial chip on the market and has GPLed some versions of the code. The latest is a binary-only release for Linux that includes suppot for the Mega163. Download it from:


    Based on John Cunningham's suggestion, I set the CLKSEL fuse bits to 1011 and the little board is now screaming along at 4.0 Mhz or so. The toasted chip is still in paperweight mode. I haven't tried resurrecting it yet.

  • Servo output works and is jitter free.

    Nothing really had to change. The 163 does have a direction control for Port C, while the 103 does not. Simple code change to set DDRC for output. I've tested it with the Futaba S3001 and HiTec HS-81 servos from our two prototype aircraft.

  • Accelerometer sampling looks good and fairly smooth.

    The faster clock rate helps give us a bit more precision. I've added a very simple weighted average to the sampling. The response is fairly good.

The Bad news:

  • Analog voltage sampling is still hosed.

    No matter what I try I can not get the internal voltage reference to come online. The bandgap is enabled (BODEN) and I can sample it and confirm that it is at 1.22 volts. But the reference voltage will not change from AVcc = 5.0V. Any ideas? You can see the ADC code here:


  • The board is UGLY.

    All those jumpers and cut traces offend me. Rev 1.0 is a mess and needs to be cleaned up. The boards are available if anyone wants one. Just add parts.

  • Murata gyros will mess it all up.

    I'll have to redesign the board, but that is life.

11 Jan 2002 (updated 11 Jan 2002 at 15:45 UTC) »

I'm still trying to get the AVR Mega163's onboard ADC to sample data from the onboard gyros but have no luck.

The source code worked on the At Mega103 STK200 development board, but the interrupts never get triggered on the Mega163 on our custom board. I've confirmed that there is voltage at AVcc and the input voltages are there.

On a related question, if I want to use the internal 2.56V voltage reference what is the correct wiring for the "bypass capacitor on Aref"? I can't find anything in the data sheet that specifies the capacitor size or wiring.

My post to the mailing list summed up the status with these points:

The good news:

  • We have the UART and RS-232 problem fixed, although with an enormous mess of jumpers.

  • The accelerometer sampling is working great with the one ADXL202-EB that is installed. It is backwards from the design, but working.

  • The ISP (In system programmer) is functioning well.

  • The power and programming LEDs work.

The bad news:

  • One Mega163 is hosed. I tried configuring it to use the external crystal and is toasted. I haven't figured out how to fix it, nor have I been able to find a reference for setting the fuse bits.

  • We're using the internal 1.0 Mhz clock sped up to 2.0 Mhz now. It is very unstable with temperature and sometimes causes UART timing errors. As well as accelerometer sampling problems...

  • The ADC is not working. If I select the internal voltage reference the ADC never generates an interrupt. If I use Aref then I get interrupts and samples are made. When the spec sheet says "connect a bypass capacitor to Aref" to use the internal reference, what does that mean?

The code checked in to onboard/avr will built a program named sample that reads the one accelerometer and attempts to read all eight analog ports. It prints the ten data values and the current time to the serial port at 19.2 kbaud.

While discussing our IMU board with Bram Stolk on comp.robotics.misc, he pointed out that there are cheap Gyration GyroPoint desk mice available on eBay.

These each contain one Murata ENC05-EA and one Murata ENC05-EB ceramic solid state gyros. Rather than spending $59 per MG100 dual axis gyro, we can buy these for $6 per mouse.

I'll have to redesign the IMU board to deal with these, but that is part of the development process. Rev 1.1 will fix the MAX231 pinouts and maybe switch to these other gyro units.

phooky: To get ExpressPCB running under Wine, I first installed it on an actual Windows boxen at work, then transfered the DLL's that it used (determined by backchaining) until it ran.

Unfortunately the installer won't run, nor will it work without a significant portion of the Windows runtime environment. And, as I mentioned earlier, it fails to correctly render the trace widths. There is also some garbage in some of the widgets, too.

I'm running the stock RedHat wine-20010822-1 rpm. I did try with the latest from WineHQ's CVS tree, but it crashed randomly.

The parts arrived from DigiKey this afternoon and I've spent much of the evening soldering things together.

The good news is that the Atmel AVR Mega163 works on the first try. The bad news is that I screwed up the MAX231 pinouts and the RS-232 line driver is hosed.

Images of the boards:

The Rev 1.1 board will correct this, as well as many other little problems:.

Size issues:
- Thinner headers.  These require grinding to fit
- Larger holes for accelerometer.
- Spacing between AVR and MAX231 is tight if socket is used
for MAX231.
- Spacing with DB9F is very tight.  Requires grinding the DB9F.
- Very small clearances between some of the traces and
through holes.
  These should be larger to make room for sloppy soldering.
- Thinner (0.25) traces are ok for digital lines.  0.30 is
just huge.
- "Cut throughs" between pins only on top-side.  None on
solder side.
- Reduce the number of "expansion holes" and spread out the

Style: - Bi-color LED for power / programming - Status LED for accelerometer/gyros - Opto-isolate digital inputs - Voltage regulator - Remove jumper for Pitch/Roll accelerometer - Make two-axis version usable with one gyro + one accelerometer - Expose all extra lines from gyros and accelerometers - Solder points for IO lines. - Voltage regulator - Divide-by-n chips for tachs - Label servo connectors

Oops: - MAX231 pinout is totally hosed. - Z / Roll accelerometer pins are backwards and must to be used for Pitch/Roll instead. No room for safety pilot PAL that way. - Va, Vr and Vcc links are difficult to reach (but should go away) - If Pitch/Roll accelerometer is used as designed it blocks the voltage regulator spot.

Maybe: - Explore MSP1005-ND from MSI (three axis accelerometer) - Explore Tokin/Murata ceramic gyros - Use two-uart AVR and connect GPS to IMU - Screw-down wire headers for analog/digital inputs

The realtime boards just arrived from ExpressPCB. It's a neat service -- I used their software (under Wine) to design the microcontroller board, sent it to them via their website and three days later had very professionally made circuit boards ready to solder.

When fully populated, the PCB will have:

  • Two MG100 dual axis rate gyros
  • Two ADXL202 dual axis accelerometers
  • Four analog inputs
  • Two pulse counting digital inputs
  • Five digital inputs
  • Eight servo outputs
  • Five servo inputs
  • RS232

The software still needs work. I hope to have the rate integration code working so that the IMU can be used as an AHRS (Attitude / Heading reference system) within a month. That can feed into an artifical horizon for the ground station as well as drive the PID loops to keep the helicopter under control.

Share this page