Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate gcode for lasers/machines which do not support laser intensity. #635

Open
Rabter1 opened this issue Feb 12, 2022 · 12 comments
Open

Comments

@Rabter1
Copy link

Rabter1 commented Feb 12, 2022

Right now the software cant control lasers without intensity regulation. (Laser raster)
It would be very easy to add support for these lasers.

Background

I am using Mach3 with a very weak laser.
Because of this i have no intensity hooked up to control the laser.
There is only Laser ON and Laser OFF. The laser is not listening to intensity values (S X.XXX).
Because i have no analog / PWM output left, i cant even hook up the intensity to my laser.

Right now i am using a custom Mach3 postprocessor to engrave contours.
I wanted to use this software to engrave surfaces aswell.
In Mach3 i can control the laser in two ways.

Possibility one:
Use custom M commands to turn on a digitalOutputs (Turn On or Turn Off Laser)
The code would look something like this.

G1 X10 Y10 
M303 ; Turn on Laser
X20 
M505; Turn off Laser
X10 Y10.2
...

The issue

The problem with LaserWeb is, that i can define custom commands in macros in Tool ON and Tool OFF for turning laser on and off, but these get not triggert in between the lines when using laser raster.
The code looks something like this.

M303
G1 X10 Y10 
S1.0 ; Turn on Laser
X20 
S0.0 ; Turn off Laser
X10 Y10.2
...
M505

The software expects the machine to turn off the laser when settings S0 but this is not the case when a machine has no intensity control.

This would be an easy fix because everytime the software outputs S0.0 we could just output Tool OFF Macro. And everytime the intensity is >0 or >0.5 we could output Tool ON Macro.

The second way to control a laser in Mach3 is by using the commands M67 and M68.
This is the prefered way becasue mach3 only turns on the laser when the axis is moving.
See also #334

The Code would look something like this:

G1 X10 Y10 
M67 E(PWMSigNo) Q(LaserPower) ; Turn on Laser
X20 
M68 E(PWMSigNo) Q(PWMMinPow) ; Turn off Laser
X10 Y10.2
...

Because I have no PWM control i just leave the Q value out.
This is basically the same code as above with just another custom macro set for Tool ON and Tool OFF

The issue is, that the Macros are not beeing called as mentioned.

There is also an awkward bug in mach3 with some controllers, that cause the machine to wait a tiny amount (maybe 1ms) when executing an S Command. This can lead to a burning spot.
Thats why it would be awesome to have an checkmark option to disable intensity values completely. (Btw. this bug is one of the reasons M67 and M68 exist in the first place)

So for Mach3 there needs to be an output ideally like this:

M67 E(PWMSigNo) Q(LaserPower) ; Turn on Laser
G1 Move

And for lasers without intensity settings, there needs to be a checkmark like Use Intensity which is checked by default but can be deactivated.

If intensity it deactivated the Mach3 G Code would look like this:

M67 E(PWMSigNo) ; Turn on Laser
G1 Move
M68 E(PWMSigNo) ; Turn off Laser

But if Mach3 would be supportet with M67 and M68. I think it would not harm to have the Power value there. So the checkmark for leaving the power values out might not even be necessary.

But it is very important to turn the laser off by calling M68 or by the Tool OFF Macro and not by calling Laser ON with Power 0 thats basically the logic right now.

I might be able to help programm these changes and submit a pull request but i dont know if this software is still maintained.

@cprezzi
Copy link
Member

cprezzi commented Feb 12, 2022

Try this:

  • TOOL_ON = M67 E(PWMSigNo)
  • TOOL_OFF = M68 E(PWMSigNo)
  • LASER_INTENSITY = ;S
  • INTENSITY_SEPARATE_LINE = on

@Rabter1
Copy link
Author

Rabter1 commented Feb 13, 2022

Hi @cprezzi thanks for the tip.

This indeed works partially for me if i delete the S lines manually.
But this only works in Laser Fill Path but not in Laser Raster or Laser Raster Merge

When using Laser Raster the logic is always Laser ON and only S value is changed even when laser is supposed to be off.

Also i noticed, that the letter i can set for Laser intensity (Settings->GCode->Laser Intensity) is ignored in Laser Raster it is always the letter S (but this is another bug)

Like i said.
I can program the desired changes by maybe add a Machine profile for Mach3 machines and add the settings and bugfixes needed for machines without intensity control.

But i dont want to go through the hustle when nobody is looking at the pull request. Is this project still maintained?

@easytarget
Copy link
Contributor

Is this project still maintained?

Yes: and a new release is in the planning. but there is a way to go. And it focuses more on UI changes and updating to 2022 web standards, no substantial changes to gcode generation.

@cprezzi
Copy link
Member

cprezzi commented Feb 13, 2022

@Rabter1 Raster operations use a different library than vector operations and this library never supported the configuration options from the gcode tab. If you like to add this, start @ https://github.com/LaserWeb/LaserWeb4/blob/dev-es6/src/lib/lw.raster2gcode/raster-to-gcode.js.

@easytarget
Copy link
Contributor

@Rabter1 ,
as @cprezzi says, LW4 actually has (for historical reasons) several independent generators for different operation types, the raster generator has a different heritage than the path cutting generator, and the various mill generators also have their own code. The individual generators are run as web-workers and all live in the src/lib folder, along with their glue logic.

  • I now know the code quite well, but I still struggle to remember which operations are associated with the various generators, and which settings they use. If you need any help navigating around this code please ask.

Also watch out for the v4.1 changes as they arrive; there are changes to the default machine profile list (it is expanded and some additional info fields are added).

@Rabter1
Copy link
Author

Rabter1 commented Feb 17, 2022

Since I need to add probably one UI elemt in the settings for Mach3 machines, I will wait with my changes until i have 4.1.
This will most likely make things easier because this avoids merge conflicts.

@easytarget
Copy link
Contributor

The 4.1 branch is rebased and renamed; and I'm doing some testing on it here and hope to have it in the main repo soon; I'm still feeling my way with releasing.

@Rabter1
Copy link
Author

Rabter1 commented Feb 17, 2022

Okay thank you!
I will follow this guide and fork branch 4.1. Merge conflicts should be minimal then.

@easytarget
Copy link
Contributor

easytarget commented Feb 18, 2022

Okidoki; I'm currently doing some testing, documenting and working out how the electron/appimage bundling works.
That guide is good, but the list of npm commands has now been changed; I have a new FRONTEND-DEVELOPMENT.md document (a practical guide, not a style/architecture guide) that supersedes the commands listed there

@Rabter1
Copy link
Author

Rabter1 commented Mar 27, 2022

Today I had a little bit of time to code the changes.
I created a Pull Request

@easytarget could you give me a hint on how to create a .exe file?
I would like to test my changes on my machine but there is no internet / nodejs installed on the machine.

@easytarget
Copy link
Contributor

@easytarget could you give me a hint on how to create a .exe file?

I dont really know that myself yet; I have not yet got round to bundling my changes into the electron appimage. I am a bit stalled in the release process.

@cprezzi
Copy link
Member

cprezzi commented Mar 30, 2022

The EXE is built from the electron_bundler branch of lw.comm-server (https://github.com/LaserWeb/lw.comm-server/tree/electron_bundler). Check out the scripts in package.json. The "nightlywindows64" tells you all the steps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants