Controlling The Laser Beam

Last Updated: 20th January 2011

This page is a sub page in my records about converting my laser cutter using Mach3... so if you've dived straight in here, you probably won't follow half of what I'm talking about and should start probably start here instead.

Overview

If you're reading around then you may have seen mention of using the pulse width modulation to control the power of the beam. However all I was looking for was a simple on/off. I figure that if I want different depths of cut then I can set the power to cut (with the knob) and use a faster feed rate for the stuff I want merely marked.

Wiring

The info at RoutOutCNC describes a pair of wires on the laser power board that are connected to the breakout board to give control of the beam, however my board is different. The image below shows the likely options. Note that I've placed a mirror under the board to show the tracks on the back of the PCB.

Laser Power Board Connectors

U1 is a P521 opto-coupler with the input pins connected to the red and yellow wires on J4. These are wires that I have added. More about them later.

The other side of U1 also connects to the yellow/black pair, and the black/black pair on J5. The yellow black pair goes to the power board that supplies the 24v for the motors and which also supplied the old controller with its 5v supply. This board also has an optocoupler to whose output these wire are connected (the input was connected to the old controller board). The black/black pair goes to the "Fire Laser" button on the control panel (used to test fire the laser).

The green pair on J4 go through the safety switch that prevents the laser from firing when the canopy is open.

The yellow/black pair on J5 looks temptingly like the black/white pair described on RoutOutCNC, but don't be fooled. They are on the 'wrong' side of the optocoupler and using these would connect the laser circuitry direct to the computer with no optocoupling. The voltage between the pins to which the yellow and black wires connect is a sweet 5v, but measure between them and earth, or ground on our breakout board, and we're looking at something more like 120v.

The optocoupler at the other end of the black/yellow pair (on the 5v/24v PSU board) seemed like another option but alas the input side is connected to the laser cutters 5v supply. Once again, it looks great when measured on its own but compare it with ground on our breakout board and things start to look unfriendly. Even if this were not the case we would still, to some extent, be bypassing the optoisolation were we to make use of it.

Now as I already mentioned, the red/yellow pair were added by me and as you can see, before they were added, optocoupler U1 was sat there doing nothing at all. There is much evidence that boards in this machine were designed for use in various machines, with different requirements, and this unemployed optocoupler is just one example; one that provides an ideal connection via which we can control the laser.

At this point however I ran into problems because I tried to use pin 1 of the parallel port to control it. Why I tried that, why that didn't work, and how I eventually found my solution is described, for those who are interested, in a document that I have sarcastically entitled Fun With Pin 1. All you really need to know however is that my successful solution involves connecting the red wire (that I added) to GND on the parallel port while the yellow wire connects to pin 6. Mach 3 is then set to use pin 6 as the control for the 'spindle'. I repeat: pin 6 and NOT pin 1. Read Fun With Pin 1 if you have any thoughts about using it.

Programing

So, with everything wired, and Mach3 set up to control the spindle (as if it were running a mill) on Output 1, I was able to do a few tests. However, there was a problem:

M3 ProblemAt this juncture I was using M3 and M5 NC-codes to turn the laser on and off. However a delay occurs between these being sent, and the next line of G-code, and this results in a 'hole' being created at points where the beam is switched on and not moving. A quick search on-line shows that I wasn't the first to have problems with this (apparently there's a 500mS delay that's intended to give the spindle time to get up to speed).

The best solution I found was posted on the Mach 3 forum at
12653.msg82436.html#msg82436,http://www.machsupport.com/forum/index.php/topic,12653.msg82436.html#msg82436
where twehr (cheers buddy) suggests using M11P1 and M10P1 instead.

Twehr notes that M11P1 is ON and M10P1 is OFF (intuitively backward from the M3/M4, M5 combination. The 'P1' bit of the command is specifying the Output number i.e. output #1 (because that's the Mach 3 output that he, and I, have configured and wired to control the beam).

Twehr also points out that M11/M10 do NOT execute immediately but wait until there is a subsequent G-code to cause movement. Clearly this is ideal when we're switching the beam on, but it's important to remember to program some move to take place AFTER switch off if you use M10P1 for off...

...but I'm not doing. I'm using M5. Even though I'm using M11P1 for on, I can still use M5 for off and then there's no need for a move immediately afterwards (even though there usually is one).

Hover over a title for a little more info about the link.

© 2018 Andy Slater - All Rights Reserved.