Resocketing my LED Tester

June 1st, 2006 by Keith Neufeld

I recently bought a $10 LED tester. It has a 9V battery, a dual-row header to put LEDs in, and resistors to provide different test currents to try different LED brightnesses. [Uh, is "brightnesses" a word??? Whatever . . .] You can use it to determine the polarity of an LED if you can’t tell by the case (I’m getting better at visual identification, though), and it’s really handy to figure out what current you want to use while the LED is still out of circuit.

LED Tester

Problem is, the manufacturer used a cheap dual-row connector intended for header pins (probably .037″) that’s way too loose on the smaller pins (probably .028″) on the LEDs, so I get bad connections that make it difficult to use–I pretty much have to hold the LED in place to keep it lit. Also, the socket elements were oriented with the metal on the sides rather than the top and bottom, so bending the LED pins further out didn’t help make any better contact.

LED Tester with Cheap Socket

Tuesday night I fixed that problem by replacing the original header with a better one from my parts bin.

Parts Bin of Headers

I started with a salvaged header that I desoldered from a printer control board a while back. The header was too long (too many pins), so I cut it to size with a razor saw. These headers are actually really nice to cut; because although they’re not snappable (I don’t see how that could work with a dual-row connector), they’re notched between every set of pins, so there’s a groove in which to start cutting.

Cutting DIP Header

I desoldered the original header from the board with solder wick and the temperature turned all the way up on my new Weller iron. It actually worked pretty well, partly because the board’s plated through-holes were way oversized, so the solder came right out. But I’ve had trouble desoldering things like this before, where the holes are the size they should be and the capillary action just doesn’t pull all the solder out into the wick. Partly spurred by my good luck on this project, I’m starting to do a little research on buying a decent vacuum-powered desoldering station (secondhand, of course).

LED Tester, Solder Side

I soldered the new header in place, tested operation, and reassembled the case. It works much better now–I have five LEDs inserted in a row for comparision, and they all consistently stay lit.

LED Tester with Blue LEDs

LED Clock: The Font

May 30th, 2006 by Keith Neufeld

Allegro LED Drivers

I ordered a handful of A6276 16-bit LED driver sample chips Friday. If you look closely at the construction of the CK-3000, you can see that they effectively use three LEDs in a row for each segment of a seven-segment display. That makes a total of 21 LEDs in a digit, plus 2 for an inter-digit colon and 1 for a decimal point, for a grand total of at most 24 per digit. Sounds like a 16-bit driver plus an 8-bit driver, or sharing three 16-bit drivers across two digits.

Font Decisions

So if the LEDs are just grouped in threes to make up a seven-segment display, why not use a seven-segment display driver and save the hassle of a 24-bit driver? Because I’m utterly enamored of the idea of making the digits as perfect as possible within a 5×9 matrix. So when it’s time to make a 3, I don’t want to do this: 3-7 I want to do this: 3-7c

I drew up three sets of fonts to represent different LED-driving strategies.

0-7 1-7 2-7 3-7 4-7 5-7 6-7 7-7 8-7 9-7

The first font is what you get by driving each strip of three LEDs as a segment in a seven-segment display–all three in each strip are on or off at the same time. (I assume this is how the CK-3000 works.) This would take 21 LEDs and seven drivers for each digit. To me, this looks even worse than a standard seven-segment display, because the corners are missing. Normal seven-segment displays have the segments “mitered” into the corners, but this has a gap in each corner.

0-7c 1-7c 2-7c 3-7c 4-7c 5-7c 6-7c 7-7c 8-7c 9-7c

The second font is what you could get using the same LEDs, but with a separate driver line for each LED. It still has 21 LEDs, but each LED can now be controlled independently.

With independent control of the LEDs, I was able to “round out” a couple of the digits–particularly the 3. I like the way the 3 looks, but the contrast between the good 3 and the bad 4–or between the top and bottom of the 2 and 5–makes this an even worse choice, in my opinion.

0-23 1-27 2-28 3-21 4-27 5-27 6-23 7-27 8-21 9-23

If I’m going to bother making a clock like this, I want it to be as close to perfect as possible. The third font uses more LEDs than the CK-3000: 28 LEDs, to be precise. It uses the original three LEDs for each of the seven segments, plus fills in each corner (see especially 4 and 7; as well as 1, 2, and 5) and the middle of each edge (see especially 0 and 1; as well as 4, 5, 6, 7, and 9).

Finally, it adds one extra LED inside the perimeter of the lower half to round the lower curve of the 2. It’s a small thing, but it transforms 2-25 into 2-28.

