Hello Guest it is January 02, 2026, 02:10:26 PM

Author Topic: Can't seem to get PWM output  (Read 171 times)

0 Members and 1 Guest are viewing this topic.

Can't seem to get PWM output
« on: December 31, 2025, 07:02:37 PM »
Hello all,

I am trying to convert from a simple spindle on/off relay to full control with speed.  I have choosen Port 2 Pin 4 as my PWM port, and Port 2 pin 5 as my DIR port.  The DIR works fine and is switching the CNC4PC C41 board appropriately.    But I cannot get Mach4 to send PWM at all.  I am using an Ethernet Smoothstepper and have followed all of their instructions, and double checked that against the Mach4 instructions for PWM spindle, and that also jives with the CNC4PC published instructions.   I have an oscilloscope on the PWM line to monitor it.  I do have pins 2-9 on port 2 set as output, have set all appropriate settings in both the ESS spindle config, output pins, pins config menus as well as the spindle menu in Mach4 under general config.
I know the pin works ok as when I switch it back and forth from active high to active low in PINS Config, I see the Oscope trace move from 0 to 5 volts and back.  But regardless, I cannot get ANY PWM out.
Would anyone have any suggestions on where I might look to see my error?
Thanks
James
Re: Can't seem to get PWM output
« Reply #1 on: January 01, 2026, 11:35:52 AM »
OK, further testing has helped me narrow the problem down.

If I start Mach4, and hit either of the Spindle CW or Spindle CCW buttons, the appropriate relay is selected but I get no PWM.  If I go to MDI and issue a spindle command (M03 S24000 for example), everything works perfectly.  I get exactly the right PWM, the spindle spins to 24K CW.  From this point on, ALL buttons and sliders work perfect.  The On/Off CW/CCW and speed slider adjusts the spindle exactly how it's supposed to!  It's only when Mach4 starts up and before issuing an MDI command manually that PWM will not work.   I checked into the screenset (using wxRouter) and I see that the CW button calling a lua script called "StartCW()" which I assume is an internal script.

I am doing my best learning about screensets and Lua scripts, but it seems like when Mach4 starts, some variable isn't passed into the Lua script to give it a value for the PWM/Speed?  I'll continue learning about this, but if anyone has an idea on what might be missing on startup, I'd appreciate any pointers.
Thanks!

James
Re: Can't seem to get PWM output
« Reply #2 on: January 02, 2026, 06:00:50 AM »
The C25 has LEDs on all I/Os, so you should see the LED for the PWM light up as soon as it is sending 100%.  There are other parameters that you are not showing in the screenshots.

It may be easier if you set up a new test profile and just run the installer to configure the C25XP on it: https://www.cnc4pc.com/knowledge/article/249

That way, you will have a working profile from which you can copy the working configuration.

Arturo Duncan
https://cnc4pc.com