Segfault Update 3

In a completely counterintuitive development, I’ve discovered that my project productivity is actually increasing with the progression of the semester. Usually, about now is when the Chaos Generator hidden in the Great Dome is powered on, causing all students to enter a frenzy of final projects, assignments, papers, and exams.

Maybe it just hasn’t hit me yet. But I’ve been working on the control side of things.

Pictured are the ADXL320 2 axis accelerometer and the LPY530AL 2-axis gyro, on cute little carrier boards from Sparkfun Electronics. They are both modern MEMS sensors. I decided to dispense with the period realism because the GG480 gyros are, while shiny, a pain to interface to. These sensors give me a plain analog voltage out.

They are more troublesome, though, because they are both 3.3 volt units. The accelerometer can also operate at 5 volts, but the gyro cannot tolerate higher voltage.

The beginnings of the analog PID controller take shape. I found a cache of LMC6484 quad op-amps at MITERS, and the controller will probably end up featuring them prominently. They are rail-to-rail input and output, and have extremely low current draw.

I’ve become fond of R2RIO type op amps because I always forget that regular ones cannot swing all the way to their power supply voltages. Inevitably I wonder why my circuitry is saturating at less than some maximum value, and it’s a pain and a half to go back and adjust components to compensate. So, with R2RIO op amps, I don’t have to think about those limitations. Not nearly as much, anyway. It’s a convenience that comes with a bit more price, as usual.

For now, I’m running a single sided 5 volt supply for all the analogic. In retrospect (and for future work), I’m going to find a way to make or get a double-sided power supply. Apparently, 7900 series voltage regulators don’t just give you a negative voltage out for a positive one in. Imagine my dismay when I found that out the hard way.

When you have double the voltage difference, you have more noise margin. Ground is real ground. Trying to reference everything to a 2.5 volt virtual ground was a complication that brought many headaches. Many behaviors of op amps that are usually neglected with a double sided supply come into play when the supply is single sided. Things leak where they shouldn’t, and small DC offsets get increasingly magnified.

In order to use the gyro’s 1.23 volt centered output, I had to “level shift” it to agree with the 2.5 volt virtual ground. Luckily, the accelerometer’s zero voltage is already 2.5 volts.

Here’s the part forest progressed far enough for me to extract a primitive P,  I, and D. The two big potentiometers are multiturn types for zeroing the two integrators in the circuit. In the actual controller, they will be precision trimpots.

I don’t yet have a diagram past scribble on a piece of plywood, so no picture to save the 1000-word essay. The construction is similar to just about every other balancing-something controller.

  • The gyro’s output is (after the level shifting) fed through an integrator, which (for input frequencies above the integrator’s RC break frequency) yields a voltage representing a change in the angle, which is then buffered by a voltage follower stage.
  • The accelerometer is severely low-pass filtered with a time constant of about 1 second, then sent through a regular inverting amplifier with a gain of five. This frequency-attenuated output is coupled to the output of the gyro buffer.  The sum of these two (read: whichever one win the two-buffers-connected-to-one-node-tug-of-war) is the tilt angle. The P component can be taken from this output with an adjustable gain block for Kp.
  • D is taken directly from the gyro output.
  • To get I, the tilt angle output is sent through another integrator, and Ki can be tuned by sending this through an adjustable gain stage.

Here’s a video of me waving the board around. Watch the scope trace bob up and down as the angle of the board changes. There’s a bit of nonlinearity near the “zero crossing”, which is actually a 2.5 volt crossing, probably because of buffers fighting eachother and capacitors needing time to drain. This is only tracing the angle output, not any of the control components after gains.

So where to from here? I intend to rebuild this whole deal in a more organized fashion, and using a split supply to avoid having to include the 2.5 volt notground. The LMC6484s can operate up to +/- 15 volts, which I might use as a “global logic” and controller gate drive supply, down-regulating only when needed (e.g. for the gyro).

Right now, the circuit is full of hacks. I want to make it more “textbook” – that is, following prescribed methods that are known to work and using “blocks”, such as buffering all the outputs, using voltage adder arrangements instead of just tying nodes together, etc. This will obviously result in a higher part count, but what it will give me is the chance to isolate problems and make debugging easier, since my EE-fu isn’t as strong. I know you can make a whole PID loop with one op amp. While amusing, I’ll leave it for later.

Where else can I go? Oh, yeah, mechanical work. Something that I like to think I’m good at.

The recurring theme in Segfault updates is the wheel picture. Well, here’s one of the same wheels again, except in more pieces.

Like most pneumatic scooter wheels, they come apart into two halves, one of which is an integral timing pulley. the issue with the pulley is that it’s wide enough to cause difficulty with mounting the wheels to a live axle (instead of riding on bearings), but also not large enough in diameter to just fit over the motor’s faceplate.

Lame, so it has to come off.

Well that’s an operation I can actually handle. I snipped the pulley section off such that it can still be reused something if you want to really badly.

Next, I took the original non-pulley-endowed half of the wheel and cleaned up the bore to accept a shoulder on a hub (yet to be developed). The original bore is tapered in areas that don’t seat the bearings, which is inconvenient.

I opened the bore up to 1.375″, a nice normal inch measurement.

Repeat once. Here are two cleaned wheels ready for mounting. I’m using a nut and bolt to hold them together, but the motor hub will have threaded holes.

Alright, so I’m still deficient on the vehicle design itself. In order to pull myself out of the project doldrum that was the first two months of class, I began wrapping up the 3d models by designing the user interface.

Sure, I could have made do with just the stick, but that’s no fun. The T-shaped handlebars will be made from spare 80/20 and some aluminum tubing. A dashboard box sits in the top center, and will feature the Degree-o-meter.

Oh, but just a degree-o-meter is boring. I also have a nifty  battery meter from 4QD, a renowned manufacturer of electric vehicle paraphenalia from across the creek. Luckily, it’s rated for 36 volts, and I intend to run a 36 volt electrical system.

You can’t have a dial and blinkenlichten without knobs. So, in what has to be the biggest potential for a prank on me ever, I’ll have the controller gains tunable from onstage. P, I, and D will be adjustable. So if you’re a total jackass, you can fuck around with the gains while I’m not watching.

Yeah. Anyway. The K knob is there for a “master gain” control, kind of like a volume knob. If I find that I got too happy with the individual gains, I can attenuate or amplify everthing slightly. It’s not an extra degree of freedom. It just turns the transfer function into something resembling K*(P + I + D).

I also might want to add more knobs for things like changing the zero angle in case the final vehicle isn’t completely balanced.  And a… uhhh, power switch or somethhing. However, drilling extra holes isn’t exactly difficult.

As usual, the whole thing is made from T-nutted, waterjet-cut aluminum plates.

The intensity is increasing. When all the remaining materials and parts arrive, I’ll find a day in which I’ll knock the whole thing out on an abrasive waterjet.