Drivers Redux

We’re now up to 28 independently-controlled LEDs per digit, plus optionally two LEDs for colons and optionally an LED for a decimal point. At 31 total per digit, it sounds like two 16-bit LED driver chips per digit, or twelve to sixteen for the whole clock (depending on whether it has a hundredths display).

I’ve been thinking about how to connect the chips to the microcontroller. They’re serial-in chips, so at one extreme, I could string them all out in a giant line and shift all of the characters’ worth of data every time there’s any change. That means that every second, I’d be shifting out another 192 bits of data, which isn’t bad–just annoying. Or every centisecond, I’d be shifting out 256 bits, which is even more annoying.

At the other extreme, I could connect each character’s 32-bit (two-chip) driver to a separate set of pins on the microcontroller, so each character was individually addressable. Since each register needs a minimum of three signal lines to operate (serial data in, clock, and latch), that’d be eighteen signal lines coming out of the microcontroller–which I don’t have enough pins to do on the PIC18F2320, and I’d rather not have to use a PIC18F4320 just to have enough ports.

I could also split the display into smaller serial chunks–for instance, dividing between character pairs (HH : MM : SS) would only require nine signal lines. I could matrix the display, using a combination of source-selection and sink-selection to strobe each character’s worth of LEDs rapidly in sequence. And I could address the driver chips out of the microcontroller, to matrix on the logic side rather than power side; this would require demultiplexing and fiddling with their clock inputs, since the A672x chips don’t have enable inputs per se.

To keep parts count low, and for the sake of simplicity in the software, I’m actually leaning toward the all-serial solution. Yes, it spends a lot of time bit-banging LED data out the ports. But the trade-off is not having to add extra chips for matrixing, and not having to determine in software which characters need to be updated. The software can simply determine the current time and pump the whole thing out to the display.

Of course, I reserve the right to reconsider after I get the chips and start playing with them.

Blue LED Clock

May 27th, 2006 by Keith Neufeld

CK-3000

A few days ago, I ran across this custom PC case via the Make blog:

WMD PC Case Mod

G-Gnome’s “WMD” Case Mod

Via
Build process, part I
Build process, part II

It’s an amazing piece of work–all hand-tooled metal, with lots and lots of polishing.

One thing that caught my attention was the clock display. It looked cool, I loved the way it used individual round LEDs as pixels instead of big segments and made the digits look rounder, and I wanted one. I read through the story. I found that the clock is the CK-3000 from Electronics USA. It’s $360.

That’s just crazy.

Design

Then two thing happened at about the same time. I emailed my friend Jeremy the links to the WMD PC case, and I started thinking about building my own clock as a backlash against the price tag on the CK-3000. Then I was talking to Jeremy about building an eye-searing blue LED model; and the next thing you know, we’re starting to discuss actual details.

Jeremy writes:

I’m mostly after a scary looking display (I realize red would be scarier, but I like blue). Being big(ger than a sane person would want a display) is part of that because something that big MUST be important, but it has to be a manageable size. 3 or 4 feet would probably be the limits for me to find a permanent spot to hang it in the computer room and smaller is not necessarily worse if we can get the feel of the thing right. Being ominous on its own is good, but it should definitely DO something. A regular clock would be bare minimum, a clock that freaks out and does a flashing doomsday 1 minute countdown every hour (or randomly… that would be scarier) would be the kind of thing I’m going for.

And I replied:

Can we make it do that in _response_ to something? Lights turned on or off, loud noise, silence? We can definitely add a horn/buzzer/piercing alarm to sound continuously/beep down the seconds/beep frantically for the last few seconds.

Um, if it’s going to be ominous, it should have a hundredths display, so some of the digits are changing too rapidly to see. The hundredths might remain blank during normal operation and only kick in when we’re down to a minute left, or something.

Technology

I think I may actually build one or two of these. I’d use the LogoChip for timekeeping and display decoding, probably supplemented by watching the 60Hz on the power line. I got a string of 5mm blue LED Christmas lights last winter, and I might get more, or I might get some frosted blue LEDs on eBay.

To drive the display, I’m interested in using Allegro Microdevices’ A6275 and/or A6276, 8- and 16-bit constant-current LED drivers. I saw them used in something linked from the Make blog that I can’t remember now, I ordered a couple of 8-bit sample chips to play with, and I recommended them to Muaz Halim for use in the TechArt exhibit Firefly Environment.

Roomba Repair

