<blockquote>
  <p>So it would seem that there is always a pulsing waveform across the windings whenever the stepper is energized, correct?</p>
</blockquote>

<p>Correct.</p>

<blockquote>
  <p>When the motor is holding its position, is there anything distinctive about the waveform?</p>
</blockquote>

<p><a href="https://www.youtube.com/watch?v=Phds2oFOIYg" rel="nofollow noreferrer">Yes there is</a>. This video contains a short example of what the current waveforms would look like.</p>

<p>If I understand you correctly: You want to detect filament events based by doing current sensing on the phases of the stepper motor. The simple of it is that, if the motor is not turning then the <a href="https://en.wikipedia.org/wiki/Counter-electromotive_force" rel="nofollow noreferrer">Back ElectroMotive Force</a> will be zero. As the speed increases the BEMF goes up, which causes the current levels to go down. Is this how stall detection in some driver systems work.</p>

<p>You may be able to determine if what you want to do is even practical by studying the fundamentals of stepper motor driving; both <a href="https://www.arrow.com/en/research-and-events/articles/voltage-versus-current-mode-control-in-stepper-motors" rel="nofollow noreferrer">voltage mode and current mode</a>.</p>

<p>Apart from that it may be just as practical to use a <a href="https://en.wikipedia.org/wiki/Rotary_encoder" rel="nofollow noreferrer">rotary encoder</a> upstream of the extruder motor to detect the filament movement, or lack thereof.</p>

<p>In your case detecting if the filament is present but not moving calls for stall detection. If the PWM pulse occurs but the rate at which the voltage increased (the slope) did not change, then there was no BEMF event. The lack of such an event would indicate that the rotor did not move. If there is no filament to push, then when the rotor moves it will <em>ring</em> (overshoot it's target position and fluctuate back and forth until it settles into the electrical position that the controller intended), because the mechanical load has changed.</p>

<p>For a NEMA17 stepper, these would be very small change in a very brief event. I would start with installing <a href="https://www.sparkfun.com/products/14544" rel="nofollow noreferrer">current sensors</a> on both phases, and then doing some signal processing on top of that. </p>

CC BY-SA 4.0
2019-05-06T17:21:32.403Z
You're in for some signal processing here. This becomes more of an electronics.stackexchange.com type question.
user77232
CC BY-SA 4.0
2019-05-16T15:19:54.627Z
@user77232, I watched the video at your first link, and it didn't address the difference between stasis and motion, nor did it discuss the pulsing voltage found on stepper windings.  You state that the OP wants to measure current, but most likely the OP can much more easily measure voltage.  Your comment about BEMF reducing the current is partially correct.  Many stepper motor drivers automatically correct for that because they sense the current and servo the PWM to deliver a commanded current.  One would need to measure the PWM waveform plus add a sense resistor and measure the current.
cmm
CC BY-SA 4.0
2019-05-17T01:28:39.330Z
Well then he could try mounting a microphone near the drive gears and train an AI to detect the different sounds that the different conditions make :)
user77232
CC BY-SA 4.0
2019-04-07T18:37:34.200Z
Thanks user77232 for the detailed reply.  So when the extruder is in a hold (energized but not extruding), the filtered waveform won't have the sinusoid overall shape or the steps or microsteps, just a flat line at some level?

The rotary encoder would only show if the filament is moving, not when it is *supposed to move*.  I'm trying to determine both, and look for a discrepancy to decide the print needs to be paused.  For actual movement, probably something like the Prusa scheme that uses an optical mouse camera to sense movement
Bill Waslo
CC BY-SA 4.0
2019-04-07T18:38:00.680Z
Though I'd use a rotary pinch wheel and sense movement of that with the mouse chip, to avoid issues with how various filaments reflect light.
Bill Waslo
CC BY-SA 4.0
2019-04-07T18:38:37.523Z
The rotary encoder seems like it might give false reports on some cases, such as printing slowly - with flexible filament for instance- with a very small nozzle, in which case the filament linear travel would be very, very slow.  And then with a Volcano or Supervolcano at maximum melt rate, a geared-up rotary would spin like mad!
Bill Waslo
CC BY-SA 4.0
2019-04-06T16:32:32.917Z
2019-05-15T17:46:27.273Z
2019-05-15T17:46:27.273Z
user77232
<p>There is nothing you can do to monitor the extruder stepper motor to assure that filament is being fed when it should be fed.  A common condition is where the filament binds but the extruder stepper continues to move as commanded.  The drive pully strips the dents it presses in the filament, and grinds down the filament.  The extruder still steps, and the filament does not.</p>

<p>You can reduce this for particular filaments by increasing the pressure on the filament by the drive pully, but the optimum pressure varies with the filament.  For instance, I've found that PET needs a lesser pressure than PLA.</p>

