Help with Switch Problems - bdring/Grbl_Esp32 GitHub Wiki
Help with Switch Problems
Checking Switch Status.
The active/inactive status of all switches can be checked with the "?" command. Use a serial port monitor to send the command. The status will look something like this...
<Run|MPos:351.154,0.000,-135.983,10.477|FS:1200,0|Pn:X>
The Pn:X part will only show if at least one switch is active. In this case, the X limit switch is currently being read in the active state. Every switch can be checked. These are the possible switches you could see PXYZABCDRHS
- P = Probe
- XYZABC = The axis limit switches
- D = Door
- R = Reset
- H = Hold
- S = Start
Check all your switches in in the active and inactive states and make sure the status query response show the correct status in both states.
Inverted States
If your switches are reporting inverted from what you expect, this can be corrected in firmware. You can invert all limit switch pins with the $Limits/Invert=On setting. You can invert the probe pin with the $Probe/Invert=On setting.
You can invert the control pins (DRHS) by flipping the appropriate bits #define INVERT_CONTROL_PIN_MASK B1111
mask in config.h
You can invert individual limit switch pins with #define INVERT_LIMIT_PIN_MASK (bit(X_AXIS)|bit(Y_AXIS))
in config.h
Switch Pull Ups
Note: a few I/O pins (34 through 39) require external pull ups (or down) resistors. If you do not have resistors on these pins, the I/O pin will "float" and not have a deterministic" state when the switch contacts are open. Most ESP32 controller PCBs, that use these pins have a pull up installed already.
Homing
Homing is controlled by a lot of settings. Don't expect a home all ($H) to work as soon as you hook up the motors. If you reduce the homing and switch features, you are more likely to have success and understand any problems. You can add features after basic homing works. Use a standard serial port rather than a gcode sender if you can.
Here is how the basic homing cycle works. It first looks at the state of the switch. If the switch is not active it starts moving towards the switch. If the switch is active, it assumes it is touching the switch and it will attempt to pull off the switch (opposite off the intended homing direction). If it still has not de-activated the switch after the full pull off, it issues an alarm 8: (Homing Fail Pulloff). If the switch was not active at the beginning the machine will move towards the switch until it touches. It then backs off to clear the switch and does a second approach and back off at a slower speed.
- Turn off hard and soft limits by sending $Limits/Soft=Off and $Limits/Hard=Off
- Make sure all axes move in the right direction when jogging and move in both directions. A simple way to jog is by sending $J=G91 X5 F200. Change X5 to X-5 to change direction. Change X to Y to use the Y axis. Make sure axes with dual motors are working properly. Also, measure the movement to make sure it is moving the amount it should. If not, adjust the resolution, like $X/StepsPerMm=nnn.nn for the X axis
- Make sure the switches correctly report when switch is activated and not activated (see above)
- Set the axis travel to the length of your axis, like $X/MaxTravel=nnn.nn for the X axis.
- Make sure you turn homing on with $Homing/Enable=On
- Put each axis on its own homing cycle like $Homing/Cycle0=Z, $Homing/Cycle1=X, $Homing/Cycle2=Y, etc.
- Turn off axis squaring with $Homing/Squared=. Don't worry you can turn it on later and dual motor axes home fine without it.
- Set the switch pull off high so it is easier to see what is going on. like $Homing/PullOff=10
- Set the speed a little slow like $Homing/Seek=800 and $Homing/Feed=100
- Set the homing direction. The default is to home in the positive direction. If any axis needs to home towards the negative direction, add it to $Homing/DirInvert, like $Homing/DirInvert=XY to make X and Y home in the negative direction.
- Try homing one axis at a time with $HZ to home the Z axis. Be ready to kill the power or click the reset button if it does something wrong.
- If you get an alarm or error number, you can send $E to see all the error descriptions or $E=n to see a specific error. The same applies to alarms with $A
Homing FAQ
- Why does the axis move a little them give an ALARM 8? This is normal behavior if switch is active before the homing starts. Grbl tries to clear the switch by moving away by the $Homing/Pulloff amount. Check the switch before homing. Is it touched? Does the status show it as touched? What is the status if you touch it?