Segfault Update 4: Fancy Ass-Inclinometer Lives

As promised, I went back to revise the sensor logic for Segfault. I am proud to annouce that I now have a stupidly overcomplicated inclinometer.

WOOOHOOO I AM SO SWITCHING MAJORS TO COURSE 6

Just kidding.

The first order of business in the new construction is creating negative 5 volts. As I mentioned before, having balanced power supply rails is tantamount to approaching more theoretical performance from op-amps.And when you’re used to crashing through EE projects like very small silicon-based china shops, textbook debugging is invaluable.

So here’s the negative-5-voltificalator.

It’s a 555-based switched-capacitor dealie found all over the blagotubes in myriad configurations. I ran the 555 at 30kHz. Maybe it should be faster, maybe not – I didn’t run any numbers, like a bad engineer. The converter takes +12 volts and yields -11 volts or so. Both are regulated using the appropriate 5 volt regulators to yield stable, double-sided rails.

Who knew it was such a pain in the ass to get a negative voltage? Why can’t I just plug it in backwards?!

So much smaller. My goal with this board was to put everything pertaining to sensor signal processing on it so I can make a simple robot-on-a-stick to test the concept. It took a while to cram the componenets that tightly. The circuit up to this point produces a voltage out that corresponds to tilt angle.

No, I didn’t calculate how many volts per radian. Bear with me as I machine-gun into the darkness with exploding electrolytic capacitors.

The hardware configuration of the sensors means that I’d actually have to run the breadboard edgewise on a robot (sensors at the bottom, edges facing front and rear). Segfault itself will have the sensors mounted more appropriately.

Hey, let’s take a look at the outpuHOLY SHIT WHAT IS THAT I DONT EVEN

Well, that’s certainly disappointing. It looks like at least some part of the -5voltificator’s 30,000hz switching frequency is making it through to the output. Strange, because it doesn’t happen anywhere else. What the heck is this? Shoot-through? That’s 3 volts plateau-to-abyss!

Piling bypass caps by the gross onto the circuit didn’t help one bit, so I tried pumping up the volume on the switching converter…

…to around 220kHz. I figure I could knock it out of the range of the op-amp’s break frequency. But no, the LMC6484 is unity gain up to 1.5Mhz.

What did the ripple look like now? Maybe I knocked it instead out of the range of whatever is resonating.

Uhh, no. In fact, I think it got closer to resonating, because the wave is now significantly more sine-like. The ripple has been reduced to around 1 volt p/p.

That’s still pretty intense, though. This can probably be lowpass filtered out without affecting the circuit operation because it occurs at hundreds of kHz, and I will hopefully not be moving fast enough to warrant conveying angle information that fast. Since the motor driver PWM frequency will probably be around 20kHz, this ripple might not even matter because the motor drivers will “sample” much slower. I use “sample” loosely here, as techically a PWM comparator would be running all the time.

Oh well. I’ll just crank the horizontal sweep way up to 1ms and pretend it isn’t there. Here’s a video demonstrating quite a few improvements over the last sensor rig:

  • No nonlinearity or weirdness around the zero crossing! Probably because zero is zero, and I properly buffered the sensor outputs.
  • Symmetrical about zero!
  • No drift! If the gyro integrator is too far off base, the DC offset of the signal increases slightly and that’s it. Same for the accelerometer. The last version would slowly drift – not significantly, ultimately settling at a small DC value, but still visibly drift.
  • Real zeroing, not “leak rate control”. The accelerometer zeroing potentiometer will be available on the user panel to adjust the rest angle. The gyro zero will be glued shut in the position of least drift. I already mined every 10-turn miniature precision pot at MITERS for this.

It’s almost time to put together the bot-on-a-stick. Since this is comparatively easy, mechanical work on the Segfault chassis is continuing. In Course 2 news,

Shazam.

After round 1 of Segfault JetMachining™, the baseplate and some minor frame structral components are done. The parts on the left are spacers for the motor mounts, and the little things on the right are vertical standoffs for the eventual upper deck, for which aluminum plate has yet to arrive.

Yes, I did cut that whole piece out from a single large sheet of aluminum.

Something is just not right when your scrap weighs more than the part. I’m sorry, Kaiser and Alcoa. I bet you’re mad at me for wasting good metal like that.

Actually, who the hell am I kidding – you probably want me to keep making large, flat unibodies so I’ll buy more aluminum.

The bigger squares will be reused for little widgets.

Hey, it’s the upper control box! This is looking pretty crazy. After a few knocks with a belt sander, the tabs and slots just sort of fell into eachother.

They will be assembled by t-nutting, but this is the sort of thing I could seam weld and get great results from.

Check THIS out! The 7-LED battery bar graph slides into its final mounting location. There are two red LEDs, a yellow, and three greens. LED bar graphs on anything just makes it look epic.

The midpoint shown here is about 34 volts or so. All the LEDs are lit at 40 volts, and all go out at about 27. Since the Koooooooolmorgen motors are actually rated for 33 volts, the midpoint is an excellent “time-to-go-find-a-charger” reference.

The chase is on. The most difficult part of the project as I envisioned it, the analog inclinometer, has been conquered. More aluminum is on the way, and the end of the semester draws close.

Bot the fuck on.

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.