May 21st, 2006 by Keith Neufeld

I fixed my original Roomba this weekend, repairing a blown trace due to incorrect battery rebuild instructions, and learning other interesting things along the way.

Repairing Roomba Original

Stepper Motors, Part V: Taming the Wild Voltage

May 20th, 2006 by Keith Neufeld

With a desired motor voltage of ~2V and the bridge feeding the coils ~11V, the motor draws way more current than it needs, and the FETs get really hot. In fact, the PC power supply I’m using, which is rated for 7.5A of 12V, can’t keep up with the load. It makes sense:

11.4V / .85Ω ≅ 13.4A

And that’s per coil, so almost 27A draw for the two-coil motor. When I measured the voltage drop across one coil, it was actually only a little over 3V. I had known I was going to want to drop the bridge voltage so the motor coils didn’t get the full 11.4V, and I had thought about doing it with diodes or resistors. Before going any further (laying out a PCB), it was obvously time to deal with the overvoltage; so last night, I sat down to do some calculations.

Dropping Voltage with Diodes

I don’t know why, but my first inclination was to try to drop the voltage with a string of diodes. Given

bridge voltage: 11.4V
desired motor voltage: ~2V

then

required drop: ~9.4V

With a .6V drop for small-signal diodes:

drop per diode: .6V
diodes required: 9.4V / (.6V / diode) ≅ 15.7 diodes

And assuming I was willing to string together 15 diodes in each direction, for each coil of each motor (uh, 15 * 2 * 2 * 3 = 180 diodes in the milling machine just for dropping voltage), how close would that get?

drop for 15 diodes: 15 diodes (.6V / diode) = 9V
motor voltage with 15 diodes: 11.4V – 9V = 2.4V
current with 15 diodes: 2.4V / .85Ω ≅ 2.8A

Granted, the rectifiers I’d actually use have a voltage drop more like 1V to 1.25V per diode; but that’s still 9 * 2 * 2 * 3 = 108 diodes in the project. Way too wasteful, and way too many.

Dropping Voltage with Resistors

It seems that Tom McGuire’s suggestion to use power resistors is the right way to go. Big sand resistors can dissipate a lot of power, but how much would be required? From above,

required drop: ~9.4V

And given

coil current: 2.5A

then each resistor would need to be capable of

9.4V * 2.5A ≅ 23.5W

That’s a pretty hefty resistor!

I looked through my parts bin, but most of my power resistors have a much higher resistance. I also browsed power resistors at All Electronics and found a few ceramics rated for 25W–but I didn’t want to have to come up with enough stuff to place a minimum (reasonable) order, wait for it to arrive, and then take a chance of it not meeting my needs. As it turns out, Radio Shack carries an 8Ω 20W resistor, so today I trotted on down and picked up a couple.

I hooked one in series with each motor coil and ran through my barrage of tests. After reconnecting a loose signal wire from the controller (oopsie!), I found that the motor was much easier to stop by gripping it with my fingertips, it had a much lower top speed without losing steps, and the coil voltage was only a little over 1V.

Dropping Voltage with the Right Resistors

At no point in the resistor discussion do I describe figuring out exactly what resistance is appropriate, because I was too impatient to get on with prototyping to be bothered with calculating. Sigh.

Okay, so I want ~9.3V dropped across the resistor and ~2.1V dropped across the motor; and the motor coil is ~.85Ω.

9.3V / 2.1V = R / .85Ω
R = .85Ω (9.3V / 2.1V) ≅ 3.8Ω

So I was embarassingly far off with my 8Ω resistors, which explains the low voltage and poor performance when I tested them.

Hmmm . . . 3.8Ω is really close to half of 8Ω. Now I’m tempted to go back and buy two more of the 8Ω resistors, to test in parallel.

On the other hand, it’d be nice to try a range of values centered around 3.8Ω, to graph the motor performance and find whether the curve has a knee in that vicinity. So now I’m back to looking at All Electronics, thinking of ordering myself an assortment. They don’t have anything in the 4Ω range, but they have 1.2Ω, 1.3Ω, 1.5Ω, and 2Ω in power ratings I could work with.

Stepper Motors, Part IV: Speed Trials

May 14th, 2006 by Keith Neufeld

First Real Motion

Tuesday night, I duplicated my H-bridge circuit for the second coil of my stepper. I provided drive power from my bench power supply, because I wanted to be able to vary it to test the effects of different supply voltages. And I didn’t (yet) do anything to drop the bridge’s voltage down to the ~2.5V that the motor wants–I just let the motor have whatever came through the bridge. The motor is hefty enough, I didn’t figure it would be damaged during brief tests.

