synthetos / TinyG

Affordable Industrial Grade Motion Control
https://github.com/synthetos/TinyG/wiki
897 stars 293 forks source link

G38.2 not working with NC limit switches #99

Closed jonhart closed 10 years ago

jonhart commented 10 years ago

In the latest build, with NC limit switches, running the G38.2 command doesn't initiate any motion at all. Note that my touch plate is wired to A min as an NO homing only switch.

aldenhart commented 10 years ago

I will take a look at this, but I want to make sure that a feed rate was specified for the probe move. It will err out with a 142 status code if not. The current list of status codes is posted here:

https://github.com/synthetos/TinyG/wiki/TinyG-Status-Codes

What status code are you getting back? Example:

g38.2 x10 f1000
{"r":{},"f":[1,0,16]}

... returned a OK (0) code.

jonhart commented 10 years ago

Yes, the whole command is G38.2 Z-20 F100.

aldenhart commented 10 years ago

What build are you on, and what code did it return?

Best to initiate this from JSON mode, of you can. Just type { to enter JSON mode, then run the G38.2 Z-20 F100 command

Thx

jonhart commented 10 years ago

I'm on 435.10. I ran G38.2 z-10 f100 in coolterm, and received the following code:

{"r":{"err":"{"},"f":[1,108,2,3839]} {"r":{},"f":[1,0,16,75]} {"sr":{"feed":100.00}} {"sr":{"coor":0,"dist":0,"stat":7}} {"r":{"prb":{"e":1,"x":390.000,"y":0.000,"z":0.000,"a":0.000,"b":0.000,"c":0.000}},"f":[1,0,0,1745]} (cm.cycle_state 0) {"sr":{"coor":1,"dist":1,"stat":3}}

On Tue, Aug 19, 2014 at 10:24 AM, Alden Hart notifications@github.com wrote:

What build are you on, and what code did it return?

Best to initiate this from JSON mode, of you can. Just type { to enter JSON mode, then run the G38.2 Z-20 F100 command

Thx

— Reply to this email directly or view it on GitHub https://github.com/synthetos/TinyG/issues/99#issuecomment-52659929.

pastprimitive commented 10 years ago

Is there a work around for the time being on this besides changing my switches to normally open?

aldenhart commented 10 years ago

Set your switches to no for the duration of the probe operation then set them back at the end. I am working on switch code that will allow switch type to be set independently (among other improvements.)

pastprimitive commented 10 years ago

Just FYI, tried setting the switches to NO for the duration of the probe operation. Tried both 435.10 and 438.02 neither would even cause movement in any direction. Issued command as you wrote above. However I did not initiate the command from JSON mode. Should I have? Thanks for all your work.

aldenhart commented 10 years ago

Was the rest of the machine working when you tried this? Perhaps setting the switches to no caused the NC switches (which then appeared closed) to send the machine into limit/reset. I know this command works, as others are using it. So something else is afoot. What switches do you have wired and how are they set at the start of this operation? JSON or command line should not matter.

jonhart commented 10 years ago

I’ll second this. I’ve had exactly the same response from TinyG in 435.10. My switches are simple microswitches that are wired for NC operation. Issuing the g38.2 command in tgfx doesn’t cause any motion whether I have TinyG set for NC or NO. It is also worth noting that setting all switches for either homing or disabled doesn’t change this response.

Jon Hart Product Design // Swarm

801.556.6112 151 W Pierpont Ave SLC, UT, USA 84101

On Sep 4, 2014, at 4:50 AM, Alden Hart notifications@github.com wrote:

Was the rest of the machine working when you tried this? Perhaps setting the switches to no caused the NC switches (which then appeared closed) to send the machine into limit/reset. I know this command works, as others are using it. So something else is afoot. What switches do you have wired and how are they set at the start of this operation? JSON or command line should not matter.

— Reply to this email directly or view it on GitHub.

pastprimitive commented 10 years ago

The machine works perfectly in every other aspect. I have 3 homing/limits, 3 limits, all wired NC. Then also have a NO wired z-probe plate connected to a-min. I did not receive any shutdown errors in either tgFX or coolTerm.

Below are my coolTerm readouts after issuing "G38.2 Z-20 F100" both with "$st=1" & "$st=0".

screen shot 2014-09-04 at 11 15 25 am screen shot 2014-09-04 at 11 14 15 am

aldenhart commented 10 years ago

I tried out probing on my Shapeoko2. It's working fine. So I wonder what you are experiencing that I am not. Here's the run - followed by my $$ dump:

command was: g38.2 z-70 f1000 response: {"sr":{"feed":1000.00}} {"sr":{"coor":0,"stat":7}} {"sr":{"posz":-1.728,"vel":500.00}} {"sr":{"posz":-3.727}} {"sr":{"posz":-5.767}} {"sr":{"posz":-7.808}} {"sr":{"posz":-9.848}} {"sr":{"posz":-11.888}} {"sr":{"posz":-13.929}} {"sr":{"posz":-15.969}} {"sr":{"posz":-17.968}} {"sr":{"posz":-20.009}} {"sr":{"posz":-20.987,"vel":0.12}} {"r":{"prb":{"e":1,"x":0.000,"y":0.000,"z":-20.987,"a":0.000,"b":0.000,"c":0.000}},"f":[1,0,0,1718]} {"sr":{"vel":0.00,"coor":1,"stat":3}}

$$ dump: [fb] firmware build 438.02 [fv] firmware version 0.97 [hp] hardware platform 1.00 [hv] hardware version 8.00 [id] TinyG ID 3X3566-YMB [ja] junction acceleration 2000000 mm [ct] chordal tolerance 0.0100 mm [sl] soft limit enable 0 [st] switch type 1 [0=NO,1=NC] [mt] motor idle timeout 2.00 Sec [ej] enable json mode 0 [0=text,1=JSON] [jv] json verbosity 2 [0=silent,1=footer,2=messages,3=configs,4=linenum,5=verbose] [js] json serialize style 1 [0=relaxed,1=strict] [tv] text verbosity 1 [0=silent,1=verbose] [qv] queue report verbosity 0 [0=off,1=single,2=triple] [sv] status report verbosity 1 [0=off,1=filtered,2=verbose] [si] status interval 250 ms [ec] expand LF to CRLF on TX 0 [0=off,1=on] [ee] enable echo 0 [0=off,1=on] [ex] enable flow control 1 [0=off,1=XON/XOFF, 2=RTS/CTS] [baud] USB baud rate 5 [1=9600,2=19200,3=38400,4=57600,5=115200,6=230400] [net] network mode 0 [0=master] [gpl] default gcode plane 0 [0=G17,1=G18,2=G19] [gun] default gcode units mode 1 [0=G20,1=G21] [gco] default gcode coord system 1 [1-6 (G54-G59)] [gpa] default gcode path control 2 [0=G61,1=G61.1,2=G64] [gdi] default gcode distance mode 0 [0=G90,1=G91] [1ma] m1 map to axis 0 [0=X,1=Y,2=Z...] [1sa] m1 step angle 1.800 deg [1tr] m1 travel per revolution 40.0000 mm [1mi] m1 microsteps 8 [1,2,4,8] [1po] m1 polarity 0 [0=normal,1=reverse] [1pm] m1 power management 2 [0=disabled,1=always on,2=in cycle,3=when moving] [2ma] m2 map to axis 1 [0=X,1=Y,2=Z...] [2sa] m2 step angle 1.800 deg [2tr] m2 travel per revolution 40.0000 mm [2mi] m2 microsteps 8 [1,2,4,8] [2po] m2 polarity 0 [0=normal,1=reverse] [2pm] m2 power management 2 [0=disabled,1=always on,2=in cycle,3=when moving] [3ma] m3 map to axis 1 [0=X,1=Y,2=Z...] [3sa] m3 step angle 1.800 deg [3tr] m3 travel per revolution 40.0000 mm [3mi] m3 microsteps 8 [1,2,4,8] [3po] m3 polarity 1 [0=normal,1=reverse] [3pm] m3 power management 2 [0=disabled,1=always on,2=in cycle,3=when moving] [4ma] m4 map to axis 2 [0=X,1=Y,2=Z...] [4sa] m4 step angle 1.800 deg [4tr] m4 travel per revolution 1.2500 mm [4mi] m4 microsteps 4 [1,2,4,8] [4po] m4 polarity 0 [0=normal,1=reverse] [4pm] m4 power management 2 [0=disabled,1=always on,2=in cycle,3=when moving] [xam] x axis mode 1 [standard] [xvm] x velocity maximum 50000 mm/min [xfr] x feedrate maximum 50000 mm/min [xtn] x travel minimum 0.000 mm [xtm] x travel maximum 280.000 mm [xjm] x jerk maximum 8000 mm/min^3 * 1 million [xjh] x jerk homing 10000 mm/min^3 * 1 million [xjd] x junction deviation 0.0100 mm (larger is faster) [xsn] x switch min 1 [0=off,1=homing,2=limit,3=limit+homing] [xsx] x switch max 0 [0=off,1=homing,2=limit,3=limit+homing] [xsv] x search velocity 3000 mm/min [xlv] x latch velocity 100 mm/min [xlb] x latch backoff 20.000 mm [xzb] x zero backoff 3.000 mm [yam] y axis mode 1 [standard] [yvm] y velocity maximum 50000 mm/min [yfr] y feedrate maximum 50000 mm/min [ytn] y travel minimum 0.000 mm [ytm] y travel maximum 280.000 mm [yjm] y jerk maximum 5000 mm/min^3 * 1 million [yjh] y jerk homing 10000 mm/min^3 * 1 million [yjd] y junction deviation 0.0100 mm (larger is faster) [ysn] y switch min 1 [0=off,1=homing,2=limit,3=limit+homing] [ysx] y switch max 0 [0=off,1=homing,2=limit,3=limit+homing] [ysv] y search velocity 3000 mm/min [ylv] y latch velocity 100 mm/min [ylb] y latch backoff 20.000 mm [yzb] y zero backoff 3.000 mm [zam] z axis mode 1 [standard] [zvm] z velocity maximum 500 mm/min [zfr] z feedrate maximum 500 mm/min [ztn] z travel minimum 0.000 mm [ztm] z travel maximum 95.000 mm [zjm] z jerk maximum 50 mm/min^3 * 1 million [zjh] z jerk homing 1000 mm/min^3 * 1 million [zjd] z junction deviation 0.0100 mm (larger is faster) [zsn] z switch min 0 [0=off,1=homing,2=limit,3=limit+homing] [zsx] z switch max 1 [0=off,1=homing,2=limit,3=limit+homing] [zsv] z search velocity 500 mm/min [zlv] z latch velocity 100 mm/min [zlb] z latch backoff 20.000 mm [zzb] z zero backoff 10.000 mm [aam] a axis mode 1 [standard] [avm] a velocity maximum 60000 deg/min [afr] a feedrate maximum 48000 deg/min [atn] a travel minimum 400.000 deg [atm] a travel maximum -1.000 deg [ajm] a jerk maximum 24000 deg/min^3 * 1 million [ajh] a jerk homing 24000 deg/min^3 * 1 million [ajd] a junction deviation 0.1000 deg (larger is faster) [ara] a radius value 1.0000 deg [asn] a switch min 1 [0=off,1=homing,2=limit,3=limit+homing] [asx] a switch max 0 [0=off,1=homing,2=limit,3=limit+homing] [asv] a search velocity 6000 deg/min [alv] a latch velocity 1000 deg/min [alb] a latch backoff 5.000 deg [azb] a zero backoff 2.000 deg [bam] b axis mode 0 [disabled] [bvm] b velocity maximum 3600 deg/min [bfr] b feedrate maximum 3600 deg/min [btn] b travel minimum -1.000 deg [btm] b travel maximum -1.000 deg [bjm] b jerk maximum 20 deg/min^3 * 1 million [bjd] b junction deviation 0.0100 deg (larger is faster) [bra] b radius value 1.0000 deg [cam] c axis mode 0 [disabled] [cvm] c velocity maximum 3600 deg/min [cfr] c feedrate maximum 3600 deg/min [ctn] c travel minimum -1.000 deg [ctm] c travel maximum -1.000 deg [cjm] c jerk maximum 20 deg/min^3 * 1 million [cjd] c junction deviation 0.0100 deg (larger is faster) [cra] c radius value 1.0000 deg [p1frq] pwm frequency 100 Hz [p1csl] pwm cw speed lo 1000 RPM [p1csh] pwm cw speed hi 2000 RPM [p1cpl] pwm cw phase lo 0.125 [0..1] [p1cph] pwm cw phase hi 0.200 [0..1] [p1wsl] pwm ccw speed lo 1000 RPM [p1wsh] pwm ccw speed hi 2000 RPM [p1wpl] pwm ccw phase lo 0.125 [0..1] [p1wph] pwm ccw phase hi 0.200 [0..1] [p1pof] pwm phase off 0.100 [0..1] [g54x] g54 x offset 0.000 mm [g54y] g54 y offset 0.000 mm [g54z] g54 z offset 0.000 mm [g54a] g54 a offset 0.000 deg [g54b] g54 b offset 0.000 deg [g54c] g54 c offset 0.000 deg [g55x] g55 x offset 140.000 mm [g55y] g55 y offset 140.000 mm [g55z] g55 z offset 0.000 mm [g55a] g55 a offset 0.000 deg [g55b] g55 b offset 0.000 deg [g55c] g55 c offset 0.000 deg [g56x] g56 x offset 0.000 mm [g56y] g56 y offset 0.000 mm [g56z] g56 z offset 0.000 mm [g56a] g56 a offset 0.000 deg [g56b] g56 b offset 0.000 deg [g56c] g56 c offset 0.000 deg [g57x] g57 x offset 0.000 mm [g57y] g57 y offset 0.000 mm [g57z] g57 z offset 0.000 mm [g57a] g57 a offset 0.000 deg [g57b] g57 b offset 0.000 deg [g57c] g57 c offset 0.000 deg [g58x] g58 x offset 0.000 mm [g58y] g58 y offset 0.000 mm [g58z] g58 z offset 0.000 mm [g58a] g58 a offset 0.000 deg [g58b] g58 b offset 0.000 deg [g58c] g58 c offset 0.000 deg [g59x] g59 x offset 0.000 mm [g59y] g59 y offset 0.000 mm [g59z] g59 z offset 0.000 mm [g59a] g59 a offset 0.000 deg [g59b] g59 b offset 0.000 deg [g59c] g59 c offset 0.000 deg [g92x] g92 x offset 0.000 mm [g92y] g92 y offset 0.000 mm [g92z] g92 z offset 0.000 mm [g92a] g92 a offset 0.000 deg [g92b] g92 b offset 0.000 deg [g92c] g92 c offset 0.000 deg [g28x] g28 x position 0.000 mm [g28y] g28 y position 0.000 mm [g28z] g28 z position 0.000 mm [g28a] g28 a position 0.000 deg [g28b] g28 b position 0.000 deg [g28c] g28 c position 0.000 deg [g30x] g30 x position 0.000 mm [g30y] g30 y position 0.000 mm [g30z] g30 z position 0.000 mm [g30a] g30 a position 0.000 deg [g30b] g30 b position 0.000 deg [g30c] g30 c position 0.000 deg tinyg [mm] ok>

pastprimitive commented 10 years ago

I'll verify my settings against yours, and post progress results today. Thanks Alden.

aldenhart commented 10 years ago

No problem. Sorry it took so long to get back to you. Please let me know what you find so we can chase this one down.

pastprimitive commented 10 years ago

Not a problem. Here's a screenshot of your dump and mine compared in Kdiff. Since I am assuming this must be a configurations issue since we're running the same firmware versions.

I'll be going through and changing the various config. variables to match with yours and see if I strike gold.

screen shot 2014-09-08 at 8 46 16 am

pastprimitive commented 10 years ago

So I matched your config in everything but some machine specific variables, feed rates, etc... Still no love. I made sure my switch setup matched yours configuration wise, although I did not pull the wiring from the board itself for the limits that you do not have present. I am wondering if Jonhart also has limits like I do. That seems an area of suspicion possibly. But it doesn't seem like that would stop my machine from attempting to probe.

I have used tgFX to setup config variables before this. Although I used cool term today.

I am wondering if perhaps tgFX is changing a variable on my EEPROM that doesn't display in the dump $$ ?

pastprimitive commented 10 years ago

Any chance to looks at this yet?

aldenhart commented 10 years ago

I have not been able to reproduce this in my setups. I've got NC homing working as expected. Would you mind trying out this experimental build and see if your results change? Also, can you please let me know what switch you are using - manufacturer and part number? Thanks.

pastprimitive commented 10 years ago

I have my homing and limit switches working all as expected on a G28.2 command as NC switches. Also limits work as expected as e-stops. But it's the G38.2 probe command that does not work for me. Maybe that is what you meant when you said you and homing working.

I've run both 438.2 from the edge branch and 435.1 from the master. When you want me to try the experimental build are you referring to the firmware version from the "dev" branch?

Here's a link to the switches I am using.

http://www.ebay.com/itm/10-pc-TEMCo-Micro-Limit-Switch-Lever-Arm-Subminiature-SPDT-Snap-Action-LOT-/281353659655?pt=LH_DefaultDomain_0&hash=item4181fc2507

pastprimitive commented 10 years ago

Also if you'd like me to try the dev branch out, do you have the hex file for me? I've not taken the time to setup the development environment yet, and am not aware of where I can download the dev branch hex file.

pastprimitive commented 10 years ago

When I compare your command response, with the command response I got above. It looks like the only difference is that my machine is considering the switch tripped as soon as I issue a command, thus coming back with the z probe readout, where mine thinks it's already there. Which seems weird since my g28.2 command works just fine. So something had my system believing the switch state is changed right from the start. What that is... not sure... I'll keep plugging away. I really want to get this feature working so I can mill some PCBs.

aldenhart commented 10 years ago

Looking back over this thread I'm not sure I understand your setup. From an earlier post you say:

"I have 3 homing/limits, 3 limits, all wired NC. Then also have a NO wired z-probe plate connected to a-min. I did not receive any shutdown errors in either tgFX or coolTerm."

The probe is set up to use the Zmin, not A, so perhaps you can disconnect the Zmin and use if for the probe instead. Since the probe is NO you will need to change the switch type before the operation and change it back at the end (as discussed previously). Does this make sense or am I mis-understanding things?

Please ignore my comment on the experimental build - I thought you were having homing problems, which you are not.

pastprimitive commented 10 years ago

No problem.

"I have 3 homing/limits, 3 limits, all wired NC. Then also have a NO wired z-probe plate connected to a-min. I did not receive any shutdown errors in either tgFX or coolTerm."

Yes that is correct.

And I had a big post ready to talk about how bizarre this all was. Than I went through disabled all my limit switches in TGFX accept for the Zmin. And guess what? IT WORKED! Thank goodness. I've been dreaming of having this feature for a while. Anyhow it DOES work even when you have limit switches set to NC as your setting, but it still expects a NO probe. This is of course very desirable. Because for z probing I can simply put a clip on my Zmin switch on the z axis and turn it into a NO switch, and keep my NO probe wired permenantly to the Zmin as well. Make sense?

Yeah, verified to work. AND THANK YOU for walking me through this. Somewhere along the line I was under the impression that you could use the Amin for the probe...

Sorry for this being so drug out. But it's nice to know you don't need to change settings on Tiny G to use the G38.2 command. You do lose the ability to easily use the Zmin as a limit switch if you have a NC switch wiring default. Which is a bit of a bummer for us paranoid, who like the increased assurance of NC switches and a Zmin limit switch as well. Would be nice to have the option to map the a axis limit switches to the Z axis.

So you do not need to change the TinyG to NO switch before sending the G38.2 command, but just make sure that you have a NO switch wired to the Zmin. That was the key.

Zmin pin must be wired NO.

Again huge thanks!

aldenhart commented 10 years ago

Glad you are up and running. I need to put this on the wiki.

melristau commented 9 years ago

"Zmin pin must be wired NO." How do you WIRE the Zmin pin to be NO? Helpful to know.

mikest commented 9 years ago

use a N.O. switch instead of an N.C. switch. For some switches (SPDT), they can be wired in either configuration.

--mikest

Sent from my iPhone

On Jan 29, 2015, at 6:22 PM, Mel Ristau notifications@github.com wrote:

"Zmin pin must be wired NO." How do you WIRE the Zmin pin to be NO? Helpful to know.

— Reply to this email directly or view it on GitHub.

ril3y commented 9 years ago

To elaborate. Look at this image.

http://jv.wikipedia.org/wiki/Gambar:Spdt_limit_switch.jpg

You can see 3 pins. One is labeled NO and the other NC. This is what Mike is talking about.

Riley

On Thu, Jan 29, 2015 at 9:37 PM, Mike Estee notifications@github.com wrote:

use a N.O. switch instead of an N.C. switch. For some switches (SPDT), they can be wired in either configuration.

--mikest

Sent from my iPhone

On Jan 29, 2015, at 6:22 PM, Mel Ristau notifications@github.com wrote:

"Zmin pin must be wired NO." How do you WIRE the Zmin pin to be NO? Helpful to know.

Reply to this email directly or view it on GitHub.

Reply to this email directly or view it on GitHub https://github.com/synthetos/TinyG/issues/99#issuecomment-72144679.

melristau commented 9 years ago

Thanks Riley - I get it now... In the context of notes on probing w/ g38.2, it makes sense that the alligator clip & plate technique would be a NO circuit. "Zmin pin must be wired NO", makes sense if referring to a three-pole switch. But this process requires a two-pole probe. So, I was thinking Andrew knew of some way to connect at the board end that would override the [st] switch type command! Me being inexperienced with CNC and way too literal! Regardless, this thread helped me get my Z working as it should.

ril3y commented 9 years ago

Very good!

Thanks for the feed back.

Riley

On Thu, Jan 29, 2015 at 11:41 PM, Mel Ristau notifications@github.com wrote:

Thanks Riley - I get it now... In the context of notes on probing w/ g38.2, it makes sense that the alligator clip & plate technique would be a NO circuit. "Zmin pin must be wired NO", makes sense if referring to a three-pole switch. But this process requires a two-pole probe. So, I was thinking Andrew knew of some way to connect at the board end that would override the [st] switch type command! Me being inexperienced with CNC and way too literal! Regardless, that thread helped me get my Z working as it should. Best to you,

Mel Ristau Ristau Sculpture, LLC 8001 Country Farms Ct. Fort Collins, CO. 80528 Mountain Standard Time 970 377-3713

On Jan 29, 2015, at 8:06 PM, ril3y notifications@github.com wrote:

To elaborate. Look at this image.

http://jv.wikipedia.org/wiki/Gambar:Spdt_limit_switch.jpg

You can see 3 pins. One is labeled NO and the other NC. This is what Mike is talking about.

Riley

On Thu, Jan 29, 2015 at 9:37 PM, Mike Estee notifications@github.com wrote:

use a N.O. switch instead of an N.C. switch. For some switches (SPDT), they can be wired in either configuration.

--mikest

Sent from my iPhone

On Jan 29, 2015, at 6:22 PM, Mel Ristau notifications@github.com wrote:

"Zmin pin must be wired NO." How do you WIRE the Zmin pin to be NO? Helpful to know.

Reply to this email directly or view it on GitHub.

Reply to this email directly or view it on GitHub https://github.com/synthetos/TinyG/issues/99#issuecomment-72144679.

Reply to this email directly or view it on GitHub.

Reply to this email directly or view it on GitHub https://github.com/synthetos/TinyG/issues/99#issuecomment-72153386.