-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
bug when using normally closed switch for hard limits #60
Comments
I have to check it. |
Hmm. It is not very simple to get rid of the signal bounce. You have to use RC filter close to uC input. |
I will have to check again on my machine.
|
I even did not put the resistance R; I only put the capacitor C. |
I agree with you. I just want to say that in most cases users will not be add additional elements (as R&C).
I think it's not quite necessary. May be you are right about separate Falling and Rising edges for NC and NO limits. |
FYI, I made some tests and it works fine. |
Hard limit switches are handled by interrupt.
By default GRBL uses normally open switches but the setup allows to invert the logic in order to use normally closed switches (with the parameter defined to invert limits).
Still the current version for stm32 has a bug in case of normally closed switches.
Currently the interrupts are only triggered on the falling edge. This is wrong for a normally closed switch.
It has to be triggered on the rising edge.
There is a pull request that propose to trigger on both edges but this generates another bug because interrupt is then triggered twice.
I thing that following change should be ok.
In file limit.c, there is a function void limits_init()
There is a line
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling; //Trigger mode, can be a falling edge trigger EXTI_Trigger_Falling, the rising edge triggered EXTI_Trigger_Rising, or any level (rising edge and falling edge trigger EXTI_Trigger_Rising_Falling)
It should be replaced by
if (bit_istrue(settings.flags, BITFLAG_INVERT_LIMIT_PINS )) { // for normally closed switches, we need to interrupt on the rising edge EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising ; //Trigger mode, can be a falling edge trigger EXTI_Trigger_Falling, the rising edge triggered EXTI_Trigger_Rising, or any level (rising edge and falling edge trigger EXTI_Trigger_Rising_Falling) } else { EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling; //Trigger mode, can be a falling edge trigger EXTI_Trigger_Falling, the rising edge triggered EXTI_Trigger_Rising, or any level (rising edge and falling edge trigger EXTI_Trigger_Rising_Falling) }
The text was updated successfully, but these errors were encountered: