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

Add support for exporting GCODE #59

Open
manthrax opened this issue Jun 16, 2018 · 18 comments
Open

Add support for exporting GCODE #59

manthrax opened this issue Jun 16, 2018 · 18 comments

Comments

@manthrax
Copy link

manthrax commented Jun 16, 2018

In a perfect world.. I could take these designs and send the gcode to my cutter/engraver! The interior polygons could use 50% laser strength to merely score the material, and then the end of the cutting pass would cut out the exterior at full power. This would be soo cool, since you could completely automate the process of turning a Blender model into a craftable object!

LOVE THIS PLUGIN BTW!!

@addam
Copy link
Owner

addam commented Jun 20, 2018

I'd love to do this and it seems quite easy to do, but I don't have a CNC.

If I write the code, will you test it for me? It may take a few trials and errors before we get this right.

@addam addam changed the title Add support for exporting GCODE for laser cutters! Add support for exporting GCODE Jun 20, 2018
@alpharesearch
Copy link
Collaborator

You don't need any hardware. Have a look at camotics.org to simulate a 3 axis CNC via OSS. With this software, you can test the GCODE output all day long... ;-)

@addam
Copy link
Owner

addam commented Jun 20, 2018

Markus, thanks! Unfortunately, Camotics doesn't work for me out of the box, it gets stuck in an infinite loop. I'll have to build and debug it, apparently.

@alpharesearch
Copy link
Collaborator

Long time that I used this program. Last time the name was still OpenSCAM, probably good idea to rename it. The Debian package I just downloaded from the web site and installed is definitely not up to the Debian standards... I had to manually install libv8-3.14.5... but after that it started up and it's running ok. I'm using Linux Mint 18.3. What OS are you using?

@Treehee
Copy link

Treehee commented Jun 22, 2018

I'm currently digging into this, and I wonder; is there anything other than surface speed that I should let the user choose (when working with laser cutters)?

@alpharesearch
Copy link
Collaborator

I would say you can use X and Y speed to change things (cutting/scoring) for some machines that have manual laser power settings. But many lasers have strength settings that can also be controlled via GCODE. You also want a travel speed setting when not cutting. The Z axis may need to be set on the beginning so the laser focuses on the paper and one more time on the end to move out of the way. But again not all machines have a Z axis. I'm not the expert anyway, if someone is reading this that knows more please add to the conversation. I have a project here on Github that converts bitmaps to gcode for laser engraving. You may want to have a look at that.

@Treehee
Copy link

Treehee commented Jun 22, 2018

I meant what variables are important for the user to set while exporting? So far I came up with;
surface speed (in m/min)
feed rate (not entirely sure what this does on a laser cutter? Could you explain that to me?)
pierce strength (in seconds of max laser power. This is done on stronger materials when starting a cut from what I found when researching the topic. It basically burns a hole in a material so it can then cut from that hole)

@Treehee
Copy link

Treehee commented Jun 22, 2018

@alpharesearch are laser cutters able to cut at an angle?

@alpharesearch
Copy link
Collaborator

The feed rate G01 is used for cutting or with a laser on, this is normally slower than feed (seek) rate G00 that is used to rapidly reposition. On GCODE lines you can overwrite the default feed rate with the F parameter.
Here is the parameter I can think about:

  • tool/laser diameter (some machines have G40/G41/G42, but not all so you probably want to compensate for this in your program)
  • feed rate for cutting (G1 Fn)
  • feed rate for scoring (G1 Fn)
  • feed rate for engraving? (G1 Fn)
  • S parameter (spindle speed) is sometimes used for laser output strenght. (G0 Fn Sn), give this as the option to all cutting/scoring/engraving feed rates.
  • option to set Z for cutting and not cutting as well
  • maybe allow seek rate overwrite (G0 Fn)

Regarding the angle, most laser cutters are 2 (XY) or 3 axes (XYZ), the laser is positioned above the XY and shines straight down. There is no 4 or 5 axis to rotate the laser as far as I know. With the Z axis, you focus the laser by moving up/down. But if you look at cutting a circular look at G02/G03. And G04 can be used to dwell.

@Treehee
Copy link

Treehee commented Jun 22, 2018

@alpharesearch with feedrate I meant G99 and could you explain to me what it actually does? CAMotics throws an error if I don't define a feedrate.

  • seems like a good plan. This would be attached to a boolean option "use G41"
  • I already mentioned this (surface speed)
  • shouldn't this just be 50% of the surface speed?
  • I don't see what this script would need to engrave
  • I thought having a constant surface speed made more sense (G96) and then set G50 to 255 (100% power)
  • I don't intend to mess with the z-axis as from what I can tell most laser cutters have a focal point, so adjusting the z axis would change the diameter of your cut. Scoring vs cutting should be done via surface speed I think.
  • people can always edit the g-code files afterwards.

@Treehee
Copy link

Treehee commented Jun 22, 2018

Ooooh engraving would be usefull for the numbers, arrows, and other text

@alpharesearch
Copy link
Collaborator

Check out this Wikipedia GCODE link. Looks like G99 is for lathes and the feedrate per revolution... not sure why CAMotics needs this?
Like all controllers support G00 and G01 and you can do pretty much everything with these codes. Other codes like G41 may not be supported. But you can account for that with a corrected G01 output. I don't this G50 will be doing what you think... some controller implementation use Z for cutting but may don't move the Z axis. Other use the S spindle speed. There is not just one standard and implementation. You would need to look for example at GRBL or some other controller to see what is supported...

