Hi All, I'm in the process of building a CNC machine,

Hi All,

I’m in the process of building a CNC machine, and have decided to use a Due with G2 Core. I have designed a board to interface the Due, with the default pinout of G2, to the CNC bits. However, there a a couple of little niggles that I’d like to get hammered out before I have the board made.

First, the GRBL related io, feed/hold, reset, and cycle start puzzle me. Are they inputs?

I haven’t trawled through the code to see how it works, primarily because it scares me. The documentation I’ve been able to find talks about those functions as used from the json interface. So I’m not really sure how to use those io pins with the hardware.

Second, is there a way to use/implement a homing plate? It’s not clear if there are any functions already implemented to allow the use of one. If there is, where do I find it described, and what hardware io is required?

Any help would be greatly appreciated.

Feed/hold, reset, and cycle start are all inputs, they are internally pulled high, if you want to use any of them you just need to connect a normally-open switch between the pin and ground.
Check GRBL wiki, everything should be explained there.

Do you mean Homing- and Limit -Switches?

Many thanks for that. I’ll have a look.

The limit switches I’ve got. I mean a homing plate for setting the height and position of the workpiece.

That would be a Tool-Length-Sensor. It has nothing to do with homing (G28.1) but with the probe command (G31).

@Marcus_Wolschon I thought it might be something like that. I found the G30, and thought that might work. That’s not really the important thing. What I am hoping is that I can use the spare limit switch inputs (Amn, Amx, Bmn, Bmx). The clever bit is whether or not there is already a default mapping for that, or am I going to have to compile a custom build?

@David_Coones ​ wouldn’t you just use the zmin pin?

I’ll be using normally closed switches for homing/limits. I could change the limit switches to a solid state solution, but I’d rather not. I did consider it (using X/Y/Z inputs), but apart from already having the hardware, it would drastically reduce flexibility. Besides, I should have plenty of io for it. But as my programming skills are rusty (iow tragically out of date) I was hoping I could use the off-the-shelf build.

This may well be something that seems trivial to most folks, but I’m new to G code and don’t really have my head around how it hangs together yet, specifically as regards reading ancillary inputs…

Someone else can chime in but I think probing in tinyg2 uses zmin. With normally open switch. There is info in the wiki.

That reminds me, I’ll need to figure out how to set the polarity of the limit switches. Presumably that’s done using json commands? As for using NO contacts, I’m a little surprised at that. It isn’t a fail safe arrangement, whereas NC is.

The usual way to wire switches with arduino’s is to have them NO and tie them to ground, using the built in pull ups. Saves on components and power.

I’m not that familiar with the G2. I have not reviewed the code. In one wiki article I read the suggestion was to have the z axis NO and the others NC. In another I found that during probing the switch is set to NO irrespective of what it should actually be.
I assume therefore that if the switch is normally NC then what the code does is look for a change in value from the initial state irrespective of whether it starts low or high. So I guess you have to make sure that when you start a probe you are not already touching the board.

Here is the quote

Note that probing cycles (G38.2) will work regardless of the switch setting. Probing (currently) assumes a normally open switch in the Z minimum position. During the probe cycle switches are set to NO (and ignored). They are restored to their actual $st setting when probing is complete.

@Justin_Adie Thanks for that, I haven’t managed to find that particular page/quote yet. I have found that the default for the X and Y axes are listed as ‘normally closed’ by default (v9). The Zmin is listed as ‘Active High’ by default. These are identical conditions, and the inconsistency is confusing. The Zmax, and A axes components are disabled by default. I can’t find anything about B.

The impression I get is that this functionality isn’t really very developed yet. In order to flesh it out properly, I’ll have to get into the code, which I don’t really feel up to yet.

I very much appreciate the support here, but I think I’m going to jettison this requirement for now and revisit once I actually have my machine completed and have managed to turn at least one circle first.

I will, however, be putting the inputs for A and B axes on my interface board. If anyone is interested in interfacing to a Due, I may have a relevant daughter board you can look at in relatively short order…

The input to the board is active high. That’s correct as I read the wiki.

