Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: rabso on October 31, 2022, 08:52:10 AM

Title: Early laser off with PWM
Post by: rabso on October 31, 2022, 08:52:10 AM
Hi everyone,
This is my first post in this forum but I have been around reading and learning, thanks to all

I have built my diy CNC and everything is fine using Mach3 with USB control board. Recently, I decided to add a laser to my machine, and I managed to make it working ok, but I have issue with early laser turning off.

Let me explain the wiring, I had to use relay as the laser needs 12v, and it's controlled by an output pin (M3/M5).
I have connected PWM pin with the laser to control its power (using S command).

As relay has some delays, I couldn't use command M11/M10. Instead, I used M3 command to turn on relay (laser is powered now) with S0 command to make no beam firing, then I used PWM to turn on/off the laser beam; S0 to cut it off and S10~S100 (depends on power I need) to turn on.

I have created a test G-code that make 4 lines with different feed rate each (start from left slowest) as follow:
Code: [Select]
(1001)
G90

G64
G54
G43 H65
M3 S0
G4 P2

G0 X-5. Y-10.
S100
G1 Y10. F100
S0

G0 X0. Y-10.
S100
G1 Y10. F200
S0

G0 X5. Y-10.
S100
G1 Y10. F300
S0

G0 X10. Y-10.
S100
G1 Y10. F400
S0
M5

G0 G53 Z0.
G0 X0. Y0.
M30

The result is that the higher feed rate I use the earlier laser will turn off as per attached photo, is this delay a limitation with mach3 same as M3/M5 as well? I have tried to write some text, but it will not connect lines as it's cutting off early.
Title: Re: Early laser off with PWM
Post by: TPS on November 01, 2022, 02:42:53 PM
IMHO you will have no luck with using M3 and S commands to control your laser properly
because these commands are not syncronized with motion commands.

the only two possibilities i know are:

- use M10/M11

- use the direction pin of a virtual axis (A/B/C) to switc laser on/off

there are o lot threads about this problem here on the board.
Title: Re: Early laser off with PWM
Post by: rabso on November 02, 2022, 01:22:18 AM
So, S command is behaving similar to M3.

I read several topics about M3 delays and possible solution. Unfortunately, I can't use M10/M11 commands as I am using a relay for laser power and relays have delays.

I am thinking of an idea to play with PWM signal; it's to use an output pin and connect it to laser PWM input, then activate it by M10/M11 commands. So, M11 = 5V mean 100% duty cycle (max power) and M10 = 0V mean zero duty cycle and beam will cut off. But I will not be able to control laser power level, so I will buy PWM Controller Module (same this https://www.aliexpress.com/item/1005003293196150.html (https://www.aliexpress.com/item/1005003293196150.html)) to control laser power manually. Hopefully it will work ok.
Title: Re: Early laser off with PWM
Post by: TPS on November 02, 2022, 02:19:09 AM
here:

https://www.machsupport.com/forum/index.php?topic=12444.msg265104#msg265104

Tweakie explained how to control this with a small pcb board.
Title: Re: Early laser off with PWM
Post by: rabso on November 02, 2022, 02:38:02 AM
I saw his post and as am civil engineer so really nothing I understood, D

I sent it to my brother maybe he will help. Moreover, I purchased the PWM module to try it and will post my result.

thank you
Title: Re: Early laser off with PWM
Post by: WhiteRoom Skis on January 01, 2023, 06:01:37 PM
It is possible to use a relay and use M10/M11. You need to figure out your ports and pins setting. I use it this way and it works well.