Closed thinkyhead closed 9 years ago
That code you pointed at is the 3 point bed leveling. Is that the only flavor that has a problem?
@Roxy-3DPrintBoard Both of the final set-leveling functions have the same closing code designed to get the "true position" based on the current position. The other one is here.
only probing half the bed
@Sniffle It shouldn't do that on a delta if 0,0 is in the middle. Seeing that on a cartesian?
@thinkyhead I covered everything in the next post i made with the video of the ABL routine, along with my Marlin_main.cpp
and Configuration.h
.
It is an i3 variant, with a RAMBo board :-) it was the main dev branch with the ABL modified to match your "debug_z" height adjustment change (thus the reason why i linked my Marlin_main.cpp
)… I'll test again next weekend. I have started a printing company, so I can't have the printer down during the week... but I will do test cases as best as I can over the weekend to get this resolved... the printer runs much better on the dev branch... but with ABL broken i can't use it…
I am with @Roxy-3DPrintBoard at this point ABL should be broken out into its own files, and broken down into less complex parts to help with maintaining it... a big part of the problem with the ABL code is trying to keep it all straight... being broken down will probably show bugs and logic errors more easily
I am with @Roxy-3DPrintBoard at this point abl should be broken out into its own files, and broken down into less complex parts to help with maintaining it... a big part of the problem with the ABL code is trying to keep it all straight... being broken down will probably show bugs and logic errors more easily
Plus... It will be clear who is having a problem. If only one particular configuration is having issues, it will be obvious where the bug is.
only probing half the bed
covered everything in the next post i made with the video of the abl routine
Ah, cool. I thought you meant you had seen that before, in-general. Looking closer at the configs now…
a big part of the problem with the ABL code is trying to keep it all straight... being broken down will probably show bugs and logic errors more easily
Breaking up Marlin_main.cpp
is a good idea, but there needs to be some fundamental work done on encapsulation first. Just the simple act of moving gcode_G29
into a separate file opens up a whole can of worms.
I completely understand that its just something that big expansive routines that get very complex between varying styles of printers really needs to have done...
For both maintaining and understanding where bugs are coming from... I know you know this... If i had the time and c++ knowledge i would help more than being a weekend tester On May 24, 2015 9:43 PM, "Scott Lahteine" notifications@github.com wrote:
a big part of the problem with the ABL code is trying to keep it all straight... being broken down will probably show bugs and logic errors more easily
Breaking up Marlin_main.cpp is a good idea, but there needs to be some fundamental work done on encapsulation first. Just the simple act of moving gcode_G29 into a separate file opens up a whole can of worms.
— Reply to this email directly or view it on GitHub https://github.com/MarlinFirmware/Marlin/issues/2040#issuecomment-105098922 .
Breaking up Marlin_main.cpp is a good idea, but there needs to be some fundamental work done on encapsulation first. Just the simple act of moving gcode_G29 into a separate file opens up a whole can of worms.
I disagree. What I'm envisioning is the current G29 mess being replaced with a few #ifdef's that pull in the code from the appropriate module (file). Right now, we have 4 different flavors. We have 3-Point, n x n grid, mesh and delta. It would be much cleaner to have each do their own thing and be defined in their own file. That all can be done with no C++ or encapsulation.
Just stepping back and looking at this from a higher level, it seems clear the G29 problem is only going to get worse. Its been 18 months since the first version showed up and now we have 4 distinctly different flavors and all for valid reasons. I bet over the next 12 months we get another 2 or 3 flavors.
Putting each flavor into its own file insulates the rest of the Marlin code from the chaos. And it drastically simplifies the maintenance of each of the independent versions. And remember... There is an iterative Least Squares Fit algorithm that can save 10+ Kb of code space when the time comes. Once again, the way to implement that is as its own file with a set of #ifdef's to control which code base gets pulled in. That is independent of which G29 flavor is being used (with the exception of 3-Point which doesn't need it.)
I agree with doing away with the current mix and separate coding per machine type/method in individual files. Makes debugging/maintaining much easier. On Mon, 25 May 2015 at 11:02 Roxy-3DPrintBoard notifications@github.com wrote:
Breaking up Marlin_main.cpp is a good idea, but there needs to be some fundamental work done on encapsulation first. Just the simple act of moving gcode_G29 into a separate file opens up a whole can of worms.
I disagree. What I'm envisioning is the current G29 mess being replaced with a few #ifdef's that pull in the code from the appropriate module (file). Right now, we have 4 different flavors. We have 3-Point, n x n grid, mesh and delta. It would be much cleaner to have each do their own thing and be defined in their own file. That all can be done with no C++ or encapsulation.
Just stepping back and looking at this from a higher level, it seems clear the G29 problem is only going to get worse. Its been 18 months since the first version showed up and now we have 4 distinctly different flavors and all for valid reasons. I bet over the next 12 months we get another 2 or 3 flavors.
— Reply to this email directly or view it on GitHub https://github.com/MarlinFirmware/Marlin/issues/2040#issuecomment-105106380 .
the current G29 mess being replaced with a few #ifdef's that pull in the code from the appropriate module.
Please post a demo PR, or make a branch that accomplishes this. If it can be done in some more encapsulated way, that would be great. I found it to be a lot more work than initially expected and gave up.
Hello, I've been messing with this all weekend and this is my first try with Marlin because I wanted to use the auto bed leveling feature. I'm running a modified Da Vinci Printer 1.0 with a RAMBO 1.2d motherboard. Server and z-probe endstop are working ok but the bed leveling and homing are all messed up. I'm not sure if it is the way I configured it or if it's the software after reading these issue comments. Sooo.. Here's what's happening. With the Da Vinci the X and Y homing endstops are off the left of the bed when standing behind the printer. So any time I try to home it goes back there and drops the probe, which will miss the bed and cause a disaster if I'm not keeping finger on power switch. I have my x and y manual home endstop settings correct I think because if I home x and y and then tell it to go to x0 y0 then it will go to the edge of the bed, but it always screws up on the homing.. If I manually run x and y to the center of the bed it will home z. But then if I run the auto bed level it will drop the probe and run across the bed with the probe down (in the x direction) one trip and that's it. Never lifts the probe or does anything else.
I'll try and post supporting documentation in a few minutes.
Any help would be appreciated!
Here is my Configuration H settings:
@jsnbrgg if you want auto leveling on marlin right now you should download the 1.0.2 tag... it doesn't have as many bug fixes but a lot of the problems that have crept into auto leveling aren't there as well... marlin and auto leveling work on 1.0.2 with a rambo board... I know it's my standard flash when i'm printing during the week.
The current development branch of marlin's bed leveling is generally not working... it is being worked on heavily, but not there yet...
On Mon, May 25, 2015 at 9:34 AM, jsnbrgg notifications@github.com wrote:
Here is my Configuration H settings:
— Reply to this email directly or view it on GitHub https://github.com/MarlinFirmware/Marlin/issues/2040#issuecomment-105244550
Cool! Thanks Sniffle! I'm downloading it now..
I would still like to help with the development as maybe a beta tester?
Here's a video of what the Dev Version was doing:
Hi everyone, I'm using auto leveling bed with 1.0.2 for a while now (works great). If you need someone more to make tests with 1.0.3 please I have time to contribute. Thanks for your job!
@thinkyhead @jsnbrgg I experiment a similar problem with the current dev 1.0.3, with the features: auto leveling bed and also the z safe homing that aren´t working. After trying to make it work i found that if you disable the max endstop by changing // #define DISABLE_MAX_ENDSTOPS
to #define DISABLE_MAX_ENDSTOPS
the auto bed leveling and the z safe homing works.
Hope this help to solve the problem
Thanks @RicardoGA ! That's definitely one of the things we're telling people right away if their axes don't move in one direction. The more insidious problem right now is that the Z position ends up being off for some setups, and it's been a bugger to track it down.
@thinkyhead @Roxy-3DPrintBoard
I have been very interrested by the behavior reported in #2240... Clearly, using G28 Z
over 2 different XY coordinates produces a different offset at the end of G29
…
This gave me an idea to test… I used the Development published 2-jun, Version 1.1.0... The G29
in that version is NOT using my proposed solution…
I pushed a pencil under the borosilicate glass, parallel to the X axis, at about 200 mm from the origin. So, the Z value increases when the Y value increases, no matter what X is…
I home X and Y, move the X to mid bed … I position Y then issue G28 Z
followed by G29
… I get an offset.
For Y=10 the offset is 0.81 mm
For Y=90 the offset is 3.46 mm
For Y=170 the offset is 5.98 mm
I conclude that G29
does NOT produce a correct Z offset, and that this offset is HIGHLY dependent on the Z height a the beginning of G29
.... Logically, I conclude that the distance to the bed MUST BE MEASURED in G29
instead of being calculated (There are too many resets of the ZERO on the Z axis during G29
)...
Please find here the evidence…
G29 Auto Bed Leveling
Bed X: 15.000 Y: 20.000 Z: 2.772
Bed X: 170.000 Y: 20.000 Z: 2.923
Bed X: 15.000 Y: 170.000 Z: 7.767
Bed X: 170.000 Y: 170.000 Z: 7.976
Eqn coefficients: a: 0.00116129 b: 0.03349500 d: 2.07005572
Mean of sampled points: 5.35949993
Bed Height Topography:
+-----------+
|...Back....|
|Left..Right|
|...Front...|
+-----------+
+2.40750 +2.61675
-2.58750 -2.43675
planeNormal x: -0.001161 y: -0.033495 z: 1.000000
Bed Level Correction Matrix:
+0.999999 +0.000000 +0.001161
-0.000039 +0.999440 +0.033476
-0.001161 -0.033476 +0.999439
N20 G1 Z0 *112
N21 M0 *48
For Y=10 the offset is 0.81 mm
N22 G1 Z8 *122
N23 G28 X0 Y0 *3
N24 G1 X90 Y90 F1500 *93
N25 G28 Z0 *78
N26 G29 V4 T P2 *114
G29 Auto Bed Leveling
Bed X: 15.000 Y: 20.000 Z: 0.169
Bed X: 170.000 Y: 20.000 Z: 0.310
Bed X: 15.000 Y: 170.000 Z: 5.103
Bed X: 170.000 Y: 170.000 Z: 5.322
Eqn coefficients: a: 0.00116290 b: 0.03315166 d: -0.53072662
Mean of sampled points: 2.72625017
Bed Height Topography:
+-----------+
|...Back....|
|Left..Right|
|...Front...|
+-----------+
+2.37675 +2.59600
-2.55700 -2.41575
planeNormal x: -0.001163 y: -0.033152 z: 1.000000
Bed Level Correction Matrix:
+0.999999 +0.000000 +0.001163
-0.000039 +0.999451 +0.033133
-0.001162 -0.033133 +0.999450
N27 G1 Z0 *119
N28 M0 *57
For Y=90 the offset is 3.46 mm
N29 G1 Z8 *113
N30 G28 X0 Y0 *1
N31 G1 X90 Y170 F1500 *102
N32 G28 Z0 *72
N33 G29 V4 T P2 *118
G29 Auto Bed Leveling
Bed X: 15.000 Y: 20.000 Z: -2.611
Bed X: 170.000 Y: 20.000 Z: -2.463
Bed X: 15.000 Y: 170.000 Z: 2.395
Bed X: 170.000 Y: 170.000 Z: 2.600
Eqn coefficients: a: 0.00113951 b: 0.03356250 d: -3.31352949
Mean of sampled points: -0.01968747
Bed Height Topography:
+-----------+
|...Back....|
|Left..Right|
|...Front...|
+-----------+
+2.41494 +2.61944
-2.59156 -2.44281
planeNormal x: -0.001140 y: -0.033562 z: 1.000000
Bed Level Correction Matrix:
+0.999999 +0.000000 +0.001140
-0.000038 +0.999437 +0.033544
-0.001139 -0.033544 +0.999437
N34 G1 Z0 *117
N35 M0 *53
For Y=170 the offset is 5.98 mm
@lrpirlet I'm just getting back to Marlin after a couple weeks of being very busy with moving to a new city. I will read through your notes and see where it points. I also went back to older code to see if I could update it with all the latest changes but leave leveling mostly alone, and then see what changes were left over. Then I figured, one of the leftover changes must be responsible. I've narrowed the issue down to a handful of changes, so hopefully your notes will help point to which of them is the most likely culprit.
@thinkyhead @Roxy-3DPrintBoard I have been trying to understand the code, but could not (sorry, I do not know C++). So, I could not find what I was looking for... I then decided not the examine the code anymore and try to understand the math behind... Sorry if some looks basic, but I have not the tools to write correctly using mathematical notation... so I define what I mean along the way.
In a 3 dimensions space, a point may be represented by A(Ax, Ay, Az) with each of the coordinate (Ax, Ay, Az) being a distance from a well-known point, invariable, stable…
We can discover on the bed 3 points A, B and C… A segment of line on the bed may be represented as a vector AB = (Bx-Ax, By-Ay,Bz-Az) We can form 2 lines AB and AC
A perpendicular line traversing the bed in Point A can be determined by multiplying the vector AB by AC, giving a vector (a, b, c)
AB*AC = (a,b,c) and the values of a, b and c are
a=(By-Ay)(Cz-Az)-(Cy-Ay)(Bz-Az) b=(Bz-Az)(Cx-Ax)-(Cz-Az)(Bx-Ax) c=(Bx-Ax)(Cy-Ay)-(Cx-Ax)(By-Ay) d=-(aAx+bAy+cAz)
Those form the values of the generic plane equation ax+by+cz+d=0
Then, in the 3d printer world, the origin is on the bed, at location x=0, Y=0, Z=0. The bed plane equation takes the form a’x + b’y + c’z = -d = 0
In G29, because I just cannot read the C++ code, I am absolutely NOT sure that we ever extract the a, b and c values… I have NOT been able to find the value d that depend from the point A common to the 2 segments in the plane… remember: d=-(aAx+bAy+cAz)
Worse, if we do NOT define the origin at the correct place (X=Y=Z=0) we end up computing a plane parallel to the bed, not the plan on the bed…
When I probe the bed using G28 at a random X and Y coordinate, I define a random Z origin, and I end up defining a plane parallel to the bed at a random distance from the bed…
When I probe the bed using G28 at the Z_SAFE_HOMING coordinate, I define a NON zero Z leading to a NON FIXED Z origin, and I end up defining a plane parallel to the bed at an unknown distance from the bed…
Now, the only solutions I see is
Now, if my theory is correct, it should explain the various reports around ABL. The above explains why it seems to work or nearly work (an offset is needed)… It does explain why I see different resulting distances when I enter the G29 after executing G28 Z at different X-Y coordinates.
It does not explain why some people report that it works for them… I could claim approximation… I think that it works because the math applied matches a “closed system”… for example, a well leveled bed going through the ABL will probably not be corrected or rather be corrected by a so small amount that it would not be measurable… another example is: if the sequence of gcodes prior G29 fills in the assumptions from the ABL code… Obviously in an open system where each and every printer and the associated Gcode prior to G29 may vary at random, we are bound to see different behavior…
In G29, because I just cannot read the C++ code, I am absolutely NOT sure that we ever extract the a, b and c values… I have NOT been able to find the value d that depend from the point A common to the 2 segments in the plane… remember: d=-(aAx+bAy+cAz)
It is more typical to say the equation for the plane is a_X + b_Y + cZ + d = 0 But, yes what you have is correct.
Worse, if we do NOT define the origin at the correct place (X=Y=Z=0) we end up computing a plane parallel to the bed, not the plane on the bed…
There is a matrix of 'd' values that get generated with all the probing. These points get stored in the eqnBVector[] array. These points are passed into qr_solve() along with the coordinates of the probed points in the eqnAMatrix[] matrix.
qr_solve() returns a least squares fit of the coefficients of this equation: a_X + b_Y + c*Z + d = 0
And if you take a look at the numbers being returned, they are pretty good! (I know! I spent some time writing an iterative version of qr_solve() and was comparing its results to the matrix solution of qr_solve() )
The biggest questions are things like "Do we need to compensate for the offset in 'd' because it is not plane normal when measured." I think the math is all good. The problem right now is there are bugs somewhere causing the Z_OFFSET to be wrong which causes air printing and such. And I think there is a similar question that relates to what you are saying: The coordinates of where you are setting the 'd' offset matter. If they are not at (0,0) the code needs to correct the Z value for where ever the nozzle is when 'd' gets set.
Update: In the older code base, this correction for not being at the origin happens. Here is the older code:
// The following code correct the Z height difference from z-probe position and hotend tip position.
// The Z height on homing is measured by Z-Probe, but the probe is quite far from the hotend.
// When the bed is uneven, this height must be corrected.
real_z = float(st_get_position(Z_AXIS))/axis_steps_per_unit[Z_AXIS]; //get the real Z (since the auto bed leveling is already correcting the plane)
x_tmp = current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER;
y_tmp = current_position[Y_AXIS] + Y_PROBE_OFFSET_FROM_EXTRUDER;
z_tmp = current_position[Z_AXIS];
apply_rotation_xyz(plan_bed_level_matrix, x_tmp, y_tmp, z_tmp); //Apply the correction sending the probe offset
current_position[Z_AXIS] = z_tmp - real_z + current_position[Z_AXIS]; //The difference is added to current position and sent to planner.
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS)
@Roxy-3DPrintBoard -- The biggest questions are things like "Do we need to compensate for the offset in 'd' because it is not plane normal when measured."
I think that is highly dependent on the nature of the bed positioning and the probe mechanism.
If we assume that the bed is "stable" (at a reproducible height and orientation) to the frame and that the probe is stable to the nozzle, then it is mostly a question of manufacturing/assembly tolerances.
If it is necessary to "calibrate" the relationship by a physical "testing" of the nozzle in close proximity to the bed (such a the "paper drag" feeler gauge approach or by measuring the actual thickness of a test layer, then there is no point in attempting to refine the calculation. Assuming that the bed is planar and at a constant orientation, and that the probe is repeatably located in relation to the nozzle, any error becomes a constant which gets incorporated into effective height of the probe.
OTOH, if the bed orientation varies significantly from print to print, compensation might improve the accuracy. However, if the printer cannot accurately reproduce the positioning, I would worry about its ability to maintain any particular pre-described position. Therefore, I question the value in attempting to compensate for the slope of the bed as it relates to the difference in the probed elevation and the "true" height of the nozzle.
Therefore, I question the value in attempting to compensate for the slope of the bed as it relates to the difference in the probed elevation and the "true" height of the nozzle.
Agreed. The reason this is true is because the bed is very close to level and the limit of sin(theta) approaches 0 as theta approaches 0. With the bed very close to level, the error from the non-normal measurements approaches 0. However... With that said, if you have a machine with large offsets from the probe to the nozzle, you are going to see error creep in when you try to set the height of the nozzle. It will change more if the distance to the probe is more.
I don't think there is any error at all because the probe is parallel to the Z axis and is placed where the nozzle would be, so it measures the height of the bed in the Z axis, which is correct. It shouldn't be a measurement normal to the plane of the bed. It is taking Z measurements of the bed at different XYs in order to work out the plane normal.
Mathematically it is wrong because it ignores the c and d values of the plane equation and takes Z from the last point probed, but I don't think that is the cause of the gross errors people report.
Mathematically it is wrong because it ignores the c and d values of the plane equation and takes Z from the last point probed, but I don't think that is the cause of the gross errors people report.
I agree with this also.
Correct, but that wasn't my point. There are two issues: (1) Is the bed nearly level? As you point out, the lateral displacement of the probe is not important as the bed approaches truly level. In any case, for a planar bed and a fixed displacement, the error is constant.
(2) Do we REALLY know the difference in the height of the nozzle and the height of the probe (when measured in a truly level space)?
If, as I typically observe, there are variations, printer to printer, in the assembly of the probe, then any small constant error in (1) may be added to the assembly error in (2) to produce a constant difference between the nozzle height and the probe contact point.
@nophead -- Chris, You are making assumptions about the probes. There are a number of probe designs. I'm not aware of any which have the probe in the true location of the nozzle. To avoid contact with the nozzle, the probe is somewhat lower than the nozzle. But in some designs, the position is also offset from the axis of the nozzle. In particular, the typical design for a delta printer has the probe permanently mounted to the carrier that positions the nozzle. When it is deployed, the probe is lowered, but there is no attempt to align it with the axis of the nozzle.
I have to say the way I implemented it in my own host software was a lot simpler. The probe operation doesn't alter the Z home point at all, so the machine simply moves around probing and never loses track of where it is and always works in machine coordinates. The values returned from my probe routine take the probe offset into account by moving to the target XY adjusted by the probe XY offset and returning the Z value adjusted by the Z offset. So again in machine coordinates.
Then when it is building the model, the model coordinates are mapped to machine coordinates by doing both a rotation and a translation.
It doesn't matter if the bed has a gross slope, my method still works because it places the probe where the nozzle would be.
I get the probe XY offset from my openscad model and a rough Z offset. I tweak it to be the exact Z offset by measuring the resultant skirt thickness.
Also I think Marlin correctly moves the probe to the XY position of the nozzle. That is what confuses people who don't understand it can't probe the whole of the bed if it has a large XY offset.
When things are planar, in determining the relative slopes between the planes, it doesn’t matter where you probe. The difference in the measured heights between two points depends only on the horizontal vector between them and the slope that you are attempting to determine. The absolute height depends on the origin, but relative heights are only the product of the normal to the plane and the relative distance vector joining the points. Yes, I realize that you ATTEMPT to move the probe to the position of the nozzle.
However, there is some error in that. In particular, for a delta printer, if we have some error in the mechanical dimensions, you will observe a “dishing” effect in what should otherwise be a planar surface. Similarly, if the axes are not truly perpendicular, you will not be placing the probe where you think that you are placing it.
Actually, I’ve wanted to try to do the probing for the calibration of my delta printer based on probing with the nozzle (not the probe itself) directly in the desired location.
Without knowing the lengths of the arms or the radius of the tower locations, assuming that the towers are parallel and that the bed is a plane, the one thing that I do know is that the difference in the height measured from the height of probe contact to the point of nozzle impact is a constant all over the bed.
On Jun 12, 2015, at 11:29 AM, Chris notifications@github.com wrote: Also I think Marlin correctly moves the probe to the XY position of the nozzle. That is what confuses people who don't understand it can't probe the whole of the bed if it has a large XY offset
A small X Y error is of no consequence when the bed is almost level. It would only make a minute ("my newt") difference in the Z reading.
The auto bed levelling is only to compensate for a sloping bed. Of course all bets are off if your machine does not move accurately in XYZ to start with.
On Jun 12, 2015, at 12:23 PM, Chris notifications@github.com wrote: A small X Y error is of no consequence when the bed is almost level. It would only make a minute difference in the Z reading.
Certainly.
The auto bed levelling is only to compensate for a sloping bed. Of course all bets are off if your machine does not move accurately in XYZ to start with.
No, it is not “accurate” movement that is required. What you need is a “repeatable” and “predictable” motion.
By probing, we can then, experimentally, fit values for the various parameters that are used to transform one coordinate system (The target object) into another (The actuator positions).
In general, the entire machine can be modeled in the form of a state vector and a transformation matrix.
By the physical geometry, we know, or presume, that many of the entries in the matrix are zero. If we can devise a set of probings that are sensitive to some particular entry, we can, experimentally, determine its value.
But the ABL software in Marlin that we are discussing is only for coping with a un-level bed assuming that the XYZ motion is accurate. You might want it to do more for a wonky delta machine, but that is a completely different piece of software.
Also a single transformation matrix is not sufficient to correct Cartesian motion errors in general, and certainly not non-linear kinematics. For example simply correcting for the Y bars not being parallel on an i3 requires a rotation about Y that varies with Y. You can't do that with a single matrix multiply.
Except for the fact that you imply that handling additional positional issues is "a completely different piece of software", I agree completely. I do observe that "different software" that is capable of handling such issues must also be capable of handling these issues as a part of a larger issue.
As for the "single matrix multiply", you are certainly correct in that a non-linear transformation cannot be done with one simple linear transformation. What can be done is to reduce the non-linear transformation to an approximation which is incrementally linear.
Even decades ago, we were implementing control systems that computed the correction vector by using the partial derivatives and computed errors to drive the system a small step in the correct direction. Then the derivatives would be re-evaluated and the next correction would be applied.
For linear systems, it isn't an issue. Once determined, the derivatives are constant.
But I will go back to my original assertion based on the assumptions being made (namely that the actuators accurately position the effector in machine coordinates, that the physical probe point is located (again in machine coordinates) at a fixed (3 dimensional) offset from the nozzle, and that the bed is stable and planar.
The only aspects that we are considering are the orientation and height of the bed with respect to the Z-axis of the machine. We assume that it is tilted and at an unknown elevation WRT the endstop/homing sensor.
I think that your approach is better.
I suspect that one of the difficulties in getting correct code is that various people are confusing coordinate systems.
On Jun 12, 2015, at 11:19 AM, Chris notifications@github.com wrote:
I have to say the way I implemented it in my own host software was a lot simpler. The probe operation doesn't alter the Z home point at all, so the machine simply moves around probing and never loses track of where it is and always works in machine coordinates. The values returned from my probe routine take the probe offset into account by moving to the target XY adjusted by the probe XY offset and returning the Z value adjusted by the Z offset. So again in machine coordinates.
Then when it is building the model, the model coordinates are mapped to machine coordinates by doing both a rotation and a translation.
One issue is here
float zPosition = -10;
This should be something like MAX_Z_HIGH?!?
That was a nice discussion that did NOT make me feel better in any way, because it went away from the point I am trying to make... Let me try to explain what I was looking for while trying to "decrypt the C++". The minimum number of probing is 3 provided that the origin is known...
I was looking for, but could not find, any clever way to see if the origin is known with X=Y=Z=0... So, G29 ABL, when using only 3 points probing, ASSUMES that the origin is known and equals to zero... I was looking for, but could not find if G29 ABL, when using more than 3 probe does reject the first probing... So, when I use G29 T V4 P2, the assumption is that all 4 probed values for Z are part of the same plan... Had I written it, I'd have written something to reject a first probe value obviously OFF the plane... But I could NOT find that...
Well, I have stopped using G29 ABL to use G29 Mesh. The later answer a lot better to the need I have with my Prusa i3 that does NOT keep a constant distance tip-bed.. The X axis is made of 2 smooth rods on top of each other, this architecture creates a torque that brings the tip about 0.15 mm (and more) closer to the bed in the middle of the X course... G29 V4 P5 T was very nice to outline this ... Note, I had either a leveled bed OR a probe in X=Y=0...
@Wackerbarth you might be interested in this: https://github.com/repetier/Repetier-Firmware/issues/367#issue-58547241
@nophead -- I'm definitely interested. It is just the sort of thing that I was planning to implement. (I hadn't figured out if I should do it in the printer, or off line.)
Basically, you can take a large array of readings (A, B, C) where the probe comes into contact with the bed. Then you can run those readings through an analyzer that spits out its best estimate of the variable elements.
The only thing that I would do differently is to ignore "tower rotation". I can do this because the locations of the towers can be expressed with only three degrees of freedom (OK, 5 if you insist in representing the true center of the physical bed -- unimportant when we don't care the true location of our target object.)
You can use either (R@0, R@A1, R@A2) or (R@0, R1@120, R2@240) to represent any three tower locations. In addition, my state vector would include the three arm lengths and the three tower registration (endstop) heights.
@thinkyhead @Roxy-3DPrintBoard and to any participant to this discussion
Ok , I was wrong again. I CAN find the a, b, c and d factors of the plane equation… But not where I expected to find it…
I do propose 2 solutions to solve this issue with G29 ending up "in the air". I wish I could code but I need to rely on people that know how to... I cannot. Please read to the bottom where I expose my solution along with some ideas to minimize the errors. It was said in the code comments that c=1. The value of a, b and d are available in the printout of the G29 V4 equation.
In fact, the problem of the offset to apply is a simple translation of the plane since both the tip of the Hot-end and the tip of the probe evolve in 2 parallel planes…
So, If we take a (coherent, more of that later) plane equation, at a particular point we can very easily determine the offset…
In the probe plane, at X=Y=0 we have Z+d=0. Since we know d, we know the correction due to the slope of this plane.
Before continuing, for the ease of the writing, I define
x’ = X_PROBE_OFFSET_FROM_EXTRUDER
y’ = Y_PROBE_OFFSET_FROM_EXTRUDER
z’ = Z_PROBE_OFFSET_FROM_EXTRUDER
In the hot-end plane at the same position as above, the plane equation becomes after translation
a(x+x’) + b(y+y’) + (z + z’) + d = 0 = ax’+by’+z+z’+d=0
We know everything in this equation except z (the needed offset) that can be computed using
-z=(d+z’+ax’+by’)
This was the formula I was looking for in the code, that would have computed the distance to compensate for the probe to the tip displacement.
Now, I also said that we need to have a “coherent” plane. I mean by that that each point in the plane is referring to a coherent origin. If we home z anywhere else than at x=y=o, then we need to apply some translation.
Please consider to the results of my experiences above posted 14 days ago. I placed the important result in this table (for Test 1, 2 and 3)
a 0.00116129 0.00116290 0.00113951
b 0.03349500 0.03315166 0.03356250
c 1 1 1
d 2.07005572 -0.53072662 -3.31352949
x 90 90 90
y 10 90 170
With a, b and d the value displayed in the G29 V4 T P4, and x,y the position to home Z ( where I invoked G28 Z)…
I am probing the same bed so the plane equation should be the same if the G28 x,y coordinates have NO incidence... We see that d is different, so I conclude that G28 x,y coordinates do have an incidence… I also see that a, b and d are about the same value, with some error due to the measure... (Note that the absolute value of ax becomes more significant as x increase, see my suggestion later)
Since I have measured the same plane, I should find a plane equation that resolve to the same value…
Using the plane formulated as -z=(ax + by + d)
, with x and y the values used to execute G28 Z, I will compare 3 “coherent” plane équations. This in fact is to translate the X and Y coordinate to the SAME place… One can read it as shifting the z home to the X=Y=0 position.
The results are for test 1, test 2 and test 3
-z = (ax + by + d) = 2.50952182 2.55758378 2.49465141
This, in my eyes is quite near enough to prove that the equations represent the same plan. The differences being due to the errors of measures.
Another thing to consider is WHERE the G28 X,Y coordinates should be determined to minimize the effects of the measure errors. In the plane equation, ax + by + z + d=0, we want to have the smallest x and y. At x=y=0 the only term affected by the errors is d, the absolute distance in error will be proportional to the value of x and y where we home Z, so we better keep the x,y coordinates (to home z) as small as possible.
Now, the quick and durty (but easy to implement) solution is to measure the distance.
The "elegant" solution is to change the code so that
• make sure to know WHERE (x,y) z is homed… Say the G29 code forces to use G28 Z at Safe_homing coordinates
• I would strongly advise to change the definition of Z_SAFE_HOMING_X_POINT and Z_SAFE_HOMING_Y_POINT to the smallest possible value… My printer would be happy with both set to 0 (zero)…
• Apply Both offset correction I described earlier, the first using -z=(d+z’+ax’+by’) for the bed slope and tips distance, followed by -z = (ax + by + d) for home coordinates coherence
I hope this helps getting a stable version 1.0.3 out of the door… Sorry, I would have coded if I could…
This is a seperate issue from what lrpirlet is bringing up in this last post. But I think it is an issue:
Please read to the bottom where I expose my solution along with some ideas to minimize the errors. It was said in the code comments that c=1. The value of a, b and d are available in the printout of the G29 V4 equation.
c=1 is being passed into the QR_Solve() function. Depending upon what value is passed in for this coefficient, you get different numbers out for the other coefficients. I think what it is doing is OK, but it can be improved. The problem is this: We are asking it to solve the ax + by + z + d=0 equation using 1 as the coefficient for the Z coordinate. That would be fine if a & b were 0 but they are not. As a result, our movements will not be unity.
I think we should do what we are doing and calculate a solution for the plane with c=1. But then we should normalize the (a,b,c) coefficients (which will make c slightly less than 1) and use those numbers instead.
Is there anything that I can do to help fix ABL? The issue which I raised a few weeks ago (#2240) was closed and this issue was referenced. I'm still unable to get a consistent first layer height even though the probed Z only has very slight variations, the first layer is either printed in the air or the hotend is crashed into the bed.
Adding support to a part only makes it worse. I've just stopped a print which has multiple parts some of which have supports. The first layer of parts without support is printed in the air and with support is dug into thd bed.
Is there anything that I can do to help fix ABL?
This may not help... But if you have your EEPROM enabled... try doing a M502 followed by a M500 and see if that more closely resembles what you have for a Z_PROBE_OFFSET_FROM_EXTRUDER in your Configuration.h file.
But if you have your EEPROM enabled...
Thanks for the suggestion but EEPROM was disabled some time ago to try to solve this problem
Btw I was adjusting my sensor and I noticed that when changing the Z Offset value using the LCD it is not immediately applied. I need to restart the printer for the new values to be picked up.
Shouldn't it be applied right away? Looking at the code it seems to update the zprobe_zoffset var but I guess it is not picked somehow.
Shouldn't it be applied right away? Looking at the code it seems to update the
zprobe_zoffset
var but I guess it is not picked somehow.
I would agree. But the problem is the zprobe_zoffset
variable is getting picked up from the EEPROM and then just gets referenced in the G29
. You can also set it for later use if you have the CUSTOM_M_CODE_SET_Z_PROBE_OFFSET
#define turned on in Configuration.h
. But until a G28
or G29
happens... It doesn't get used.
Well but the way I was testing was changing the value and storing the EEPROM and then sending a print job where I have the G28
& G29
.
@Roxy-3DPrintBoard
What you said 2 days ago just worries me...
I thought that the general plane equation of the form
a'x + b'y + c'z + d'=o
was expressed as
(a'/c')x + (b'/c')y + (c'/c')z + d'/c' = ax + by +1z +d =0
Provided that C is NOT zero, we express here the exact same plane equation (we can see it expressed in a different scale). To me this means that we do NOT need to normalize anything...
Should we expect that this fonction change the plane equation (3 dots in a plane and a perpendicular vector) to something else?
Again, I am not a programmer to fully translate into math expression, but I would be very suspicious to use a function that corrupt the plane equation.
What you said 2 days ago just worries me... I thought that the general plane equation of the form...
Well... I'm not an authority on this stuff... But... QR_Solve() takes a couple of matrix's and does a least squares solution based on the numbers you pass in. The call to QR_Solve() is instructing the algorithm to solve for a, b, and d assuming the value for c=1. In the general case this works because a & b are very close to 0. But the problem is this: The a,b & c coefficients are being used to generate the correction matrix and they are not being normalized prior to being used to build the matrix.
I think the plane equations are fine. The problem is I don't think you can generate a correction matrix from them without first normalizing the coefficients.
We've gotten rid of a lot of little bugs in homing and leveling lately, but the current Development code still has an obscure Z positioning problem with
G29
. So, I've narrowed down the current leveling issues to a small handful of recent changes, and rolled back the leveling code to around March 26 at the branch https://github.com/thinkyhead/Marlin/tree/before_delta_mergeThe differences between that code and the current leveling / homing code are embodied in commit https://github.com/thinkyhead/Marlin/commit/3f0a990360d04a45c11ba6ebdfeff2b16d26bf34 One of the changes in this commit is almost certainly responsible for the current weird behavior.
So, I suggest starting with before_delta_merge to see if it behaves properly. Then we can try to determine which of those recent changes is responsible for any remaining problems.
Once these leveling bugs are squashed, we can close all these issues:
1507 #1833 #1844 #1894 #1701 #1730 #1731 #1737