Laser turns off after following code is sent after M3
-
I have messed around for about 2 days trying to figure out how to correctly run my laser from the Duet 2 wifi board as a tool running along side by extruder using a 24 PSU for controls and 12V PSU for my heated bed and laser.
There is a quick flash when I first go into laser mode which I am fine with. The unit turns on and off and changes power as I have expected based on giving it different codes. However I have one huge issue that boggles my mind. As soon as the next line of g-code is sent, the laser turns off. I can manually tell it to turn on with a M3 command but as soon as I tell the system to move in any direction, the laser turns off.
Please help! the following is my setupHardware:
I have the 12VDC from the PSU to the laser control board and then negative terminal of the control board to the E1- terminal. Then I have the TTL+ pin of the control board going to HEATER3 (pin 8 of the expansion board). This is so the fan on the laser doesn't run all the time since it is powered on as long as the control board has power.Software:
In config.g file
M307 H2 A-1 C-1 D-1 ; Set E1 Heater logic to laser
M307 H3 A-1 C-1 D-1 ; Set Heater3 logic to laser
M452 P2 R255 F200 ; Set Laser Mode E1 Heater
M452 P3 R255 F200 ; Set Laser Mode Heater3
M451 ; Return to FFF mode
M563 P2 S"Laser" ; Assign Laser to tool 2
G10 P3 X50 Y0 Z0 ; Laser axis offsetIn Macro for laser mode
M452 P2 R255 F200 ; Set laser mode for E1
M3 s255 ; Set power to laser on
M452 P3 R255 F200 I1 ; Set laser mode for HEATER3
T2 ; Select Tool 2
M3 S0 ; Make sure laser is off -
Which firmware version are you using?
As a safety measure, the firmware will turn off the laser if the motion system runs out of GCode commands to process. This should not normally happen when you are "printing" from SD card.
A more modern way to control the laser is to use the S parameter on the G1 commands to set the laser power. This is supported in firmware 2.02. Caution: you need to change your homing files to use H parameters on G0/G1 commands instead of S.
-
I am using the newest firmware that was just released, 2.02.
It isn't running out of gcode commands. The problem is that as soon as I send another command, the laser turns off. If I am in the g-code console and I send a M3 S1 signal, it turns on to the lowest setting, but if I then send a message in the machine console to move in a direction, it turns off.
If I run a g-code file, there are times where turning a travel move the laser is told to turn off and then turn on again. Each time the M3 code is sent, the laser turns on for a split second. The control board only likes to see 5V PWM/TTL signals. Is there a different pin on the board besides HEATER3 that I can use that might not have this issue? Should I skip the control board all together and run the laser from E1 heater?
For reference, the laser is 5.5W.
I made a slight modification to the system. It is now running fully on 12V so the board is providing all power and no longer directly from the PSU. Issue is persistent. -
Here is a segment of the gcode file I am using. Is there something I am missing?
M05 S0
G90
G21
G1 F3000
G1 X78.027 Y53.1606
G4 P0
M03 S255
G4 P0
G1 F750.000000
G2 X67.4647 Y58.2199 I3.2607 J20.3625
G2 X61.308 Y68.2625 I13.9842 J15.4816
G2 X60.6505 Y73.2702 I18.3579 J4.9575
G2 X61.3345 Y78.3007 I19.2122 J-0.0508
G2 X63.9352 Y84.1174 I20.1897 J-5.5369
G2 X68.1532 Y88.8641 I17.4699 J-11.2768
G2 X74.512 Y92.7553 I16.8015 J-20.3154
G2 X77.7869 Y93.0201 I2.0283 J-4.7017
G3 X78.3207 Y92.9989 I0.3174 J1.2641
G1 X78.4301 Y93.1283
G2 X79.0747 Y93.7511 I0.6232 J0.
G2 X85.4415 Y92.8863 I-1.1045 J-32.0006
G2 X88.8112 Y91.7702 I-4.9161 J-20.4871
G2 X91.8733 Y90.1351 I-7.9239 J-18.525
G2 X99.9914 Y79.6837 I-11.0149 J-16.9343
G2 X99.9025 Y66.4387 I-19.1661 J-6.4941
G2 X94.4483 Y58.2217 I-19.0985 J6.7584
G2 X85.8249 Y53.6123 I-13.412 J14.7204
G2 X81.6389 Y52.9782 I-5.5116 J22.2482
G2 X78.027 Y53.1606 I-0.9673 J16.6973
G1 X78.027 Y53.1606
G4 P0
M05 S0
G1 F3000
G1 X77.1071 Y56.4577
G4 P0
M03 S255
G4 P0
G1 F750.000000
G1 X77.0617 Y56.5215 F750.000000
G3 X76.4537 Y56.684 I-1.4259 J-4.1163
G3 X75.9837 Y56.6826 I-0.2312 J-1.2096
G1 X75.9401 Y56.5826
G3 X76.7081 Y56.0991 I0.8778 J0.5425
G3 X77.1071 Y56.4577 I0.0384 J0.3586
G1 X77.1071 Y56.4577
G4 P0
M05 S0 -
In firmware 2.02 it is assumed that if you put the firmware into laser mode with M452 then you will use the G1 S parameter to set the laser power. This provides better control and synchronisation than using M3. If you want to go on using M3 to control the laser then I suggest you don't use M452.
-
The plugin I have for inkscape generates code with the M3 commands. Could you recommend a plugin that generates using G1 S parameters?
If I don't use M452, how would I set the E1 heater and Heater 3 to laser mode in order for the M3 commands to work correctly? -
Both Smoothieware and GRBL use the S parameter to control laser power, so you could look for a plugin that works with one of those firmwares. If you can't find one, I guess I could add a parameter to the M452 command that selects how the laser is controlled.
-
I will look around for a Smmothieware/GRBL plugin.
I'm confused on what I would change in the M452 command. I have set the P, R and F parameters and I don't see anything else besides inverting the signal that you can do with the command. From other places on the forum, it looks like people have had success using the M452 with M3 commands when using a fan pin to control. However, I need to use a 5V TTL signal. Is there something inherent to how the HEATER3 pin is controlled? Is there another pin I might try instead?
-
No there is nothing inherent to heater 3, it's just the first PWM-capable output on the expansion connector.
I'm wondering whether it would work to have M3 preset the laser power (without actually turning it on) in laser mode. Then the power you set with M3 would be used on subsequent G1 commands with no S parameter (but not on G0 commands). Do you think that would work for you?
Meanwhile you could try using CNC mode (M453) which lets you map M3 to an output for spindle motor control in a similar way to M452. Note, in CNC mode, G0 commands ignore the feedrate and always use maximum speed as set by M203.
-
Hi. Im using LightBurn for generating gcode. Most of preset machine have persistent power so gcode have S power only on change. It will be good if M5 lock the output so none of G1 movements turn on laser. M3 without without Sxxx could unlock laser with previously setup power or with S to set new power. But Laser would only turn on with G1 movement. If S is included in G1 new power is set up. G0 cannot reset power.
Now im using custom written program convert gcode. It reads line by line and if S power param is in this line i stor it, If G1 line without S i add S with stored power at the end.
-
@bishop86 said in Laser turns off after following code is sent after M3:
Hi. Im using LightBurn for generating gcode. Most of preset machine have persistent power so gcode have S power only on change. It will be good if M5 lock the output so none of G1 movements turn on laser. M3 without without Sxxx could unlock laser with previously setup power or with S to set new power. But Laser would only turn on with G1 movement. If S is included in G1 new power is set up. G0 cannot reset power.
Are there any other firmwares that behave in this way?
-
@dc42 I've tired a lot of software (lightburn, laserweb4, lasergrbl) in the last few days that generate GCode using G1 Xnnn Ynnn Snnn to set the laser power. However, as @bishop86 mentioned, the S parameter is only included when the S is supposed to change, meaning G-Code will look like this:
G1 X33.73 Y16.07 S255.00 G1 X36.89 Y19.23 G1 X36.94 Y19.30 G1 X36.96 Y19.38
This means that S is supposed to stick, and I doesn't do that currently. That's why @bishop86 wrote a script to append the S paramter to G1 lines that have it missing.
In the meantime, would you be able to share the script you wrote @bishop86 ?
-
Which firmware version are you running? The G1 S parameter is already sticky in 2.03beta2 (although I regard this as dangerous, and a very bad decision on the part of those who introduced the S parameter and made it sticky).
-
@dc42 Oh, I haven't tried the beta yet, still running 2.02. Will give it a try in the next days!
-
Advance warning: in 2.03beta3 the G1/G2/G3 S parameter will only be sticky if you add parameter S1 to your M452 command.
-
Hi @bishop86 it's possible to send me your program please ?
Thanks -
Hi,
Any progress on this?
I ran in same situation with following code with Release 2.04 (Duet 2) and 1.25 (Duet 06/085).
Tested also with 3.0beta12 (2019-11-02b1) using M452 C"exp.heater3" Q200.
Config is in attached file.config.g
Seems that heater3 output is turned off.
gcode:
;Project bugbug
; *** START begin ***
G90
G21
M84 S0
G92 X0 Y0 Z0
G00 X0.0000 Y0.0000 Z5.0000;No. 2: Engraving 1
G00 X25.7569 Y48.9645 Z5.0000
G00 Z0.5000
G01 Z0.0000 F1200
M3 S255
G01 X19.7518 Y30.6457 F750
;bug hits here. previus move is lasered ok, next 2 moves not.
;if run line by line (pasting one by one to console) all works ok.
G01 X1.1829 Y30.6942
G01 X16.1260 Y19.5851
M5
G00 Z5.0000
G00 X0.0000 Y0.0000
M05 -
@morokolli, I'll test that when I get time.
Are you able to configure your GCode generator to generate S parameters on the G1 commands instead of using M3? That's the modern way of doing laser engraving, and it benefits from velocity ramping in RRF3.
-
Tested with S parameter -> works like it should.
I had to ask from CAM software developer is it possible. I'm using ESTLcam at moment.
Waiting answer from there also. -
I did more testing.
While using attached G-Code error hits in even with S255 parameter.
First square is burned ok, then on another part start and goes well until light turns off after couple moves (somewhere around line 30-32) and comes back after next move.
Using Release 3.0beta12
Sample G-code:
[0_1573400684875_peukku.nc](Uploading 100%)