<p>@User77232 suggests using a separate rotary encoder to detect the motion of the filament through a different sensor.  This may be better, since you can detect a filament jam with extruder motion.  If you are using a PTFE tube to deliver filament to the extruder, the encoder can be mounted at the other end of the tube.  You may need to make allowance for some compression and stretch of the filament in the tube, which could delay detecting "lack of movement".</p>

<p>I had hoped that the Triaminic TMC2100 chips (spec <a href="https://www.trinamic.com/fileadmin/assets/Products/ICs_Documents/TMC2100_datasheet_Rev1.09.pdf" rel="nofollow noreferrer">here</a>) would provide detection of drive torque by watching the back EMF, but reading the spec didn't look helpful.  There was an old patent (that should be long expired) that detected the current needed to move a stepper motor to achieve faster acceleration and quieter operation, but I didn't find on the Triaminic driver a useful torque limit signal.  If one could detect the torque required, one could set a peek torque value that is lower than the initial filament strip torque.</p>

<p>Perhaps one could mount the extruder stepper motor with a compliant mount, perhaps something like a TPU or rubber material, and use a strain gauge to measure the stretch of the mount.</p>

CC BY-SA 4.0
2019-05-16T15:53:38.507Z
2019-05-16T15:53:38.507Z
cmm
<p>This may be a long shot, but I was wondering if the signals seen across a stepper motor's windings could indicate whether the stepper was being told to move over some short time period.  This is in particular for the stepper used on extruders.</p>

<p>I've read that PWM in used in stepper drivers and controls current patterns to move the motor.  And that a current must also be maintained through the windings if the motor is to hold its position.  So it would seem that there is always a pulsing waveform across the windings whenever the stepper is energized, correct?  When the motor is holding its position, is there anything distinctive about the waveform?</p>

