In my continued hunt for the holy grain of CNC Controller cards my thoughts have moved away from current chopping IC’s and towards linear control.
This has driven a number of interesting experiments and distractions all over the place, but it’s getting to the point where I’m close to building the first one, so making it worthy of a blog and hopefully some feedback.
Big Caveat: I am not an electronics expert, all opinions expressed here are gathered from the net, my experiments, and more usually mental extrapolation with very questionably foundations. So please feel free to point out the errors of my way.
Stepper motors seem to be devices that usually like a very small voltage, the Nema17 ones I’m playing with seem to like 2.8V, and for speed control the typical approach is to use PWM and vary the duty cycle. Marry these two things together and you can get away with much higher (easier to control) voltages and use PWM and current limiting to ensure the total power is appropriate for the motor.
There are loads of devices out there that do this, I’ve researched (and prototyped) the TB6560 which is used in many lower cost CNC controller boards (including a chinese one that I’ve battled with), I’ve also used the Pololu A4983 boards which are based on the Allegro A4983 chip. Actually these devices to a pretty good job, they also allow micro-stepping to provide more steps that the motor physically accomodates (it does this by diffentially powering the different windings to hold the motor in a sub-step position.)
So far, all is good. I’m using a 16 stepping A4983 at the moment (see my Home Grown driver board) and it does a nice job.
However … the PWM approach uses a high frequency to turn the supply on and off and this can be heard in the motors as a whine or squeal depending on how good the driver is and how much current you are supplying. This chopping also leads to more heat generation in the motor (there a good Wiki article on why, but it’s really beyond my capabilities). Also, some of the existing driver IC’s have quite limiting requirements … the signal pulse width requirement on the TB6560 is something that I’m sure more people are running out of spec, especially on Mach3 which doesn’t do long pulses!
All that said, I was fairly content with the drivers until I discovered the Linistepper, this showed that there were relatively simply ways to use a linear driver. The Linistepper didn’t handle bipolar motors, but the principles look applicable.
Basically the linear approach is all about driving the motor at the correct voltage and then varying the voltage (and hence current) to acheive the desired positioning. It’s linear because the voltage is constantly applied, there’s no chopping, no PWM … so there should be no whining, the motor should be cooler (although you’ll get the heat in the driver) and you have infinite ability to vary the microstepping by controlling the voltage.
So … thoughts forming … rather than using a fairly limited resistor stack to select current levels, we could use a microcontroller (I love microcontrollers) … then we could either use a PWM source with a low-pass filter to create a control voltage or a DAC.
For actual motor control, a traditional H-Bridge, but with Darlingtons, one pair will be used as simple switches (could probably use FET’s here, may be cooler, need to experiment) and the other pair will be used to control the current (and hence voltage) … using the TIP122/127 combination, we have a gain of 1000 … therefore for a 2A capable system we only need to drive the base 2mA, should be doable.
So, all conceptually looking good … the Atmel ATTiny261A has a high speed timer that we could use at the PWM source, with two compare registers and a bit of switching logic and an op-amp or two we could drive everything we need. But … I know nothing about filters, so Spice (circuit emulation) allows a bit of experimentation.
So after playing with both passive and active filters for a while, I get a bit concerned about the responsiveness … you are basically filtering out the high frequency PWM signal and should be left with a DC voltage proportional to the duty cycle. To get the best smoothing you need a bigger RC network, but this slows down the overall ramp up/down speed. You get better performance if you speed up the PWM, but this then limits your granularity.
Grrr … there’s always compromises! Anyway, bottom line is that PWM looks viable, and I’ll probably do some experimenting with it, however I am concerned about speed and smoothness … both are probably fine, but if you’re going to do it, lets to it well!
So, DAC’s are the other option … because of the way you need to drive the motors you need four DAC’s (or some switching) to control the two phases of the motor. So I started looking at how to interface DAC’s to the Atmel … again a bit tough, parallel uses loads of pins, anything serial has speed implications, not to mention an overall cost impact.
How about microcontrollers with DAC’s built in? Bizarely there aren’t many of these, some of the newest Atmel devices (the XMega’s) have two DAC’s in, but they seem quite limited and noise prone … and these devices are very fine pitch 100 pin SMT packages and will be a nightmare to prototype.
A number of the the PSoC1 devices have the capability to run 4 x 9Bit DAC’s at pretty high speed and they have enough analogue control to inject an offset (to get near to the 1.4v base threshold on the TIP’s) and enough power to drive them with no extra components (other than a resistor to control base current.)
As an aside, the PSoC3 and 5 devices are really really nice, you can build a load of stuff actually in the programmable logic area, and I think the next project will be building a much more capable device with those, with virtually no software. More on that later.
So, current status…
I have a breadboard H-Bridge with TIP122/127 transistors capable of driving a single phase of the stepper.
I have a PSoC1 device programmed up to create the Sine Wave’s for the two control lines and two signal lines for the single phase … adding the second phase is very trivial.
I have a schematic and board designed.
So, some testing on the breadboard, and then hopefully onto first prototype board. I put a single axis controller (capable of anything down to 128 microsteps, depends on your ability to drive it), capable of 2A per winding, driving a max of 3.6v … around £10. So a fully functional 3-Axis board (obviously including my customary spindle PWM controller) at around £40.
I’d love some feedback on this.