Sunday, October 18, 2020

Adjusting PWM Frequency on D6? (RAMPS 1.4)

Hi all, Modifying Marlin to work with my CNC setup running on RAMPS1.4, namely configuring the spindle speed control to D6 PWM. I have a chinese speed controller that accepts a PWM input via optocoupler. However it looks like it uses Mach 3 (~12V VPP 1,000-10,000 Hz as shown by the documentation I was able to hunt down. Scaled up the voltage from PWM via P55NF06L with 10k pull-up, voltmeter says the 0-12V PWM works nicely (yay). Problem is frequency is way too slow by the look of things. When PWM is off, Spindle reads ~0V. But then no matter how I scale it, it's always stuck at 52V. I read that PWM on all pins is 490/980Hz by default, but can be adjusted up to 8MHz by adjusting the timers. Then reading into some Marlin documentation I discover that D6 uses TIMER4A. This looks like a custom timer breakout that doesn't quite fit the naming convention I've seen elsewhere on guidance for changing frequency.

Essentially I'm a little bit in over my head, looking to get pin D6 running at say, 5kHz, smack-bang in the middle of the accepted Mach3 range, and I would love any guidance on how!

Thank you very much for your time :D

No comments:

Post a Comment