<p>This is for a filament sensor I'd like to make.  The sensor would be located at the extruder motor.  It would monitor movement/flow of the solid filament.  A lack of filament flow could be because of filament runout, tangled or caught filament, or non-extruding travel moves. I'd like to be able to tell the first two causes from the last one (when it's not supposed to be extruding for some hundreds of milliseconds or so).  It would also be nice to tell 'no directed movement' from 'very slow movement' which would happen with small nozzles, slow speed or other slow extrusion situations.</p>

<p>I watched the waveforms with an oscilloscope while printing, but travel moves were quick and relatively rare, so I couldn't definitely see if there was something I could use during those times. Could I just filter the pulse waveform (what corner frequency?) to get an approximation of the current waveform going through the coils -- on the idea that the waveform should resemble a DC level during non-extruding but still energized times.  Perhaps another low-pass filtering of that DC level, or a high-pass of the waveform to indicate directed extrusion?  Using DSP on a micro, of course.</p>

<p>Are there any experts here on the subject of low-level stepper motor control?</p>

CC BY-SA 4.0
2019-05-15T23:28:54.377Z
Yes, there is an input called DIR, so 1 is one direction 0 is the other direction; There is another called STEPS, this receives pulses, if not so the motor is stopped.
Fernando Baltazar
<extrusion><stepper-driver><stepper><extruder-driver>
Is there any (relatively simple) way to determine whether a stepper is being directed to move by the voltage signal across its winding?
Bill Waslo
# Is there any (relatively simple) way to determine whether a stepper is being directed to move by the voltage signal across its winding?

(Asked by: username_0 on 2019-04-06)

This may be a long shot, but I was wondering if the signals seen across a stepper motor's windings could indicate whether the stepper was being told to move over some short time period. This is in particular for the stepper used on extruders.

I've read that PWM in used in stepper drivers and controls current patterns to move the motor. And that a current must also be maintained through the windings if the motor is to hold its position. So it would seem that there is always a pulsing waveform across the windings whenever the stepper is energized, correct? When the motor is holding its position, is there anything distinctive about the waveform?

This is for a filament sensor I'd like to make. The sensor would be located at the extruder motor. It would monitor movement/flow of the solid filament. A lack of filament flow could be because of filament runout, tangled or caught filament, or non-extruding travel moves. I'd like to be able to tell the first two causes from the last one (when it's not supposed to be extruding for some hundreds of milliseconds or so). It would also be nice to tell 'no directed movement' from 'very slow movement' which would happen with small nozzles, slow speed or other slow extrusion situations.

I watched the waveforms with an oscilloscope while printing, but travel moves were quick and relatively rare, so I couldn't definitely see if there was something I could use during those times. Could I just filter the pulse waveform (what corner frequency?) to get an approximation of the current waveform going through the coils -- on the idea that the waveform should resemble a DC level during non-extruding but still energized times. Perhaps another low-pass filtering of that DC level, or a high-pass of the waveform to indicate directed extrusion? Using DSP on a micro, of course.

Are there any experts here on the subject of low-level stepper motor control?

**Tags:** extrusion, stepper-driver, stepper, extruder-driver
> **Comments:**
> **username_1**: Yes, there is an input called DIR, so 1 is one direction 0 is the other direction; There is another called STEPS, this receives pulses, if not so the motor is stopped.  

---

## 2 answers

### Answer by username_2 on 2019-04-06. Score: 2

> So it would seem that there is always a pulsing waveform across the windings whenever the stepper is energized, correct?

Correct.

> When the motor is holding its position, is there anything distinctive about the waveform?

[Yes there is](https://www.youtube.com/watch?v=Phds2oFOIYg). This video contains a short example of what the current waveforms would look like.

If I understand you correctly: You want to detect filament events based by doing current sensing on the phases of the stepper motor. The simple of it is that, if the motor is not turning then the [Back ElectroMotive Force](https://en.wikipedia.org/wiki/Counter-electromotive_force) will be zero. As the speed increases the BEMF goes up, which causes the current levels to go down. Is this how stall detection in some driver systems work.

You may be able to determine if what you want to do is even practical by studying the fundamentals of stepper motor driving; both [voltage mode and current mode](https://www.arrow.com/en/research-and-events/articles/voltage-versus-current-mode-control-in-stepper-motors).

Apart from that it may be just as practical to use a [rotary encoder](https://en.wikipedia.org/wiki/Rotary_encoder) upstream of the extruder motor to detect the filament movement, or lack thereof.

In your case detecting if the filament is present but not moving calls for stall detection. If the PWM pulse occurs but the rate at which the voltage increased (the slope) did not change, then there was no BEMF event. The lack of such an event would indicate that the rotor did not move. If there is no filament to push, then when the rotor moves it will *ring* (overshoot it's target position and fluctuate back and forth until it settles into the electrical position that the controller intended), because the mechanical load has changed.

For a NEMA17 stepper, these would be very small change in a very brief event. I would start with installing [current sensors](https://www.sparkfun.com/products/14544) on both phases, and then doing some signal processing on top of that.

> **Comments:**
> **username_0**: Thanks user77232 for the detailed reply.  So when the extruder is in a hold (energized but not extruding), the filtered waveform won't have the sinusoid overall shape or the steps or microsteps, just a flat line at some level?  The rotary encoder would only show if the filament is moving, not when it is *supposed to move*.  I'm trying to determine both, and look for a discrepancy to decide the print needs to be paused.  For actual movement, probably something like the Prusa scheme that uses an optical mouse camera to sense movement  
> **username_0**: Though I'd use a rotary pinch wheel and sense movement of that with the mouse chip, to avoid issues with how various filaments reflect light.  
> **username_0**: The rotary encoder seems like it might give false reports on some cases, such as printing slowly - with flexible filament for instance- with a very small nozzle, in which case the filament linear travel would be very, very slow.  And then with a Volcano or Supervolcano at maximum melt rate, a geared-up rotary would spin like mad!  
> **username_2**: You're in for some signal processing here. This becomes more of an electronics.stackexchange.com type question.  
> **username_3**: @user77232, I watched the video at your first link, and it didn't address the difference between stasis and motion, nor did it discuss the pulsing voltage found on stepper windings.  You state that the OP wants to measure current, but most likely the OP can much more easily measure voltage.  Your comment about BEMF reducing the current is partially correct.  Many stepper motor drivers automatically correct for that because they sense the current and servo the PWM to deliver a commanded current.  One would need to measure the PWM waveform plus add a sense resistor and measure the current.  
> **username_2**: Well then he could try mounting a microphone near the drive gears and train an AI to detect the different sounds that the different conditions make :)  

---

### Answer by username_3 on 2019-05-16. Score: 0

There is nothing you can do to monitor the extruder stepper motor to assure that filament is being fed when it should be fed. A common condition is where the filament binds but the extruder stepper continues to move as commanded. The drive pully strips the dents it presses in the filament, and grinds down the filament. The extruder still steps, and the filament does not.

You can reduce this for particular filaments by increasing the pressure on the filament by the drive pully, but the optimum pressure varies with the filament. For instance, I've found that PET needs a lesser pressure than PLA.

@User77232 suggests using a separate rotary encoder to detect the motion of the filament through a different sensor. This may be better, since you can detect a filament jam with extruder motion. If you are using a PTFE tube to deliver filament to the extruder, the encoder can be mounted at the other end of the tube. You may need to make allowance for some compression and stretch of the filament in the tube, which could delay detecting "lack of movement".

I had hoped that the Triaminic TMC2100 chips (spec [here](https://www.trinamic.com/fileadmin/assets/Products/ICs_Documents/TMC2100_datasheet_Rev1.09.pdf)) would provide detection of drive torque by watching the back EMF, but reading the spec didn't look helpful. There was an old patent (that should be long expired) that detected the current needed to move a stepper motor to achieve faster acceleration and quieter operation, but I didn't find on the Triaminic driver a useful torque limit signal. If one could detect the torque required, one could set a peek torque value that is lower than the initial filament strip torque.

Perhaps one could mount the extruder stepper motor with a compliant mount, perhaps something like a TPU or rubber material, and use a strain gauge to measure the stretch of the mount.


---

