MarlinFirmware / Marlin

Marlin is an optimized firmware for RepRap 3D printers based on the Arduino platform. Many commercial 3D printers come with Marlin installed. Check with your vendor if you need source code for your specific machine.
https://marlinfw.org
GNU General Public License v3.0
16.28k stars 19.24k forks source link

### Compile error since Release 1.1 if G38 enabled #7250

Closed sergioausrio closed 7 years ago

sergioausrio commented 7 years ago

Got a Compiler Error if i enable the G38 Support in Configuration_adv.h. Need this for my MPCNC Error from Arduino IDE;

sketch\Marlin_main.cpp: In function 'void process_next_command()':

Marlin_main.cpp:10527: error: 'subcode' was not declared in this scope

       if (subcode == 2 || subcode == 3)

           ^

exit status 1 'subcode' was not declared in this scope

thinkyhead commented 7 years ago

Will patch shortly. Here's the fix:

if (parser.subcode == 2 || parser.subcode == 3)
  gcode_G38(parser.subcode == 2);
sergioausrio commented 7 years ago

Thank you. The Compiler error is gone but G38.2Z-99 dont stops on Probe Contact (Z Min Endstop on Ramps). G28Z0 works fine with the same Probe

thinkyhead commented 7 years ago

Hmm, there haven't been any logical changes to G38 (as far as I know). I will take a look at 1.1.3 and compare to see what might have broken.

thinkyhead commented 7 years ago

Seems not to have changed since 1.1.3 — so does it not work in 1.1.3 either?

sergioausrio commented 7 years ago

No. G38 doesn't work since the 1.1 release. I tried every release. I have one of the last RC8 Bugfix Version with working G38

thinkyhead commented 7 years ago

So, RC8 seems to be the last? I will compare to that instead…

thinkyhead commented 7 years ago

Are you using ENDSTOP_INTERRUPTS_FEATURE?

sergioausrio commented 7 years ago

No

thinkyhead commented 7 years ago

What is your Z_MIN_PROBE_PIN setting? The old G38 used the Z_MIN_PIN while the current G38 requires the use of Z_MIN_PROBE_PIN.

sergioausrio commented 7 years ago

Ok. If have only #define Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN enabled. Is this my Problem ? What should i enter on Z_MIN_PROBE_PIN for a normally open switch (Probe with a CNC Bit)

Bob-the-Kuhn commented 7 years ago

The idea is to use Z_MIN_PIN for homing and Z_MIN_PROBE_PIN for setting your work piece origin.

I believe that this set of definitions will get G38 working:

//#define Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN
#define Z_MIN_PROBE_ENDSTOP
#define Z_MIN_PROBE_ENDSTOP_INVERTING true

Some of the CNC bits are not very conductive if you're probing in the X or Y directions. You may need to lightly rub some fine grit sandpaper on the side of the bit.

thinkyhead commented 7 years ago

@Bob-the-Kuhn

I see that #5897 is also concerned with G38. It looks like it can be closed, as I believe you can probe in any direction now.

Can G38 be made to work with Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN? There may be some obscure reason someone is homing Z to max and choosing to use the Z min pin as the probe pin.

sergioausrio commented 7 years ago

I got it working in the Z Direction only with

define Z_MIN_PROBE_ENDSTOP

define Z_MIN_PROBE_ENDSTOP_INVERTING true

but in X or Y Direction the Probe does not stop...

Bob-the-Kuhn commented 7 years ago

My robot is down so I can't verify this.

Please do a sanity check on the X & Y movement. Assuming you have an alligator clip on the bit and a touch plate similar to the triquetra system, issue a G38.2 X100 F200 and then touch the clip to the plate.

If the head doesn't stop then there's a software problem.

If the head stops immediately then the problem is poor electrical contact on the side of the bit.

sergioausrio commented 7 years ago

I tried it with a Alligator Clip direct on the Touchplate for many Times. It works only in both Z Directions. The crazy Thing is: Marlin throws allways the "Error: failed to reach target" Message even if the Probe stops in Z Direction on contact.

The optional PROBE_DOUBLE_TOUCH does not work either with G38

Bob-the-Kuhn commented 7 years ago

That's not what I was expecting to hear.

Time to jerry rig something so I can test.

sergioausrio commented 7 years ago

This morning i give the latest 1.1.4 Bugfix a try.... and IT WORKS !!! G38.2 is full functional! All directions working.

I put this in Configuration.h:

#define Z_MIN_PROBE_ENDSTOP
#define Z_MIN_PROBE_PIN Z_MIN_PIN
Bob-the-Kuhn commented 7 years ago

GREAT!!!

sergioausrio commented 7 years ago

Is it normal that a G28Z0 does not work in this configuration ? I dont need a G28 for CNC but i tried it and the Z-Axis does not stop on contact. (G38.2, G29 and G30 woking fine) On the other hand, the MPCNC is a multitool and can be used for 3D printing and Lasercutting. A G28Z is needed...

thinkyhead commented 7 years ago

Does G28 Z work, but G28Z does not?

sergioausrio commented 7 years ago

No. G28 works only with my regular Microswitch Endstops on X-Min & Y-Min but not on the Z-Axis with the Probe wich is on Z_MIN_PIN

Bob-the-Kuhn commented 7 years ago

It's really strange that G28 Z doesn't work but the others do.

I think the easiest thing to try is to replace #define Z_MIN_PROBE_PIN Z_MIN_PIN with #define Z_MIN_PROBE_PIN xx where xx is the number of the Z_MIN_PIN. Sometimes the first method doesn't work.

I think the long term fix is to change the G38 code to use either the probe pin or the Z_MIN pin. Try this: a) change configuration.h

//#define Z_MIN_PROBE_ENDSTOP 
//#define Z_MIN_PROBE_PIN Z_MIN_PIN
#define Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN

b) in endstops.cpp replace #if ENABLED(G38_PROBE_TARGET) && PIN_EXISTS(Z_MIN_PROBE) && !(CORE_IS_XY || CORE_IS_XZ) with #if ENABLED(G38_PROBE_TARGET) && (PIN_EXISTS(Z_MIN_PROBE) || PIN_EXISTS(Z_MIN)) && !(CORE_IS_XY || CORE_IS_XZ)

thinkyhead commented 7 years ago

It's really strange that G28 Z doesn't work but the others do.

It only homes with the probe if Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN, because it then assumes you have no Z min endstop.

#define HOMING_Z_WITH_PROBE (HAS_BED_PROBE && Z_HOME_DIR < 0 \
        && ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN))
sergioausrio commented 7 years ago

I changed

#define HOMING_Z_WITH_PROBE (HAS_BED_PROBE && Z_HOME_DIR < 0 \
        && ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN))

to

#define HOMING_Z_WITH_PROBE (HAS_BED_PROBE && Z_HOME_DIR < 0 && ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) || ENABLED(Z_MIN_PROBE_ENDSTOP))

and G28Z (G38 too) works now with Probe:

#define Z_MIN_PROBE_ENDSTOP
#define Z_MIN_PROBE_PIN Z_MIN_PIN
github-actions[bot] commented 3 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.