I'm currently working on a project that uses one AVR Mega48 microcontroller to drive four MOSFET's using hardware PWM and hopefully no current sensing resistors.
This is for unipolar motors.
Basic concept:
I have hooked 4 PWM output lines to the gate pins on 4 IRFP250 transistors (not the best choice, but those are the only ones I have 4 of).
The AVR is running at 20MHz, and the PWMs are 8bits and no prescaler.
PWM frequency is 78.125kHz.
The PWM values are stored in EEPROM, and can be programmed throug a standard PC com-port to match each motor perfectly.
Utilizes the lo/hi current output in MACHn
What I have discovered:
The IRFP250 parts can handle >30 amps continiously, but due to the rather slow switch-on/off times they start to heat up at less then 1A
To solve this, I could get some faster transistors and / or slow down the PWM to maybe 20kHz.
In my silly attempt to do microstepping, I guessed that a SIN/COS function on the duty-cycle would be the right thing to do...
While a SIN/COS function on the current in the A/B coils would definetly be the ideal way to do microstepping, that doesnt mean that setting the PWM duty cycle to a SIN/COS function would be good, unless the motor have zero inductance, and the transistors have zero switching time...
I did some measurements on the PWM duty-cycle to current ratio, and have plotted the results for two of my motors in this grap:
To get the results as accurate as I could, I built a monster filter between the transistors and the power supply, and placed the ampere-meter between the filter and the PSU.
As you can see, the relation between motor current and duty cycle is far from linear... It's really very exponential... To the power of ...alot!
I also plotted this grap. showing the difference between the motors.
If this had been a more or less straight line, I could have done some fancy computations to compensate for the hugely nonlinear nature of the current/duty-cycle ratio, but as you can see, it's not very straight at all...
This makes microstepping really hard!
Still, I managed to do a fairly decent torque-compensated half step by just using two sliders in a windows program, that would set the PWM values "live" by feeding it to the processor throug a COM port.
One slider is for the max value, and the other are for the reduced value.
Extending on this idea, I think it would be possible, by using SIN/COS to calculate the apropriate current value for each microstep, and using more sliders to adjust the PWM values "live" until the desired current for that microstep is showing on the A-meter.
Not a very neat way, but I beleive it could work.
Almost the same as using current sensing, but it's a one-off for each motor, and never have to be done again unless some of the components are changed (Power-supply, motor or transistors).