Troubleshooting / Debugging CNC Router Machine and Controller Enclosure

  • Measure between limits by enabling hard limits

So I’ve connected the CNC machine to my enclosure but there’s still a few things I want to do, and quite a few teething troubles to solve. I’ve also installed bCNC onto my laptop which is the software I will be using to send gcode, and I’ve made a separate video about that installation which I’ll link too in the information card. One of the reasons I installed bCNC was the multidate of features including a margins scan, although that doesn’t seem to work. I’ll start with that problem because the sooner I can identify the margin, the sooner I can start preparing the waste board

Ok so I can’t seem to get the margins scan to work on bCNC with my CNC machine or in particular my controller. I’m hoping that maybe in the future I can delve into the firmware and workout whether there’s something I can write or change that will allow me to achieve that. But in the meantime I think I’ve figured out a way of measuring the distance between the limits. What I’ve done is enabled hard limits, and position the spindle and gantry on one side until the limits have been reached, and they won’t more any more. And the plan is to just move the gantry across until it stops and read the measurement off the software.

I’ve just reset bCNC so I should be able to move that across limit switch. When its hit that, or more to the point when it’s detected the oncoming gantry it should stop.

That was a bit scary to watch.

  • Setting stepper controller switches / and steps in bCNC software

What the fuck happen there?

That happen because I accidently left one of the switches on the stepper driver in the wrong position. This is the correct layout of the switches. 1-3 define the current being sent to the motors, 4 determines whether the motors receive half or full current while idle and 5-8 define the micro-stepping.

It’s probably worth mentioning how the micro-stepping switches relate to the settings in the software. I’ve already set my steps within software and if I ever change the steps on the drivers for whatever reason, I’ll have to recalculate the steps and input those again.

Setting the steps correctly will ensure the machine moves accurately and also how noisy the motors are. I’m using leadscrews with a pitch or screw spacing of 2mm and a lead or travel of 8mm per revolution. I used the step calculator on the RepRap website to work this out – by setting the motor step angle at 1.8 degrees, the driver micro stepping to 1/16 and where it reads Leadscrew pitch well that’s wrong – it’s actually Leadscrew lead which is the travel from one full rotation – in my case 8mm. I ignored the pitch pre-sets, and the gear ration should be 1:1 because the leadscrew is directly connected to the motors. And the magic number I wanted was 400.00

Over in bCNC under the Tools tab, I selected the Controller Configuration and put that number at $100 for x, $101 for y and $102 for z.

I had one of the switches in the wrong position, so they were moving at different steps. Ok anyway, here goes again.

So after that I was able to move between the hard limits and get a number for the wasteboard – which was 315mm square. I don’t think I’ll be keeping the hard limits enabled because my CNC machine is so small it’s highly likely I will accidently get close to them and halt jobs mid-cut.

There are however two new problems. While the CNC was trying to rip itself apart I noticed the estop didn’t halt the motors, and three of the four stepper motors were not holding position while idle.

  • Three of the four motor couplers do not hold when machine is in idle

Ok so the only stepper motor that seems to be holding when the machine is stationary is Y. All the others ones I can move around a little bit. What I am going to do is check the wiring by swapping each one with the Y terminal and see if the motor holds. I’ll start with A. Push that in and move across to here – that’s holding.

I began testing all the wiring first by swapping all the cables outside the case with the one socket I knew worked, and then I checked the wiring inside the enclosure between the aviation panel mounts and the one driver I knew worked. All the wiring seemed ok.

I then noticed something else.

So if I pull the USB cable, out all the motors are being held, so it’s something to do with the controller and the USB when it’s plugged suddenly only one motor is holding.

My instinct with these things is to think it’s a physical problem but I never learn. When it comes to Arduinos, the problem is seldom where you think it is. This time, coincidently another YouTuber called Kyo uploaded a video about stepper wiring and mentioned parameter $1 – also known as step idle delay, which when set to 255 solved this problem instantly.

Essentially anything under 255 will be the duration in milliseconds before the stepper drivers essentially disable the motors, and stop running powers to them.  And obviously I don’t want that to happen. I want to maintain power to the motors so they hold in their position and I can use that to keep a reference of where I’m position in the software. So I’m just going to do that now.

