laserTest?

Hi @cprezzi,
I have an issue with the lw.comm-server modified for MPG. Within function laserTest(data), there are appSocket.emit calls on which the server crashes on “ReferenceError: appSocket is not defined”. I have a feeling the appSocket.emit can only be called from within io.sockets.on. I think laserTest function is special in its use of appSocket.emit as it’s the only function using it to communicate actively with the front end. The other functions with appSocket.emit are only reporting errors, which may explain why it was not caught so far.

Any thoughts?

1 Like

You are right. I restructured the code shortly and made a mistake.

To quickly correct that problem you can just replace appSocket.emit in the laserTest function by io.sockets.emit.

io.sockets.emit is globaly available and sends the meaasge to all connected frontends (if multiple) while appSocket.emit is only available inside the io.sockets.on('connection', function (appSocket) {}); block and only sends the message to the one frontend that issued the command.

1 Like

Ok thanks Claudio,
Maybe you can help me understand this then. When I look at the code, the GCode and other control boards commands are queued using addQ(), but in between those you have the appSocket.emit to signal the front end that laser is On then is off after a timeout (sounds like an external task?), but only turning off if duration is more than zero. We can enter that function if duration is greater or equal than zero. That means a laserTest with a duration of zero will be On until a manual intervention is done. Is this really the intent??? It looks dangerous.

Remi;
laserTest=0 is, indeed, how you specify ‘no time limit’ for the test function.

For a lot of tube lasers this is a bad idea. And LaserWeb itself could probably do with a better warning when setting it.
… but it is a feature that should remain, not a bug. Small diode lasers can run on very low power settings without marking the work (*) and having a safe alignment dot is really useful when setting up and focussing.

(*) with its’s 10bit pwm, 0 to 1023, my esp32/FluidNC machine turns on at 4, eg 0.4%.

Ok I understand now. On my laser I have a separate alignment dot similar to a laser pointer. This is separate from the main laser function. The laser pointer lights up when I do the equivalent of opening the cover.

Personally if I had a small diode laser I’d have a GCode macro for stock or workpiece alignment. For me the laser test is more to look into the alignment of the optics rather than stock positioning.

At least in the upcoming versions if we had a big warning that would be a compromise.

Owen is right. LaserTest=0 is intended for diode lasers with visible light that can be set to such a low power, that it doesn’t even mark the material. This can then be used as a pilot laser.

On stronger CO2 lasers, the LaserTest feature is mostly unused. It could eventually be used to fire short pulses of a few miliseconds for mirror alignement.

For safety reasons the default of “Tool Test Power” is set to 0%. A warning when “Tool Test Power” is set >0 would be better.

At first I got scared when I read the code, because it queues the command to turn the laser On, then the server crashed, so you’re left hopefully with a working e-stop. But rereading the code it doesn’t sound like the queue is sent to the control board until send1Q() is called. But still dangerous on large laser setups.

@cprezzi: yes mirror alignment was what I thought the laser test was meant for, much less for stock or workpiece alignment

For me, duration is more dangerous.

Fun fact: when I got my laser source, the poorly done software that came with it can’t figure out what a millisecond is, despite the GUI clearly showing ms. So instead of firing the laser for 20ms for a test shot, duration ended up something like 2 seconds. Burning the table from the very first shot!!

1 Like

You are right, addQ()only adds the command to the queue buffer, send1Q() takes the next line from this buffer and sends it to the machine.

For posterity:

We can definitely handle this better in the GUI.

1 Like

Thanks Owen!
What’s the latest on your end? Is the punchlist almost done that we can see a release candidate?

I’ve been a bit time-starved for LW stuff recently. I’ll throw something together in the dev chat section.