# Filtering PWM output to stepper motor coil to read voltage drop of sense resistor

#### Travm

Joined Aug 16, 2016
287

Voltage jumps at sense resistor all over the place.

#### Danko

Joined Nov 22, 2017
914
Voltage jumps at sense resistor all over the place.
Where you go...
But I guess you should dynamically change % of PWM instead analog stabilization, for economical regulation.

EDIT:

#### Attachments

• 1.3 KB Views: 0
Last edited:

#### crutschow

Joined Mar 14, 2008
24,704

#### Danko

Joined Nov 22, 2017
914
Last edited:

#### Danko

Joined Nov 22, 2017
914

#### Travm

Joined Aug 16, 2016
287
Danko,
That seems to achieve what i'm looking for, however we're still filtering Vsense independently.
I think the best route is to file this under future research and move forward filtering the Vsense to an acceptable average. The actual current ripple could be helpful in the application.

I also don't see how the flyback diode in the image above works connected in series with the power supply?

I've attached my .asc as well. What I see at Vsense is the voltage jumps up and down, rapidly.

#### Attachments

• 1.2 KB Views: 4

#### Danko

Joined Nov 22, 2017
914
Danko,
That seems to achieve what i'm looking for, however we're still filtering Vsense independently.
I am delighted to hear it.
I think the best route is to file this under future research and move forward filtering the Vsense to an acceptable average. The actual current ripple could be helpful in the application.
Good idea.
I also don't see how the flyback diode in the image above works connected in series with the power supply?
Inner resistance of voltage source V1 is zero, independent from its voltage. Therefore, when voltage of V1 becomes zero, anode of D2 is connected to ground (kind of cheating).
I've attached my .asc as well. What I see at Vsense is the voltage jumps up and down, rapidly.
These voltage pulses are really horrible.

#### ebp

Joined Feb 8, 2018
2,332
Returning to the original post:

What exactly do you want to accomplish with the motor current? Can you post a sketch of what the current waveform looks like and what you would like it to look like? After all the posts, I'm left with the feeling you are trying to accomplish something that simply isn't possible.

#### Travm

Joined Aug 16, 2016
287
Returning to the original post:

What exactly do you want to accomplish with the motor current? Can you post a sketch of what the current waveform looks like and what you would like it to look like? After all the posts, I'm left with the feeling you are trying to accomplish something that simply isn't possible.
I am trying to simulate an idea, where I can filter the current through a coil, and a sense resistor, so that there isnt any voltage ripple at the sense resistor.
I have a feeling you are correct. And the original suggestion of simply filtering the voltage at the sense resistor is the best path forward.

#### Travm

Joined Aug 16, 2016
287
I"ll keep playing with simulation and see if i can get anywhere else with filtering the coil.

#### crutschow

Joined Mar 14, 2008
24,704

#### crutschow

Joined Mar 14, 2008
24,704
I"ll keep playing with simulation and see if i can get anywhere else with filtering the coil.
My simulation of your circuit below looks okay.
The Sense voltage has very little ripple.

But for more realistic simulation, you should use the models for a real transistor and diode, not the idealized generic LTspice models.

#### ebp

Joined Feb 8, 2018
2,332
Travm, do you understand why the current in crutschow's simulation has the shape it does and what the current waveforms through the transistor and diode would look like? This may give you some clues about why you can't effectively change the motor current waveform.

Incidentally, I don't understand the waveforms versus the numeric values for PULSE and .tran that appear on his schematic.

#### Danko

Joined Nov 22, 2017
914
Sorry, I wasn't clear.
I was directing that request to the OP.
Sorry, for me it was omnidirected, like voice from Haven.
Excuse me.

#### Travm

Joined Aug 16, 2016
287
So I guess i was able to get this to work in simulation. I found the resonance too. I will probably build this as well. It shouldnt resonate as much when the current changes are smaller I would expect. The resonance is interesting, much to learn about that I think.

#### Attachments

• 1.3 KB Views: 1

#### Travm

Joined Aug 16, 2016
287
Travm, do you understand why the current in crutschow's simulation has the shape it does and what the current waveforms through the transistor and diode would look like? This may give you some clues about why you can't effectively change the motor current waveform.

Incidentally, I don't understand the waveforms versus the numeric values for PULSE and .tran that appear on his schematic.
I believe I do yes, the R-C filter on the voltage dropped by the sense resistor (Vsense) is charging and dischargin from the capacitor between pullses

#### Travm

Joined Aug 16, 2016
287
Another note, I just priced inductors, and wow. Definately a simple R-C on the sense line is the way to go. I was able to get spice simulating a neat clean power line, but the inductor I would need to buy to do this, \$ expensive.

#### crutschow

Joined Mar 14, 2008
24,704
So drop your desire to smooth the inductor current (which I see little need for) and just use an RC filter for the current signal, as I simulated in post #32.

#### crutschow

Joined Mar 14, 2008
24,704
I don't understand the waveforms versus the numeric values for PULSE and .tran that appear on his schematic.
Here are the PULSE parameters:

and here are the the .tran parameters:

#### ebp

Joined Feb 8, 2018
2,332
Thanks, crutschow. It was the "1000" in the pulse def and the fact the X axis starts at 0 that seemed odd.