Adding auto leveling or tramming gcode to dual extruder

The official subforum for discussion of the installation and use of the official M2 Dual Extruder upgrade.
User avatar
Tim
Posts: 1205
Joined: Thu Apr 10, 2014 2:19 pm
Location: Poolesville, Maryland
Contact:

Re: Adding auto leveling or tramming gcode to dual extruder

Post by Tim » Sat Aug 15, 2015 2:20 am

This may be relevant only to my smoothieboard, which has completely different software for doing Z-probes. But, with the Z-probe sitting in front of the extruders, you can't just do a "home", or else when X = 0 and Y= 0, the Z-probe is off the end of the bed, so it will never trigger. To do a proper home in Z, you either (1) have to have the firmware move the X and Y to an offset position before attempting to home Z, or else (2) you need to have both the original Z-min switch AND the Z-probe active, which doesn't solve one of the original problems that the Z-min switch can move relative to the nozzle, requiring all the Z-stage adjustment. I guess there's always solution (3), stick a piece of metal off of the front of the bed so that the Z probe will be on top of it when X = 0 and Y = 0.

I ran a three-point calibration and it seemed to work well, although I then was stuck with the problem of not knowing how to home the whole system. I then tried the Smoothieware's Z-grid method, which is what I want, ultimately, but that first tried to drive the bed downward, then moved up and crashed the bed into the hot-end (I was enough lacking in confidence that I had my finger hovering over the power switch).

Will need more (careful) investigation. . .

Ronnien55
Posts: 60
Joined: Mon Dec 08, 2014 2:50 am
Location: Holly Springs NC

Re: Adding auto leveling or tramming gcode to dual extruder

Post by Ronnien55 » Sat Aug 15, 2015 8:42 pm

Tim wrote:This may be relevant only to my smoothieboard, which has completely different software for doing Z-probes. But, with the Z-probe sitting in front of the extruders, you can't just do a "home", or else when X = 0 and Y= 0, the Z-probe is off the end of the bed, so it will never trigger. To do a proper home in Z, you either (1) have to have the firmware move the X and Y to an offset position before attempting to home Z, or else (2) you need to have both the original Z-min switch AND the Z-probe active, which doesn't solve one of the original problems that the Z-min switch can move relative to the nozzle, requiring all the Z-stage adjustment. I guess there's always solution (3), stick a piece of metal off of the front of the bed so that the Z probe will be on top of it when X = 0 and Y = 0.

I ran a three-point calibration and it seemed to work well, although I then was stuck with the problem of not knowing how to home the whole system. I then tried the Smoothieware's Z-grid method, which is what I want, ultimately, but that first tried to drive the bed downward, then moved up and crashed the bed into the hot-end (I was enough lacking in confidence that I had my finger hovering over the power switch).

Will need more (careful) investigation. . .
I used PcS's Marlin code, so mine homes X and Y then moves to bed center and homes Z, this happens when i enter G28. Not sure how he set the code up to do this would have to ask him.

User avatar
Tim
Posts: 1205
Joined: Thu Apr 10, 2014 2:19 pm
Location: Poolesville, Maryland
Contact:

Re: Adding auto leveling or tramming gcode to dual extruder

Post by Tim » Sat Aug 15, 2015 9:46 pm

Ronnien55 wrote:I used PcS's Marlin code, so mine homes X and Y then moves to bed center and homes Z, this happens when i enter G28. Not sure how he set the code up to do this would have to ask him.
Okay, thanks. I'm not using Marlin, but it's good to know how other firmwares are handling it. Obviously the normal "home" procedure doesn't work, but moving to the center is a reasonable solution. Except that "home" is supposed to go to X=0, Y=0, Z=0. So after homing Z, does it do another X and Y homing, or do you just set your origin at the center of the plate?

Ronnien55
Posts: 60
Joined: Mon Dec 08, 2014 2:50 am
Location: Holly Springs NC

Re: Adding auto leveling or tramming gcode to dual extruder

Post by Ronnien55 » Sun Aug 16, 2015 10:14 am

