New 6-Axis Dual Mach3/GRBL CNC Controller that we have designed to control our new CNC D-500 Machine.
This new controller has dual inputs and allow the popular Mach3 software to be used via the parallel port and also USB port to control GRBL firmware running on the Arduino Mega2560 board.
So best of both worlds for those wanting to experiment running their machines with different Gcode engines.
Being 6-Axis allows for future expansion of the machine.
Multiple limit trigger inputs that are all buffered and opto isolated along with a ARM processor that monitors the motor alarm lines.
We have programmed the Arduino board with the Grbl-Mega-5X firmware which is open source and can be downloaded from the following link
https://github.com/fra589/grbl-Mega-5X
As you can see in the picture above the main breakout board in the middle will plug into the Arduino Mega 2560 R3 board and then the board on the right plugs into the breakout board.
When mounted in our controller box that we designed, you can see you have easy access to the USB port, DC power input and parallel port.
Inside the controller box there is plenty of room to mount the controller as well as power supply and cables.
The box itself is all made out of aluminium plates that have been finished with a black oxidisation and laser marked.
The whole box acts as a sturdy heat sink and helps keep everything nice and cool.
Also their are two AC input sockets on the back, one for the main power supply and another for the spindle. Both have power switches at the front of the box.
We are supplying it with a branded, genuine MEAN WELL 36V 8.9amp power supply that has a wide range working voltage input of between 88V and 264V AC.
As you can see there are no stepper drivers inside the controller box as we now use Closed Loop Stepper motors on all our machines. the Closed Loop Stepper motors have the driver built on on the motor. along with an encoder that makes sure their are no lost steps and great performance.
So all we need to do is supply power to each motor and data control lines from our controller board.
The controller board itself has a huge number of inputs and outputs to take full advantage of the features found the 6-axis GRBL firmware and the Mach3 interface. These I/O’s can be switched to to either configuration by simply setting a jumper or by connecting a single way switch.
To view the picture above in more details, you can right click and save the image or click on it and choose view full size from the bottom of the image frame.
All the I/O’s have been been broken out to connector blocks and the PCB has legends next to each one. It also has JST connectors for some of the I/O’s that are commonly used on a 3-Axis machine such as the D-500. These allow for custom made cables to be simply pushed in and connected back to the motors and limit switches.
Here is a quick breakdown of the I/O’s
- For each of the X, Y, Z, A, B, C Axis outputs there is a 5V, Enable, Step and Direction lines.
- The X, Y1, Y2, Z also have Alarm monitoring connections for the each motor. These are found on Closed Loop motors. These are monitored by an ARM processor on the main board which will display which one is triggered by lighting up the indicators at the front of the controller box.
- The Y Axis also has dual output, so we have Y1 and Y2 which is for gantry systems that use two motors. Y1 and Y2 are synchronised.
- All motor control lines are electronically protected with open collector buffers. Being open collector means they switch the step line with a negative pulse.
- Each Axis has a Limit switch connector block and supplies power +/- and an input back in. The + output can is based on the voltage of the Limit switch input. We use 5V inductive switches with our machine and so simply loop the 5V output of the board to the Limit supply input.
- You can connect between 5-24V DC from a separate supply if you want to use other Limit switches.
- Each Limit input is opto isolated and designed for negative input switching.
There is a Limit Min and Limit Max input for each Axis and this is mainly for GRBL. For Mach3 you would usually just use the Min inputs but there are jumpers to allow the Max inputs if preferred. - For the Emergency Stop input there is a input and GND output that can be connected to a N/O switch.
This is also monitored by the ARM processor on the main board that will trigger an alert for Mach3, but also send a reset to the Arduino board that is running GRBL.
When a trigger is detected by he ARM processor it will light up the indicators at the front of the controller box. - The Reset, Probe, Cycle, Feed, Spindle Enable, Spindle Direction, Spindle PWM, Motor Coolant, Flood Coolant, Safety Door I/O’s all go directly to the Arduino processor and more information can be found on the GRBL wiki https://github.com/fra589/grbl-Mega-5X/wiki
- Finally there is a jumper on the top board that switches control to the Printer Port input for use with Mach3 or if removed, switches control to GRBL which uses the USB port. If you do not want to use the jumper then this input can be taken out to a switch like we do on our controller box.
So that is a quick run down of the I/Os and below is a quick connection diagram.
To view the picture above in more details, you can right click and save the image or click on it and choose view full size from the bottom of the image frame.
Included on the picture is the 8 pin JST connector that we use on our machine which shows connections to the Closed Loop motor.
If not using cables with JST plugs and the connector blocks instead then remember to split our the single 5V line to each input of the stepper driver.
Also below is connections using normal Closed Loop motors.
Machine travel speed.
Because of the solid build of the machine, the travel speed can hit some impressive speeds of over 10000mm/min.
But there is no reason to really travel this fast, plus you only have 500mm of travel, so you are going to run out of travel room before you know it!
For both the Mach3 and GRBL configurations below we have set the travel speed to 6000mm/min which should be fast enough for anyone. But feel free to have a play with the speed and acceleration settings until you find a suitable setup for your needs.
Note this is travel speed and not cutting speed. Cutting speed you will specify when creating your Gcode and this will vary depending on the material you want to cut.
Mach3 configuration.
Mach3 has been around for years and very popular.
It can be downloaded from Newfangled Solutions on this link, https://www.machsupport.com/software/mach3/
Note that it is not free of charge and will limit you to only a few lines of gcode you can send until you purchase a licence.
If choosing to use Mach3 software then you will need to download the configuration file, extract the zip file and copy the CNC Design D-500.xml to your C:\MACH3 folder.
Download Mach3 Config File
This will configure the Pins below
Pin1 Enable Line
Pin2 X-Step/Pulse
Pin3 Y-Direction
Pin4 B-Step/Pulse
Pin5 A-Direction
Pin6 A-Step/Pulse
Pin7 Z-Step/Pulse
Pin8 Z-Direction
Pin9 Spindle Motor
Pin10 X-Limit
Pin11 Y-Limit
Pin12 Z-Limit
Pin13 A-Limit
Pin14 X-Direction
Pin15 Emergency Stop
Pin16 Y-Step/Pulse
Pin17 B-Direction
The Mach3 Gcode engine software still uses the printer port (Parallel Port) from the computer to send Step, Direction and enable signals, as well as switching spindle and limit inputs. Direct fast output from your PC with no latency like USB.
We still use Mach3 to run our workshop machines and tend to pickup old computers from Ebay that still have the printer port. Most new computers these days just have a USB ports.
There are USB to Parallel adapters that work well, but must be designed to work with Mach3 such as the USB motion controller UC100. We have tested these and they work well.
After you have copied the CNC Design D-500.xml file to your C:\Mach3 folder then launch the Mac Loader Icon.
Mach3 should now load and be configured for the D-500 machine.
Next Press Reset and press Tab key to bring up the Jog interface.
You should now be able to jog the machine around.
GRBL configuration.
Grbl is a free, open source, high performance software for controlling the motion of machines that move, that make things, or that make things move, and will run on a straight Arduino. If the maker movement was an industry, Grbl would be the industry standard.
GRBL uses the USB port and buffers commands in the Arduino board processor. This then sends out the Step, Direction and enable signals, as well as switching spindle and limit inputs.
We supply the Arduino Mega 2560 already programmed with the Grbl-Mega-5X firmware that has been configured to work with our controller and machine.
So you will not need to re-program it unless you buy a new board or something serious goes wrong!
For people wanting to play and compile it for themselves, here is the main changes we made.
Edited the config.h file and set the following sections:
// To use with RAMPS 1.4 Board, comment out the above defines and uncomment the next two defines
#define DEFAULTS_RAMPS_BOARD
#define CPU_MAP_2560_RAMPS_BOARD
#elif N_AXIS == 5 // 5 axis : homing
#define HOMING_CYCLE_0 (1<<AXIS_3) // Home Z axis first to clear workspace.
// #define HOMING_CYCLE_1 (1<<AXIS_4) // Home 4th axis (A)
//#define HOMING_CYCLE_2 (1<<AXIS_5) // Home 5th axis (B)
#define HOMING_CYCLE_3 (1<<AXIS_1) // Home X axis
#define HOMING_CYCLE_4 (1<<AXIS_2) // Home Y axis
// After homing, Grbl will set by default the entire machine space into negative space, as is typical
// for professional CNC machines, regardless of where the limit switches are located. Uncomment this
// define to force Grbl to always set the machine origin at the homed location despite switch orientation.
#define HOMING_FORCE_SET_ORIGIN // Uncomment to enable.
As our breakout has the same pin-out as the popular Ramps Board we have changed this to suit in the defaults.h
Note we have not setup the A, B or C Axis as people would be using these for a rotary Axis and it would be different depending on which one they have purchased.
#ifdef DEFAULTS_RAMPS_BOARD
#define DEFAULT_AXIS1_STEPS_PER_UNIT 160
#define DEFAULT_AXIS2_STEPS_PER_UNIT 160
#define DEFAULT_AXIS3_STEPS_PER_UNIT 320
#define DEFAULT_AXIS1_MAX_RATE 6000.0 // 9000 mm/min = 9000/60 = 150 mm/sec
#define DEFAULT_AXIS2_MAX_RATE 6000.0 // 9000 mm/min = 9000/60 = 150 mm/sec
#define DEFAULT_AXIS3_MAX_RATE 1000.0 // 300 mm/min = 300/60 = 5 mm/sec
#define DEFAULT_AXIS1_ACCELERATION (300.0*60*60) // 300*60*60 mm/min^2 = 300 mm/sec^2
#define DEFAULT_AXIS2_ACCELERATION (300.0*60*60) // 300*60*60 mm/min^2 = 300 mm/sec^2
#define DEFAULT_AXIS3_ACCELERATION (100.0*60*60) // 100*60*60 mm/min^2 = 100 mm/sec^2
#define DEFAULT_AXIS1_MAX_TRAVEL 500.0 // mm
#define DEFAULT_AXIS2_MAX_TRAVEL 500.0 // mm
#define DEFAULT_AXIS3_MAX_TRAVEL 100.0 // mm
#if N_AXIS > 3
#define DEFAULT_AXIS4_STEPS_PER_UNIT 8.888889 // Direct drive : (200 pas par tours * 1/16 microsteps)/360°
#define DEFAULT_AXIS4_MAX_RATE 1440 // °/mn
#define DEFAULT_AXIS4_ACCELERATION (100.0*60*60) // 100*60*60 mm/min^2 = 100 mm/sec^2
#define DEFAULT_AXIS4_MAX_TRAVEL 360.0 // °
#endif
#if N_AXIS > 4
#define DEFAULT_AXIS5_STEPS_PER_UNIT 8.888889 // Direct drive : (200 pas par tours * 1/16 microsteps)/360°
#define DEFAULT_AXIS5_MAX_RATE 1440 // °/mn
#define DEFAULT_AXIS5_ACCELERATION (100.0*60*60) // 100*60*60 mm/min^2 = 100 mm/sec^2
#define DEFAULT_AXIS5_MAX_TRAVEL 180.0 // °
#endif
#if N_AXIS > 5
#define DEFAULT_AXIS6_STEPS_PER_UNIT 8.888889 // Direct drive : (200 pas par tours * 1/16 microsteps)/360°
#define DEFAULT_AXIS6_MAX_RATE 1440 // °/mn
#define DEFAULT_AXIS6_ACCELERATION (100.0*60*60) // 100*60*60 mm/min^2 = 100 mm/sec^2
#define DEFAULT_AXIS6_MAX_TRAVEL 180.0 // °
#endif
#define DEFAULT_SPINDLE_RPM_MAX 1000.0 // rpm
#define DEFAULT_SPINDLE_RPM_MIN 0.0 // rpm
#define DEFAULT_STEP_PULSE_MICROSECONDS 10
#define DEFAULT_STEPPING_INVERT_MASK 0
#define DEFAULT_DIRECTION_INVERT_MASK 0
#define DEFAULT_STEPPER_IDLE_LOCK_TIME 255 // msec (0-254, 255 keeps steppers enabled)
#define DEFAULT_STATUS_REPORT_MASK 1 // MPos enabled
#define DEFAULT_JUNCTION_DEVIATION 0.02 // mm
#define DEFAULT_ARC_TOLERANCE 0.002 // mm
#define DEFAULT_REPORT_INCHES 0 // false
#define DEFAULT_INVERT_ST_ENABLE 1 // false
#define DEFAULT_INVERT_LIMIT_PINS 0 // false
#define DEFAULT_SOFT_LIMIT_ENABLE 0 // true
#define DEFAULT_HARD_LIMIT_ENABLE 1 // false
#define DEFAULT_INVERT_PROBE_PIN 0 // false
#define DEFAULT_LASER_MODE 0 // false
#define DEFAULT_HOMING_ENABLE 1 // true
#define DEFAULT_HOMING_DIR_MASK 3 // move positive dir
#define DEFAULT_HOMING_FEED_RATE 300.0 // mm/min
#define DEFAULT_HOMING_SEEK_RATE 2500.0 // mm/min
#define DEFAULT_HOMING_DEBOUNCE_DELAY 250 // msec (0-65k)
#define DEFAULT_HOMING_PULLOFF 5.0 // mm
#endif
If you simply want to download the compiled firmware HEX file instead of re-compiling it then you can download it from our site SD-500-GRBL-Mega-5X-Firmware.zip
Programming Arduino MEGA 2560 with grbl-Mega-5X Firmware
Xloader is the easy way to upload the compiled firmware.
It can be downloaded from here http://www.ukcnc.info/Xloader.zip
Launch Xloader.exe and load up the grblUpload.ino.mega.hex
Select the device as ATEMGA2560 and set the Com port to suit your board.
Now click Upload.
Configuring grbl-Mega-5X to suit your machine.
There are a few settings you need to configure after programming grbl into your controller, these include bed max travel, feed rates, steps/mm etc etc.
Again check out the grbl-Mega-5X Wiki https://github.com/fra589/grbl-Mega-5X/wiki for full details.
You can do these manually by communicating with grbl using a terminal emulator such as HyperTerminal or there are various applications around for different platforms.
For Windows 10 we have knocked up a quick application that can be downloaded from the Windows App Store.
It allows you to connect to your controlling and read out the configuration. You can then alter the values to suit your machine and write them back in.
Also it allows other commands to be sent and the reply to be displayed in the Read Data box.
You can send test Gcode commands and request status to see the results.
Download from the Windows App Store
Please note the values shown in the screenshot above are not the same as values in our default settings, this screenshot is just to show what the interface looks like and values will be different when reading out from our controller. In other words I was too lazy to do a new screenshot 🙂
Software for sending Gcode to grbl-Mega-5X.
You are spoilt for choice when it comes to software to send Gcode to Grbl and your best place is to google it.
I personally like Candle that can be downloaded here https://github.com/Denvi/Candle
Version 1.2B was released October 2019 and worth a look at
https://github.com/Denvi/Candle/releases/tag/v1.2b