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)
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.
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.
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
Comments
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)
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.
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.
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?
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
Great it now works.