Tim wrote:
Ronnien55 wrote:I used PcS's Marlin code, so mine homes X and Y then moves to bed center and homes Z, this happens when i enter G28. Not sure how he set the code up to do this would have to ask him.
Okay, thanks. I'm not using Marlin, but it's good to know how other firmwares are handling it. Obviously the normal "home" procedure doesn't work, but moving to the center is a reasonable solution. Except that "home" is supposed to go to X=0, Y=0, Z=0. So after homing Z, does it do another X and Y homing, or do you just set your origin at the center of the plate?
this my starting script in Simply3d:

M108 S255 ; Turn on M2 fans
T1 ; Switch to right extruder offsets for homing
G28
G29
T0 ; Switch to left extruder
G1 X0 Y50 Z0.3 F9600 ; Move forward to avoid binder clips
G1 X250 Z10 F3600 ; Move off platform (i had to change this X location to get it off the table)
G1 Z0.4 ; Position nozzle above buildplate
G92 E0 ; Zero extruder
G1 E25 F225 ; Purge left extruder
G92 E0 ; Zero extruder
G1 X160 Z0.1 E1.0 F1200 ; Slow wipe
G1 X140 Z0.25 ; Lift

it ran with out any issues.

User avatar
Tim
Posts: 1205
Joined: Thu Apr 10, 2014 2:19 pm
Location: Poolesville, Maryland
Contact:

Re: Adding auto leveling or tramming gcode to dual extruder

Post by Tim » Sun Aug 16, 2015 1:27 pm

Ronnien55 wrote:this my starting script in Simply3d:
Thanks, even more helpful. . .
T1 ; Switch to right extruder offsets for homing
Wait, what? I don't get why you (or PcS, rather) do this. Does it make any difference to the homing which extruder is active?
G29
Unsupported on Smoothie. But I'll cope.

The RepRap documentation doesn't really give much detail about the "G28" command. I guess it's up to the firmware to figure out how to properly get the hardware to point (0, 0, 0). I see from the "move off platform" command that the X position off the right edge of the bed is at X=250, which means that the origin hasn't been moved to the center, which answers one question.

Ronnien55
Posts: 60
Joined: Mon Dec 08, 2014 2:50 am
Location: Holly Springs NC

Re: Adding auto leveling or tramming gcode to dual extruder

Post by Ronnien55 » Sun Aug 16, 2015 2:46 pm

Tim wrote:
Ronnien55 wrote:this my starting script in Simply3d:
Thanks, even more helpful. . .
T1 ; Switch to right extruder offsets for homing
Wait, what? I don't get why you (or PcS, rather) do this. Does it make any difference to the homing which extruder is active?

this comment has always been in my start Gcode. Never felt a reason to remove and have never crashed or had an issues, so never removed. I think i found this on the internet chat rooms and has worked out fine. I did not get this from PcS.
G29
Unsupported on Smoothie. But I'll cope.

The RepRap documentation doesn't really give much detail about the "G28" command. I guess it's up to the firmware to figure out how to properly get the hardware to point (0, 0, 0). I see from the "move off platform" command that the X position off the right edge of the bed is at X=250, which means that the origin hasn't been moved to the center, which answers one question.
I always forget to change the S3D setting for the build volume bed, x at 175, y at 250 and z 200.

Ronnien55
Posts: 60
Joined: Mon Dec 08, 2014 2:50 am
Location: Holly Springs NC

Re: Adding auto leveling or tramming gcode to dual extruder

Post by Ronnien55 » Sun Aug 16, 2015 3:31 pm

T1 ; Switch to right extruder offsets for homing

Wait, what? I don't get why you (or PcS, rather) do this. Does it make any difference to the homing which extruder is active?
this comment has always been in my start Gcode. Never felt a reason to remove and have never crashed or had an issues, so never removed. I think i found this on the internet chat rooms and has worked out fine. I did not get this from PcS.

User avatar
Tim
Posts: 1205
Joined: Thu Apr 10, 2014 2:19 pm
Location: Poolesville, Maryland
Contact:

Re: Adding auto leveling or tramming gcode to dual extruder

Post by Tim » Mon Sep 21, 2015 2:59 am

Okay, I've been delving into the mysteries of the grid-based tramming in Smoothieware today, and made much progress.

