grbl laser control

Use this forum to ask questions about how to do things in QCAD.

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files and screenshots.

Post one question per topic.

Post Reply
treeman
Newbie Member
Posts: 3
Joined: Wed Apr 21, 2010 6:19 am

grbl laser control

Post by treeman » Thu Nov 24, 2022 4:08 am

Hi,
I have upgraded my cnc router to laser
and just wondering how to control laser power with the variable spindle PWM.
The grbl controller is setup to only use 2 axes, X-Y, no Z axis.
It turns the laser on with M4 dynamic power mode or M3 constant power mode.
followed by Sxxxx power level.

Devuan Linux current, grbl v1.11, Qcad/cam v3.15.5

Cheers,
Colin

CVH
Premier Member
Posts: 3416
Joined: Wed Sep 27, 2017 4:17 pm

Re: grbl laser control

Post by CVH » Thu Nov 24, 2022 7:04 am

Hi,

Are you working in mm or in inch?

LaserGrblMM.js is based on LaserGrbl.js
LaserGrbl.js is based on LaserBase.js
LaserBase.js is based on GCodeBase.js

In order of appearance:
GCodeBase.js is the common base for all that export G-code.
It declares the standard things and I am not going into details, remark that some are overwritten by what follows.
LaserBase.js disables Z movements, changes tool type 'Mill' in 'Laser'.
But most important, it changes the dialog so 'Spindle Speed' is renamed to 'Power'.
LaserGrbl.js disables line numbers, turns on the laser with M4 before every contour or pass and off after with M5.
For the laser it uses the Speed variable.
You might detect that it can also be configured with variable power per entity.
LaserGrblMM.js sets mm and 3 digits.

I think that everything you require is already build in, but if not one can always derive a custom postprocessor.
Important :!: : You should not alter the above listed postprocessors.
These are reinstalled as they are when you update QCAD/QCAM.

M4 'dynamic power' should be OK when your setup can accelerate enough to keep the Feed up.
It might be required to setup a minimal PWM in the controller depending the material and the Feed drop with small arcs/circles.
Just like a car that can't take corners at high speed. :wink:
M4 might do nothing when the actual local Feed is to low.
M3 will scorch your material more when local Feed goes down.
There is more information about this to be found online.
Some trial and error may be required, a good idea is to keep a record of what works and what not. :wink:

Now let's assume you want M3 instead of M4.
Make a copy of LaserGrblMM.js and rename it to MyLaserGrblM3MM.js.
Set something meaningful for the displayName.
include:

Code: Select all

    // before every contour or pass, switch on laser:
    this.zPassHeader = [
        "M3 [S!]"
    ];
This will overwrite the zPassHeader declared in LaserGrbl.js
Restart QCAD/QCAM and select your custom postprocessor.
That's all there is to it.

In the same way you can override almost everything as desired.
As example one can also include the variable power per entity what is ruled out in LaserGrbl.js.
Just add this line in your postprocessor:

Code: Select all

    this.linearMove = "G1[X][Y][F][S]";
The rest is already taken care of in LaserBase.prototype.initEntity.
An entity custom property called CamSpindleSpeed for each entity will alter the Speed AKA Power on the fly.

What I am missing is the footer after the output.
GCodeBase.js declares ["[N] M30"].
LaserGrbl.js clears this entry.

And then there is this bugreport: https://qcad.org/bugtracker/index.php?d ... sk_id=2397
There are things you could try explained here but there was no feedback.
https://www.qcad.org/rsforum/viewtopic. ... 165#p39165

Regards,
CVH

Post Reply

Return to “QCAD 'How Do I' Questions”