LED Clock: LED Control Bus Architecture

June 9th, 2006 by Keith Neufeld

Circuit Layout

The same time alone in the car solidified my thinking about the bus architecture I want to use to get the control lines from the microcontroller to the 16-channel LED drivers.

Each digit of the clock will have 28 LEDs, plus two for inter-digit colon and one for decimal point; hence 32 channels / two driver chips per digit. Probably six of those banks in the whole clock, for HH:MM:SS or MM:SS.TH, depending on the operating mode.

I’ve settled on this plan: Each digit will be independently addressed. The two A6276 chips within each digit will be chained together in serial, but all the different digits will fan out in parallel. That means strobing 32 bits of font data for every character change, which is (1) the minimum required, because that’s how many it takes to change the data anyway; and (2) a nice maximum, compared to strobing all 192 every time.

Here’s where it gets fun, and where my time spent growing up studying 8-bit microprocessor circuits pays off. It takes three lines (data, clock, and latch) to operate a series-chain of 6276es, so at first glance this plan looks like an 18-line architecture; and that’s more pins than I have available on the PIC18F2322 LogoChip.

But the way the drivers work, it doesn’t matter what’s in the serial-in buffer until you enable the latch to that chip, which captures the serial-input buffer it into the parallel-output buffer. Ergo use a single data/clock output pair from the LogoChip to all the characters at once, and only use six separate lines for the latch controls. Yeah, it seems a little odd to deliberately shift meaningless data into all the chips all the time, but there’s really no harm in it. Tee-hee.

It boils down to having a system-wide data bus with enable lines to select which chip listens, which is how every multichip computer (even the ones old enough for me to comprehend their design :-) ) is built.

I’m even going to be a good boy and check the fanout, to make sure the LogoChip can drive that many 6276 inputs (or whether I’ll need to interject a buffer).

Board Layout

I’d like to start drawing out the circuit in EAGLE, but it doesn’t have a library entry for the 6276, and I haven’t checked on the DS1302 and DS1340 yet. I’ll probably have to design symbols for them.

Another set of questions revolves around whether the entire display will be a single ~2″ x ~12″ PCB, or a set of adjacent smaller PCBs that tie together. I kind of like the aesthetics of a single PCB; I kind of like the maintainability of smaller PCBs that permit swapping out single digits if LEDs fail, which gets the clock running again quickly. Hm, if I did do that, I’d want some kind of test harness that was ready and waiting to plug in and drive the lone digits.

Either way, I picture laying out the board as individual modules, with a control bus that extends across the entire width. Then the design isn’t dependent on the decision, and we can make it pretty late in the process.

One other consideration is manufacturing the PCB. I had assumed I’d use EAGLE; but of course the free version only edits boards up to about 3″ x 4″, which wouldn’t be nearly big enough for the full board. Maybe it’s time to learn to use FreePCB, which has always been my plan for laying out larger boards.

Also, I assume I’ll hand-draw and hand-etch the board rather than have it produced commercially, and my friend Joel’s drilling machine only has a travel of about 12″. If the display board is monolithic, I might have to produce drill files such that I could drill half the length of the board, flip it end for end, and drill the other half. I obviously wouldn’t get perfect alignment, but I think I could get close enough to be satisfied. It’s still a significant extra hassle, as is coming up with a much larger etching tank than the plastic case I’m currently using.

Ultimately, though, I want to make as many decisions as possible based on what’s right for the project, not what’s easiest to get away with. I don’t feel bad about DIY frosting the narrow-angle clear LEDs, because I think the result is about the same. But that’s not true of the difference between a single long board and a bunch of plug-in modules, whichever way we decide would be better.

LED Clock: Ordering Parts

June 9th, 2006 by Keith Neufeld

I’m starting to gather parts to prototype the blue LED clock.

LED Drivers

I ordered four samples of the Allegro Microdevices A6276 constant current 16-LED driver chip that I want to use to run the display. I didn’t care whether I got traditional or lead-free; but due to availability and the way their sample fulfillment process works, they’ve sent me four lead-free and will send me four traditional when they restock their samples. Cool.

LEDs

I’ve purchased 500 blue LEDs (10,000 mcd) on eBay from Best Hong Kong for $50.35 with free shipping and free resistors.

I haven’t figured out their pricing scheme, other than arbitrary. On their web site, these LEDs (AFAICT) are $.18 each, or $90 for 500; on eBay, they were $50, with a Best Offer option that suggests they’re willing to negotiate even further. That suggestion seems to be incorrect, though–they gave no response whatsoever to my two offers and my ask seller a question.

The LEDs have a 20° viewing angle, which is too narrow. Jeremy and I tested some of my Phillips LEDs, and they’re so directional we’re afraid we might not be able to see both ends of the clock from the same viewing position. However, I scuffed one up with 1500-grit sandpaper, and it looked fantastic–a very uniform brightness from a wide range of viewing angles. Yes, it’d be nice to just buy frosted ones, but I can’t find them in the quantity I need for anywhere near the price. I expect I’ll dedicate a buffing wheel to being a scuffing wheel when the LEDs arrive.

Timekeeping

I had several hours to myself in the car in the last couple of days, and did some thinking about timekeeping and battery backup. As much as I’d enjoy programming timekeeping functionality in the LogoChip, I shudder to think of dealing with backup during power loss.

I could take a reference timekeeping source from the 60Hz line supply like consumer alarm clocks, but then I’d have to switch to the internal oscillator for timekeeping when the clock was unplugged. To do that with any more accuracy than my alarm clock, I should compare the oscillator to the line frequency during normal operation and record the actual number of oscillator cycles per period. Add in dealing with battery changes–and do you have to recalibrate from scratch if you do lose all power? Or add a 1-bit NVRAM chip to the design? All of that’s doable, but ecchhh. I’ve started thinking about using an external real-time clock (RTC).

I have an old Dallas NVRAM/timekeeper DIP (probably lots of them, actually), which provided RTC functionality for 8088-vintage computers. Unfortunately, it’s made to work with a microprocessor and has 8-bit and wider address and data buses, registers, etc. Way too many pins to work with a small microcontroller, when I already have other pins to deal with to drive the LEDs.

Google on “real time clock” integrated circuit led me via Wikipedia to Maxim/Dallas. I feel like I’m starting to get a clue about browsing manufacturer’s offerings–after looking up their 1309, I visited related products and found the DS1340 I2C RTC with integral trickle controller to recharge the backup battery, and the DS1302 RTC with trickle-charge and a simple three-wire serial interface. I ordered samples of the DS1340C SOIC with internal 32KHz crystal, the DS1302 DIP, and (bless Maxim!) the external crystal for the 1302.

Replacing My PowerBook Screen

June 4th, 2006 by Keith Neufeld

This weekend, I transplanted the screen from a nonfunctional 500MHz PowerBook G4 onto my 550MHz G4 to replace the one that broke off.

Writeup here.

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.