And that’s how switches are normally down. Set the port as input_pullup and wire an NO switch to ground. When the switch is pressed the line goes to low.

How that is interpreted by the due I don’t know. The term ‘active high’ could have opposite interpretations.

Were I you I would read the wiki pages on the tinyg and g2. The latter is a port of the former so the basic tenets should be reflected.

Autolevelling in chilipepper seems to work well for many people so probe functionality must equally work well.

Unless you have a very unlevel workpiece or your axes are way out of alignment I expect that level probing is more critical for PCBs and engraving than for milling

@Justin_Adie Nope. Active high means a normally low signal, and action is taken when the signal goes high, i.e. nothing happens when the signal reads low/off/closed/0. So wire the switches normally closed to ground with a pullup. When the switch actuates (opens) the signal goes high and the system responds.

“Set the port as input_pullup and wire an NO switch to ground. When the switch is pressed the line goes to low…” is an active low signal.

Nevertheless, your advice to read the wiki’s is good, and is exactly what I intend to do. I have made a start and will try to digest things thoroughly.

With regard to flatness of the machine, I’ve been very careful with my setup and my base is within about half a mm over 1 metre span. Given that it’s made both of mdf and by my little hands, I’m pleased with that. But who knows what strange workpieces may find their way onto it…

You’re right, of course, most of the time it won’t be necessary, but that doesn’t mean I don’t want the capability. That is also the reason I’m going to leave this for now. I think getting up and running is probably a little more important. My machine isn’t even finished yet…

Thanks. I understand what active high means! The point was that it can be interpreted either way in the context of a limit switch.

Ie. The axis remains active in that direction until the input is low or the limit is active (axis is inactive) when the input is high.

By base I guess you mean the workbed relative to the x axis? The actual bottom of the machine shouldn’t matter too greatly if all the axes are true perpendiculars to each other.

On the subject of MDF - is that stable enough under torque? Everything that I make from MDF (or ply) goes horribly wrong due to the seasonal change in humidity where I live. Maybe yours is sealed; although even kitchen units sealed with laminate look quite poorly after a couple of years in my neck of the wood!
0.5mm over a 1000mm sounds impressive. Particularly when the typical circuit boards I buy have 0.2mm of thickness difference between one side and another! And when I autolevelled one I found it had at lease 0.6mm of warpage in the middle. Probably moisture.

@Justin_Adie I take your point about active signal vs active output. However, I have only ever known the term to apply to the control signal, not the controlled variable. Are you saying that when the wiki says, for instance, “active high” that it could be referring to the axis under control rather than the control signal? If so, that’s a worry because then the only way to figure out what is happening is to inspect the code.

Yes, that’s what I mean by the base. I built a torsion box on which sits the bed and spoil board.

I very much share your concerns about mdf, but until the budget allows, that’s what I’ve got. And the sections are all 18mm thick. The torsion box is impressively stiff, and flat. The bed and spoil board are anchored to the box.

It is very flat, and I’m quite proud of it. Having said that, I haven’t used it yet, because the machine isn’t up and running. So it might not stay that way long. But the temperature and humidity are pretty stable. The temperature year round never moves by more than about 5 degrees C. And the diurnal excursion is really narrow, so temp is very stable. Better than my home, that’s for sure. Humidity I can’t control, but RH is typically in the 50-70% band and only changes slowly.

this link may be useful:Homing and Limits Description and Operation · synthetos/TinyG Wiki · GitHub

suggests that you wire to across the ground as I suggested and then use either an NC or NO as you want and add the decision to the config. on the tinyg2 they have debouncing RC circuits on the inputs; and a pullup resistor. The Due’s have input pullups too (in the chip). you may need to build your own RC filter if you are getting a lot of noise; but there may be some software debouncing in the code - probably not given the purpose of the limit switches.

looking forward to seeing some pics of your build in action!

@Justin_Adie So am I!

NC is typically not a good choice for mechanical limit/homing switches. Machine vibrations can open a NC switch for enough time to falsely trigger. Low pass filtering (RC or SW) may not be needed, especially if homing speeds are slow enough that a few ms of switch bounce will only cause miniscule homing error.