As mentioned some posts ago on this thread, I just did my best to fill in the relevant values in the configuration file for the Smoothie, and then ran the z-grid tramming ("G32" command), and ended up with an immediate head crash. I then went on vacation, followed by moving to a new house, and so it has taken me some time to get back to looking into it in more detail.

Today I stared at the source code to figure out what it was doing for the z-grid, and found a few hidden features plus a few errors. I have submitted an error report for the errors I found to Arthur Wolf, and hopefully my fixes will get merged into the Smoothieware code base on github soon.

The root of the problem turned out to be that normally, the Z-grid calibration wants to start at position (0, 0) and mark off the board in a grid, to the limits. It will do this by putting the sensor at each of those grid points. But the sensor is offset from the extruder head, so depending on where the sensor is located, the value (0, 0) may not be possible to reach. With the sensor to the right of the nozzle, it's to the left of where the X endstop stops the extruder assembly (in fact, I didn't suffer a head crash after all; it was just the X motor trying to ram the extruder assembly into the left side of the frame. A little hard to tell what was going on with all the noise and shaking, and the immediate reaction to go for the kill switch).

Even if you could get the sensor to position (0, 0), you wouldn't want it there, because it's an inductive sensor and needs enough metal underneath to induce a loop current. Being at the very corner of the metal plate isn't going to do it. So the Z grid to calibrate to is going to have to be smaller than the heated bed plate.

The "hidden features" was the configuration options "cal_offset_x" and "cal_offset_y":

Code: Select all

leveling-strategy.ZGrid-leveling.cal_offset_x      26
leveling-strategy.ZGrid-leveling.cal_offset_y      20
These happen to be undocumented anywhere that I could find, but they do exactly what I was looking for: They make the grid calibration start at a point other than (0, 0). There is also "bed_x" and "bed_y":

Code: Select all

leveling-strategy.ZGrid-leveling.bed_x      169
leveling-strategy.ZGrid-leveling.bed_y      196
These are "lightly documented" and don't actually tell you that they do not represent the length and width of the bed, but rather the length and width of the calibration area. So the values shown above allow me to reduce the calibration area so that the entire area can be reached with the probe, and without the probe running off the plate or crashing into my binder clips.

My entire Smoothieware configuration section for the Z-grid calibration looks like this:

Code: Select all

leveling-strategy.ZGrid-leveling.enable         true       #
leveling-strategy.ZGrid-leveling.bed_x          169  # Reduced by 2x probe head width
                                                     # plus X offset
leveling-strategy.ZGrid-leveling.bed_y          196  # Reduced by Y offset and
                                                     # Addition for clips
leveling-strategy.ZGrid-leveling.bed_z          180  # Unused, manual probe only
leveling-strategy.ZGrid-leveling.cal_offset_x   26   # Add offset + probe head width
leveling-strategy.ZGrid-leveling.cal_offset_y   20   # To clear clips
leveling-strategy.ZGrid-leveling.rows           7          # X divisions (Default 5)
leveling-strategy.ZGrid-leveling.cols           9          # Y divisions (Default 5)
leveling-strategy.ZGrid-leveling.probe_offsets  15.55,-19.0,0.0 # Offset from nozzle
leveling-strategy.ZGrid-leveling.slow_feedrate  100        #
leveling-strategy.ZGrid-leveling.wait_for_probe false      #
leveling-strategy.ZGrid-leveling.home_before_probe homexyz # home-Z uses Z-min stop
The probe offsets measure the distance between the probe and the left nozzle. The probe is to the right of the nozzle and slightly forward (thus the negative Y value). The last line shows that I have kept the Z-min stop switch. I think this is pretty critical. Since at Y=0, the Z probe is hanging off the front edge of the heated bed plate, you can't do a normal "Home all" using the proximity sensor. I decided it works much better to use the Z-min switch for "Home all". Keeping the Z-min switch allows the "Home all" to keep the same meaning/function as before, and prevents crashing the extruder nozzle into the heated bed plate. It no longer has to be precisely aligned, though. The Z-grid calibration takes care of that. To get both functions at the same time, I left the Z-min switch connected to the Z-min socket on the controller board, then connected the probe to the Z-max socket. In the configuration file, I set up the two pins as:

Code: Select all