Dual H-Bridge MOSFET Stepper Motor Driver

I hooked up the motor, started my LogoChip program with a clockwise drive pattern, and slowly turned up the supply voltage. Around 2-3V, the motor started chunking along. And I found that I couldn’t supply more than 2-3V–no matter how high I turned my variable supply (like, up to 20V), it wouldn’t provide more than 2-3V. It’s only rated for 1.5A on the channel I was using, and it was giving everything it had.

Using a loop [ step-cw mwait ___ ] command from the LogoChip console, I was able to get down to 4ms wait without losing steps, or 250 steps per second. I assumed that with a stronger power supply, I could do at least a little better than that, and I was not to be disappointed.

Dedicated Power Supply

Wednesday night, I brought in an old PC power supply and wired it into the driver board. I first used its 5V supply to power the driver, wanting to work up to 12V in stages. It was clearly driving the motor more powerfully than my bench supply did Tuesday night–motion was smoother and able to run at slightly higher speeds.

Next, I switched it over to using the 12V supply. Ideally, I’d like to run it on 8-9V, but I wanted to see what 12V did to the FETs and motor. As expected, running on 12V gave the best performance I’ve experienced yet. I was unable to stop the motor’s movement by gripping the 1″-diameter pulley with my fingertips (!), and I was able to get down to a 2ms wait in the loop shown above without losing steps.

How Fast Is That?

It was losing steps continually with a 1ms wait, but that’s a full factor of two difference in speed from the 2ms wait, so I was curious where between the two the fastest possible speed lay. I rewrote the loop to use a no-op (which the LogoChip Language Reference lists as 13μs) for the delay instead, and tweaked it down to about 150 no-ops without losing steps. Since 150 * 13μs = 1950μs ≅ 2ms, it looks like that’s about as fast as I’ll be able to get the motor to run with the current drive system.

What does that translate to in the real world? 2ms / step = 500 steps / second. This stepper has 200 steps per revolution, so 500 steps / second = 2.5 revolutions / second. I was planning to use 20 tpi all-thread for the drive screws, so (2.5 revolutions / second) / (20 revolutions / inch) = 1/8″ / second. That’s kinda slow.

Speed Improvements?

I deliberately designed the H-bridge drivers so that they could be quiesced and deliver no power to the motor. Some drivers use a single bit to select forward or reverse, and are therefore always on; I provide one bit for each half-bridge, like the 754410, allowing both sides to be high or low together for no power delivery to the load.

My current control software, however, always energizes each coil in one direction or the other, so both stepper coils are always active at the same time. Assuming the power supply is up to the task, this provides greater torque, as you have two magnets holding the rotor at all times instead of only one. However, if I recall correctly, this also results in a slower maximum speed. I’d like to experiment with rewriting the code to energize only one coil at a time.

Another approach to explore is half-stepping. When two adjacent coils are both energized (as they are under my present controller), the rotor is pulled to a position halfway between the two coils. If you change the control code to energize coil A, then A and B, then only B, etc., you cause the motor to “half-step,” doubling your steps per revolution. I’d like to test whether this motor performs better when single-stepping or half-stepping.

Finally, I’m not presently ramping the speed at all. When the controller starts up, it’s immediately powering the motor to move at full speed. Because the rotor has mass and therefore inertia (even without an external mechanical load), it’s possible that it’s losing steps because it can’t immediately move at full speed, and never achieves synchronization with the controller. Any CNC control software I might use will have ramp-up capabilities, so it’s worth trying with my test controller as well.

Power Supply Issues

The PC power supply I was using is a switching power supply, and switching supplies don’t like to operate without a load. Projects to adapt PC power supplies to use as bench power supplies generally suggest putting a large load resistor in parallel with the outputs to keep the power supply loaded at all times; but for my quick testing, I didn’t do that. Newer PC power supplies also have “smart switching” or “soft switching,” enabling them to be turned on and off under motherboard control, to shut off the PC when you halt the operating system, facilitate wake-on-LAN circuitry, etc.

For whichever reason, I found that after the power supply warmed up a bit, it would no longer power on unless the stepper driver was already receiving signals that caused it to draw current. That is, I had to start the stepping software on the LogoChip controller before turning on the power supply. Since in a drilling machine, the power supply needs to be on continuously to be ready to receive operating commands, this obviously won’t do. I guess I’ll have to address the dummy load issue sooner than I had hoped.

