Quote Originally Posted by Roxy View Post
I found a number of things that I think were a problem in your Marlin_Main.cpp. First, in the run_z_probe() function you were missing these lines:

// we have to let the planner know where we are right now as it is not where we said to go.
zPosition = st_get_position_mm(Z_AXIS);
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], zPosition, current_position[E_AXIS]);

// move up the retract distance
zPosition += home_retract_mm(Z_AXIS);
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], zPosition, current_position[E_AXIS], feedrate/60, active_extruder);
st_synchronize();

// move back down slowly to find bed
feedrate = homing_feedrate[Z_AXIS]/4;
zPosition -= home_retract_mm(Z_AXIS) * 2;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], zPosition, current_position[E_AXIS], feedrate/60, active_extruder);
st_synchronize();

I don't think you meant to delete them. But if you did, I put them back in the file so you are going to have to remove them again. These lines are important because when it is trying to touch the bed with the Z-Probe it goes at a higher speed at first, and then once it touches, it backs off and does it again at a slower (and more accurate) speed.

I actually compiled your modified Marlin_Main.cpp file that I'm sending back to you and loaded it into my printer.

When you do a G28, you are going to see the nozzle move up, and then move down and up 3 times. This is just to confirm the G28 code is going to raise the nozzle when it starts. After you see it do that... Go to line 1284 and delete the 6 lines of C code that do that. (and of course... Recompile and load it into your board)

For the G29 stuff... You need to go into your Configuration.h file and set:

#define AUTO_BED_LEVELING_GRID_POINTS 5

Is your origin in the front left of the bed? I assume that was where it was and set the G29 to use that as the origin. If this is not true, go to line 1511 of Marlin_Main.cpp and enable the #define for where your origin is. That will setup the Bed Level Topology map so you can see how high or low a given spot is on your bed. (Do a G29 n 4 T)

When you do the G29 Watch the Z-Probe. After it takes the measurement, it raises. And then it raises again. We might have over done it. And it is possible the problem we were fighting is related to that missing code in the run_z_probe() function. Let me know if you think it is raising twice on your machine. If so, we can pull out the extra lift.

At the end of the G29 I have it raise the nozzle (and then once again, I think we see the Z go up twice because the retract_z_probe() function is doing it too) and then move it to (x,y) = (100,100). I know you said (x,y) = (0,0) but isn't (100,100) more useful because that is in the center of the bed??? If you really want the nozzle to goto (x,y) = (0,0) you will see the line that makes that happen at line # 1790. However, even if you want it at (0,0) I would encourage you to make it (5,5) because at (0,0) you are going to trigger the X & Y end-stops.

Also, It was easier to put the M48 Z-Probe_Repeatability code into your Marlin_Main.cpp than to work around it when I was making sure your code compiled. So... If you want to see how accurate your Z-Probe is, just give it a command like: M48 x 100 y 100 n 10 v 4 Or... If you want to stress the X & Y axis while taking measurements give it a M48 x 100 y 100 n 10 v 4 L 6
Wow! Thanks for all of that, you have been busy. I will give it all a try this morning.
I have been busy too and have made a build page of one of these little machines that this code will be working on.
http://regpye.com.au/SmartRap%20builds.html