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.

Übercløcker RЭmiχ RЭvived, and SEGFAULT Update 2

In the last Überclocker-related post, I said

this conversion ought to go quickly since I’ve already drilled the new mounting holes to accommodate them.

By this I meant ”

this conversion ought to go quickly since I’ve already drilled the new mounting holes but am swamped with classes, other duties, and a lack of motivation to do anything robot-related so Überclocker has been sitting on a table at MITERS taking up work space for two months

But that’s over now. I charged the Mental Capacitor of Project Motivating (+1) enough to go take apart the drivetrain to stuff the DeWalt motors in. The whole operation actually took about 30 minutes total, by the way, it’s just that the time constant of the MCPM is a semester or so.

Here’s a picture of the robot.

I excavated the carcass of Test Bot SP1 to use as a chew toy for testing ‘clocker. There’s no test video, unfortunately.

I can’t exactly describe the new drivetrain as “Fast”. In fact, I think the HTI motors resulted in an overall higher speed, but not by much. Calculations put the anticipated top speed around 8 to 9 miles per hour. The bot isn’t slow by any means, but it was almost too controllable. I like a bit of unpredictability in robot handling.

For future events, I might consider recutting the intermediate drive gears to act as a speed increaser. 8MPH is nice for small arenas and stages like Dragon*Con, but in a larger arena it is a handicap.

Here’s an overall picture of the robot internals, now featuring DeWalt drill motors mated to undoubtedly overdriven Harbor Freight drill gearbox parts.

Segfault

Alright, so I’m pretty damn sure the project is moving forward now, considering I just dropped big Benjamins on aluminum plates. The project has actually been limbo for a while because I’ve been slammed with everything else that does not pertain to building. As the assignments-and-papers season winds down and OH-GOD-EXAMS-AND-FINAL-PROJECTS season begins, there’s an occasional moment where I can… you know, do other stuff.

I’m also in luck because I have no classes this term which have final exams.

In the last SEGFAULT episode, we left off with a picture of two wheels.

Like before, not exciting at all. Through some more excavation of the archaeological site that is MITERS, I sequestered these 180 watt DC scooter motors, which seemed to have been paired with the wheels at one point in time. They have matching pulley pitches.

The pulleys gave a speed reduction of roughly 6 to 1. Through some crafty mathematics, I backsolved the specs of the motors so I can actually play some numbers games.

The manufacturer, Unite Motor, was kind enough to give some measurements of torque and current for these motors. Real measured numbers are better than theoretical ones, and leaps better than bullshit such as “TURNS” and “WINDS”.  The rated torque (Tr) and rated current (Ir) were 0.7 N-m and 10.6 A, respectively.

This was nice because if you have torque and amps, you can immediately get a critical constant of the DC motor, the torque constant (Kt). The Kt of this motor , Tr/Ir,  is 0.66 Nm / A.

This alone doesn’t tell me much, because I don’t know what the maximum torque of the motor is if I don’t know how many amps it can ultimately pull if stalled. This is not provided by Unite Motor, shame on them.

But fortunately, they also gave a rated speed specification, which occurs (I hope to Robot Jesus on a stick, anyway) at the same point they rated Tr and Ir. This rotational velocity ω at the rated input voltage Vin of 24 volts is 2,600 RPM, or 272.3 radians (rad) per second.

In an ideal motor, power in equals power out. Power is torque (T) * speed(ω) AND also volts (V)* amps(I). Therefore, the crafty relation T/I = ω/V occurs.

Hey, this is convenient, because what it’s saying is that in SI units, torque per amp IS speed per volt. The motor back-EMF constant, Kv, is equal to Kt. So this motor as an ideal model gets 0.66V / rad / s. This is to say that if you turned the motor at 1 radian per second, it would generate 0.66 volts for you. Conversely, running the motor at 0.66 volts will make it turn 1 radian per second. Kv = Kt only works in metricland, by the way.

But real motors aren’t ideal transducers. They have resistance in the windings that turns input power into heat. A real motor can be modeled as a resistor in series with the ideal motor. The resistor drops some voltage across it while the motor is under load, so the ideal motor sees some value below your input voltage.

