Xcarve / Shapeoko Driver Settings, Motor Directions and Homing Cycles

We get lots of questions about tuning motor drivers and setting directions so … here goes with a blog post covering the topic.  Its a long read and may seem like too much information…but please persist – its good to know whats happening here as when things aren’t working right and you have the theory… you can fix it. 

After you have wired up the X-Carve/Shapeoko/Ox or similar CNC machine running GRBL,  there will be some settings to update and tuning of the machine required. This is regardless of whether you are using the G-Sheild, CNC-shield, or another electronics setup.

Steps we will cover:

  1. Setting Driver(s) Current
  2. Setting Jogging motor Directions
  3. Setting Homing Motor Directions
  4. Testing Homing Sequences – This section coming soon!
  5. Calibrating the steps per/mm of each axis. This section coming soon!


1) Setting Driver(s) Current.

We are actually setting the drivers ‘current limiting’ not ‘driver current’.  The motors will consume as much power as they can/need and we need to make sure that they do not consume so much that the driver overheats trying to provide it thereby going into thermal shutdown.  

The A4988, DRV8818, DRB8825 and most similar drivers have thermal threshold that if exceeded could cause damage to the chip.  And so there is some thermal monitoring inside the chip and if the die temperatures hit this threshold the driver will shut its self down for a period until the die temperature has come back down below the threshold.  This may only be for a very short time (sometimes thermal shutdown may kick in and out many times in a second)  and in this case can be quite hard to diagnose.

Your drivers will survive thermal shutdown!  They will kick in and out of thermal shutdown all day long without being damaged – the threshold is set to a temperature below a level at which damage will occur.  

What we are trying to avoid is the missing steps that should have occurred in those moments when the driver had shut down.  There is no feedback to the GRBL controller to tell it that a step instruction given to the motor was or was not successfully taken, and so during either a) thermal shutdown or b) under a higher load than the motor can manage, steps may be lost.  

If a step is lost, GRBL has no idea about it and so continues along as if everything is fine. However it will then be cutting away doing your job,  completely unaware that the machine isn’t in the position its supposed to be.  These lost steps generally end up leading to a broken milling bit, a ruined job… & some profanity from yourself.

We need to limit the current that the motors are able to draw on the drivers so that the drivers don’t shut down, steps are not lost and your work looks like it should. We do this by limiting the current and therefore limiting the heat created to a level that it is able to dissipated without hitting the shutdown threshold.

Before attempting to set current limiting its important to note:

  • You must have heatsinks stuck to the drivers!
  • You must have active cooling – IE a fan positioned directly above the heatsinks.

These two requirements are not negotiable. You will need both fan and heatsink unless you are running the machine outside in a Russian winter you will not be able to keep the drivers cool enough to ensure they stay online unless you have limited the current so far that you are starving the NEMA 23 motors of the power they require to do the job. Without a fan, everything may appear to be working perfectly as you jog the machine around doing a few tests… it is not.


1)  Setting the current.

There are two methods:

  • Mathamagically:   a google search of “vref = 0.5 A” will bring up some results on this method.
  • By feel – this is our preferred method.

We choose to set the driver current limiting by feel as the (NEMA23) steppers we are using can handle the full power (and maybe a little more) than the A4988 / DRV8818 / DRV8825 can offer.  What they can offer without going into thermal shutdown differs based on your active cooling methods and environment.

Its important to note that we don’t really care what the current offering from the drivers is! We care only that we have as much as possible from our unique setup and that the motors are power fuelled enough to do what we ask!  AND without overheating the motors as well.

Knowing the amount of current the motor drivers have been limited to providing may be nice, you may want to read on the methods / maths behind it (its quite simple) but it doesn’t help us find the max current we can supply. It only tells us what that figure is once we have already found it by feel, and so at this point the figure is itself… useless.


Open your GRBL Settings and set parameter named “Step Idle Delay” to 255:

  • For GRBL V.08 and V.09 this is:   $1   (step idle delay, msec)
  • Your stepper motors consume most current when sitting ‘holding position’.  This is different than and ‘idle’ state, its a locked state using all power available to try an stop any external force from moving the machine. You are straining the stepper drivers more in this state than you would during a cutting operation so its the best place to start.   
  • If we can get the machine to sit here for a few minutes holding its position, using the most amount of current it will ever pull from all the drivers without any of them shutting down… we know that they will never shut down during our cutting work.