And I was able to do that directly in bCNC. I’ll link to his video in the information cards as well.

I can’t turn this, I can’t turn that. This can’t turn.

  • Stepper motor delay when Estop pressed

I’m not sure what to do about the eStop but I suspect I am going to have to re-wire this.

At the moment, one of the two switches on the emergency stop is connected to the power supply of the phoenix control board, while the other trips the break on the VFD.

The problem I have with cutting power to the control board is the steppers drivers still receiving powered separately from the controller. This delays the stepper motors by a couple seconds before they slow to a full stop.

I’m going to move the gantry across this way, and press this button here which will kill the power to the controller. I want to see whether the motors stop abruptly or if they carry on for a little while.

So there was a second delay.

What’s going on?

So I just turn the controller back on and for whatever reason the gantry moved back a little and again in the direction it was originally going, so simply killing the power isn’t enough for the estop to do what I want it to do. Which is to stop everything and for nothing to carry on once the controllers been reset.

There’s a prevailing logic that an Estop should kill all power but the problem with that is you need power to break motors – otherwise they coast to a stop.

Ok that was not breaking at all, so killing the power and hoping there’s enough residual power in the power supply of the VFD to apply the break in the spindle clearly won’t work

If the motor and spindles don’t break at the same time this can cause expensive CNC bits to snap off in material, or worse, if you are caught in a machine you could get pulled in by the momentum of the moving parts.

There is an abort terminal on the controller which is now alongside the pause and resume buttons, and actually that little silver button is my temporary estop.

I’m just going to move the gantry across that way and then I’m going to press this button here which is actually connected to the emergency stop on the control board.

3,2,1… it stops instantly. If I turn the spindle on. 

And this is what happens when I press the big red latching emergency stop

And then again side by side.

That stops a lot quicker.

I’ll come back to the estop after I have done a little more research – for now if something goes wrong I can press that silver button instead.

  • Check how square X and Y axes are and adjust

The other thing I want to do is check that the X and Y axis are square – this is a little annoying as ideally both sides of the y axes would have their own independent limits which can be micro adjusted.

So this a sacrificial board. It’s relatively flat. Probably could be flatter. And what I’m going to do is drill four point of a square using a 60 degree vee cutter, and then I’ll measure between the point and check whether the x and y is square.

In the same why that you check if drawers are square by measuring between opposite corners – I make four point onto a piece of ply and measures between them. It looks good so I don’t have to do anything but had I, I would have removed one of the stepper cables for one of the y axes, (342mm) adjusting the individual coupler by hand and plugging the cable back in so the power held it in the new position. (342mm that’s not bad).

I also engraved a rectangle and checked that’s ok, which it is.

  • Cut into sub waste-board and set insert nuts, fit waterboard, surface MDF.

The next thing I did was use the CNC machine itself to mark the top two corners positions the wasteboard, and then to cut four countersunk holes into the sub-wateboard which will hold the wood inserts that I’ll later attach the sacrificial waste-board too.

So remember earlier I sunk the vee bit in and made two points. Well they are going to correspond with the two corner of this piece of 18mm MDF.

Because I didn’t reset the origin position of the x and y axes, the cuts through the 18mm MDF lined up accurately and even pushed a tiny round bit of MDF into the opening of the insert nut.

Ok this is how accurate the machine is. It’s actually pushed the tiny wafer of wood that was left at the bottom into the hole of the insert nut. That is fucking amazing.

I then used a spoil board bit which was sent to me by to surface the top of the MDF so it flat and parallel with the gantry.

I’m going to surface the stoll (sic) bored – the stoll board? I’m going to surface the spoil board and use this bit here. It looks a bit Klingon. The important thing about doing this is the make sure the CNC machine is in the position you want to use it for the foreseeable future. I am happy with the position of the spindle, how that’s clamped in place, how everything seems to be travelling.

After which I drilled several more counter-sunk holes for additional wood inserts which I’ve use to hold downs material I am working on.

