Below is a kind of work-flow I did while testing the wiring of various components and setting up the firmware for the CNC control board. I’ve included the probe although this doesn’t feature in the video, as well as the limit switches, control inputs, the 8 channel relay module and how to update the bootloader on the Gradus M1 Pro. It does assume some previous knowledge but also is written in a simple series of steps which might point you in the right direction if you working on a similar thing. A copy of my firmware and the diagrammatic images featured in this video will be made available to my Patreons.
****
Relay module:
- Active high low 24v 8 channel relay module – opto-isolated. Three for Limits, one for hard stop, one for soft stop, one for feed-hold (button and door switch), one for resume button, and one for probe button.
Probe:
Firmware:
- // #define DISABLE_PROBE_PIN_PULL_UP
- $6 = 0 – Invert Probe Pin so it is triggered when voltage is pulled from 0v to 5v.
Physical Wiring:
- Probe and ground to Normally Open terminals on Relay module – terminal is held at 0v.
- Terminal set to Active High and Probe button wired to Normally Closed terminals on button.
- Probe wired to input terminal on relay module via 24v
Actions:
- If button is pressed before probe cycle starts or wires broken the G38.4 or G38.5 probe cycles will result in alarm.
- If wires from control board terminal to N/O relay are broken, probe cycle will result in alarm.
- If relay fails in an open state, the G38.4 or G38.5 probe cycle will result in alarm.
Limitations:
- Do not perform G38.2 or G38.3 probe cycles.
- If relay module fails in normally closed state – because internal components get fused together, the probe cycle will only stop after set probing distance is reached.
Limit Switches:
Firmware:
- // #define DISABLE_LIMIT_PIN_PULL_UP
- $5 = 1 Invert Limit Pins so it is triggered when pulled from 0v to 5V.
Physical Wiring:
- Limit and ground wires of X, Y and Z terminals on controller are wired to normally open and com terminals on relay module – terminal is held at 0v as normally open terminal is closed when powered up.
- All proximity sensors are wired to 24v DC power supply.
- X and Y axes are wired in parallel to two sensors and a single proximity sensor is wired to Z.
- Relay module terminal set to active high and the proximity sensors are NPN N/O.
Actions:
- If any proximity sensor are triggered or wires cut home cycles will result in alarm.
- If wires from controller terminal to N/O relay are damaged probe cycle will result in alarm.
- If relay fails in an open state home cycle will result in alarm.
Limitation:
- If relay fails in normally closed state, the Home Cycle will stop after max travel distance is reached. Physical hard stops are in place on CNC machine to prevent moving parts damaging machine or components.
Control Pins:
Firmware:
- // #define DISABLE_CONTROL_PIN_PULL_UP
- #define ENABLE_SAFETY_DOOR_INPUT_PIN
- #define SAFETY_DOOR_SPINDLE_DELAY 4.0 // Float (seconds)
- #define SAFETY_DOOR_COOLANT_DELAY 1.0 // Float (seconds)
- // #define INVERT_CONTROL_PIN_MASK ((1<<CONTROL_SAFETY_DOOR_BIT)|(1<<CONTROL_RESET_BIT))
- #define PARKING_ENABLE
- #define PARKING_AXIS Z_AXIS // Define which axis that performs the parking motion
- #define PARKING_TARGET -5.0 // Parking axis target. In mm, as machine coordinate [-max_travel,0].
- #define PARKING_RATE 500.0 // Parking fast rate after pull-out in mm/min.
- #define PARKING_PULLOUT_RATE 100.0 // Pull-out/plunge slow feed rate in mm/min.
- #define PARKING_PULLOUT_INCREMENT 5.0 // Spindle pull-out and plunge distance in mm. Incremental distance.
- #define ENABLE_PARKING_OVERRIDE_CONTROL
Physical Wiring:
- Hold-feed, Reset (abort), and Cycle Start (resume) and their grounds, to Normally Open and Com terminals on relay module.
- Relay set to active high.
- 24V and ground from PSU to relay and 24v power daisy-chained along barrier block.
- Reset (abort) – 24v power to momentary normally closed button, when pressed 24v drops to 0v and relay de-energises. Controller side goes from 0v to 5v.
- Hold-feed – 24v power to momentary normally open switches (door) which is held closed to simulate door closure and to normally closed button on front of controller. When open 24v goes to 0v and relay de-energises. Controller side goes from 0v to 5v.
- Cycle Start (resume) – 24v goes to momentary normally open button. Relay is energised when button is pressed closing circuit.
- Reset and Hold-Feed are active high, and Cycle Start is Active low on controller – all held high by pull up resistor.
Actions:
- If feed-hold button, switch or cables are disconnected cutting job will not start or will stop if already commenced.
- If Reset (abort) buttons or cables are disconnected during job – alarm will display preventing continuation and a hard reset will be needed.
- If Reset (abort) is disconnected before job commences, hold feed and resume buttons will result in alarm and not their normal behaviour.
- If Cycle Start (resume) is disconnected before job start, job will only commence from software – hold feed and reset continue to work.
- If Cycle Start (resume) is disconnected while hold-feed switch is open (simulating door opening) job does not resume.
- If Cycle Start (resume) is disconnected during job hold-feed being pressed, job cannot resume, Reset (abort) results in alarm.
- If Cycle Start (resume) is disconnected and job is loaded, and hard reset performed while Cycle Start (resume) is disconnected job does not commence.
Bootloader
https://forum.arduino.cc/index.php?topic=504367.0
The Gradus M1 Pro uses the Arduino Pro / Pro Mini bootloader “an outdated bootloader that requires a larger boot section than the Uno’s optiboot bootloader.” When I #define PARKING_ENABLE, and #define ENABLE_PARKING_OVERRIDE_CONTROL the compile file became larger than the available space on the Gradus. As the Gradus (Arduino Pro / Pro Mini) uses the same chip as the Uno I used an ISP-USB bootloader connected to ICSP header to burn the uno’s bootloader to the Gradus. After that when re-compiling the firmware and uploading it to the controller instead of using Board: “Arduino Pro or Pro Mini” and Processor: “ATmega328P (5V, 16MHz)” I can now select Board: “Arduino, Genuino Uno”
****
In this video I’m going to install the components for the CNC controller onto the backing plate. This will include the Gradus M1 Pro control board by Panucatt, an eight channel opto-isolated relay module and two 12 terminal barrier blocks.
I’ve already wired the components together – paying particular attention to getting the right combinations of wiring to settings on the firmware, so that if peripheries were not in place actions would not occur. For example, if the hold-feed button which also acts as the door safety-switch was not in place the controller would alarm.
I’m using the stand-off with the threaded bit facing upwards – securing with a machine screw and split washer through the galvanised plate. I fit one component at a time, removing the parts before drilling the next set of holes.
So I’ve got my M2.5 standoffs. I’m going to go with some small ones for the first layer and then I’ll have to double a few up to get the second layer. (I need to buy a nut spinner.)
The second layer will hold a four-channel relay module which I’ll connect to the spindle enable terminal on the controller. This will allow me to control a hand router, turning it on and off with the m3 and m5 commands. I want to have the option to use one in-case I decide I don’t want to use a dedicated frequency drive and spindle. The other channels could be for the flood and mist enable or I could connect some LED lights to illuminate the machine when in different states – red while cutting for example and white for idle.
I am finishing off installing the first layer of components – using larger m4 machine screws to secure the barrier block with the one closest to the relay module raised to give me clearance to connect wires. I’m using a couple nylon spacers with this raised section here.
I haven’t really explained what I’ve done with the connection as I don’t think these will translate to videos easily – so what I will do is provide an illustrative diagram as a copy of my amended firmware as a downloadable link on the Patreon post for this video. But for those who don’t want to venture far from the relative safety of YouTube – this is a rough non-technical sketch of the limit switches and control input connections. As I mentioned previously I wanted to utilise fail-safe’s into the control box design so actions wouldn’t occur if parts for example, rattled themselves loose or failed. This process took a while and I don’t think I’ve entirely cracked it, as there’s still some scenarios which might cause problems, but this controller feels safer than any I’ve built before. Alongside the physical layout I had to edit the firmware somewhat, and I wrote what I had done as a work-flow in a text document because I have the memory of a goldfish. Anyway if you want to understand technically what I’ve done I suggest you go read that on my website: http://www.miscpro.com.
There’ll also be a section there about updating the bootloader on the control board to increase the space available to upload the amended GRBL firmware.
So this is a Gradus M1 Pro here, and then I’ve got an eight channel relay module board which has opto-isolators or opto-couplers along there. I’ve also got this set to active high, it’s 24 volts. And these are the barrier blocks which interface between the switches and limit switches and the buttons. I’ve got 24v coming in and being separated to where it’s needed essentially, and the power which is going to come in to the control board and that’s going to go to the 36v DC, which I’ll cable tie along the front there just to make it look a little bit neater. It looks pretty neat but I probably could have shifted this a little bit further that way. The main this is that all the terminals are accessible here, and I can tighten then up if I need to and these will go off to the various stages.
Ok that’s good.
I’ll just quickly mention about setting up the drivers. These ones are onboard the controller themselves. I’m planning to use 1/16 steps on my BSD109A bigfoot drivers – which you set with jumpers on the drivers themselves. I’ll be using them with Nema 23 1.16Nm 1.5A 4 Wires stepper motors from OMC stepper online, and for these to work I’ll need to set the vref by adjusting the trim pot on the driver.
The Vref can be worked out by dividing the current limit by two in my case 1.5amps divided by 2 is 0.75, and this can be measured on the driver with a voltmeter by holding the positive lead to the crown of the trim-pot or the Vref jumper pin and placing the ground lead to any ground pin on the host controller.
I’ll turn it off from the switch. And if I turn it back on the power doesn’t come back on. To line up the hex standoffs to the upper level I began by trying to trace the layout on a piece of paper – and then realising that was a waste of time, and that I could use fusion 360 and simply triangulate the position between the known layout openings of the Gradus control board and the eight-channel relay module.
I’ll just show you what I drew up on the software. I know the layout for the four individual holes on the control board and relay module, and in the software I was able to input and specify the measurements from top left to top right hex standoff and from the bottom left to the bottom right, which automatically adjusted the shapes so all the parts line up – assuming that I made the original holes square, which I tried to do. So there’s no need for me to do the maths which is probably how society as we know it ends. Someone decided they didn’t need to do the maths.
While that prints I’m going to make the holes for the buttons. These buttons were by far the cheapest of the 24v LED back-lit variety, that I could find. They are not great but for low DC voltage applications I think they will do.
I’m going to place the parts back into the box just to double check they won’t whack into anything.
After laying out and trying to imagine that once placed, parts wouldn’t conflict with one another I used my step drill to make the 16mm openings which would mount them. I have four switches at the front – the red will connect to the control boards hard stop, the blue will connect to the GRBL reset or soft stop terminal, yellow or amber is for the hold feed and green is for resume start.
Hazar! The 3d print is complete and I can test the fit.
I’m using a pipe deburring tool to remove the brim from the print. It looks ok but I think I’ll later make this out of a galvanised metal sheet which I can ground. A metal backing plates as opposed to a plastic one can conduct electricity and should help with draining and shielding parts from EMI. I’ll carry on with the buttons. I first wired up the onboard LED lights however noticing the labels on some of the terminals were back to front. This meant that when I initially test-wired all the LED in series one half turned on.
They all turned on there because I resolved the issue, and once I was happy with the test wiring, I made this permanent by soldering the connection onto the buttons and using heat shrink to cover any exposed ends.
I’m now going to wire up the individual buttons to their terminals.
I didn’t film this but I will describe these connections. Now use your imaginations. The hard stop goes to normally closed terminals on the button, cycle start resume to normally open, and the hold feed and reset to normally closed.
Don’t trust this footage as exactly correct. I missed-wired the cycle start to the normally closed terminals, so it’s relay module light is on and that should be off. This wiring setup causes a conflict in the software. I also wired the hard stop to the normally open terminal on the relay, by accident. This meant the controller was in a perpetual state of alarm. It’ll need counselling before being able to connect to the CNC software.
And later what I’ll do is wire to the old feed to that a switch comes out of the enclosure and be connected to an enclosure for the CNC machine.
Oh yeah – later I will build an enclosure and wire the door to the hold feed switch. There are some settings in the firmware which turn off and park the spindle at a safe machine position, when the hold feed button or door switch are activated. In my notes for this video I wrote maybe show settings in notepad++
I just screwed the fan onto this piece of 3D printed plastic. That’s going act as the second layer. I’ve also added the four channel relay module, and I’ve also added hex standoffs which will eventually hold the Raspberry Pi. These will go to the relay although I’m not going to use the flood and mist at the moment. I just want the option of having those there and available.
I am now drilling the openings for the glands which will secure the cables from the steppers motors and limit switches.
There’s still a few holes I want to make for the VFD and for the laser signal. But I’ve done the switches and I’ve got the glands on the opposite side over here for the stepper motors.
I’m jumping ahead now wiring the cables through the glands. My stepper motors have four wires so they are bipolar, with two motor windings. To wire up your steppers you need to identify the pair of wires for each of those windings, and I did this by simply hold two of exposed wire ends together while trying to turn the motor shaft. If it resists movement then you’ve identified the pair for one of the motor windings. I wired one pair to A1 and A2, and the other to B1 and B2 on the control board. My Y axis uses two stepper motors, so I need to make sure those are wired identically. And later when I turn the machine on for the first time, before homing, I’ll jog the machine a few mm to make sure the axes are moving in the right direction. If they are not I’ll swap one pair of wires around in the terminal on the control board. I want to get this thing moving and hopefully it doesn’t make any future work to the electrical box too fiddly.
Using glands helps reduce breaking the shielding or screening around the core wires, but also prevents dismantling the machine from the controller.
I check the limit proximity sensors work correctly, looking out for the led turning on and the relay module switching when the sensor comes into contact with metal – a precision screw driver in this case.
I ran into a little trouble getting the machine moving – and it turned out to be something very simple. Ok I’ve got it moving. It was something quite simple which I had overlooked. It was the hard reset which was wired into the normally open terminal on the relay.
I’ll start with the hard stop. Soft stop. (Hold feed) Ok I miss-wired the resume start button which should have gone to the normally open terminals on the button. I just didn’t pay attention to my notes again – but it was a quick fix. I can now show you all the buttons working.
I’m now going to show you the buttons working while this is performing a test movement from a G-code file. I’ll start by pressing the Hold Feed button. That stops the machine and slowly move the z axis up to a safe parking position. If you imagine that was a door that was open that was be the last action that would occur. When the door is closed you press the Cycle Resume which is the green button. That brings the spindle down and there will be a dwell for a few seconds while the spindle turns on and plunges down. If this was an emergency I would press the blue button and it would suddenly stop. And I’m not able to resume from this. I have to physically go to the software and reset it there.
Fooking hell. I think my rapid speed is too fast. Set to 1000mm/min.
I didn’t get a chance to explain the difference between the red hard stop and blue soft stop buttons, but what I’ve now noticed is that the hard stop will reset the machine position which means I’d have to re-home after pressing so that the work positions are referenced from the right starting points. And the soft stop may result in the work position resetting, if for example I’d used a G92 command to offset an axis. The resetting of the axis work position is something that I’ve noticed and has annoyed me for quite some time – probably the straw which broke the camel’s back, so to speak starting me on my journey into building CNC machines. And simply put the G92 Position Register / Set Position commands will reset if a M30 command is executed at the end of a g-code job, or if the GRBL soft stop is pressed. This will effect restarting jobs and instead of G92 it is recommended to use a G10 Set Tool Offset / Programmable Data Input command. Now I’ve got that off my chest.
I still have a lot of fiddling to do to the firmware but I’ll save that for another time. What I’ll try now is to cut the galvanised plate for the second layer of components. And I’ve got to do this the old fashion way with my trusty pillar drill or hole making machine.
I’ll wipe this down with a bit of methylated spirit.
So this is where I’ll leave the control box for now. I still have to wire and install the stationary probing button as well as the outputs from the controller so there’ll be more videos to come. I’ll provide a link to a more descriptive article explain the physical connections and firmware changes in the description below.
And finally it’s probably a good time to mention that I’ll be attending Maker Central this year. I’ll be sharing a stall with Nathan from OpenTronic or now Blinkenlits – he’ll have his synthesizers with him and I’ll have bought this machine in a more complete a state then what you see it now. So look out for us on 11th and 12th of May 2019 at Maker Central in the Thunderbird hangers of the NEC.