CNC Control Box Part 4 / Laser Wiring, LED Warning Lights, Bootloader D13 Pin Toggle Fix

In the last few videos I began assembling the electronics for my latest CNC machine – fitting those into an enclosure, wiring up various components include a stationary touch probe button.

While I’m waiting for a few things to arrive in the post I’m going to wire a terminal which I may later use for a laser engraving module.

This one here is going to take the 5v PWM signal from the controller on two pints and the 24v from the power supply unit to allow me to use this Optlaser engraving module.

You may remember a while back I was sent a 6w diode laser module by a company called Optlaser – and well I still have it and it needs somewhere to go. This process should be pretty simple, because the laser module has onboard circuitry to accept the 24v power and PWM signal, and the Gradus M1 Pro control board has separate terminals for a 0-5v PWM and another 0-10v for an inverter.

Because I’ve got components inside, I’m going to make sure the hoover is on just behind where I’m drilling the hole.

I’m now soldering the panel mount and I’ve started by tinning each of the four cups. I then wire a red cable for the 24v DC power and a black cable for the PSU ground.

I also add heat shrink to the soldered ends to hide my shoddy soldering skills – only joking it’s to keep them snug, like a thick pair of house socks. I’ve added boot ferrules to the ends where they will be screwed into the terminals on the control board. I’ll also wire the PWM to the panel mount, with the brown wire going to the PWM ground and blue wire to PWM positive.

I’ve wired the 24v directly to the power supply unit and the PWM to the controller.

This is the second layer with the four-channel relay module for the controller outputs. To neaten up the wiring I’ve daisy chained the power from the relay module to the fan which cools the control board stepper drivers.

I’m now wiring the cable from the socket to the docking station which holds the laser module. And it’s the same thing of soldering and writing notes and crimping and so on and so on.

This is the docking station for the laser I happen to have. So that’s what it looks like and I’m just going to check it with a volt meter.

You could wire the power via a lockable switch directly next to the terminal for additional safety, but as the laser is dismountable, I know I can always pack it away when I don’t want to use it.

You may notice that as the laser turn on the surrounding area turns red. That’s not the lasers doing – as I’ve wired some LED lights to the spindle enable terminal which turn red when on and white when off. This is a safety feature which I’ll overview laser in the video. Now the unusual thing that happen here was, the LED lights flickering upon start up.

Now If I had not mounted the laser, turned the control box on, and then clipped the laser in place I would not have got the flickering lights.   It seems that when everything is plugged in together and turned on the draw from the laser results in this behaviour. I could add a capacitor along the power supply to the laser but this could result in the laser remaining on for a short period of time when powered down. Capacitors can be dangerous if you touch the contacts and they discharge electrically – and if you look at the panel mounts terminals the pins are exposed on the socket while the terminals on the plug are sunken into the plastic. This assumed the signal is coming from the plug to the panel, or in other words the female is in fact a male, and the male is in fact a female and this assumed a direction they should be used. So I need to do a little bit more research but potentially I may need a separate power supply unit for the laser, but in the meantime I’ll show you how I wired the under gantry LED lights.

Ok I’ve just mocked up the wiring for some LED lights which connect to a relay module which is triggered by the spindle enable pin on the controller. Now what this allows me to do is create a signalling system on the CNC machine when the controller is in different states. So when the machine turns on, and I’ll turn it on now, you get the white light which will illuminate from underneath the gantry and when the spindle is on which I’ll just turn which I’ll just turn on using the software, it becomes red, red for danger.

I’ve mocked up the wiring to this barrier block. The red cable is the 24v power coming in which goes to the back cable on the LED strip. The blue, green and red cables correspond with the LED light colours – when connected to ground their corresponding colour turn on. Different combination make different colours so if all three wires are connected to ground the strip produced a cold blue white light.

In the shot on screen I’ve used two 500mW 24v Zener Diode – BZX55C to create the circuity needed to swap between the two lighting states, but later I only used one, and further later still I swapped over to RGBWW LED light strip, where the WW stands for warm white light.

I’ll just place the heatshrink on and another piece over here to cover the wires once I’ve soldered them. Ok I’ve already place the wires through the trunking. I just need to get to the other side and get this to the right length.

The double sided tape is terrible. It’s not sticking.

