-
Notifications
You must be signed in to change notification settings - Fork 65
Basic user guide
Jump to section
Since µCNC was designed over Grbl protocol most of the details regarding interfacing, connecting, commands, jogging and other can be refereed to the Grbl Wiki page. About ~95% of the commands and interfacing is the same except a few minor things that will be covered in this page.
By default, and as a safety measure, µCNC control pins (Emergency stop, Safety door and feed hold) and all limit switch pins are all set high by internal MCU weak pull up resistors (if the MCU has this feature). This prevents the user from accidentally forgetting to plug/wire an input and run the machine freely, crashing it or causing an accident. That also means that if left unconnected, Emergency stop will always be active upon plugin µCNC, and prevent any kind of motion or command appearing to be locked. There are 3 ways of overcoming this.
-
Short the ESTOP pin to ground. After this µCNC should reset and emergency alarm should be normalize. You can mask/invert command pins via setting $7. After masking/inverting control pins Emergency stop will be active again. At this point remove the short to ground to unlock/reset µCNC.
-
This only works from version 1.4.0 and future versions. Go to cnc_config.h file and uncomment the INVERT_EMERGENCY_STOP option to invert the Emergency stop input logic. Recompile and upload the firmware.
-
You can disable all control pins by setting option
DISABLE_ALL_CONTROLS
in the cnc_config.h file. By doing this also all control pins will be undefined in the HAL. -
It's also possible to disable the weak pull up resistor for your specific board. This will leave the board more susceptible to EMI noise and false triggers. To disable weak pull up resistor read the info about board/pinout customization in the wiki.
For the full list of supported commands by µCNC read Grbl's configurations wiki page. The following commands don't match the existing ones in Grbl.
-
$I
- View build info is implemented on µCNC but has to be enabled viaENABLE_SYSTEM_INFO
option in the in cnc_config.h.
This will print out 2 messages similar to Grbl's $I command. The first will print the version µCNC version and board name. Here is an example:
[VER:uCNC v1.4.0 - Arduino UNO]
After that it will print a message with some info on enabled options. The format will be:
[OPT:<Option codes separated by comma>,<planner buffer size>, <interface letter><rx buffer size>]
- The interface letter will be blank if the hardware serial is used or U if USB is used. Future letters might be added.
Possible option codes are:
Option code | Description |
---|---|
Cn | Cartesian kinematic followed by the number of axis |
XYn | CoreXY kinematic followed by the number of axis |
Dn | Linear delta kinematic followed by the number of axis |
Tn | n being the number of tools |
N | Enabled N word parsing (line numbers) |
16B | 16-Bit bresenham enabled |
S | S-curve acceleration enabled |
NI | Alternative interpolator step generator |
IE | Emergency stop inverted |
DC | Disabled all control input pins |
DL | Disabled all limit switch input pins |
DP | Disabled probe input pin |
XC | Enabled extra system commands |
F | Enabled fast math |
LP | Enabled linear actuator planner |
SK | Enabled axis skew correction |
SKXY | Enabled axis skew correction only for xy plane |
RAM | Settings storage in non volatile memory is disabled. RAM only settings |
IODBG | Alarm IO debug is available. The status of the limits and controls will be printed after an Alarm condition |
SP | Force soft polling is enabled. Special inputs will not be triggered via ISR but via software polling in the main loop |
HMAP | Height map G39 is enabled |
DSSn_nnn | Dynamic step spread followed by the maximum level and cutoff frequency |
Note - Some extension modules might modify the $I command output with added capabilities
-
$SLP
- Sleep command is not implemented on µCNC. -
$SS $SL and $SR
- Check µCNC configurations for more informations. These commands can be enabled viaENABLE_SETTING_EXTRA_CMDS
in cnc_config.h. -
$P
- View the configured pins states (used mostly for debugging purposes). This prints a formatted message[<pin type>:<internal pin number>:<pin value>]
with each pin state/vale. In the end it will also report the stepper motors position in steps. This command can be enabled viaENABLE_SETTING_EXTRA_CMDS
in cnc_config.h.
Pin type | Description |
---|---|
SO | Special Output Pin (Step, Dir and Step Enable pins) |
P | PWM Output Pin (PWM pins) |
O | Generic Output Pin (DOUT output pins) |
SV | Servo Pin (SERVO output pins) |
SI | Special Input Pin (Limit, Control, and Probe pins) |
A | Analog Input Pin (Analog input pins) |
I | Generic Input Pin (DIN input pins) |
STEPS | Each motor position in steps (separated by commas) |
This command can be disabled via ENABLE_SETTING_EXTRA_CMDS
in cnc_config.h.
-
G10 L20 Pn
- Is not supported by µCNC. Grbl states thatG10 L20 Pn
is part of the NIST RS274NGC standard. But reading the document I didn't find this definition, so L20 is not accepted as part of G10 syntax. OnlyG10 L2 Pn
commands are accepted. Also to store homing coordinates in EEPROMG10 L2 P28
andEEPROM G10 L2 P30
are supported. This is more inline with the NIST RS274NGC standard. -
G28.1
- Is not supported by µCNC. The same effect is achieved by doing aG10 L2 P28
command as stated above. To match Grbl's interface this may be added later on. -
G30.1
- Is not supported by µCNC. The same effect is achieved by doing aG10 L2 P30
command as stated above. To match Grbl's interface this may be added later on. -
G91.1 (relative IJK in arc commands)
- Is not supported by µCNC. This is not part of the NIST RS274NGC standard. -
G92.1
- Is supported by µCNC. This cancels offset coordinate systems and resets the offset parameters as defined by RS274. -
G92.2
- Is supported by µCNC. This cancels offset coordinate systems but do not reset parameters as defined by RS274. -
G92.3
- Is supported by µCNC. This apply previously defined parameters to offset coordinate systems as defined by RS274. -
G93.4
- Is supported by µCNC. This apply previously defined parameters to offset coordinate systems as defined by RS274. -
M6
- Is supported by µCNC. This allows to make a tool change as defined by RS274. -
M10
- Is supported by µCNC. This command is available if SERVO type pins are configure. Controls the servo sinal control type pins. Is not defined by RS274. Usage: M10 P[x] S[yyy] where x is the servo number and yyy pwm vale from 0 to 255. -
M42
- Is supported by µCNC. This command can change the state of any generic output, pwm or servo Pin. It's not defined by RS274. Usage:M42 P[xxx] S[yyy]
where x is the pin internal µCNC number and yyy pwm vale from 0 to 255. -
G39
- Is supported by µCNC with Height map enabled. This command probes and creates a rectangular height map of a surface and deforms gcode to match a generated bilinear plane that fits the map. It's not defined by RS274. Usage:G39 X[starting point (optional)] Y[starting point (optional)] I[map X width] J[map Y width] Z[max probing depth] R[retraction height between probes] F[probing feed rate]
. -
G39.1
- Is supported by µCNC with Height map enabled. Disables the current Hmap. -
G39.2
- Is supported by µCNC with Height map enabled. Re-enables the previous Hmap.
Note: G92.x offsets are stored in non volatile memory in µCNC version 1.0.x. From version 1.1.x forward this will only be kept in RAM. Values will be mantained during a soft reset, but a hard reset will delete previous values.
For the full list of settings by µCNC read Grbl configuration wiki page. This is the configuration list for:
Stepper drivers are rated for a certain minimum step pulse length. Check the data sheet or just try some numbers. You want the shortest pulses the stepper drivers can reliably recognize. If the pulses are too long, you might run into trouble when running the system at very high feed and pulse rates, because the step pulses can begin to overlap each other. On Arduino UNO the maximum step frequency of 30Khz (33.333ms) or about 40Khz (25ms) by enabling 16-bit bresenham algorithm , which is the default value. If set bellow the system capabilities the value will be automatically clamped. The minimum value depends on the MCU used.
This feature is not implemented on µCNC
This setting inverts the step pulse signal. By default, a step signal starts at normal-low and goes high upon a step pulse event. After a step pulse time set by $0
, the pin resets to low, until the next step pulse event. When inverted, the step pulse behavior switches from normal-high, to low during the pulse, and back to high. Most users will not need to use this setting, but this can be useful for certain CNC-stepper drivers that have peculiar requirements. For example, an artificial delay between the direction pin and step pulse can be created by inverting the step pin.
This invert mask setting is a value which stores the axes to invert as bit flags. You really don't need to completely understand how it works. You simply need to enter the settings value for the axes you want to invert. For example, if you want to invert the X and Z axes, you'd send $2=5
to Grbl and the setting should now read $2=5 (step port invert mask:00000101)
.
Bit | Step port |
---|---|
0 | STEP0 |
1 | STEP1 |
2 | STEP2 |
3 | STEP3 |
4 | STEP4 |
5 | STEP5 |
6 | STEP6 |
7 | STEP7 |
This setting inverts the direction signal for each axis. By default, Grbl assumes that the axes move in a positive direction when the direction pin signal is low, and a negative direction when the pin is high. Often, axes don't move this way with some machines. This setting will invert the direction pin signal for those axes that move the opposite way.
This invert mask setting works exactly like the step port invert mask and stores which axes to invert as bit flags. To configure this setting, you simply need to send the value for the axes you want to invert. Use the table above. For example, if want to invert the Y axis direction only, you'd send $3=2
to Grbl and the setting should now read $3=2 (dir port invert mask:00000010)
Bit | Step port |
---|---|
0 | DIR0 |
1 | DIR1 |
2 | DIR2 |
3 | DIR3 |
4 | DIR4 |
5 | DIR5 |
6 | DIR6 |
7 | DIR7 |
By default, the stepper enable pin is high to disable and low to enable. If your setup needs the opposite, just invert the stepper enable by setting the correspondent bit value to 1. (May need a power cycle to load the change)
Bit | Step port |
---|---|
0 | STEP0_EN |
1 | STEP1_EN |
2 | STEP2_EN |
3 | STEP3_EN |
4 | STEP4_EN |
5 | STEP5_EN |
6 | STEP6_EN |
7 | STEP7_EN |
By default, the limit pins are held normally-high with the MCU's internal pull-up resistor (has configured in the respective boardmap and if supported by the hardware). When a limit pin is high, µCNC interprets this as triggered. This differs from Grbl's default (this way if you forget to plugin the end-stop(NC to ground) for example the limit will be active). For the opposite behavior, just invert the limit pin by masking it with the appropriate integer (0-255) value. The following table describes the bit in the value:
Bit | Limit |
---|---|
0 | LIMIT_X and LIMIT_X2 |
1 | LIMIT_Y and LIMIT_Y2 |
2 | LIMIT_Z and LIMIT_Z2 |
3 | LIMIT_A |
4 | LIMIT_B |
5 | LIMIT_C |
6 | unsused |
7 | unsused |
NOTE: For more advanced usage, the internal pull-up resistor on the limit pins may be disabled in config.h.
By default, the probe pin is held normally-high with the Arduino's internal pull-up resistor. When the probe pin is low, Grbl interprets this as triggered. For the opposite behavior, just invert the probe pin by typing $6=1
. Disable with $6=0
. You may need a power cycle to load the change.
By default, the control pins are held normally-high with the MCU's internal pull-up (has configured in the respective boardmap and if supported by the hardware). When a control pin is high, µCNC interprets this as triggered. This differs from Grbl's default (this way if you forget to plugin the control button/switch(NC to ground) for example the control will be active). For the opposite behavior, just invert the control pin by masking it with the appropriate integer (0-255) value. The following table describes the bit in the value:
Bit | Limit |
---|---|
0 | ESTOP (Emergency stop) * |
1 | SAFETY_DOOR (Safety door) |
2 | FHOLD (Feed hold) |
3 | CS_RES (Cycle start/Resume) |
4 | unsused |
5 | unsused |
6 | unsused |
7 | unsused |
NOTE: For more advanced usage, the internal pull-up resistor on the limit pins may be disabled in boardmap file that matches your board. It's also possible to invert ESTOP pin via option INVERT_EMERGENCY_STOP in the cnc_config.h file
When encoders are enabled it's possible to define if the counting occurs on a low to high transition (default), or from a high to low transition. Just invert the pin by masking it with the appropriate integer (0-255) value. The following table describes the bit in the value:
Bit | Limit |
---|---|
0 | ENC0 |
1 | ENC1 |
2 | ENC2 |
3 | ENC3 |
4 | ENC4 |
5 | ENC5 |
6 | ENC6 |
7 | ENC7 |
When encoders are enabled it's possible to define if the counter increment occurs when dir is high (default), or a decrement occurs when dir is low. Just invert the pin by masking it with the appropriate integer (0-255) value. The following table describes the bit in the value:
Bit | Limit |
---|---|
0 | ENC0 |
1 | ENC1 |
2 | ENC2 |
3 | ENC3 |
4 | ENC4 |
5 | ENC5 |
6 | ENC6 |
7 | ENC7 |
This setting determines what Grbl real-time data it reports back to the user when a '?' status report is sent. This data includes current run state, real-time position, real-time feed rate, pin states, current override values, buffer states, and the g-code line number currently executing (if enabled through compile-time options).
By default, the new report implementation in Grbl v1.1+ will include just about everything in the standard status report. A lot of the data is hidden and will appear only if it changes. This increases efficiency dramatically over of the old report style and allows you to get faster updates and still get more data about your machine. The interface documentation outlines how it works and most of it applies only to GUI developers or the curious.
To keep things simple and consistent, Grbl v1.1 has only two reporting options. These are primarily here just for users and developers to help set things up.
- Position type may be specified to show either machine position (
MPos:
) or work position (WPos:
), but no longer both at the same time. Enabling work position is useful in certain scenarios when Grbl is being directly interacted with through a serial terminal, but machine position reporting should be used by default. - Usage data of Grbl's planner and serial RX buffers may be enabled. This shows the number of blocks or bytes available in the respective buffers. This is generally used to helps determine how Grbl is performing when testing out a streaming interface. This should be disabled by default.
Use the table below enables and disable reporting options. Simply add the values listed of what you'd like to enable, then save it by sending Grbl your setting value. For example, the default report with machine position and no buffer data reports setting is $10=1
. If work position and buffer data are desired, the setting will be $10=2
.
Report Type | Value | Description |
---|---|---|
Position Type | 0 | Enable WPos: Disable MPos: . |
Position Type | 1 | Enable MPos: . Disable WPos: . |
Buffer Data | 2 | Enabled Buf: field appears with planner and serial RX available buffer. |
Junction deviation is used by the acceleration manager to determine how fast it can move through line segment junctions of a G-code program path. For example, if the G-code path has a sharp 10 degree turn coming up and the machine is moving at full speed, this setting helps determine how much the machine needs to slow down to safely go through the corner without losing steps.
Instead this value stands for junction cosine factor (value must be set between -1.0 and 1.0). If set to 0.0 is the same as exact path mode (G61) and -1.0 is the same as exact stop mode (G61.1)
Grbl renders G2/G3 circles, arcs, and helices by subdividing them into teeny tiny lines, such that the arc tracing accuracy is never below this value. You will probably never need to adjust this setting, since 0.002mm
is well below the accuracy of most all CNC machines. But if you find that your circles are too crude or arc tracing is performing slowly, adjust this setting. Lower values give higher precision but may lead to performance issues by overloading Grbl with too many tiny lines. Alternately, higher values traces to a lower precision, but can speed up arc performance since Grbl has fewer lines to deal with.
For the curious, arc tolerance is defined as the maximum perpendicular distance from a line segment with its end points lying on the arc, aka a chord. With some basic geometry, we solve for the length of the line segments to trace the arc that satisfies this setting. Modeling arcs in this way is great, because the arc line segments automatically adjust and scale with length to ensure optimum arc tracing performance, while never losing accuracy.
Grbl has a real-time positioning reporting feature to provide a user feedback on where the machine is exactly at that time, as well as, parameters for coordinate offsets and probing. By default, it is set to report in mm, but by sending a $13=1
command, you send this boolean flag to true and these reporting features will now report in inches. $13=0
to set back to mm.
Soft limits is a safety feature to help prevent your machine from traveling too far and beyond the limits of travel, crashing or breaking something expensive. It works by knowing the maximum travel limits for each axis and where Grbl is in machine coordinates. Whenever a new G-code motion is sent to Grbl, it checks whether or not you accidentally have exceeded your machine space. If you do, Grbl will issue an immediate feed hold wherever it is, shutdown the spindle and coolant, and then set the system alarm indicating the problem. Machine position will be retained afterwards, since it's not due to an immediate forced stop like hard limits.
NOTE: Soft limits requires homing to be enabled and accurate axis maximum travel settings, because Grbl needs to know where it is. $20=1
to enable, and $20=0
to disable.
Hard limit work basically the same as soft limits, but use physical switches instead. Basically you wire up some switches (mechanical, magnetic, or optical) near the end of travel of each axes, or where ever you feel that there might be trouble if your program moves too far to where it shouldn't. When the switch triggers, it will immediately halt all motion, shutdown the coolant and spindle (if connected), and go into alarm mode, which forces you to check your machine and reset everything.
To use hard limits with Grbl, the limit pins are held high with an internal pull-up resistor, so all you have to do is wire in a normally-open switch with the pin and ground and enable hard limits with $21=1
. (Disable with $21=0
.) We strongly advise taking electric interference prevention measures. If you want a limit for both ends of travel of one axes, just wire in two switches in parallel with the pin and ground, so if either one of them trips, it triggers the hard limit.
Keep in mind, that a hard limit event is considered to be critical event, where steppers immediately stop and will have likely have lost steps. Grbl doesn't have any feedback on position, so it can't guarantee it has any idea where it is. So, if a hard limit is triggered, Grbl will go into an infinite loop ALARM mode, giving you a chance to check your machine and forcing you to reset Grbl. Remember it's a purely a safety feature.
Ahh, homing. For those just initiated into CNC, the homing cycle is used to accurately and precisely locate a known and consistent position on a machine every time you start up your Grbl between sessions. In other words, you know exactly where you are at any given time, every time. Say you start machining something or are about to start the next step in a job and the power goes out, you re-start Grbl and Grbl has no idea where it is due to steppers being open-loop control. You're left with the task of figuring out where you are. If you have homing, you always have the machine zero reference point to locate from, so all you have to do is run the homing cycle and resume where you left off.
To set up the homing cycle for Grbl, you need to have limit switches in a fixed position that won't get bumped or moved, or else your reference point gets messed up. Usually they are setup in the farthest point in +x, +y, +z of each axes. Wire your limit switches in with the limit pins, add a recommended RC-filter to help reduce electrical noise, and enable homing. If you're curious, you can use your limit switches for both hard limits AND homing. They play nice with each other.
Prior to trying the homing cycle for the first time, make sure you have setup everything correctly, otherwise homing may behave strangely. First, ensure your machine axes are moving in the correct directions per Cartesian coordinates (right-hand rule). If not, fix it with the $3
direction invert setting. Second, ensure your limit switch pins are not showing as 'triggered' in Grbl's status reports. If are, check your wiring and settings. Finally, ensure your $13x
max travel settings are somewhat accurate (within 20%), because Grbl uses these values to determine how far it should search for the homing switches.
By default, Grbl's homing cycle moves the Z-axis positive first to clear the workspace and then moves both the X and Y-axes at the same time in the positive direction. To set up how your homing cycle behaves, there are more Grbl settings down the page describing what they do (and compile-time options as well.)
Also, one more thing to note, when homing is enabled. Grbl will lock out all G-code commands until you perform a homing cycle. Meaning no axes motions, unless the lock is disabled ($X) but more on that later. Most, if not all CNC controllers, do something similar, as it is mostly a safety feature to prevent users from making a positioning mistake, which is very easy to do and be saddened when a mistake ruins a part. If you find this annoying or find any weird bugs, please let us know and we'll try to work on it so everyone is happy. :)
NOTE: Check out config.h for more homing options for advanced users. You can disable the homing lockout at startup, configure which axes move first during a homing cycle and in what order, and more.
Unlike Grbl, µCNC assumes your homing limit switches are in the negative direction (move to origin). If your machine has a limit switch in the positive direction, the homing direction mask can invert the axes' direction. It works just like the step port invert and direction port invert masks, where all you have to do is send the value in the table to indicate what axes you want to invert and search for in the opposite direction.
The homing cycle first searches for the limit switches at a higher seek rate, and after it finds them, it moves at a slower feed rate to home into the precise location of machine zero. Homing feed rate is that slower feed rate. Set this to whatever rate value that provides repeatable and precise machine zero locating.
Homing seek rate is the homing cycle search rate, or the rate at which it first tries to find the limit switches. Adjust to whatever rate gets to the limit switches in a short enough time without crashing into your limit switches if they come in too fast.
Whenever a switch triggers, some of them can have electrical/mechanical noise that actually 'bounce' the signal high and low for a few milliseconds before settling in. To solve this, you need to debounce the signal, either by hardware with some kind of signal conditioner or by software with a short delay to let the signal finish bouncing. Grbl performs a short delay, only homing when locating machine zero. Set this delay value to whatever your switch needs to get repeatable homing. In most cases, 5-25 milliseconds is fine.
To play nice with the hard limits feature, where homing can share the same limit switches, the homing cycle will move off all of the limit switches by this pull-off travel after it completes. In other words, it helps to prevent accidental triggering of the hard limit after a homing cycle. Make sure this value is large enough to clear the limit switch. If not, Grbl will throw an alarm error for failing to clear it.
This setting is applicable for rotary delta kinematics only
When using the kinematics for rotary delta machines this value should be set to match the angle the arms will form with the base after hitting the limit switches used for homing the robot (in degrees).
This sets the spindle speed for the maximum 5V PWM pin output. For example, if you want to set 10000rpm at 5V, program $30=10000
. For 255rpm at 5V, program $30=255
. If a program tries to set a higher spindle RPM greater than the $30
max spindle speed, Grbl will just output the max 5V, since it can't go any faster. By default, Grbl linearly relates the max-min RPMs to 5V-0.02V PWM pin output in 255 equally spaced increments. When the PWM pin reads 0V, this indicates spindle disabled. Note that there are additional configuration options are available in config.h to tweak how this operates.
This sets the spindle speed for the minimum 0.02V PWM pin output (0V is disabled). Lower RPM values are accepted by Grbl but the PWM output will not go below 0.02V, except when RPM is zero. If zero, the spindle is disabled and PWM output is 0V.
When enabled, Grbl will move continuously through consecutive G1
, G2
, or G3
motion commands when programmed with a S
spindle speed (laser power). The spindle PWM pin will be updated instantaneously through each motion without stopping. Please read the GRBL laser documentation and your laser device documentation prior to using this mode. Lasers are very dangerous. They can instantly damage your vision permanently and cause fires. Grbl does not assume any responsibility for any issues the firmware may cause, as defined by its GPL license.
When disabled, Grbl will operate as it always has, stopping motion with every S
spindle speed command. This is the default operation of a milling machine to allow a pause to let the spindle change speeds.
When axis skew compensation is enabled these value allow to compensate skew deformations for XY, XZ and YZ planes on (usually on cartesian type) machines.
The factors represent the deviation percentage of an axis relative to another. For example if you travel 100 units in the X axis, and your Y distance changes in 0.1 units, then you have a deviation of 0.1/100 = 0.001. This is your skew factor of Y relative to X.
Skew compensation uses X axis as a base reference and applies motion compensations to other other axis to try and get better perpendicularity. This highly depends also on the machine axis resolution. Low resolution axis (low step/mm values) are more hard to fix since a single step makes a bigger distance change.
The factors can also be calculated without any special tool like in Marlin, by making the machine draw a square and taking some measures.
/**
* Bed Skew Compensation
*
* This feature corrects for misalignment in the XYZ axes.
*
* Take the following steps to get the bed skew in the XY plane:
* 1. Print or draw a test square (e.g., https://www.thingiverse.com/thing:2563185)
* 2. For XY_DIAG_AC measure the diagonal A to C
* 3. For XY_DIAG_BD measure the diagonal B to D
* 4. For XY_SIDE_AD measure the edge A to D
*
* Skew factors need to be computed and set manually:
*
* - Compute AB : SQRT(2*AC*AC+2*BD*BD-4*AD*AD)/2
* - XY_SKEW_FACTOR : TAN(PI/2-ACOS((AC*AC-AB*AB-AD*AD)/(2*AB*AD)))
*
* If desired, follow the same procedure for XZ and YZ.
* Use these diagrams for reference:
*
* Y Z Z
* ^ B-------C ^ B-------C ^ B-------C
* | / / | / / | / /
* | / / | / / | / /
* | A-------D | A-------D | A-------D
* +-------------->X +-------------->X +-------------->Y
* XY_SKEW_FACTOR XZ_SKEW_FACTOR YZ_SKEW_FACTOR
*/
These parameter set the PID Kp, Ki and Kd values for each defined PID controller module. The settings index-4 aligned for each PID parameter group.
PID0 Kp, Ki and Kd are stored in settings $40, $41 and $42 respectively.
PID1 Kp, Ki and Kd are stored in settings $44, $45 and $46 respectively.
PID2 Kp, Ki and Kd are stored in settings $48, $49 and $50 respectively.
...
PID7 Kp, Ki and Kd are stored in settings $68, $69 and $70 respectively.
$80
sets the default tool loaded at startup.
$81 to $86
sets the length offset to each of the 16 possible tools that can be configured in µCNC. These values can be loaded via G43 Hn
with n being the tool index.
Grbl needs to know how far each step will take the tool in reality. To calculate steps/mm for an axis of your machine you need to know:
- The mm traveled per revolution of your stepper motor. This is dependent on your belt drive gears or lead screw pitch.
- The full steps per revolution of your steppers (typically 200)
- The microsteps per step of your controller (typically 1, 2, 4, 8, or 16). Tip: Using high microstep values (e.g., 16) can reduce your stepper motor torque, so use the lowest that gives you the desired axis resolution and comfortable running properties.
The steps/mm can then be calculated like this: steps_per_mm = (steps_per_revolution*microsteps)/mm_per_rev
Compute this value for every axis and write these settings to Grbl.
This setting is applicable for linear delta kinematics only
When using the kinematics for linear delta machines this value should be set to the length of the delta arms (in mm) (assuming all arms have the same length)
$107 - Linear delta kinematic radial difference between the arm's tower joints and the effector joints, mm
When using the kinematics for linear delta machines this value should be set to the radial difference between the arm's tower joints and the effector joints (in mm).
This is equivalent to measure the distance of the projected horizontal points of the joints of one when all towers are at the same height.
o <--tower joint
|\
| \
| \
| \
| \ <--arm
| \
| \
| \
|________\o <---effector joint
|---------|
$107
This setting is applicable for rotary delta kinematics only
When using the kinematics for rotary delta machines this value should be set to match the distance from the machine center of the bicep/motor (shoulder joint) (in mm). This assumes all motors and biceps are the same length and at the same distance from the center.
$106 - base radius
|
V
shoulder joint-> o----------|
/ |
$108 - bicep-> / |
/ |
o |
\ | <- center
\ |
\ |
$109 - forearm-> \ |
\ |
\ |
wrist joint-> o-------|
|
V
$107 - effector radius
This setting is applicable for rotary delta kinematics only
When using the kinematics for rotary delta machines this value should be set to match the distance from the effector center and the forearm end (wrist joint) (in mm).
This setting is applicable for rotary delta kinematics only
When using the kinematics for rotary delta machines this value should be set to match length of the bicep arm (in mm). This assumes all biceps are the same length.
This setting is applicable for rotary delta kinematics only
When using the kinematics for rotary delta machines this value should be set to match length of the forearm arm (in mm). This assumes all forearms are the same length.
This sets the maximum rate each axis can move. Whenever Grbl plans a move, it checks whether or not the move causes any one of these individual axes to exceed their max rate. If so, it'll slow down the motion to ensure none of the axes exceed their max rate limits. This means that each axis has its own independent speed, which is extremely useful for limiting the typically slower Z-axis.
The simplest way to determine these values is to test each axis one at a time by slowly increasing max rate settings and moving it. For example, to test the X-axis, send Grbl something like G0 X50
with enough travel distance so that the axis accelerates to its max speed. You'll know you've hit the max rate threshold when your steppers stall. It'll make a bit of noise, but shouldn't hurt your motors. Enter a setting at 10-20% below this value, so you can account for wear, friction, and the mass of your workpiece/tool. Then, repeat for your other axes.
NOTE: This max rate setting also sets the G0 seek rates.
This sets the axes acceleration parameters in mm/second/second. Simplistically, a lower value makes Grbl ease slower into motion, while a higher value yields tighter moves and reaches the desired feed rates much quicker. Much like the max rate setting, each axis has its own acceleration value and are independent of each other. This means that a multi-axis motion will only accelerate as quickly as the lowest contributing axis can.
Again, like the max rate setting, the simplest way to determine the values for this setting is to individually test each axis with slowly increasing values until the motor stalls. Then finalize your acceleration setting with a value 10-20% below this absolute max value. This should account for wear, friction, and mass inertia. We highly recommend that you dry test some G-code programs with your new settings before committing to them. Sometimes the loading on your machine is different when moving in all axes together.
This sets the maximum travel from end to end for each axis in mm. This is only useful if you have soft limits (and homing) enabled, as this is only used by Grbl's soft limit feature to check if you have exceeded your machine limits with a motion command.
Each parameter $140 to $147 can set the number of steps to compensate for backlash on the system. This is enabled via config file. $140 sets the backlash compensation value for STEPPER0, $141 sets the backlash compensation value for STEPPER1, etc.
A new set of commands allow a more granular control over the settings stored in EEPROM/Flash to prevent wearing (optional build config ENABLE_SETTING_EXTRA_CMDS
in cnc_config.h).
When enabled all Grbl $x=val
are only changed in SRAM.
3 additional commands are added:
µCNC's interface is very similar to Grbl but some features are not yet implemented or have extra codes. The full list of interface messages can be check at Grbl interface wiki page. The following messages, errors and reports don't match Grbl.
µCNC only implements the recommended streaming protocol which is simple Send-Response. Since most applications that work with Grbl also use this protocol there was no point in implementing other less reliable protocols.
This is the full list of error and alarm codes used in Grbl plus the ones reported by µCNC.
ID | Error Code Description |
---|---|
1 |
G-code words consist of a letter and a value. Letter was not found. |
2 |
Numeric value format is not valid or missing an expected value. |
3 |
Grbl '$' system command was not recognized or supported. |
4 |
Negative value received for an expected positive value. |
5 |
Homing cycle is not enabled via settings. |
6 |
Minimum step pulse time must be greater than 3usec |
7 |
EEPROM read failed. Reset and restored to default values. |
8 |
Grbl '$' command cannot be used unless Grbl is IDLE. Ensures smooth operation during a job. |
9 |
G-code locked out during alarm or jog state |
10 |
Soft limits cannot be enabled without homing also enabled. |
11 |
Max characters per line exceeded. Line was not processed and executed. |
12 |
(Compile Option) Grbl '$' setting value exceeds the maximum step rate supported. |
13 |
Safety door detected as opened and door state initiated. |
14 |
(Grbl-Mega Only) Build info or startup line exceeded EEPROM line length limit. |
15 |
Jog target exceeds machine travel. Command ignored. |
16 |
Jog command with no '=' or contains prohibited g-code. |
17 |
Laser mode requires PWM output. |
20 |
Unsupported or invalid g-code command found in block. |
21 |
More than one g-code command from same modal group found in block. |
22 |
Feed rate has not yet been set or is undefined. |
23 |
G-code command in block requires an integer value. |
24 |
Two G-code commands that both require the use of the XYZ axis words were detected in the block. |
25 |
A G-code word was repeated in the block. |
26 |
A G-code command implicitly or explicitly requires XYZ axis words in the block, but none were detected. |
27 |
N line number value is not within the valid range of 1 - 9,999,999 . |
28 |
A G-code command was sent, but is missing some required P or L value words in the line. |
29 |
Grbl supports six work coordinate systems G54-G59 . G59.1 , G59.2 , and G59.3 are not supported. |
30 |
The G53 G-code command requires either a G0 seek or G1 feed motion mode to be active. A different motion was active. |
31 |
There are unused axis words in the block and G80 motion mode cancel is active. |
32 |
A G2 or G3 arc was commanded but there are no XYZ axis words in the selected plane to trace the arc. |
33 |
The motion command has an invalid target. G2 , G3 , and G38.2 generates this error, if the arc is impossible to generate or if the probe target is the current position. |
34 |
A G2 or G3 arc, traced with the radius definition, had a mathematical error when computing the arc geometry. Try either breaking up the arc into semi-circles or quadrants, or redefine them with the arc offset definition. |
35 |
A G2 or G3 arc, traced with the offset definition, is missing the IJK offset word in the selected plane to trace the arc. |
36 |
There are unused, leftover G-code words that aren't used by any command in the block. |
37 |
The G43.1 dynamic tool length offset command cannot apply an offset to an axis other than its configured axis. The Grbl default axis is the Z-axis. |
38 |
Tool number greater than max supported value. |
39 |
A comment is in an invalid format. |
40 |
An invalid tool number was chosen. |
41 |
Issued motion command (except G0) without setting the feed rate. |
42 |
Failed to write settings to non volatile memory (programming error). |
43 |
Failed to write settings to non volatile memory (write protected). |
44 |
Program has ended (after an M2 or M30 command). A soft reset is needed before accepting new Gcode. |
45 |
Probing was successful. |
46 |
Canned cycle command is missing word P. |
47 |
Canned cycle command is missing word Q. |
48 |
Canned cycle command issued with active inverse feed rate mode. |
49 |
Canned cycle command issued with active radius compensation mode. |
50 |
Canned cycle command requires spindle to be turning clockwise. |
51 |
TMC driver command is incomplete or missing arguments. |
52 |
VFD driver communication failed. |
53 |
Settings stored in external storage OK. |
54 |
Laser PPI mode disabled. |
55 |
Tool failure. |
56 |
Invalid plane selected. |
57 |
Hard limits are disabled. |
58 |
Status stream failed. |
59 |
Jog motion was canceled. |
255 |
A critical failure of some sort has happen. This can be any failure of a safety mechanism in the interlocking loop check. |
ID | Alarm Code Description |
---|---|
1 |
Hard limit triggered. Machine position is likely lost due to sudden and immediate halt. Re-homing is highly recommended. |
2 |
G-code motion target exceeds machine travel. Machine position safely retained. Alarm may be unlocked. |
3 |
Reset while in motion. Grbl cannot guarantee position. Lost steps are likely. Re-homing is highly recommended. |
4 |
Probe fail. The probe is not in the expected initial state before starting probe cycle, where G38.2 and G38.3 is not triggered and G38.4 and G38.5 is triggered. |
5 |
Probe fail. Probe did not contact the workpiece within the programmed travel for G38.2 and G38.4. |
6 |
Homing fail. Reset during active homing cycle. |
7 |
Homing fail. Safety door was opened during active homing cycle. |
8 |
Homing fail. Cycle failed to clear limit switch when pulling off. Try increasing pull-off setting or check wiring. |
9 |
Homing fail. Could not find limit switch within search distance. Defined as 1.5 * max_travel on search and 5 * pulloff on locate phases. |
10 |
Homing position with dual drive axis (auto square) was not achieved. |
11 |
Homing can not start due to a prior active limit alarm. |
12 |
Tool was not able to reach the desired sync speed (requires encoder). |
13 |
Hard limit was hit without any motion. User should check what caused the fault. If everything is ok a $X command can unlock the machine |
µCNC supports feedback messages inserted in comments like defined in the NIST RS274NGC.
If this option is enabled, when presented with a comment µCNC will output the comment in a Non-Queried Feedback Message [MSG: ]
[OPT:]
Queried Feedback Messages are not implemented on µCNC.
-
Input Pin State:
-
Pn:XYZABCPDHR
indicates which input pins µCNC has detected as 'triggered'. -
Each letter of
XYZABCPDHR
denotes a particular 'triggered' input pin. -
X Y Z A B C
XYZABC limit pins, respectively -
P
the probe pin. -
D H R
the door, hold, emergency-stop, respectively.
Note: Start-Resume pin does not have a status flag as in Grbl.
Note2: Grbl reset pin in µCNC is replaced by Emergency stop. -
To check how jog works on µCNC check the Grbl jogging wiki page. Jogging behavior should match Grbl.
Since µCNC v1.2.0 this is now fully capable of driving a laser engraver/cutter. For more info check the Grbl laser mode wiki page. It's possible to completely disable this feature in the cnc_config.h file
µCNC is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. µCNC is distributed WITHOUT ANY WARRANTY.
Also without the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
µCNC Wiki
- Home
- Basic user guide
- Porting µCNC and adding custom HAL
- Customizing the HAL file
- Adding custom Tools and Modules to µCNC
- FAQ
µCNC for ALL MCU
µCNC for AVR
µCNC for STM32F1 and STM32F4
µCNC for SAMD21
µCNC for ESP8266
µCNC for ESP32
µCNC for NXP LPC176x
µCNC for NXP RP2040