Something seems strange: Coding Problem
-
This macro is being called from daemon.g, about every half second or so. It reads information from the object model, and it has an echo near the end for troubleshooting.
What seems very strange is that with the same values, it's producing different results from the calculation of RowsReachedCount. And this is during mesh compensation probing, in the middle of a row, so the Y coordinate isn't even changing around that time. Same inputs to the calculation; different result. I really don't even know how to troubleshoot this. It's unique in my experience.
Maybe I'm missing something obvious, but to me, this looks like it should be impossible for it to come up as 5 just one time (~4th line), and 6 all the others. This isn't the only place I've seen this when this macro gets run; it's infrequent, but happens several times each time a G29 gets run. I wonder if someone else will see something I missed.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; UpdateGridProbing ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Get current carriage position var X = move.axes[0].machinePosition var Y = move.axes[1].machinePosition set var.X = var.X + sensors.probes[0].offsets[0] set var.Y = var.Y + sensors.probes[0].offsets[1] ; Get front left probe point var XMin = move.compensation.probeGrid.mins[0] var YMin = move.compensation.probeGrid.mins[1] ; Get rightmost probe point X value var XMax = move.compensation.probeGrid.maxs[0] ; Get probe point spacing distances var XSpacing = move.compensation.probeGrid.spacings[0] var YSpacing = move.compensation.probeGrid.spacings[1] ; Calculate current probe point ordinal var NodesPerRow = (var.XMax - var.XMin) / var.XSpacing + 1 var RowsReachedCount = floor((var.Y - var.YMin) / var.YSpacing) + 1 var NodesDoneCount = var.RowsReachedCount * var.NodesPerRow if mod (var.Y - var.YMin, var.YSpacing) < 0.001 ; Y coord is not between rows var NodeCountAdj = 0 if mod(var.X - var.XMin, var.XSpacing) >= 0.001 ; X coord is between columns set var.NodeCountAdj = 1.0 else set var.NodeCountAdj = 0.5 var NodesLeftCountThisRow = 0 if mod(var.RowsReachedCount, 2) == 1 ; On a +x row var NodesDoneCountThisRow = floor((var.X - var.XMin) / var.XSpacing) + var.NodeCountAdj set var.NodesLeftCountThisRow = var.NodesPerRow - var.NodesDoneCountThisRow else ; on a -x row set var.NodesLeftCountThisRow = floor((var.X - var.XMin) / var.XSpacing) + var.NodeCountAdj set var.NodesDoneCount = var.NodesDoneCount - var.NodesLeftCountThisRow ; Calculate proportion of points done var Factor = var.NodesDoneCount / global.ProgressEndVal[0] echo "Factor(",var.Factor,")=NodesDoneCount(",var.NodesDoneCount,")/EndVal(",global.ProgressEndVal[0],") Point:(",var.X,",",var.Y,") RowsReachedCount=",var.RowsReachedCount," YMin=",var.YMin," YSpacing=",var.YSpacing ; Update NeoPixels G4 P200 M98 P"/macros/Lights/NeoPixel/Progress/UpdateProgress" F{var.Factor}
daemon.g
while global.IsLEDProgressEnabled if global.JobStatus == "ProbingGrid" M98 P"/macros/Lights/NeoPixel/Progress/UpdateGridProbing" G4 P500
-
@DonStauffer While I was falling asleep an idea occurred to me, so when I woke up in the middle of the night I tried something.
Operating on the bizarre assumption that the Y coordinate representation was slightly different when the location was between probe points (even when the Y coordinate didn't change, in reality and in appearance), I added 0.0001 to the values inside the floor function and the first argument to the mod function when dealing with float values. That seems to have fixed the problem, or maybe masked it (I'm not sure).
I'm aware of problems with programming using floating point, but it hadn't previously occurred to me that the representation of a particular value could be different at different times.