Luckily, I know that the motor is rated for 24 volts Vin while turning 2,600 RPM or 272.3 rad/s and having a BEMF contstant of 0.66 V/rad/s. This means the voltage the motor is generating by virtue of turning, Vbemf = 272.3 rad/s * 0.66 V/rad/s = 17.97v.

Even better is that this is known to happen while Ir amps are flowing through the windings.  When you have the differential voltage across a resistance and the current flowing through it, you know the resistance R through Ohm’s Law.

So the motor resistance Rm is simple (Vin – Vbemf) / Ir = 0.56Ω.

Now the stall characteristics of the motor can be calculated. When the motor is stalled balls to the wall, Vbemf = 0 because there is no rotation. Rm dissipates all the power you put into the motor, and the only current flowing is therefore Istall.  Through Istall = Vin/Rm I know that the motor will pull a maximum of 42 amps. Then smoke. At 42 amps, the motor can make about 2.75 N-m of torque.

The no-load speed of the motor ideally occurs when the input current approaches 0. In practice this never happens because of Rm, but the NL speed is something that has to be measured. I can only conjecture on how fast the motor will turn with no load by ωnl = Vin * Kv, and assume the motor current to be something small. This usually gets you within 10% or something. The guessed no load speed of these motors is around 345 rad/s, or about 3300 RPM.

Okay, enough DC motor theory.  So now I wanted to find out what the limit is in terms of speed and tilt angle if I used these motors and their matching wheels.

Here’s a (really, really) rough model of me on a balancing vehicle. Segway-type vehicles are a variant of the inverted pendulum, a classical problem in control theory and physics. The actual equations of motion for such a system are a bit convoluted, though rest assured I have been forced at chalkpoint to derive them step by step.

I just want a ballpark number for how fast I can go, so I can gauge the type of helmet I need to prevent too much brain splatter when I fall over. This can be easily approximated in the above system, where you have a point mass approximation of me, tilted out in front of the vehicle by an angle Φ, and away from the center of rotation by a distance d. d is the distance that my center of mass is above the vehicle platform. In a typical human, the CoM / CoG occurs a bit above the hips. I assumed this was 1 meter for sake of argument, since I’m not that tall and this is not very scientific. The vehicle itself is assumed to have no mass yet. This is a very bad thing to assume, and strictly limits this to guessing “steady state” characteristics – i.e. no acceleration of any kind is allowed.

In classic 8.01 fashion, the goal is to keep me-in-a-black-hole from acclerating. That means all forces and torques have to be balanced.

Φ is referenced from the vertical, so the Condensed Matter Charles Equivalent Force Diagram™ is thus. N is provided by the ground – we are assuming I’m on solid ground here, not flying, so the vehicle doesn’t have to generate lift. This may also be bad assumption.

That leaves just F and mg sin Φ to fight it out.  The latter is provided by me existing and also tilting the vehicle forward or backwards. F comes from the torque of the motor and the radius of the wheels: F = T/r. Therefore, mg sin Φ = T/r.

The uber-ballparked approximate steady state model of the vehicle is then given by Φ = arcsin ( T / mgr ). If I have a torque figure, I can estimate the maximum angle of tilt that the motors can sustain while moving at constant velocity. That means if I run over a pebble, it’s all over.

To avoid this scenario, I want to size T to be under half the stall torque of the motors. The reason is that Tω = VI maxes out at one half of any of the input variables. This is the point which the motors make maximum power. If I’m crusing at maximum power, there is no recovery if the unstable system deviates further from the vertical because the motors can’t exert any more torque without slowing down. Which of course will only make the situation worse.

I decided that 33% peak torque was the “safe point”. This gives me some leeway such that the motors can exert a momentary, more powerful shove to counteract my attempts at crossing the critical Φ. The real Segway does something like this – if you try to go too fast, it will start tilting back to save your ass (/face).

33% of stall torque for my two motors driving a 6:1 reduction  on 4″ radius ( 0.1m) wheels is  (2 * 2.75 N-m * 0.33 * 6) = 10.89 N-m. So that gives Φ = arcsin ( T / mgr ) of 9.6 degrees or so.