And I’m delivering a much higher voltage to the motor than it’s rated for. As noted earlier, the motor’s label indicates .85Ω and 2.5A per coil, which is about a 2.1V drop. I don’t remember the source-drain drop of a FET, but my 12V supply is obviously putting more than 2.1V across the motor coils, which means I’m running them at a much higher current, as well. That doesn’t concern me too much for the motors during a brief test, but my FETs are getting awfully hot awfully fast.

I’ve talked a bit with Tom McGuire about how to drop the voltage closer to what the motors would like. He’s seen designs with power resistors in series with low-inductance motors like this, but (1) that seems inelegant, and (2) I’m not sure I have appropriate resistors on hand. I guess I could dig through my bins.

I’m also considering stacking a series of 1N400x diodes (one string in each direction) in series with the motor, to drop the voltage. As Tom points out, I need to be careful to respect the current rating of the diodes in comparison to the draw of the motor.

Stepper Motors, Part III: MOSFET Drivers

May 13th, 2006 by Keith Neufeld

The Theory

Sunday night, I read the MOSFET chapter in my semiconductor textbook several times, in preparation for beginning to build FET motor drive circuitry Monday. I took away these key points (some of which I already knew):

  • Because MOSFET channels are very thin, their junctions are easily damaged by overvoltage conditions, not just overpower conditions. This is the reason for the standard cautions about static electricity and admonitions to store FETs in conductive bags or with foil wrapped around the leads, etc.–high voltage (even at a very low current) can destroy FET junctions.
  • Because MOSFET gates are very high impedance, it doesn’t take much current to turn them on; thus it’s critical to tie the gates with a pull-up or pull-down resistor to keep them from floating and triggering wild dumps of power through the source/drain.
  • MOSFETs like to have > 7V to saturate, i.e. turn completely on. If they’re not completely on, they’ll act as a resistive load and potentially dissipate a lot of power (equals heat, equals shortened lifespan).
  • Read the datasheet carefully to determine which lead the heatsink tab is common with. On the ones I’m using, it’s the drain; so heatsinking to ground would short them out instantly.

The Circuit

I knew I wanted to design my bridge with complementary FETs (N-channel and P-channel), like I’ve done before with bipolars. There are designs available to do bridges with all N-channel FETs, but it takes extra work to bias up the upper FETs and their gate signals. It all seems very complex and nasty to me, especially when I have complementary FETs available: a large quantity of a couple of different MOSFETs, extracted from old printers’ stepper drivers. The IRF510 is a very common N-channel, capable of 5.6A; the IRF9532 is a P-channel that can do -10.0A.

Because the gate voltage should really exceed 7V to saturate the FETs, I didn’t want to feed the gate directly out of the LogoChip (or other TTL-like source). I have SN75452 peripheral drivers on hand, which buffer a TTL input into a high-voltage output. I’d looked at their datasheets before, scouring them over and over trying to find VCC2 (the high-voltage supply) on the pinout, to no avail. Finally I noticed that they have open-collector outputs (DUH), meaning the chips won’t source a high-voltage output, but they’ll sink an output that has a high voltage on a pull-up resistor.

Monday night, I started prototyping with a single IRF510 switching an LED on and off, to make sure I understood basic FET operation. I added an IRF9532 in a half-bridge configuration (the left half of the circuit below), and from their common drains wired one LED high and another low (with resistors, of course), then tested that the LEDs alternated as I applied a square wave to the gates. After demonstrating that the half-bridge worked correctly, I built the full bridge shown below, again testing with LEDs.

MOSFET Stepper Motor Driver Element

Note that the pin numbering on the 75452 is incorrect–EAGLE doesn’t have a definition for the 75452 and I haven’t made one yet, so I subbed a 7400-series chip with open-collector outputs. Now that I think about it, I probably have a 7400-series chip with high-voltage open-collector outputs that I could have used in the circuit instead. I’ll have to keep that in mind.

The Motion

None, of course. A single H-bridge is enough to drive a DC motor; but a stepper needs two, one for each coil. It was late enough, I quit for the evening knowing the bridge was driving LEDs okay, but without testing the motor.

My Uncle’s Iron

May 10th, 2006 by Keith Neufeld

My uncle Adolf is probably most directly responsible for my interest in electronics. When I was growing up, he and Aunt Wanda ran A&W Electronics, retailing and repairing TVs and other equipment. This was back in the days of chassis construction, before circuit boards, when everything was built onto a metal chassis with insulating standoffs, vacuum tubes, lots of wire, and lots of solder.