While cutting these I realised the spindle was turning a lot faster than the pre-set speed from the tool database I had for the g-code. I tried changing the speed in g-code but realised something probably in the firmware was preventing variable speed.

I could tell this because the number of Hz on the VFD display panel at the top of the enclosure was near 400, but I was cutting at around 85% of the max RMP. So these didn’t add up. Also the speed toggle bar in bCNC was also unresponsive

  • What I changed in GRBL V0.9 config.h file to access variable speed.

So I was time to edit the firmware for the controller.

It’s possible to edit a few parameters in bCNC but to access further features you’ll need to download the source file from GitHub, edit the config.h file with either a text editor or something like Notepad ++, and flash the resaved file to your controller using the Arduino IDE app.

I’m going to go into that process with a lot more detail in a separate video, but for now I will scroll though notepad++ and mention some of things I changed.

So these are the features I have changed in GRBL V0.9

Line 112, I uncommented the Limits Two Switches on Axes. Line 254, I changed spindle max RPM to 24000. Line 255, I changed the spindle min RPM to 10000. Line 261, I uncommented Minimum Spindle PWM which I also set to 0. And finally Line 271, which I again uncommented which was Use Spindle Dir as Enable Pin.

Doing this meant the speed toggle bar in bCNC began to work, but for some reason I still couldn’t get the margin scan to work so if anyone has any clues I would appreciate them.

  • Re-wiring Estop

I’m going to go back to the estop now.

I’m going to undo the back of another one, and simply clip this on. That’s the normally closed side, and that’s the normally open side. I’ll connect these two terminal to the VFD, and these two to the abort terminals on the controller, and I might even connect these two to the power supply of the controller just so the power gets killed as well. I think that makes sense.

One normally open switch is connected to the braking terminals on the VFD, and I extended some wires from the control boards abort terminal to the other normally open switch. I’ve also kept the silver momentary switch wire to the abort terminal so I have two ways of stopping the machine. I also kept the power cable of the control board wired via the normally closed terminal of the estop. So now when I press the emergency stop – the break is applied to the stepper motors via the controller and then the control board loses power. The VFD also applied the break and stop the spindle rotating at around 2 seconds compared to the normal 5 seconds.

 I messed about with the settings a little bit, and I’ve seemed to have overcome the overload problem – which you may remember I experienced in a previous video.

Ok the last thing I changed was function 034…

I spoke too soon, and it seems have stopped working… or more to the point, sometimes the brake holds and disengaged  when it’s meant to and other times it just holds endlessly until I reset the latching emergency stop or an overload message reappears on the VFD display panel. I think I’ll buy a braking resistor for the VFD and see if that helps.

  • End

I’m going to stop the video now. It’s kinda gone on a little too long, but I have gone through quite a few different stages, and parts of the machine, to debug and troubleshoot problems that I have had with it. I think it is ready to use and it’s about as safe as I can get it. I really feel like saying that if you are planning to do something similar I strongly recommend, in the first instance getting a VFD and spindle at the same time, so they are a bundle and they have been properly configured to work with one another. I have to admit I am not a trained electrician so if I have any bad habits I may not even be aware of them. Obviously the quickest way to make a CNC controller is to just buy one. As a learning experience this has been very valuable to me, so I don’t regret it but this has taken me away from my main channel to the point that pocket83 even noticed I’d not been around for several months – which is nice, he cares. But I’ve got a little bit obsessed with this. It just takes so long for me to make these videos because I don’t really know what I am doing. I have to go through every single stage and check, double check, and triple check that I am not producing information that is wrong and could be dangerous to people doing similar things, and information that doesn’t make sense in the end. And to be honest sometimes I fail. I have lost a few YouTubers – god knows what’s happen to them. I can only assume they’ve been electrocuted by a variable frequency drive. Anyway thanks again for watching. I am working on another two videos. One will be a screen capture of how I edited the firmware on bCNC, and the second will involve making a dust shoe for the machine. Thanks again for watching, don’t forget to sacrifice a thumb, and check out all the usual links in the information card and description. thank you very much, bye.

Leave a Reply