Decently smooth. 10 degrees is pretty steep for a lean angle during travel, but I was concerned with the peak torque (/force) limiting how quickly the platform could react to a sudden input like me jumping on it. If this is limited, then the whole vehicle will feel sloshy and risk not being able to recover from a sudden disturbance, like hitting a small child.

Okay, so I’m not designing to target small children (honestly!), but things like bumps in the ground, terrain changes, sidewalk seams, door and hallway thresholds, etc. all represent sources of external disturbances.

Having these numbers, I put the motors into the parts bin (i.e. LOLrioKart) and began working on vehicle design.

This is a kewl motor.

I wasn’t able to design for too long before another intrepid MITERer mentioned that he crufted some motors out of a lab cleanup.

The deal with lab cleaups here is that the proper response as an engineering student is, as soon as you receive an email containing the words “LAB CLEANUP” or similar, drop everything you are doing and immediately report to the scene to claim cool stuff. Sadly, I don’t make it to many of them, but a surprising majority of cool Reuse stuff goes to MITERS because there are so many of us that at least one person is on guard.

These are Kollmorgen Servodisc motors, renowned in the industry for being flat and pancakey…as well as being extremely power-dense. They are coreless motors. That means there is no big iron thing in the rotor to accelerate, and such motors can reach extremely high angular accelerations. That means they respond to commands fast.

Fast is good. Also, Kollmorgen, being a legit motor manufacturer for legit industries, completely chracterized their motors in the datasheet. Even handily providing me with armature inertia if I care to include that in the system dynamics (hint: No.)

These type U9D-E motors are attached to 10:1 precision spur gearboxen. Convenience in motor form – so I borrowed them on good faith that they won’t be baked or damaged. I sincerely hope this will remain true, because I sure as hell can’t possibly afford these motors in real life.

Running the numbers, I got that the vehicle could achieve almost 30 degrees of forward tilt. This just shot the error margin into low earth orbit, so the ‘morgs win the motor race. When the vehicle is 30 degrees off kilter, shit has gone down anyway. Or is about to go down. Hard.

With these, even if I was completely wrong on the physical modeling, I’d have enough torque capacity to tune the final system to taste.

What to do with kewl moters? Digitize them!

I like motors that are flat colors and prismatic.

Hey, it’s a circle.

I’ve recently taken a liking to the truncated circle profile. This is clearly visible on my 2.007 robot. It’s alot less boring than just plain square sides.

SEGFAULT is built around a 24 inch diameter circle. Having an actual 2 foot circle as a baseplate is excessive, so the ends will be clipped off.

Underside, showing the motor carriers.

The circle is cut where the motor modules end. The overall length is now around 17 inches.

…Okay, just a LITTLE LEAP OF FAITH THERE.  What the hell is that?

I skipped over more screenshots of the CAD work because it was essentially done in one night. That means it sucks and is riddled with flaws. I’m putting this here because it will probably represent the overall shape of the thing, even if details change.

The frame is all 1/4″ and 3/8″ aluminum appropriately waterjetted and T-nutted together. I’m currently on a mission to reduce the sheer amount of metal used in construction. While the whole thing (including stick AND both drive motors!) only weighs 36 pounds, it needs alot of metal. And it’s a waste of the metal, because the plates are totally trussed out and hollow.

What was that I said about it sucking and being done in one night?

The difference between this frame and essentially all the other DIY balancing vehicles is that it has tiny-ass wheels. I mostly chose this route because i already had said wheels. In order to fit components, then, I had to make an “middle deck” above the motors, where most DIYers will just put parts between the motors and under the top platform. A bit convoluted, but I don’t want to go back and redesign everything. Batteries go in the middle deck, along with most controls.

There’s nothing on the stick yet, because I haven’t gotten around to it. At most, there will be a simple panel dashboard showing battery voltage and probably speed, along with a main power switch. And handlebars.

Steering will be performed by tilting the stick left and right, so there’s no conventional grip throttle like on the first generation Segways.

Alright, enough is enough. Time to start on something – pay attention to this space. And I promise that SEGFAULT will get its own page soon!

ω