gamma_min_endstop                            1.28^!           #
gamma_max_endstop                            nc               #
zprobe.probe_pin                             1.29!^          # pin probe is attached to
This setup is in contradiction to the instructions on the Smoothieware web site and the source code, which suggest that you cannot use the Z-min endstop and the Z-probe at the same time. Not true.

With this hardware setup and configuration, it is possible to do the Z-grid calibration correctly, and finish with real results (which can be reported back with command "G31"). It's quite fast, although it remains to be seen how accurate it is at the speed I'm running it. Now I mentioned up at the top of this post that I found some errors. Neither error causes obvious problems. One of them is an unnecessary travel during calibration so that for every calibration point, first the nozzle moves to the position, then it corrects itself and moves the probe to the position, then makes the probe measurement. It's awkward and it wastes time, but it's harmless. The other error is that the correction routine returns a zero correction value for any point outside the calibration grid. That will tend to mess up any print that extends outside the boundary defined by the grid, especially if the bed is fairly out of level. I have a code fix for both problems.

Since I spent all evening submitting bug reports and doing this writeup, print tests will have to wait until tomorrow. Stay tuned.

User avatar
PcS
Posts: 667
Joined: Mon Mar 09, 2015 12:19 pm
Location: Michigan

Re: Adding auto leveling or tramming gcode to dual extruder

Post by PcS » Mon Sep 21, 2015 5:28 pm

I cannot comment on smoothie firmware . But G28 homes x and y then moves to the center of bed to probe z height. The grid size is set by the user and calculated from the center of the grid. So center of build plate is best. I actually never liked z height measured at zero. Most people do smaller prints usually close to center so if the bed is unlevel. And it usually always is. At least a little. It amplifies the issue. Measured in the center even for manually adjusted beds seems more logical to me. Then G29 runs the probing grid which is also user adjustable. Marlin has a very nice firmware at this time for auto tramming , and in general.

User avatar
Tim
Posts: 1205
Joined: Thu Apr 10, 2014 2:19 pm
Location: Poolesville, Maryland
Contact:

Re: Adding auto leveling or tramming gcode to dual extruder

Post by Tim » Tue Sep 22, 2015 2:31 pm

PcS wrote:I cannot comment on smoothie firmware . But G28 homes x and y then moves to the center of bed to probe z height. The grid size is set by the user and calculated from the center of the grid. So center of build plate is best. I actually never liked z height measured at zero. Most people do smaller prints usually close to center so if the bed is unlevel. And it usually always is. At least a little. It amplifies the issue. Measured in the center even for manually adjusted beds seems more logical to me. Then G29 runs the probing grid which is also user adjustable. Marlin has a very nice firmware at this time for auto tramming , and in general.
The thing is that "G28" is supposed to home the axes---it seems like it is no longer working according to spec if you move to the center. Although it would make some sense if the bed was defined such that (X = 0, Y = 0) is in the center, "homing the axes" means go to home position, not necessarily (0, 0). I've always thought "home position" always meant "against the endstops". Is there any official specification that says what the G28 command is supposed to do, or is it machine- and firmware-dependent?

Anyway, I actually have my dual extruder + Smoothieware running, correctly, with the Z-grid calibration method. It works really well, although I had to make several critical changes to the Smoothieware source code. I don't think the code was written with the idea of having both the Z-min endstop and Z-probe active at the same time. But that setup works best for the M2 using the inductive proximity sensor, because it prevents things from going bad when the sensor is not sitting over the bed plate and the "home Z" command is sent. Maybe I could write something into the code in which the Z-probe is used to home the Z-axis, but the Z-min stop can be used as an additional input to prevent head crashes and as a trigger to force a sequence of "move to center, home Z, move back to current X, Y position". On the whole, I think it makes more sense if the Z-probe is used as the endstop, other than the (severe) problem of what happens when it isn't sitting over the plate, but using the original Z-min switch as the endstop works, too. It's just a point of reference for starting the Z-probe calibration, so as long as it's consistent, things will work correctly. I'm just not sure how consistent that switch is. Inconsistency in the Z-min switch appears to be the reason that I have to keep adjusting the Z height up and down slightly every now and then even when the bed remains level.

Post Reply