Anyone interested in a microstepping stepper object?
pedward
Posts: 1,642
So, I wrote code to do real sin/cos microstepping with the Prop counters. Presently it's just a demo/proof of concept that exists as a bit of forum code.
I haven't seen much enthusiasm for any of the code I've written thus far, so I'm trying to decide if there would be any demand for a microstepping driver?
I'm talking about a driver object that implements all of the microstepping commutation in the Prop, so you would only need a quad half-h-bridge driver.
I would plan on implementing the driver with table based values for the current control, so you would tune the table values to give you the stepping current
you want for each microstep. The driver would consume 1 prop and 4 pins per motor driven, which is fairly cheap. It would implement step/direction to
start, later on a motion controller could be implemented to drive acceleration and speed. Right now I have done 64 microsteps, which is 1/16th microstepping.
This is twice the resolution of most commercial driver boards, I would probably have a setting for 1/2, 1/4, 1/8, and 1/16th microstepping.
I haven't seen much enthusiasm for any of the code I've written thus far, so I'm trying to decide if there would be any demand for a microstepping driver?
I'm talking about a driver object that implements all of the microstepping commutation in the Prop, so you would only need a quad half-h-bridge driver.
I would plan on implementing the driver with table based values for the current control, so you would tune the table values to give you the stepping current
you want for each microstep. The driver would consume 1 prop and 4 pins per motor driven, which is fairly cheap. It would implement step/direction to
start, later on a motion controller could be implemented to drive acceleration and speed. Right now I have done 64 microsteps, which is 1/16th microstepping.
This is twice the resolution of most commercial driver boards, I would probably have a setting for 1/2, 1/4, 1/8, and 1/16th microstepping.
Comments
Over the last weekend I built up a stepper driver board with an old L6219 H-bridge chip. It's not quite running yet, but all the chip support parts are in place; all it needs are wires to the propeller board and wires for a stepper to plug into. Plus propeller code.
I've never used this chip before. But it looks like for each of the two H-bridges, besides the phase pin, it includes two logic pins to give four levels of current strength for the driver.
Would your microstepper be useable with this chip?
If you're sure it works, then by all means please do share.
If you're so inclined, be sure to add some description in the code that describes how it works, how things should be wired, and provide plenty of comments along the way.
For that, people will be eternally grateful.
Thanks!
I am always interested in articles that pertain to stepper motor control. If you have a good plan, then go for it!
In my opinion, the BIGGEST problem with stepper motors is current control, so whatever solution you develop, please document it very well.
Bruce
The idea is that an PWM signal has a normal and inverse output, where 50% are related to 0 output voltage. I do it this way, that the duty cycle is always more than 40% to have a first minimal time to do some house keeping.
Lets say we want a +50% level, that is 75% duty cycle. This is normal operation. Next, lets have -50% level, that is 25% duty cycle. In this case I just toggle the invert the output signals and again have 75% of duty cycle.
Next: I want to generate two phases in one cog. So I need two transitions, where they can change their sequence. To overcome this problem I decided to have different switching patterns for every octant of a full circle.
The PWM process is feed with two transition times. The cycle starts with both outputs on one level, then the first and second transition takes place both channels end up on the second level.
Also there is a mode which determines the pattern to output.
I didn't find the time to transfer the pattern selection in the ASM driver, what certainly is not a big deal. So the driver is to feed with angle and amplitude.
I use a framework I always apply for starting and running parallel processes.
If a L293 is used (only one input for every half bridge, out pin 0, 2, 4, 6 are used for channel A and B.
The demo just spins up and down a motor changing direction.
About current control:
There is no need to measure current if the PWM amplitude is adjusted at stand still to create the torque wanted. When speeding up, the amplitude should be increased proportional to speed. That should result in a constant current even at changing speed.
Enjoy!
ErNa
The stepper motor is modelled as a cosine and sine wave through 360 degrees. I generated a table of 64 integers to map all 64 steps in a complete cycle to degrees in a circle. Then I use the sine/cos functions to generate +/- 255 values, for a range of 255-0-255, with 0 being 50% duty cycle. I pack 2 signed values into 1 32bit value and pass that to the PASM routine. The beauty is that the PASM routine runs continuously, so the SPIN top end doesn't have to be time conscious.
Current is a function of the sin/cos value. This is something that probably needs a "fudge" factor setting to adjust for different motors. The mathematical model doesn't match how the motor responds, so you end up having to generate non-linear stepping values to get linear output from the motor.
No doubt there will be some tweaking to get it 100% right, but testing has shown the back EMF is dramatically reduced. I wrote a half stepping driver and that would top out at 3000 steps per second in half stepping, with acceleration (on the test motor). The microstepping control would run at 34,000 steps per second, without acceleration needed. Acceleration control seems to improve the top speed by ramping the rate, even a relatively short time is enough to boost the step rate by 25-50%.
Right now we are suffering the aftermath of a nasty windstorm that caught PG&E with their pants down. It's going on 72hours since we had utility power, so I'm running off a generator... ;(
I have a mini stepper from an optical drive sitting on my desk, running a simple SPIN loop with a delay of 1600 clocks. This is the highest step rate I've been able to achieve so far. I added a Vin terminal block to my PPDB and I'm running the motor from 9v. This necessitated figuring out a static current control method. The simple solution appears to be altering the period of the PWM, so the effective period is changed, while the input values stay the same.
The counter is running at 80Mhz, with a PWM period of 256 cycles (80Mhz / 256 = 312.5Khz), using the PWM modulation code from the AN001 app note. The period is at minimum 256, because the input range is +-256 (just what I chose because it's less than 512, and I can detect packed signed values with an immediate #$1FF comparison. If you adjust the period of the waitcnt in the PASM COG, it reduces the effective duty cycle of the PWM, reducing current. You could couple this with a current sensing resistor to do automatic current regulation, but that's not on the immediate roadmap.
Reducing the current of the motor also reduces the torque, power dissipation, and heat. I'm shooting from the hip, but I would assume that stepper motors will benefit from field weakening at higher speeds, just like 3 phase motors. The reason (recalling from memory) is that as the speed increases, so does the back EMF. When increasing speed, you increase voltage to overcome the back EMF and continue to accelerate. You reach a point at which you cannot increase the voltage any more, so you have to cut back the current and (more advanced drives do this) adjust the phase relationship so that the generated magnetic field leads the induced magnetic field, and this phase lead increases as speed increases, like timing advance on a distributor. This is again, food for thought and not on the immediate roadmap.
I'm not going to try and get all fancy with the stepper driver, I think that field weakening via adjusting the period could improve the top speed of steppers. The top speed, or steps per second, has always been a real problem to overcome, mostly because the back EMF is the biggest factor. With the software approach, you have complete control over the waveform, so you can achieve a more tailored set of parameters than a one-size-fits-all chip on a board. The optimum saturation point changes with speed and torque output. If you want higher speed, but don't need a lot of torque, you could tweak it one way. If you need a lot of torque or holding power, you could tweak it another way.
I've been playing with the sample program I wrote so I could decide what features I need to implement for a good starting point.
I have considered the following to be important:
Step selection: 1, 1/2, 1/4, 1/8, and 1/16 step
Current setpoint: You can select a percentage from 0-100% or specify an exact period. This is the PWM duty of the driving signal.
Step current offset: You can specify a scaler value to be used in calculating the current values. This is the minimum current value to generate movement of the stepper motor.