Ok you can see I’ve wired this all up. Everything is exposed because I’m just testing it out and then I’ll re-do it to make it a bit neater.

The cable for the white light went via the normally closed terminal on the relay module, which is idle state, and red cable via normally open, which closed when the spindle is enabled. The blue light was affecting filming in the workshop, because the florescent lights have a different kelvin temperature to the LED ones, so I replaced the entire thing, as I mentioned, with RGBWW which needed to diodes at all.

So back to the flickering lights… I had a brain fart and tried to add a bucks voltage regulator between the power supply and the power cables to the laser, hoping that the regulators onboard circuity might act like a soft start but it didn’t make a difference.

One thing to notice is it’s not the coolant or the mist signals which are flickering but specifically the spindle enable.

So I decided to wire the lasers 24v power via a latching circuit, which I would energise after the main controller electronics was turned on.

And when I want to turn the power on I simply press the on button, the circuit latches and in this case you can see the LED is on and then I simply break it to turn it off.

My thinking was this would delay the draw of power from the laser, but this also didn’t work.

I can tell you already that it isn’t going to work but I’ll show you what it does.

I tried two variation of this, wiring via the four channel relay module which I was using for the output from the control board. However this method resulted in all the relays turning on when I pressed the on button. You’ll just have to believe me as I wasn’t paying attention to where the camera was filming so you can’t see the light on the relay module. Anyway I then move the latching circuit via a separate relay, and while this resulted in the flickering relays yet again.

So I don’t think the issue is with the laser module drawing too much power. I also tried wiring the ground of the 36v and 24v power supply together, in case this behaviour was the result of a grounding issue, but this resulted in the same behaviour. I then noticed something unusual that I hadn’t noticed before. When I turned the machine on or pressed the hard stop button, the lights on the relay module, where the spindle enable was plugging into would flicker. The output of the spindle enable pin seems to be switching or oscillating on and off, not enough to energise the relay but enough to be noticeable via the LEDs.

Ok I’m going to try something now to see whether removing this relay module and placing an LED light on the spindle enable pin and ground still results in power outputting when the machine is turning on or resetting. So I’ve got my LED here.

This seems too consistent to be a coincidence.  And come to think of it – my older phoenix CNC controller did a similar thing, when I would re-flashed the firmware the onboard relay module would toggle on and off. Now I was planning to use a delay timer relay module to try hide these effects by delaying the power to the output relay module but luckily, I found a few illuminating articles which have pointed me to a solution. It seems that it is a feature of the Atmega328 bootloader that causes the D13 or in my case the spindle enable pin to toggle, and I quote “cause things to act randomly when using this pin as an output to control something like a relay.” Which is what I’m doing. To fix this, the articles suggested downloading the Optiboot source files from github, and compiling the bootloader making sure the line or lines LED_START_FLASHES=0 and not 3 which it would normally be set to. There also happen to be a direct link to an already compiled hex file, so I used this thing here – a USBasp device along with a piece of software called avrdudess to burn that hex file onto the controllers Arduino. After doing this the lights have stopped flickering but I then noticed the spindle enable signal wasn’t able to trigger the relay input – but would trigger if the flood enable signal was also plugged into another input along the same relay module. If I sent a M3 or M8 command both the spindle enable and flood enable relays would turn on at the same time. I suspected this was a grounding issue, and the final thing I did was connect the ground of the spindle enable pin to the ground of the four channel relay module and this seems to make that unwanted behaviour disappear.

Here I’m just going to show you the laser module plugged in and powering up, and that the LED under gantry lights are not flickering, and I also turn the laser and the spindle on at the same time. I was wearing laser goggles and in future when using this machine I will have to unplug one device when using the other.

I’ll just take this out as I’m not using that.

In this shot I’m showing you the output relay module turning on and that the spindle enable pin is not causing the small onboard LEDs to flash. And I also turn on the spindle enable pin with the M3 command, and later the flood enable pin with the M8 command. Now I’ve turned off the spindle with a M5 command, waiting a moment before turning the flood enable off with an M9 command. Why GRBL controllers are sent out without the amended bootloader is a bit of a mystery to me – but I would recommend everyone to do this especially if they plan to use relay modules to interface from the output pins to their tool.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s