When they received TVs that were irreparable, he’d often remove the dangerous parts (picture tube, flyback transformer, and huge capacitors) and give the remaining pieces to my brother and me to take apart. Which we did with great zeal, and a couple of wirecutters. I still have boxes of components that we salvaged out of those TVs; and man, they don’t make resistors and capacitors like they used to. And that’s mostly a good thing.

So when they had a household auction recently, in preparation for moving to a retirement community, I was pleased and proud to purchase two boxes of soldering equipment.

Boxes of Soldering Equipment

I could see the Weller/Ungar pencil irons, and knew that any one of them was worth the $16 I paid for the box. It wasn’t until I got home that I could really see what all I got:

Soldering Equipment

There’s just an amazing amount of stuff crammed into the boxes. These irons have replaceable, screw-in heating elements, and the boxes have several spares of different wattages. One or two of the elements have replaceable tips like we’re used to using these days, and there are plenty of spare tips, too. Eventually, I plan to go through everything, sort out what goes with what, and do a little cleaning on the pieces that do fit together–replace brittle power cords, clean iron handles, polish heating elements, etc.

So?

I desolder a lot of components from dead electronic equipment that people give me. I really prefer older stuff with through-hole components, because SMT parts are a pain to identify and sort, and through-hole stuff is easy to prototype and breadboard with. The fastest method I’ve come up with is to pry up crimped leads with a $2 chisel, heat the solder side with a heat gun, and pull the components out with a chip puller or needlenose and drop them into a tub.

Generally.

Except (he finally gets to the point) for the TO-220 MOSFETs on the printer boards. For whatever reason, their through-holes were plated only barely larger than their leads, and I was having a dickens of a time desoldering them with the heat gun. The board was scorching, I was breathing really noxious fumes (and I like the smell of solder flux, but not so much burning fiberglass epoxy), I was bubbling and flexing the board as I pulled on the FETs’ tabs with a pliers, and still no joy. I ended up pulling the entire plated through-holes clean out of the board (um, maybe “clean” isn’t the best word to use here) and sliding them off the transistors afterward with my soldering iron.

And the Iron?

I’ve previously desoldered with soldering irons and guns, and under some circumstances, direct heat can be very effective at removing stubborn leads. So a couple of nights ago, I got around to digging through the auction boxes to see whether I could find a wide tip. I was looking for something that would hit all three transistor leads at once, and I found exactly that–a gimongous .3″ chisel-tip 40W heating element, still sealed in its original bubble package.

I opened the package, cleaned the oxidation off the tip, screwed it into one of the handles, and plugged it in. When it started getting up to temperature, I smiled in appreciation at the ceremonial first tinning of the new tip. I grinned at its extreme shininess as I wiped off the solder on the damp sponge. I dropped my jaw in amazement as the transistor slipped right out of the board in about a second of applying the tip to the leads. I desoldered the remaining thirty or so transistors in a matter of brief minutes.

The tip kept heating up the whole time. As I was finishing, I would occasionally cast shadows on the iron and see that the tip was now red-hot. I’d wipe it on the damp sponge and see little embers rise into the air as it tore off and burned rough parts of the sponge surface. I was rather unnerved to see this from an element rated at 40W.

But boy, did it desolder them transistors! Yee-haw!

Obligatory FPS Reference

I’m somehow reminded of the differing effectiveness of various weapons against various monsters in Doom. When you run into a cacodemon, you better make sure you have the nailgun handy–even though it’s utterly useless against several other species.

Stepper Motors, Part II: Testing Motion

May 10th, 2006 by Keith Neufeld

The Wiring

Sunday, worked in around the community orchestra concert, I got the stepper motor moving using my old friend, the 754410 dual H-bridge driver. I hooked each coil across an H-bridge, and used my Curiously Strong LogoChip as a controller, with two pins running each bridge (forward and reverse). Four pins per motor may or may not be the best way to build a complete CNC machine, but it worked nicely for testing.

Stepper Motor with LogoChip Controller and 754410 Driver

The red/yellow/black wire set from the LogoChip to the driver board provides regulated 5V and unregulated 9V to any auxiliary circuits I want to connect–I like to think of it as the PTO. The red/grey/blue/orange wires from the LogoChip to the driver board are the step control signals, and the red/black/blue/orange wires are permanently cabled into the motor. The yellow/green wires feed from one of the variable outputs on my bench power supply, and provide drive power separate from logic power, to keep dips and noise due to the motor from interfering with the logic control circuitry.

