Welcome! Log In Create A New Profile

Advanced

Adjust PWM Frequency?

Posted by SJMaybury 
Adjust PWM Frequency?
October 16, 2020 03:40PM
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, 10kHz, 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 grinning smiley
VDX
Re: Adjust PWM Frequency?
October 16, 2020 04:09PM
... ist it controlled by "normal" PWM with a fixed frequency and only varying the pulse/pause ratio, or by a variable frequency?


Viktor
--------
Aufruf zum Projekt "Müll-freie Meere" - [reprap.org] -- Deutsche Facebook-Gruppe - [www.facebook.com]

Call for the project "garbage-free seas" - [reprap.org]
Re: Adjust PWM Frequency?
October 16, 2020 04:24PM
I think it is fixed frequency. Of course, measuring across the load I get different frequencies at different duty cycles but my (somewhat rudimentary) knowledge suggests that's just because the high-low ratio of the duty cycle has changed. It's just whatever the default in Marlin/arduino is, which sadly I don't know, I'm not even sure where to start looking for that little nugget of data!

EDIT: For sure while the PWM is at a stable output the frequency is also stable.

Edited 1 time(s). Last edit at 10/16/2020 04:25PM by SJMaybury.
Sorry, only registered users may post in this forum.

Click here to login