@Treehee
Copy link

Treehee commented Jun 23, 2018

@alpharesearch I was already using that link 😄
And yes, G99 is feedrate per revolution - it's the same thing you can set on G00 and G01, except it makes it the default value for your file.
Yes, but for those who have a machine that does support it it is still a nice option since it is probably more accurate.
as for G50 I think you may be correct. From what I can tell I can literally just omit this, as machines are not able to fire over 100%. From what I have read online most laser cutters divide the spindle speed by 255 and set that as the % of their max power (0 is off, 255 is max, 128 is half). G96 should automatically adjust the speed and power of the laser to give the same exposure to every line, ensuring a clean cut. CNC lathes appearently require G50 so they don't spin out of control, but as far as I can tell other CNC machines (like laser cutters) do not.

@Treehee
Copy link

Treehee commented Jun 23, 2018

@alpharesearch I did some more research and G96 doesn't do anything on laser cutters (or milling machines) as both already have a constant speed so I will just use G97 :)

@Treehee
Copy link

Treehee commented Jun 23, 2018

That also means I will use G94 to control feedrate

@alpharesearch
Copy link
Collaborator

My GRBL laser mode test from 2014 shows some GCODE on it's page. GRBL has a native laser mode now that is more advanced but works the same way. I have a ShapeOko V1 CNC with a 3 watt laser diode. It will cut paper and cardboard.
Here is a list of all the commands I would normaly use to write a GCODE file by hand to use with my laser:

  • G20 or G21 inches vs mm
  • G90 Absolute programming
  • G94 (default, I don't have to include)
  • G64 default cutting mode
  • G40 radius compensation
  • G17 XY plane selection
  • G0 G1 G2 G3 (G1 F500 to change feed rate or G0 X0 Y0 Z0 goes to the origin)
  • M3 M4 M5 M30 (M3 S1000 to change laser power)

@manthrax
Copy link
Author

manthrax commented Jun 24, 2018

Very cool that you're working on this! I actually have gotten a decent workflow going for this using this plugin combined with:

https://github.com/LaserWeb/LaserWeb4...

and Here is the low price laser cutter I am using:

https://www.banggood.com/2500mW-A3-30x40cm-Desktop-DIY-Violet-Laser-Engraver-Picture-CNC-Printer-Assembling-Kits-p-1003863.html?cur_warehouse=CN

This cutter is my first experience with laser cutting and I have had no major problems with it, and it seems to work well with cardstock, but I haven't tried with anything heavier due to ventilation constraints in my apartment.

But fair warning if you do get one! Use the goggles, since sometimes it will boot with the laser at full power for no good reason, so you really have to pay attention when using it!

First off, here are a few objects I've scored and cut on cardstock using my workflow:

https://files.slack.com/files-pri/T02GC8M7E-FBAV7LQ77/20180620_045949.jpg

Here is a screenshot for an intermediate tool I wrote to do some processing on the output SVG , but I ended up not neccessarily needing it, once I figured out I could change the different line colors on the object export.. more on this in a sec...

https://files.slack.com/files-pri/T02GC8M7E-FBA4GAEAC/image.png

Let me describe my workflow and perhaps it will give you some ideas...

I first export the object with rgb pure red for the object perimeter lines, green for valley folds and blue for the mountain folds... (in practice I treat both fold types the same since the laser cutter can only score one side...

This is neccesary so that LaserWeb can be configured to use different laser energies for each line type.. since it can key off the line color to select the laser power.

So then in LaserWeb, I create 2 different operation configuration sets... One called "laser cut" and the other called "laser score"

I then make two instances of the "score" operation, and one of the "cut" operation.
the 2 Scoring instances are keyed off of Green and Blue, and the Cut operation is keyed off of the Red paths.

I've arranged it like this so that the scoring of the interior lines happens first, because if the cuts happened first, the piece could fall out of the cardstock and shift position, and screw up the positioning of the subsequent scoring operations.. so Scoring happens First (at low laser power) and Exterior cutting happens Last and 100% laser power.

My settings for the 2 operation types are as follows:

Scoring:
Laser power: 15%
Cut Rate: 3000
Segment Length: 0.3 (mm)

Cutting:
Laser power: 100%
Cut Rate: 1000
Segment Length: 0.3 (mm)

So from the settings above you can see that cutting vs scoring is controlled both by the laser intensity AND the Cutting rate which is the speed the printer moves the head...
So scoring lines can be drawn much faster, but cutting has to happen slower to get full penetration through the cardstock.

The segment length controls the size of the minimum feature.. this turned out to be important because otherwise the generated gcode can program the path to do Very small movements, which cause the laser to dwell near the same spot for too long, and will overburn. this mostly happens at the vertices of objects, but setting the minimum feature size to 0.3 mm mostly fixed that, and now I get pretty clean and uniform cuts.

For reference, each of the objects in the screenshot above took just a couple minutes each to cut. Assembly is what takes the most time.

@Treehee
Copy link

Treehee commented Jun 27, 2018

@manthrax could the overburn problem also be fixed by making the gcode print those edges at different moments or would that not make a difference (ie if you have a sharp angle it cuts one edge, then cuts some other stuff, then cuts that edge at a later moment)?

If not, what does "minimum feature size" do on that program? Does it ignore smaller lines completely, or does it remove them and bring the closest two edges together, or does it increase their size? If you're not sure, what do you think would give the best results? Does it do anything about sharp angles? If so, what?

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

4 participants