The Software

After wiring up the driver board, I wrote a little LogoChip program to control the driver. I needed to provide a quadrature-encoded signal (one goes high, two goes high, one goes low, two goes low) on two sets of two pins, and be able to reverse it. It turned out to work really nicely to modularize the CW/CCW quadrature code in one function, and put the icky code to deal with turning pins on and off in a separate function–it makes the quadrature code reusable to run multiple motors, among other things.

Here’s what I ended up with:

  • stepper.txt – Program to drive bipolar stepper motor

Here’s the code:

;   stepper.txt
;
;   06-May-2006  Keith Neufeld
;
;   Test/drive bipolar stepper motor, using external 754410 driver chip.
;   Two coils are driven in quadrature:
;
;       ===|       |=======|       |=======|       |=======|
;          |       |       |       |       |       |       |
;          |=======|       |=======|       |=======|       |===
;
;       =======|       |=======|       |=======|       |=======|
;              |       |       |       |       |       |       |
;              |=======|       |=======|       |=======|       |

;------------------------------------------------------------------------------
;   Debug system
;------------------------------------------------------------------------------

constants [[debug 0]]
;constants [[debug 1]]

;------------------------------------------------------------------------------
;   Section to manipulate stepper motor.
;   Coil 1 driven by C7/C6.  Coil 2 driven by A2/A3.
;------------------------------------------------------------------------------

constants [
    [coil1-port portc] [coil1-ddr portc-ddr]
    [coil1a-bit 7] [coil1b-bit 6]

    [coil2-port porta] [coil2-ddr porta-ddr]
    [coil2a-bit 2] [coil2b-bit 3]
]

to stepper-off
    clearbit coil1a-bit coil1-port      ;   set all coil outputs low
    clearbit coil1b-bit coil1-port

    clearbit coil2a-bit coil2-port
    clearbit coil2b-bit coil2-port
end

global [steps-per-sec msec-per-step]    ;   timing "constants"
global [coil1-pos coil2-pos]            ;   current coil state

to init-stepper
    stepper-off                         ;   shut down all coil outputs

    clearbit coil1a-bit coil1-ddr       ;   set all coil pins as outputs
    clearbit coil1b-bit coil1-ddr

    clearbit coil2a-bit coil2-ddr
    clearbit coil2b-bit coil2-ddr

    setsteps-per-sec 2                  ;   2 steps per second
    setmsec-per-step 1000 / steps-per-sec       ;   precalculate wait per step

    setcoil1-pos 0                      ;   initialize quadrature to (0,0)
    setcoil2-pos 0
end

to step-set                             ;   push out new quadrature values
    ifelse debug [
        send 48 + coil1-pos             ;   0/1 with no CR
        send 32                         ;   space with no CR
        print coil2-pos
    ] [
        ifelse coil1-pos [
            clearbit coil1b-bit coil1-port      ;   clear before set
            setbit coil1a-bit coil1-port
        ] [
            clearbit coil1a-bit coil1-port      ;   clear before set
            setbit coil1b-bit coil1-port
        ]

        ifelse coil2-pos [
            clearbit coil2b-bit coil2-port      ;   clear before set
            setbit coil2a-bit coil2-port
        ] [
            clearbit coil2a-bit coil2-port      ;   clear before set
            setbit coil2b-bit coil2-port
        ]
    ]
end

;   CW pattern:
;       0110.0110
;       0011.0011

global [new1 new2]                      ;   temps for coil values

to step-cw
    setnew1 not coil2-pos
    setnew2 coil1-pos

    setcoil1-pos new1
    setcoil2-pos new2

    step-set                            ;   do it
end

to step-ccw
    setnew1 coil2-pos
    setnew2 not coil1-pos

    setcoil1-pos new1
    setcoil2-pos new2

    step-set                            ;   do it
end

;------------------------------------------------------------------------------
;   Routines to tie it all together
;------------------------------------------------------------------------------

to init-all
    init-stepper
end

to powerup
    init-all
end

to startup
    init-all
    loop [
        step-cw
        mwait 100
    ]
end

The Movement

I started up the motor control with a loop [ step-cw wait 10 ] from the LogoChip console, then turned up the variable power supply until the motor was chunking along at a step per second. That channel of my power supply is only good for 1.5A, and I found that no matter how high I turned the dial, the meter didn’t read any higher than about 2.5V. I guess the coil power calculations were pretty close.

