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