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.23k stars 19.22k forks source link

[FR] Z Homing for PCB milling #10861

Open salihonur opened 6 years ago

salihonur commented 6 years ago

Hello,

I wanna make PCB milling. I have tried many CNC firmwares but no one was stabil. So I decided to modify my working Marlin 3D firmware.

I use PCB copper surface as end stop. But this is not min or max end. This is reference point. What I need: 1) When engraving bit touches the surface the point will be set as reference point. 2) Then after homing Z axis, Z axis should move up abit (like -0.2 mm) to avoid from scratch while X and Y homing. 3) Then Z axis should move to required value (for example +0,2mm to mill or +1,5mm to cut the pcb) .

So touch point should be reference point and Z axis can be move both up and down direction.

NOTE: The picture is an protoype. In the picture PCB is drilled pcb. But in real action it will be solid copper. Distances will be real distance not header pins.

Can you help how can I do? Thanks...

Picture: https://pasteboard.co/HmYZXXr.jpg

salihonur commented 6 years ago

I found how to set the touch point as the reference point by "#define MANUAL_Z_HOME_POS 0". Now I need to know that how I can move Z a bit mm up after Z homing and before XY homing.

GMagician commented 6 years ago

Have you tryed to use input like it's for a probe instead on min?

salihonur commented 6 years ago

The probe setting is for bed leveling, isn't it? Can I use it for reference point?

Meanwhile my Z settings like Z_MIN_POS -22, Z_MAX_POS 2

NeoCortex3 commented 6 years ago

You might wanna look at G38.3 and G92. But as of Marlin 1.1.8 G38 is broken. I'm currently working on that.

GMagician commented 6 years ago

Yes you can. using Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN and connecting probe to min input

GMagician commented 6 years ago

... and tell system you have a probe (I was using such solution with bl-touch)

thinkyhead commented 6 years ago

@NeoCortex3 — Keep us posted on G38 testing, and be sure to use the latest bugfix branches, since we've recently updated endstop checking.

We're also looking at implementing G38.4 and G38.5.

salihonur commented 6 years ago

I'm sorry I supposed another probe can be used for reference point except end stops. I have already use a probe for max Z_MAX_PROBE_USES_Z_MAX_ENDSTOP_PIN.

At the moment all works fine except Z axis going up before homing XY. I home Z axis, then move up manually. Then I'm adding "G00 Z-10.0" and "G28 X Y" rows the top of codes in gcode file.

I have copied and added theese lines in gcode_G28() function but still it doen't go up.

NOTE: Positive direction is down, negative direction is up.

    #if Z_HOME_DIR > 0  // If homing away from BED do Z first

      if (home_all_axis || homeZ) {
        HOMEAXIS(Z);

        // SALIH <-
        if (home_all_axis || homeX || homeY) {
          // Raise Z before homing any other axes and z is not already high enough (never lower z)
          destination[Z_AXIS] = LOGICAL_Z_POSITION(Z_HOMING_HEIGHT);
          if (destination[Z_AXIS] > current_position[Z_AXIS]) {

            #if ENABLED(DEBUG_LEVELING_FEATURE)
              if (DEBUGGING(LEVELING))
                SERIAL_ECHOLNPAIR("Raise Z (before homing) to ", destination[Z_AXIS]);
            #endif

            do_blocking_move_to_z(destination[Z_AXIS]);
          }
        }
        // SALIH->

        /*#if ENABLED(DEBUG_LEVELING_FEATURE)
          if (DEBUGGING(LEVELING)) DEBUG_POS("> HOMEAXIS(Z)", current_position);
        #endif*/
      }

All settings about Z axis

#define Z_CLEARANCE_DEPLOY_PROBE   -10 //10 // Z Clearance for Deploy/Stow
#define Z_CLEARANCE_BETWEEN_PROBES  -10 // Z Clearance between probe points

#define Z_PROBE_OFFSET_RANGE_MIN -20
#define Z_PROBE_OFFSET_RANGE_MAX 20

#define Z_HOME_DIR 1

#define Z_MIN_POS -22
#define Z_MAX_POS 2

#define MANUAL_Z_HOME_POS 0

#define Z_SAFE_HOMING

#define Z_HOMING_HEIGHT -10 
DerAndere1 commented 2 years ago

Have you tried to change this ?https://github.com/MarlinFirmware/Marlin/blob/c3af6bd8ce731737d0812a0e554e37dc0779127f/Marlin/Configuration_adv.h#L836