Welcome! Log In Create A New Profile

Advanced

Stepper driver current question

Posted by GeertB 
Stepper driver current question
May 11, 2009 12:23PM
I'm still trying to get a better understanding of the behavior of my stepper motors in order to drive them faster and quieter. Now I've wired up my Arduino to both control the steppers as well graph the Vsense currents, I see some effects that I find hard to understand.

On an unloaded motor, the behavior is as I expect after learning more about the way the Stepper Motor Driver 1.2 works (thanks, nophead):

The first part of the graph is where no current is flowing through the driver, as induction means current through the motor can't reverse instantaneously. Then current builds up gradually until we get chopper action, which essentially shuts out the sense resistor resulting in a very blocky waveform. The scale is here 0.5ms/div and 0.5V/div and the motor is stepping at 800 half steps per second.

However, when loading the motor, an initial "bulge" appears with high current, followed by a gradual drop and eventual climb to the chopping current. I wonder, why is this, and what causes this effect?

If I load the motor enough (to the point it's about to lose steps), there even is chopping action very close after activation, even though the total time to reach a stable full current state increases from 3ms to 4ms.






At higher speeds (sorry, forgot to record exactly which, guess about 1200hs/s), the phenomenon gets even more pronounced:


Thanks in advance for any clues or insights! I hope to find a way to automatically characterize stepper motors and find performance values for them that can then be used to optimally drive Repraps and Repstraps without losing steps.

-Geert
Re: Stepper driver current question
May 11, 2009 03:59PM
Hey, nice plots! Is that from data you collected on the Arduino, or a scope? Would love to see more detail on how you did that!

As a first guess as to the cause of your "bulges" in the current, I would think that the back EMF generated by the stepper coil as it begins to turn is responsible for the dip in current that starts around 2ms. As the load on the stepper is increased (or as the speed is increased for a given load), it takes longer for the stepper to get up to speed for that step, and so you get some oscillation in the field current. Mechanical oscillations (noise) also probably show up in there somewhere as well - which of those tests were the most noisy?

Running a stepper near it's limit is like running a well tuned synchronous AC motor; I would think that would be one of the smoothest spots.

I hear multistepping drivers are much quieter overall; might be worth trying.

Wade
Re: Stepper driver current question
May 11, 2009 04:14PM
Geert,
It is not just inductance that resists the build up of current, back EMF has a big effect also.

When the motor is stationary the current builds up as you would expect with a simple inductor. When the motor is turning the current builds up slower because the motor is generating a voltage that subtracts from the applied voltage.

As you apply load, the rotor is held back and lags the position it would be without load. That causes the back emf to peak later so the current builds up faster to start with.

If you look at the first curve you see it curls the wrong way for an inductor. I.e. it should rise quickly to start with and then level off. The back emf and the inductive curves are both occurring together so you see the sum of the two.

In the last curve the inductive build up happens first and is roughly the correct shape, then the rotor moves towards a magnet pole and the generated EMF reduces the current. Then it passes the pole and the generated emf reverses, so the current rises again.

Normally with a chopper drive you would have a bigger supply voltage to motor voltage ratio, so the BEMF effect is less dramatic. Wiring bi-polar parallel rather than serial would improve things in that respect if you are using 8 wire motors.


[www.hydraraptor.blogspot.com]
Re: Stepper driver current question
May 12, 2009 04:34PM
Wade, thanks for your comments. I'm using a Scope function in a Processing app (see processing.org). It simulates an old-fashioned analog scope. At the moment there is little if any user interface: changes to scale or serial port speed and the like need to be done in the source. This is not a big issue for me, as it's interpreted code anyway.

I'll attach the code to this mail. Basically, you'd use it instead of the serial monitor in Arduino (or a terminal program) to connect to the board. Then on the Arduino, you have a certain incoming byte on the serial port execute the test (start stepping, wait for a trigger) and then you call oscilloscope(int pin, int sample_time) followed by dump_scope() at a time you'd like to transmit the data (131 bytes).

Unfortunately, I called both the Arduino and the Processing sketches Scope, and they got the same extension as well. Just see which is which. Warning: this code comes with absolutely no warranty. I license it on GPL v3 terms.

-Geert
Attachments:
open | download - Scope.pde (2.9 KB)
open | download - Scope.pde (3.4 KB)
Re: Stepper driver current question
May 13, 2009 12:22AM
Nophead,

To measure just inductance, I just toggle the "enable" line on the stepper motor driver board. At my low testing current (Vref = 250mV, I=500mA, this has been the setup I used all along, not 0.5V as I mentioned earlier), the build-up is much quicker than I see when stepping the motor due to the lack of BEMF.

It doesn't quite look like an exponential build-up yet, but that may be because I'm only looking at the very start of the graph and have the rest chopped off due to my low Vref. Indeed, if I look at how the graph changes at higher voltages, I see a bit more flattening but nothing too much. If I manually try to turn the motor a bit while running this experiment (flipping the enable input without stepping), I see the build-up time lengthening to 3 ms again as well as lots of different interfering waveforms.

I'm starting to think is that at about 1600 hsps, which seems to be almost the absolute top speed in serial setup, regardless of drive current or stepper mode, the BEMF might about cancel out the driving voltage. Does that sound at all plausible? I might connect two steppers together using a coupling and then use the second motor as a generator and measure the voltage.

What does surprise me though is that even without BEMF, current can't build up much past 500 mA when stepping at 1000 hsps, yet there is still good torque at such speed with this RRRF setup (Keling NEMA23 motor, SMD v1.2 driver), I'll connect the motors in parallel as well (which I plan to use eventually anyway) and see how that changes things.

-Geert
Re: Stepper driver current question
May 13, 2009 06:27PM
Geert,
Quote

It doesn't quite look like an exponential build-up yet, but that may be because I'm only looking at the very start of the graph and have the rest chopped off due to my low Vref. Indeed, if I look at how the graph changes at higher voltages, I see a bit more flattening but nothing too much.

Yes the idea of a chopper drive is to operate with a supply voltage significantly bigger than the motor voltage, so that the current rises quickly. It is heading off on an exponential to a much higher value but gets chopped off at the current limit. That means you only see the start of the exponential, where it is almost linear.

Unfortunately with the L298 you can lose about 4V so you are effectively driving the motor from only 8V. In bipolar serial mode the Keling motor is rated 6.12V 1.7A, so 8V drive is not going to increase the speed much.

Here are a couple of pictures to illustrate: -

The same motor in bipolar parallel driven from 12V with a MOSFET drive. It is being full stepped at 1000pps.



It is going faster and the voltage is bit higher than your case but the BEMF is still dominating. If I increase the speed I can actually get a situation where the BEMF causes the supply voltage to rise several volts. That could cause PC power supplies to shut down.

One thing to note is that with the A3977 I am using the clamping diodes are internal so the current can flow both ways through the sense resistor, hence the sense voltage goes negative. With the L298 you only see a positive voltage.

Here is a picture with everything the same but with a 35V supply.



Here you can see the rise is much faster and the BEMF is lost in the chopping.

I think the rise in current at the end of the step must be a BEMF effect. The chopper has a fixed off time and a minimum on time so it can't keep the current low enough when driven from a high voltage and the BEMF is adding to it as well.

Quote

I'm starting to think is that at about 1600 hsps, which seems to be almost the absolute top speed in serial setup, regardless of drive current or stepper mode, the BEMF might about cancel out the driving voltage. Does that sound at all plausible? I might connect two steppers together using a coupling and then use the second motor as a generator and measure the voltage.

Yes at 8V the BEMF is canceling out most of the drive at that speed and at 12V it is canceled out at 2000 fsps.

The pull in speed, i.e. instantaneous start, will be around that speed. It is determined by the torque and the moment of inertia. Increasing the current increases the torque so will increase the pull in speed. Increasing the voltage to make the current rise faster also increases it a little.

Where the high voltage really helps is that there is more torque left at higher speeds, so you can still drive a load. The pull out speed is where the torque falls to less than required and the motor stalls. That is much faster than the pull in speed, but you can only get to it with acceleration, and only stop from it by deceleration. The motor is said to be slewing when in between pull in and pull out.

Quote

What does surprise me though is that even without BEMF, current can't build up much past 500 mA when stepping at 1000 hsps, yet there is still good torque at such speed with this RRRF setup (Keling NEMA23 motor, SMD v1.2 driver), I'll connect the motors in parallel as well (which I plan to use eventually anyway) and see how that changes things.

500mA is about 30% torque. That is about the same as a good NEMA17 and is enough to drive a Darwin. I use about 1A in bipolar parallel, which is the same torque. Unless you need the full torque from the motor I would recommend parallel connection.

The reason it is not enough torque to start is that you are trying to accelerate the inertia of the rotor over only one step.

Edited 2 time(s). Last edit at 05/13/2009 06:33PM by nophead.


[www.hydraraptor.blogspot.com]
Re: Stepper driver current question
May 13, 2009 10:11PM
Thanks so much for your insights. I've studied the "Stepper Motors, Fundamentals, Applications and Design" book by V.V.Athani cover to cover (see [www.amazon.com] for preview), but still get the most from your posts.

What time base do you have in the scope pictures above? Also, are you measuring voltage over Rsense or something else? I was wondering about pull out rate, as it seems indeed like I can start/stop at 1600 hsps without acceleration, so I never really get into slew territory, right?. BTW, I also have not found any significant speed difference in half/full stepping. In my benchmarks I do use acceleration profiles, but just found they are not really necessary yet.

The problem of rising supply voltage can be mitigated by running multiple stepper drivers (or heaters or other power consuming devices) of the same supply. Any returned energy from BEMF will then be used by the other drivers (assuming they don't step as fast and in sync).

-Geert
Re: Stepper driver current question
May 14, 2009 04:29AM
Yes this is the voltage across one of the sense resistors.

The time base is 0.2ms / div. I.e, the whole step is 1ms, so this is five revs per second. That would be 200mm/s on a Darwin and about 5mm/s on a McWire. The pull in speed is a bit lower on Darwin because of the extra mass, but I got 150mm/s on X and 120mm/s on Y.

The reason I showed full step is that half step is more complicated on the A3977. The current is reduced to 70% when both coils are on. That gives equal torque on each step and gives smoother running.

Yes you are not in the slew region if you can start in a single step. If you think about it you are accelerating a significant mass to a significant speed in a very short time, which is why it needs high torque just to start. Once started there is little friction, so all that torque becomes available.

With a few steps of acceleration you should be able to go a lot faster with an unloaded motor.

This is the Python code I use to make a table of linear acceleration steps
    def set_ramp(self, steps, run_delay):
        table = pack('>h',steps)                #start with the number of entries
        k = 4 * run_delay * run_delay * steps
        last = 0
        for i in range(steps):
            t = sqrt((i + 1) * k)
            table = table + pack('>h', int(round(t - last)))
            last = t
        return table
It uses a square root so I calculate it on my host and send it to the controller.

The table is used at the start and the end of a line segment with this code in the Bresenham loop :-

            if(steps < ramp_length) {    // near end of line ?
                del = ramp[steps];
                if(del < run_delay)
                    del = run_delay;
            }
            else
                if(stepped < ramp_length) {  // near start of line ?
                    del = ramp[stepped];
                    if(del < run_delay)
                        del = run_delay;
                }
                else
                    del = run_delay;  // middle of line, use the specified speed

To maintain high torque at high speed you will need a higher voltage though.

Yes other loads would keep the supply voltage down but I only see the effect when the BEMF is big enough to swamp the chopper. It may explain some problems people have reported in the past with PC power supplies shutting down or failing. These tests were done with a linear bench supply.

Edited 1 time(s). Last edit at 05/14/2009 04:31AM by nophead.


[www.hydraraptor.blogspot.com]
Re: Stepper driver current question
May 14, 2009 11:10PM
Hi Nophead,

You wrote:
-------------------------------------------------------
> The reason I showed full step is that half step is more complicated on the A3977.
> The current is reduced to 70% when both coils are on. That gives equal torque on
> each step and gives smoother running.

Actually, I noted that a while ago with the RRRF SMD-1.2 board when trying to find a good dither function for smooth running at lower speeds. I tried to recall some high-school physics today and figure out a modification of the RRRF board to do the same adaptive torque when two phases are active. The idea is that there already are 4k7 resistors between the sense resistors and pins 13 and 14 of the L297. By adding some more resistors, it would be possible to let the second active phase help pushing up the sensed current, resulting in earlier chopping.

For this I'm assuming we want 1A with 1 phase active and .7A with two phases active. So, respectively 0.5V and 0.35V at the sense resistors. If by chance my calculations are right, 11k resistors at the following locations would magically achieve 1.42V at the sense inputs of the L297 with either that phase at 1A or two phases at 0.7A.

11k between L298 pin 1 and L297 pin 13
11k between L298 pin 15 and L297 pin 14
11k between L297 pin 11 and L297 pin 14
11k between L297 pin 12 and L297 pin 13

This is an easy enough modification that I'll try it next week when I find a moment.

-Geert
Sorry, only registered users may post in this forum.

Click here to login