Next, I played with different timing values, to watch the motor turn at different rates and test its torque. I found that on this power supply, I could very easily stop or spin the motor contrary to the control signal. That was a little disappointing, but I realize also not at all a fair test, with the motor so underpowered.

Finally, I knew the 754410 is only rated for 1A per bridge, and I was attempting to use it for much more than that. I was being careful not to sustain high-voltage testing for long periods, but I was still curious how the 754410 was reacting thermally. The result was fascinating–I could quite distinctly feel the chip getting warmer as I ran the motor and cooler when I stopped it. I’m used to components heating up, but I’ve never before experienced it so directly in real time (at least, not without scorching my fingers).

I had known that the 754410 wouldn’t be my ultimate drive circuit, but I hadn’t known I would hit the wall with it so quickly. After realizing how hot it was running, I knew the next step was building a drive circuit with discrete power transistors. And I just happened to have some on hand: MOSFETS, from the stepper drivers in some old printers.

Review time in my Malvino–quite possibly the best $130 I ever spent.

Stepper Motors, Part I: Confirming Values

May 6th, 2006 by Keith Neufeld

The Project

My friend Joel has a computer numerically controlled (CNC) drilling machine that he built from a mail-order unpopulated circuit board and a set of plans. Its table holds materials up to about 10″ x 14″, and I go over to use it any time I need to drill a circuit board. It’s not terribly inconvenient to use his, and it’s always a nice excuse to visit with him while we’re setting it up and letting it run–but I’ve wanted my own for as long as I can remember. They’re just cool.

There are lots of descriptions of and plans for CNC drilling machines on the Web, so I won’t go into a lot of detail. The basic idea for this model, though, is that a drill is suspended in place above a table that slides around to position the workpiece. The table is positioned by long screws (all-thread) turned by stepper motors, which are motors that move small increments (steps) in response to an input signal, rather than running freely. Each step is a small fraction of a complete rotation, and coupled with the worm-drive effect of the lead screw allows for very precise positioning of the workpiece–easily 1/1000″, and often 1/8000″. (Of course, mechanical issues like backlash do intrude, but 1/1000″ doesn’t seem to be terribly hard to achieve.)

The Motors

So . . . I want to build my own CNC drilling/milling machine, and since I do electronics bottom-up, the project starts with the motors. And boy, do I have motors. I have these giant steppers out of heavy-duty wide-carriage impact printers from a former employer just begging to be used.

Big Stepper Motor

If you look carefully, you can see the ruler underneath the motor–it’s a good 2″ in diameter. Pretty heavy, too.

As we wrapped up our TechArt installation, my thoughts have been returning to these motors, and wondering what it would take to start building drivers for them. This weekend, in between community orchestra rehearsals, I sat down with one of the motors and started making notes. Here are the specs from the sticker on the back side:

PULSE MOTOR
TYPE PJ55E1U97A

A / Phase: 2.5
Ω / Phase: 0.85

Nippon Pulsemotor Co Ltd

Uh, .85Ω per phase? Are they kidding??? That’s an insanely low coil impedance compared to what I’m used to on traditional motors. I can see already this is going to be a challenge.

The Coils

The first thing to do with an unknown stepper motor is figure out the coil wiring. Steppers have multiple coils, each determining either one or two rotor positions, and each with an external wire or pair. From the steppers I’ve played with, four wires generally means two coils each powered in alternating directions, five wires is one common plus four unidirectional coil connections, and six wires is three unidirectional coils. This motor has four, so it was a simple check with an ohmmeter to determine which wires go to which coils.

Red to black: 1.3Ω
Orange to blue: 1.2Ω

Internal resistance of meter (shorting probes together): .3Ω
Variation due to probe placement and pressure against pins: up to .2Ω

So yeah, that’s pretty much .85Ω per coil. Wow.

The label says 2.5A per coil. To get 2.5A current, 2.5A * 1Ω = 2.5V and 2.5A * .85Ω ≡ 2.1V. That’s a really low coil voltage, given some assumptions I’ve already made about the drive circuitry, so I can tell that’s going to be a challenge.

Finally, I hooked wires to my bench power supply and touched them to the coil wires, just to watch the rotor move. In that very unscientific experiment, it looked like the stepping behavior (speed and impact of single steps) was about the same when using a 5V supply as when using a 2.5V supply. That gave me hope that I might be able to fudge on the details and use a higher coil voltage than nominal–although I don’t want to heat up the motor and melt the coils during intense use.

The step pattern I tried moved the motor CCW: black/red, blue/orange, red/black, orange/blue.