Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mks sbase z-probe wont invert #49

Closed
swashman opened this issue Nov 16, 2020 · 8 comments
Closed

Mks sbase z-probe wont invert #49

swashman opened this issue Nov 16, 2020 · 8 comments

Comments

@swashman
Copy link

swashman commented Nov 16, 2020

Hello,
I am working on setting up a cnc using a MKS Sbase.
I noticed in testing my limit switches that the probe pin was showing as activated. I changed the $6 to invert it however this has made no change. It appears to be expecting a NC switch either way but I am using a touchplate with 2 wires. When I attempt to run a probe command it fails saying the switch is in the wrong state.
I am using the precompiled bin file. is there a setting somewhere i need to change and compile myself?

@cprezzi
Copy link
Owner

cprezzi commented Nov 17, 2020

Limit switches expect an NC switch by default (for protecting from broken wires), but the probe pin should not. The default behaviour with $6=0 should be that the pin is pulled up from the board and the probe trigges when you connect the pin to ground.

@swashman
Copy link
Author

So I switched the limits back to the original setting and connected them as NC. However my probe still shows as tripped.
I will try and reflash the firmware and see if it fixes.
20201117_190355

@cprezzi
Copy link
Owner

cprezzi commented Nov 18, 2020

Are you sure that you use the probe pin for the probe? This pin should not have anything to do with the limit pins and config.

@swashman
Copy link
Author

Yes so maybe I got it a little confused at the beginning talking about the limit switches. I tried reflashing and this didn't change anything.

So when I do connect the probe, it does work just
backwards , as if I'm going to do probe away. So I was reading the the probe.c file and was thinking if I just switch the return in probe_get_state this should fix my issue. Would this cause any adverse effects?

@tscofield
Copy link

tscofield commented Dec 1, 2020

The setup you are describing should work. Trying on my setup ($6=0, probe connected to pin P1.27), here is the status output of an open probe and a closed probe.

Grbl 1.1f ['$' for help]
<Idle|WPos:0.000,0.000,0.000,0.000|FS:0,0|Pn:ZA|WCO:0.000,0.000,0.000,0.000>
<Idle|WPos:0.000,0.000,0.000,0.000|FS:0,0|Pn:PZA|Ov:100,100,100>

@swashman
Copy link
Author

swashman commented Dec 1, 2020

I was never able to get it to work normally. I ended up just changing the code to invert what is returned, and it seems to be working just fine.

For some reason changing to $6=1 never did anything at all. Since no one else seems to have the issue, I just chalk it up to some form of board defect that isn't of major issue. Maybe a bad pullup or down, whichever one it is, I can never remember.

@swashman swashman closed this as completed Dec 1, 2020
@tscofield
Copy link

tscofield commented Dec 1, 2020

I'm not sure how many people have used this function, so folks other than yourself may have had the same issue. I think I found the problem, I haven't done any testing yet.

Probe.c line 25 should probably be changed to a uint32_t from an 8 bit. I never tested trying to invert it the output with previous testing. Right now the logic is ((PROBE_PIN & PROBE_MASK) ^ probe_invert_mask), with the probe_invert_mask being 8 bit you have a bitwise operation of ((32 bit AND 32 bit) XOR'd with 8 bit). Since we are dealing with the 27th bit, and the xor could only possibly change the first 8, nothing happens.

I can try testing this out, but it might be a few days before I get a chance to re-setup a build environment for this.

@cprezzi
Copy link
Owner

cprezzi commented Dec 1, 2020

@tscofield Good catch! This may have been forgotten when porting grbl to LPC. If you have time, please add a pull request after testing. Thanks!

@cprezzi cprezzi reopened this Dec 1, 2020
tscofield added a commit to tscofield/grbl-LPC that referenced this issue Dec 2, 2020
Correct 32bit mask for probe invert.

Probe Physically Open
$6=0
<Alarm|WPos:0.000,0.000,0.000,0.000|FS:0,0|Pn:ZA|WCO:0.000,0.000,0.000,0.000>
Probe is not triggered

$6=1
<Alarm|WPos:0.000,0.000,0.000,0.000|FS:0,0|Pn:PZA|Ov:100,100,100>
Probe is triggered

Probe Physically Closed
$6=0
<Alarm|WPos:0.000,0.000,0.000,0.000|FS:0,0|Pn:ZA|WCO:0.000,0.000,0.000,0.000>
Probe is not triggered

$6=1
<Alarm|WPos:0.000,0.000,0.000,0.000|FS:0,0|Pn:PZA|Ov:100,100,100>
Probe is triggered
cprezzi added a commit that referenced this issue Feb 19, 2021
Fix for issue #49 (probe invert mask 8 bit instead of 32)
@cprezzi cprezzi closed this as completed May 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants