PWM to set a voltage

tim griff

Member
Hello,

I want to set a voltage ( between 1v and 3v) on a pin of the L297 stepper motor controller to limit current.

I 've looked at a commercial piece of equipment that outputs a pin on a PIC to a low pass filter onto Vref of L297 ( 10nF and 10K Resistor).


I'm OK working out the mark space ratio to get these voltage, but what might be a silly question is ..... does it matter the frequency of the PWM, sorry if this makes no sense.
regards
Tim
 

stan74

Senior Member
The pwm charges a capacitor and the voltage is an average. If you take too much current the voltage will fall faster so it's just for reference by a high impedence pin or meter. Frequency shouldn't change the voltage much. Try measuring it with a dmm and change frequency. Changing the mark space ,or period changes voltage.
 

inglewoodpete

Senior Member
I 've looked at a commercial piece of equipment that outputs a pin on a PIC to a low pass filter onto Vref of L297 ( 10nF and 10K Resistor).

I'm OK working out the mark space ratio to get these voltage, but what might be a silly question is ..... does it matter the frequency of the PWM, sorry if this makes no sense.
Since you are using an integrator to smooth out the pulses of the PWM, the size of the capacitor will have an inverse relationship with the frequency of the PWM. If you have already selected your capacitor, then the frequency should chosen to balance between ripple and lagging voltage across the capacitor.
 

tim griff

Member
Hi thanks for both replies.

The board already has these components and is driven by a PIC chip I'm putting in a PICAXE 40X2 to pick up the existing pin configuration.
The L297 pin draws a maximum of 10uA.

I understand the need to experiment but have you any thought were I start off from?

regards
Tim
 

rq3

Senior Member
Hello,

I want to set a voltage ( between 1v and 3v) on a pin of the L297 stepper motor controller to limit current.

I 've looked at a commercial piece of equipment that outputs a pin on a PIC to a low pass filter onto Vref of L297 ( 10nF and 10K Resistor).


I'm OK working out the mark space ratio to get these voltage, but what might be a silly question is ..... does it matter the frequency of the PWM, sorry if this makes no sense.
regards
Tim
Tim, it makes perfect sense. If you have a Picaxe PWM output charging and discharging a 10 nF capacitor through a 10 Kohm resistor, the time constant of the RC network is 10,000*0.00000001=0.0001 seconds. Assuming no load, 5 time constants ( or a 5 times faster "clock"), will keep the capacitor within 0.707% of your target value. So, 1/.0001 seconds=10,000 Hz. Times 5 is 50,000 Hz. This is perfectly do-able with a picaxe.

Your 10 microamp load is equivalent to a 500,000 ohm resistor if the RC network were to charge all the way to 5 volts, so it's kind of "in the noise" for your application. Having said that, you can make the DC signal out of the RC network "smoother" by either increasing the capacitor value, or increasing the PWM frequency.

As the current reference for your motor driver, what you are doing should work fine with the component values you have chosen at a PWM frequency of 50 KHz. There's no way the stepper driver can be clocked at anywhere near that, so there shouldn't be any serious interactions (famous last words). If you get glitches, increase the capacitor value, decrease the resistor value, or play with the PWM frequency, in that order.

This is all "back of the napkin", but you should be fine. I've not used the L297, but similar stepper drivers have similar current limit controls. Just be aware that the voltage that controls the stepper current may be (and usually is) considerably more restricted than the supply voltage of the stepper driver chip. Also, be aware that almost all stepper motors are current driven. Just because the date sheet says it is, for example, a "5 volt" stepper doesn't mean that the driver should run at 5 volts. It may need to run at 12, 24 or even 48 volts to "stuff" enough current into the stepper coils to get it to move properly at speed. The function of the current limit you are dealing with is to tell the driver that each coil has received enough current, because the driver voltage may be MUCH higher than you may be expecting to provide.

EDIT: Also keep in mind that once you get the L297 doing what you want, you'll still need to provide the high current switches that actually drive the motor. Devices like the Texas Instruments DRV8825 do both of the functions within one tiny package. Pros: Really small footprint on the circuit board. Built-in over-voltage, over-current, and over-temperature protection. Very inexpensive. Cons: they're a bear to solder, unless you have a reflow oven. But, they are available premounted on a circuit board from places like https://www.pololu.com/product/2133 or even https://www.amazon.com/DRV8825-Current-Stepper-Driver-Carrier/dp/B00B9G8CAE
 
Last edited:

tim griff

Member
Hi
I get it.
Thanks for the comprehensive answers.

The L297 drives a L298 the power supply for the motors is 24volts.
The project ,(to give this thread some context) I want to add a stepper motor to my rotary table(also dividing head) in my engineering workshop. Using a L297 on half steps with the rotary table 90:1 worm drive I need to send 36,000 steps for 360degrees.
I'm ok with setting position however, my next thoughts need to be how to implement some sort of "ramping"' I think I'll worry about that another day.
Regards
Tim
 
Top