# Motorized Bed Level Correction with 4 Independent Z Screws?

2»

• Ya those variables are the xmax/ymax and xmin/ymin. Trying to get as close to the screws as possible. I'll let you know how it works.
• edited October 2020
So using that exact code I posted yielded unexpected results. The carriage crashed into the back wall because it moves the wrong direction for the last measurement point and I have no idea why. First it measures the front left corner, then moves to the back left, then to the back right. However, instead of moving to the front right next it tries to move backwards. zProbeY1 = 0 and it goes to it properly when I use that variable on the first point but not on the fourth point. This doesn't make sense to me.
• Is this already in your measurement or do you have grid measurement activated and what you see is the bed measurement you afterwards ignore where plane gets calculated?

For grid measurement you can not define the left fron and back right point directly. You define the left front point as P0, the front right as P1 and left back as P2 and the opposite edge is the P0 + (P1-P0) + (P2-P0)

• edited October 2020
I'm not quite understanding what you're trying to say. I think maybe I didn't explain what's going on very well. I've drawn this diagram to help visualize the problem. The green arrows are the printer moving how I expect it to. It measures p0, p1, and p2 properly but moves the wrong direction when moving to p3. I'm not sure what you're referring to by asking if I have grid measurement activated. I changed the firmware to the code I posted above and then send a G32 command and get this behavior. As far as I know I'm calling the right function to move the carriage and telling it to move to (zProbe X2, zProbeY1), but it's just moving the wrong direction and I have no idea why.
I also just noticed on another test that when it does the move backwards from p2 it moves extremely slowly too. Much slower than the other moves.
• WHat I said is you are forgetting the bed measurement happening before yours take into place. That is the one failing due to having wrong position for zProbe 1-3 points. You must have
P1: 0 , 0
P2: 280, 0
P3: 0, 280

and adjust your code to use these. Then first measurement for the unused plane equation will work and then it moves further to your points.
• edited October 2020
I commented out this line "Printer::buildTransformationMatrix(plane);" and it started working better but it's still behaving odd. On repetitions every other time it goes to Y=304.8 rather than Y=0. Here's the log from what I just ran.
```12:33:46.274: Z-probe:11.663 X:-0.00 Y:0.00
12:34:31.532: Z-probe:11.548 X:-0.00 Y:279.99
12:35:16.821: Z-probe:11.576 X:280.00 Y:279.99
12:36:02.190: Z-probe:11.737 X:280.00 Y:304.80
12:36:02.190: plane: a = 0.0001 b = 0.0001 c = 11.5940
12:36:48.862: Z-probe:11.647 X:-0.00 Y:0.00
12:37:34.116: Z-probe:11.550 X:-0.00 Y:279.99
12:38:19.405: Z-probe:11.578 X:280.00 Y:279.99
12:39:04.768: Z-probe:11.648 X:280.00 Y:0.00
12:39:04.768: h1 = 11.6471 h2 = -0.0973 h3 = -0.0695 h4 = 0.0006
12:39:04.864: Printer height:312.40
12:39:04.864: CurrentZ:11.59 atZ:11.34
12:39:50.813: Z-probe:11.875 X:0.00 Y:0.00
12:40:36.245: Z-probe:11.723 X:0.00 Y:279.99
12:41:21.583: Z-probe:11.629 X:279.99 Y:279.99
12:42:07.048: Z-probe:11.821 X:279.99 Y:304.80
12:42:07.048: plane: a = -0.0003 b = 0.0001 c = 11.7893
12:42:54.022: Z-probe:11.399 X:-0.00 Y:0.00
12:43:39.086: Z-probe:11.343 X:-0.00 Y:279.99
12:44:24.151: Z-probe:11.361 X:280.00 Y:279.99
12:45:09.247: Z-probe:11.376 X:280.00 Y:0.00
12:45:09.248: h1 = 11.3995 h2 = -0.0568 h3 = -0.0388 h4 = -0.0239
12:45:09.295: Printer height:312.85
12:45:09.311: CurrentZ:11.79 atZ:11.34
```
Also you said it's still doing the old measuring and plane calculating system. What do I need to change in the code to stop that?
• I managed to stop it from doing the weird measurements every other time. I ended up commenting this if statement out of the runBedLeveling() function
```//        if (!measureAutolevelPlane(plane)) {
//            Com::printErrorFLN(
//                PSTR("Probing had returned errors - autoleveling canceled."));
//            UI_MESSAGE(1);
//            return false;
//        }```
The call to measureAutoLevelPlane(plane) was what was causing the erroneous movements. I added a new section to check the precision since I'm not using the planebuilder anymore. It seems to be working now. Here's my full BedLeveling.cpp if you're interested in seeing what all I've changed. https://pastebin.com/efXdirGF
• Yes that was the part I meant interpreting the point not as you expected:-)
Great it now works.