Inconsistent Behavior When Limit Pullups Disabled While Using NC Switches
Inconsistent Behavior When Limit Pullups Disabled While Using NC Switches
We've been using grblHAL for a while now for a project (4-axis machine) and managed to get everything up and running so far. But we were using NO switches at first, so we now decided to create a new breakout board that has proper IO (no more breadboards) and supports normally closed (NC) switches by default. However, we are having some issues with that. The relevant settings are limit switches inverted ($5=15
), pullups disabled ($18=15
), and hard limits enabled ($21=1
). In this article, we will explore the inconsistent behavior when limit pullups are disabled while using NC switches.
With the above configuration, grblHAL will not go into an alarm state when a limit switch is triggered, even though the triggered switch is properly reported in the status command. Homing also works fine. However, when not inverting the limit switches ($5=0
), the limit pins are reported as on at all times, unless pressed (as expected). But now, when a switch is triggered (so the status command shows it as off), grblHAL goes into a alarm:1
. While we want to go into an alarm state when a switch is pressed, we want that to happen when the switch is reported as on in the status, not when it changes to off. The second issue is that with this non-inverted configuration homing doesn't work, since the limit pins are reported as on, which causes homing to try to pull off of the switch, leading to alarm:8
.
To better understand the issue, let's analyze the output of $I
. The output is as follows:
[VER:1.1f.20250407:]
[OPT:VNMHSL+,100,1024,4,0]
[AXS:4:XYZA]
[NEWOPT:ENUMS,RT+,HOME,ES,EXPR,SED]
[FIRMWARE:grblHAL]
[SIGNALS:HSDEP]
[NVS STORAGE:*FLASH]
[FREE MEMORY:36K]
[DRIVER:STM32F401]
[DRIVER VERSION:250328]
[BOARD:Nucleo-64 CNC Breakout]
[AUX IO:4,4,0,0]
ok
From the output, we can see that the firmware version is 1.1f.20250407, and the driver version is 250328. The board is a Nucleo-64 CNC Breakout, and the driver is an STM32F401.
Let's also analyze the output of $
. The output is as follows:
$
$0=10.0
$1=255
$2=15
$3=13
$4=15
$5=15
$6=0
$9=1
$10=7167
$11=0.010
$12=0.002
$13=0
$14=72
$15=0
$16=0
$17=0
$18=15
$19=0
$20=0
$21=1
$22=3
$23=0
$24=400.0
25=1200.0
$26=250
$27=8.000
$28=0.100
$29=0.0
$30=1000.000
$31=0.000
$32=0
$33=5000.0
$34=0.0
$35=0.0
$36=100.0
$37=0
$39=1
$40=0
$41=0
$42=2
$43=1
$44=8
$45=4
$46=1
$47=2
$56=5.0
$57=100.0
$58=-5.0
$59=500.0
$60=0
$61=0
$62=0
$63=3
$64=0
$65=0
$100=20.00000
$101=20.00000
$102=20.00000
$103=67.00000
$110=12000.000
$111=4000.000
$112=2000.000
$113=4000.000
$120=50.000
$121=50.000
$122=10.000
$123=10.000
$130=1000.000
$131=650.000
$132=135.000
$133=50.000
$341=0
$342=30.0
$343=25.0
$344=200.0
$345=200.0
$346=1
$370=0
$372=0
$376=0
$384=0
$392=4.0
$393=1.0
$394=4.0
$398=100
$481=0
$484=1
$486=0
$534=0
$538=0
$539=0.0
$673=1.0
$676=3
ok
From the output, we can see that the limit switches are inverted ($5=15
), and the pullups are disabled ($18=15
). The hard limits are enabled ($21=1
).
In conclusion, we have identified the inconsistent behavior when limit pullups are disabled while using NC switches. The issue is that the limit switches are reported as on at all times, unless pressed, and the alarm state is not triggered when a switch is triggered. We have also analyzed the output of $I
and $
to better understand the issue. To resolve this issue, we need to find a configuration that supports our NC switches, supports homing, and goes into an alarm state when a limit switch is triggered.
- Revert to NO switches: One possible solution is to revert to NO switches, which are easier to work with.
- Use a different driver: Another possible solution is to use a different driver that supports NC switches.
- Modify the firmware: We can also modify the firmware to support NC switches.
- Use a different breakout board: We can also use a different breakout board that supports NC switches.
In the future, we plan to investigate the issue further and find a solution that works for our project. We will also document our findings and share them with the community.
We would like to thank the grblHAL community for their help and support. We would also like to thank the STM32F401 and Nucleo-64 CNC Breakout documentation teams for their documentation.
Frequently Asked Questions (FAQs) - Inconsistent Behavior When Limit Pullups Disabled While Using NC Switches
A: When limit pullups are disabled while using NC switches, the limit switches are reported as on at all times, unless pressed, and the alarm state is not triggered when a switch is triggered.
A: This issue is occurring because the limit switches are not being properly detected when the pullups are disabled. The NC switches are normally closed, which means they are connected to ground when not pressed. When the pullups are disabled, the limit switches are not being pulled up to the high voltage level, which is required for proper detection.
A: The possible solutions to this issue are:
- Revert to NO switches: One possible solution is to revert to NO switches, which are easier to work with.
- Use a different driver: Another possible solution is to use a different driver that supports NC switches.
- Modify the firmware: We can also modify the firmware to support NC switches.
- Use a different breakout board: We can also use a different breakout board that supports NC switches.
A: To modify the firmware to support NC switches, you will need to change the code that detects the limit switches. You will need to add a pull-up resistor to the limit switch pins and modify the code to detect the switch when it is pressed.
A: The benefits of using NC switches are:
- Improved safety: NC switches are safer than NO switches because they are normally closed, which means they are connected to ground when not pressed.
- Improved reliability: NC switches are more reliable than NO switches because they are less prone to wear and tear.
- Improved performance: NC switches can improve the performance of your machine by providing a more accurate and reliable detection of the limit switches.
A: The limitations of using NC switches are:
- Increased complexity: NC switches are more complex than NO switches because they require a pull-up resistor to be added to the limit switch pins.
- Increased cost: NC switches are more expensive than NO switches because they require a more complex circuit.
- Increased risk of error: NC switches are more prone to error than NO switches because they require a more complex detection circuit.
A: To troubleshoot this issue, you can try the following:
- Check the limit switch connections: Make sure that the limit switch connections are correct and that the pull-up resistor is properly connected.
- Check the firmware: Make sure that the firmware is properly configured to detect the limit switches.
- Check the breakout board: Make sure that the breakout board is properly configured to support NC switches.
**Q: Where can I find more information about this issue?=====================================================
A: You can find more information about this issue on the following websites:
- GrHAL documentation: The GrHAL documentation provides information about the firmware and how to configure it to support NC switches.
- STM32F401 documentation: The STM32F401 documentation provides information about the microcontroller and how to configure it to support NC switches.
- Nucleo-64 CNC Breakout documentation: The Nucleo-64 CNC Breakout documentation provides information about the breakout board and how to configure it to support NC switches.