If using a CNC Shield, or other shield with removable drivers, remove all but the first driver

  • As we will be listening to the motors from here on in, its nice to be able to turn off the other 3 so that we can deal with them one at a time.  If using a G-Shield you don’t have the option as the drivers are not removable.  (NO YOU CANT JUST LEAVE THE OTHER MOTORS DISCONNECTED! these drivers must have a motor connected if they are powered up – or they will likely die.)  If using G-shield, turn all the trim pots far anticlockwise to minimise current output instead.

Power your CNC shield, G-shield, or other A4988/DRV8818/DRV8825 based device based device 

  • You will usually be required to provide between 12 and 36 Volts to the driver board.   Its best to use as higher voltage as you can for the driver (forget the stepper rated voltage of 3-5V).   Please take note that the A4988 drivers can only handle 35V – so your best using a 24V , and the DRV8818 & DRV8825 (G-Shield or CNC Shield) can handle 45 so best to use 24-36V

Connect your Arduino to the computer via usb and initiate a connection through Universal Gcode Sender  (use the Will winder version)

  • Why: The stepper drivers need 3 inputs to run. Enable, Direction and Step.  By connecting the Arduino GRBL will be up and running (as it uses the 5v supplied by the USB port) and since we set the Step Idle Delay parameter to 255 it will immediately lock the motors by setting the enable signal.


  • You should hear a hiss and hum from one (or more if G-Shield) motors.  Which ever motor we are listening to, find the driver and its current limiting potentiometer, as per the photos below:
  • G-Shield
  • CNC Shield:
  • The G-shield needs dialling clockwise for more power, anticlockwise for less.   The CNC shield step stick drivers are usually opposite dialling anti-clockwise for more power, clockwise for less.   Don’t dial too far, a few minutes on a clock face at a time. Take a minute between each adjustment,   listen to the motor, we are looking for a nice loud hiss/hum – we want a solid noise, with no breaks. If the motor driver is going into thermal shutdown you will hear it cutting in and out.  You will also notice that during shutdown you will be able to move the axis on the machine, when not in shutdown it will be held tight.   Keep making small adjustments until the sweet spot is found where its dialled up as much as possible without going into thermal shutdown.  Once the machine has been able to sit here for a few minutes without the motors releasing (no noise stops and you are not able to push the axis by hand) you can continue 
  • Whilst at this step also watch the temp of the motor, if its hotter than is comfortable to grip with your hand, you did this tuning job too well and should turn it down a little!

Move onto the next driver/motor combination. 

  • Start the process again, looking for max current without shutdown for each of the drivers/motors.

Done!  You now have the machine set to the sweet spot, its sitting there doing nothing but locking.  You cannot move any of the axis by hand, at any time.  You can move on.



2) Setting Jogging motor Directions 

Before going through these steps, you should know that inventables EASEL program has a simple method for setting these feed and homing directions.  If your planning to use easel anyway you can go that route, otherwise do it manually this way.

First, there are two sets of motor directions to set:

  • Standard Jogging Directions
  • Homing Directions

The motor directions can be modified in two ways 

  • Changing some wires
  • Setting in GRBL parameters

We use the GRBL parameter method as there are two sets of directions to set and they may both need changing, if they do simply changing the motor wiring will fix one set and break the other.

If your using GRBL v.08 – Follow these directions to set motor directions

For GRBL V.09 read on.

The directions you want the machine to go in when you hit a positive jog command are:

  • X to go to the right
  • Y To Move away from you
  • Z to go up

If any of this is not true on your setup we will need to adjust a parameter called $3=6 (dir port invert mask:00000110)

Using the following table, set the $3 variable to change motor directions.

Setting ValueInvert XInvert YInvert Z

For example,

  • if your X and Y are both backwards but Z is fine,  set $3= 3
  • if your X is backwards but Y & Z are fine, set $3 = 1



Setting Homing Motor Directionss

The procedure to set the homing directions is pretty much the same as above, however you are setting the value of a different parameter:  $23 – Homing dir invert mask, int:binary

Don’t work on this setting until your emergency stop button is in place and ready to hit!! If your Z axis goes up… and doesn’t stop because your limit switches are not wired correctly, or you have not turned on $22 – Homing cycle, the limit switch will get smashed and that will put a halt on your build.