Contnuous PWM Output while monitoring Input Changes

Thanks Again Tony

I tried it out today to see if I can get the Arduino Uno to read and follow the information from the LPT port output of MACH3 CNC software.

Attached is the code I ended up with.
I also attached a note with what I did on which line.

The code follows the MACH3 output very well.
I modified some lines here and there.
One area was to get the PWM to send the signal out at all times.... If that is not needed then I will move it back down to the end.
I added a Spindle pin as it turns on when the CNC Code tells it to and turns off when the CNC code tells it to or when any emergency switch is pressed.

A few questions as I noted

  1. Does the PWM output stay at the value that you send it or does it need to have the value sent over and over again????

  2. If the Spindle pin goes LOW can we ensure the PWM goes to "0"? (see code notation and info on Note)

Maybe we can swap the Enable_Pin for the Spindle_Pin to act as the one that make the UNO send out a PWM of "0" when the Spindle_Pin is LOW???
But when the Spindle_Pin returns to HIGH the PWM must return to the accumulated Step_Count_Val

This will be controlling a BLUE LED Laser which does burn wood and also will burn unprotected eyes.
Having the safety switches able to turn off the PWM is a must.... so every time the code stops or the emergency stop button is pressed the Spindle goes LOW.

I may need to have a way to trigger the UNO to reset the step value to "0" but that is something that we can add on later....

Once again your assistance has been a blessing

Many thanks

Duewy

PWM_LASER_MACH3.ino (5.15 KB)

Notes.txt (920 Bytes)