Tuesday, July 15, 2008

Easy stepper motor control with the Freescale MCZ33970

Freescale MCZ33970 Dual Gauge Driver IC

While prototyping an ambient-display project that I've been mulling over, I came across the Freescale MC(Z)33970 Dual Gauge driver IC.  The part seemed interesting, so I ordered a sample and whipped up a small C library to use in conjunction with a perf-boarded USB Bit Whacker I had on my workbench.  (An Arduino library is also available below)

The MC(Z)33970 is a neat little stepper motor driver specifically designed to control small, two-phase steppers for automotive instrumentation displays.  I should immediately point out that this driver isn't designed for general purpose stepper control, like the Allegro A3967.  It has relatively weak current drivers and is only designed to sweep a pointer for a total of 340-degrees; this means low torque and a limited range of motion.  

While these limitations may seem annoying at first, they make sense given the niche these ICs are designed to fill.  Besides, the MCZs have a number of other redeeming features, such as programmable sweep velocity, programmable acceleration and deceleration parameters, and automatic "Return to Zero (RTZ)" functionality, which make them great for creating analog displays.

MC33970 Datasheet

MCZ33970 C Library

MCZ33970 Arduino code

Modified UBW Firmware

UBW Python Scripts

I didn't have any automotive displays about, but I did have a pair of Vexta steppers, so I decided to use them for this project.

Interfacing schematic (Courtesy Freescale)

As you can see from the schematic, the connections are very straight-forward.  The MCZ has built in protection diodes, so stepper windings can be connected directly to its pins.  I couldn't find any optocouplers in my workshop so I connected the MCZ directly to my Bit Whacker.  This is an EXTREMELY BAD idea, since the high-voltage stepper motor supply can potentially short to the digital supply if the IC fails.  Since the Bit Whacker is conveniently connected to your USB port, this may lead to a very bad day.  I *HIGHLY* recommend that you use optocouplers on the SPI lines in your design!  

Moving on, to make wiring a bit easier I decided to move the SS pin over from RA5 to RB2.  I'm pointing this out to those readers who may be scrutinizing my daughterboard photograph (absolutely none).

MCZ33970 Daughterboard

I epoxied the 24-pin SOICW IC to a perfboard, and with a few other parts, made a little daughterboard for a Bit Whacker.  

USB Bit Whacker

I modified the firmware of the UBW to add two additional commands:
  • CM - Configure the stepper motor driver IC
  • SM - Send a position update command to the driver IC
I also wrote a small C library that you can modify and use in your own UBW or non-UBW (ala Arduino) based projects.  The library is simple and should be self-explanatory.

The completed assembly

Here is a video demonstrating the dual-drive and velocity control capability of the IC.  

To make things slightly more interesting (very slight, indeed), I connected a Spectra Symbol SoftPot to one of the ADC pins of the Bit Whacker and used the readings to control the position of the stepper motor pointers.  You can find the Python scripts above.

SoftPot stepper motor control

A bunch of pots

I can imagine a number of uses for this chip, especially in low-power ubiquitous computing devices.  Things get really exciting when you have multiple ICs operating in concert.  As I continue to burn through my summer-projects list, I'll see if I have time (or the need) for a MCZ-based Arduino shield.  As always, if you find any bugs or need any help, please let me know.


Sumanth P.


tobycatlin said...

Any ideas where i can get some of these chips. they look perfect for some gauges i am making. I am based in the uk. Farnel list them but not in stock and you have to buy 30


my12a3 said...

I couldn't get your code, could you check it again for downloading available? Thank you.

will29102 said...

I know this is rather an old post, but maybe you still monitor it!

I'd like to use your Arduino library to interface to a MCZ33970 IC for a gauge project of mine, but the link is dead. Any chance you could host it elsewhere?

theory meets application.