# M4: Calibration fail observations, large portrait vertical

**URL:** <https://forums.maslowcnc.com/t/m4-calibration-fail-observations-large-portrait-vertical/20473>\
**Category:** Troubleshooting\
**Created:** [April 2, 2024, 12:30am UTC](https://forums.maslowcnc.com/t/m4-calibration-fail-observations-large-portrait-vertical/20473 "2024-04-02T00:30:16Z")\
**Posts on this page:** 20\
**Page:** 7

<div class="post-metadata">

**Author:** ![dlang](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/dlang/32/859_2.png) [@dlang](https://forums.maslowcnc.com/u/dlang)\
**Post date:** [April 16, 2024, 1:14am UTC](https://forums.maslowcnc.com/t/m4-calibration-fail-observations-large-portrait-vertical/20473/121 "2024-04-16T01:14:50Z")

</div>

Brad wrote:

> So I want to make sure I am doing this right. Am I correct to say we  
> not longer update the Yaml file for the Frame size it’s in the Fluid Config  
> Items tab?

correct

> My Belts are fully retracted,

make sure the system knows they are fully retracted, after a power up, even if  
they are fully retracted, the system doesn’t know that (there are no limit  
switches to detect that the belt is retracted, it notices that the motor cannot  
make the belt move without hitting it’s current limit), so you still need to hit  
‘retract all’

> So I am going to have to extend all, and connect them to the 4 corners.

correct

> Once that is done, do I take Slack? Or just press the Calibration button, and  
> It will automatically take up Slack?

As I understand it, you need to hit ‘take slack’ and then calibration.

David Lang

---

<div class="post-metadata">

**Author:** ![ronlawrence3](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/ronlawrence3/32/7886_2.png) [@ronlawrence3](https://forums.maslowcnc.com/u/ronlawrence3)\
**Post date:** [April 16, 2024, 1:22am UTC](https://forums.maslowcnc.com/t/m4-calibration-fail-observations-large-portrait-vertical/20473/122 "2024-04-16T01:22:05Z")

</div>

It takes a measurement in the center, then travels to the bottom and takes a measurement, then does the grid

---

<div class="post-metadata">

**Author:** ![bar](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/bar/32/10_2.png) [@bar](https://forums.maslowcnc.com/u/bar)\
**Post date:** [April 16, 2024, 2:56am UTC](https://forums.maslowcnc.com/t/m4-calibration-fail-observations-large-portrait-vertical/20473/123 "2024-04-16T02:56:27Z")

</div>

> [@ronlawrence3](#):
>
> Please let me know if you want me to try anything else. I will see if I can spend more time staring at the algorithm some more and see if I see anything.

I’ve been digging into this today too and it seems like the initial conditions are super important. I can make it work or not work by changing the initial value of initial guess.

I’m playing around with randomizing it right now and it works sorta 30% of the time.

```auto
//Establish initial guesses for the corners
var initialGuess = {
  tl: { x: 0, y: initialHeight + Math.floor(Math.random() * 200) - 100 },
  tr: { x: initialWidth + Math.floor(Math.random() * 200) - 100, y: initialHeight + Math.floor(Math.random() * 200) - 100 },
  bl: { x: 0, y: 0 },
  br: { x: initialWidth + Math.floor(Math.random() * 200) - 100, y: 0 },
  fitness: 100000000,
}

```

---

<div class="post-metadata">

**Author:** ![bar](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/bar/32/10_2.png) [@bar](https://forums.maslowcnc.com/u/bar)\
**Post date:** [April 16, 2024, 3:00am UTC](https://forums.maslowcnc.com/t/m4-calibration-fail-observations-large-portrait-vertical/20473/124 "2024-04-16T03:00:11Z")

</div>

I haven’t found the pattern yet for when it converges and when it doesn’t

---

<div class="post-metadata">

**Author:** ![md8n](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/md8n/32/28197_2.png) [@md8n](https://forums.maslowcnc.com/u/md8n)\
**Post date:** [April 16, 2024, 3:51am UTC](https://forums.maslowcnc.com/t/m4-calibration-fail-observations-large-portrait-vertical/20473/125 "2024-04-16T03:51:54Z")

</div>

Once I get my machines out of customs I’ll have a go at the problem.

My gut instinct is that you’re missing an implied variable in the algortihm. For example, maybe there should be an initial ‘margin of error’ value, that decreases with each test. So if the early tests look correct, but are still less than the margin of error, further tests are required.

---

<div class="post-metadata">

**Author:** ![WFD](https://avatars.discourse-cdn.com/v4/letter/w/41988e/32.png) [@WFD](https://forums.maslowcnc.com/u/WFD)\
**Post date:** [April 17, 2024, 1:01am UTC](https://forums.maslowcnc.com/t/m4-calibration-fail-observations-large-portrait-vertical/20473/126 "2024-04-17T01:01:45Z")

</div>

I took these numbers and worked out a solution using Excel. Its not quite as good as the solution the Maslow arrived at, but it is very interesting. Before I communicate this, I would like to calculate the fitness of the numbers I arrived at using Excel.

Can someone communicate the formula for fitness? I searched the forum and couldn’t find it. My coding skills are almost 40 years old so it would take me forever to find it in the source code. Thanks.

---

<div class="post-metadata">

**Author:** ![bar](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/bar/32/10_2.png) [@bar](https://forums.maslowcnc.com/u/bar)\
**Post date:** [April 17, 2024, 1:11am UTC](https://forums.maslowcnc.com/t/m4-calibration-fail-observations-large-portrait-vertical/20473/127 "2024-04-17T01:11:46Z")

</div>

Each measurement is a set of four lines which should meet at a single point.

In practice if the calibration is not perfect they will not meet perfectly.

To compute the fitness we find the distance between the ends of each of the lines in a measurement and then take the average. That gives us the fitness of that set of measurements.

Then we do that for all of the sets measurements and average the results.

The resulting number gets smaller as the calibration improves so we do 1/it to get a number that gets bigger as it improves.

---

<div class="post-metadata">

**Author:** ![dlang](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/dlang/32/859_2.png) [@dlang](https://forums.maslowcnc.com/u/dlang)\
**Post date:** [April 17, 2024, 1:29am UTC](https://forums.maslowcnc.com/t/m4-calibration-fail-observations-large-portrait-vertical/20473/128 "2024-04-17T01:29:02Z")

</div>

Bar wrote:

> Each measurement is a set of four lines which should meet at a single point.
> 
> In practice if the calibration is not perfect they will not meet perfectly.
> 
> To compute the fitness we find the distance between the ends of each of the lines in a measurement and then take the average. That gives us the fitness of that set of measurements.

for you to measure the distance between the ends of the lines, you need to plot  
the lines at some angle. do you pick the angle based on where you think the sled  
is? do you try to make the ends of the lines get as close as possible?

and is this the raw length of the lines? or do you correct the length to account  
for slope resulting from the height of the anchor? (and if so, what do you  
figure as the height of each belt?

David Lang

---

<div class="post-metadata">

**Author:** ![ronlawrence3](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/ronlawrence3/32/7886_2.png) [@ronlawrence3](https://forums.maslowcnc.com/u/ronlawrence3)\
**Post date:** [April 17, 2024, 2:29am UTC](https://forums.maslowcnc.com/t/m4-calibration-fail-observations-large-portrait-vertical/20473/129 "2024-04-17T02:29:41Z")

</div>

Let me take a crack at describing it and Bar can correct me if I’ve read it wrong. It is not so much a formula as a set of iterative functions. Given the 4 line lengths and an initial “guess” as to the anchor points, a series of guesses are made at plus/minus angles to get the closest match to the endpoints, and this is iterated on over various precisions of “theta” the angles for the tr, tl, br, bl lines. at the end of each iteration, a fitness score is computed and if its greater than the previous best guess, that is stored off. many more iterations are done, and if no bigger fitness is found or the max number of iterations expires, then the answer is given. There is also a “projection” function to project the belt lengths down to the surface, but I’m not clear on when that’s used.

I’m sure I don’t have the whole thing in my head yet, and I’m still “iterating” on my understanding. Did I come close, Bar?

---

<div class="post-metadata">

**Author:** ![bar](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/bar/32/10_2.png) [@bar](https://forums.maslowcnc.com/u/bar)\
**Post date:** [April 17, 2024, 4:06am UTC](https://forums.maslowcnc.com/t/m4-calibration-fail-observations-large-portrait-vertical/20473/130 "2024-04-17T04:06:18Z")

</div>

I think that you described it perfectly.

It’s very hard to picture without drawing it

---

<div class="post-metadata">

**Author:** ![gazinux](https://avatars.discourse-cdn.com/v4/letter/g/dec6dc/32.png) [@gazinux](https://forums.maslowcnc.com/u/gazinux)\
**Post date:** [April 17, 2024, 5:49am UTC](https://forums.maslowcnc.com/t/m4-calibration-fail-observations-large-portrait-vertical/20473/131 "2024-04-17T05:49:52Z")

</div>

Is it possible that calibration challenges we are facing are due to measurment distortion in mechanical resistance backlash in the other three lines tugging back on the sled when a measurement is taken?

I am wondering because the shape some fitness curves, they inflect and start to decrease—is the algorith carrying forward a historical measurement and compounding it into future measurments?

The may be no backlash on the locked servos but  
still possible for backlash in slacked belts that are loosely roll up on the gear spindle might be getting ‘released’ when another line is tensioning during measurement, causing shift of sled and the that error is compounded over future samples.

---

<div class="post-metadata">

**Author:** ![WFD](https://avatars.discourse-cdn.com/v4/letter/w/41988e/32.png) [@WFD](https://forums.maslowcnc.com/u/WFD)\
**Post date:** [April 17, 2024, 2:53pm UTC](https://forums.maslowcnc.com/t/m4-calibration-fail-observations-large-portrait-vertical/20473/132 "2024-04-17T14:53:40Z")

</div>

So for each calibration point, I calculate the intersection of each of the four pairs of belt lengths and the distance from each of those points to the centroid of the set of four points at that calibration point. I then average all those error measurements across all the calibration points, and then take the reciprocal, and that is the ‘fitness’.

Is that correct?

---

<div class="post-metadata">

**Author:** ![bar](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/bar/32/10_2.png) [@bar](https://forums.maslowcnc.com/u/bar)\
**Post date:** [April 17, 2024, 3:12pm UTC](https://forums.maslowcnc.com/t/m4-calibration-fail-observations-large-portrait-vertical/20473/133 "2024-04-17T15:12:37Z")

</div>

> [@gazinux](#):
>
> Is it possible that calibration challenges we are facing are due to measurment distortion in mechanical resistance

I think that those will be important as we continue to dial things in further, but the issues that we are seeing right now are 100% a software bug. In cases where it’s not working I am able to take the same data and get good results by tweaking the software…the trick is just to get it to work every time in every situation automatically. The real world has a lot of possibilities so we need to make it work with all of them.

> [@WFD](#):
>
> the distance from each of those points to the centroid

I think that this would give similar results, but I am measuring from the end of each line to each other line without finding the centroid. Finding the centroid might actually be better.

I am very very open to improving the system and I’m confident that there are a lot of ways that we can improve it.

---

<div class="post-metadata">

**Author:** ![ronlawrence3](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/ronlawrence3/32/7886_2.png) [@ronlawrence3](https://forums.maslowcnc.com/u/ronlawrence3)\
**Post date:** [April 19, 2024, 10:01pm UTC](https://forums.maslowcnc.com/t/m4-calibration-fail-observations-large-portrait-vertical/20473/134 "2024-04-19T22:01:44Z")

</div>

Tried a fresh 6x6 600x600 after taking about 2 feet off the belts (not expecting things to change, but was having retraction issues on one sometimes and this cleared it out a bit).

Fitness: 0.25881129524959634 in 2500

```auto
CLBM:[{bl:1697.27, br:1711.67, tr:1738.57, tl:1768.06},{bl:1514.89, br:1529.87, tr:1945.97, tl:1973.02},{bl:1274.36, br:1805.47, tr:2161.12, tl:1780.36},{bl:1358.99, br:1863.41, tr:2083.95, tl:1685.74},{bl:1445.92, br:1928.48, tr:2011.15, tl:1594.47},{bl:1535.84, br:1994.22, tr:1942.78, tl:1507.37},{bl:1626.00, br:2062.67, tr:1879.68, tl:1424.87},{bl:1714.27, br:2132.28, tr:1822.50, tl:1348.14},{bl:1777.59, br:2036.03, tr:1716.62, tl:1444.08},{bl:1692.78, br:1963.93, tr:1777.45, tl:1515.95},{bl:1609.26, br:1892.75, tr:1843.88, tl:1593.66},{bl:1525.83, br:1822.47, tr:1915.72, tl:1676.31},{bl:1441.85, br:1756.31, tr:1992.07, tl:1763.29},{bl:1362.71, br:1693.58, tr:2072.63, tl:1853.97},{bl:1459.95, br:1585.95, tr:1987.49, tl:1932.24},{bl:1534.16, br:1653.90, tr:1903.21, tl:1845.32},{bl:1611.84, br:1722.62, tr:1823.07, tl:1762.42},{bl:1691.47, br:1796.60, tr:1747.48, tl:1683.97},{bl:1771.82, br:1870.68, tr:1677.10, tl:1610.71},{bl:1854.48, br:1947.01, tr:1612.55, tl:1543.17},{bl:1933.90, br:1863.23, tr:1511.06, tl:1645.18},{bl:1856.86, br:1785.03, tr:1579.90, tl:1708.58},{bl:1779.79, br:1705.11, tr:1654.28, tl:1777.92},{bl:1706.44, br:1627.08, tr:1733.92, tl:1852.43},{bl:1633.75, br:1552.05, tr:1817.96, tl:1931.50},{bl:1566.58, br:1479.32, tr:1905.74, tl:2014.65},{bl:1674.76, br:1381.49, tr:1828.44, tl:2100.65},{bl:1737.08, br:1459.08, tr:1736.67, tl:2020.97},{bl:1806.29, br:1540.09, tr:1648.52, tl:1945.50},{bl:1875.56, br:1622.97, tr:1564.57, tl:1874.69},{bl:1950.70, br:1705.75, tr:1485.61, tl:1809.12},{bl:2021.87, br:1789.31, tr:1412.38, tl:1749.32},{bl:2117.63, br:1721.59, tr:1317.18, tl:1855.45},{bl:2046.10, br:1634.33, tr:1395.53, tl:1911.92},{bl:1976.14, br:1546.64, tr:1479.39, tl:1974.12},{bl:1908.38, br:1458.20, tr:1567.87, tl:2041.54},{bl:1843.84, br:1373.38, tr:1660.24, tl:2113.52},{bl:1781.69, br:1291.18, tr:1756.19, tl:2189.73},]

```

---

<div class="post-metadata">

**Author:** ![ronlawrence3](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/ronlawrence3/32/7886_2.png) [@ronlawrence3](https://forums.maslowcnc.com/u/ronlawrence3)\
**Post date:** [April 19, 2024, 10:41pm UTC](https://forums.maslowcnc.com/t/m4-calibration-fail-observations-large-portrait-vertical/20473/135 "2024-04-19T22:41:44Z")

</div>

I just made sure I was on the latest firmware and UI and tried again. got a wierd loop / mutiple calibration calculation thing… and I apparently didn’t copy the right output, because this clbm is the same…

---

<div class="post-metadata">

**Author:** ![ronlawrence3](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/ronlawrence3/32/7886_2.png) [@ronlawrence3](https://forums.maslowcnc.com/u/ronlawrence3)\
**Post date:** [April 19, 2024, 11:43pm UTC](https://forums.maslowcnc.com/t/m4-calibration-fail-observations-large-portrait-vertical/20473/136 "2024-04-19T23:43:13Z")

</div>

OK, another. this time I know for sure I was using 0.69

```auto
CLBM:[{bl:1697.39, br:1713.68, tr:1738.56, tl:1768.10},{bl:1514.10, br:1530.66, tr:1946.10, tl:1973.02},{bl:1273.87, br:1806.60, tr:2161.27, tl:1780.41},{bl:1359.12, br:1864.80, tr:2083.92, tl:1685.77},{bl:1445.08, br:1929.21, tr:2011.12, tl:1594.51},{bl:1536.12, br:1994.92, tr:1942.78, tl:1507.33},{bl:1626.52, br:2063.51, tr:1879.76, tl:1424.89},{bl:1714.40, br:2133.63, tr:1822.44, tl:1348.18},{bl:1777.23, br:2036.60, tr:1716.57, tl:1444.04},{bl:1692.46, br:1966.21, tr:1777.49, tl:1515.94},{bl:1609.13, br:1892.80, tr:1843.85, tl:1593.65},{bl:1526.08, br:1823.84, tr:1915.61, tl:1676.35},{bl:1442.44, br:1756.93, tr:1992.16, tl:1763.33},{bl:1363.86, br:1694.50, tr:2072.56, tl:1854.01},{bl:1461.54, br:1586.58, tr:1987.24, tl:1932.26},{bl:1534.04, br:1654.50, tr:1903.20, tl:1845.33},{bl:1612.39, br:1723.95, tr:1823.04, tl:1762.44},{bl:1690.40, br:1797.18, tr:1747.53, tl:1684.02},{bl:1770.69, br:1872.58, tr:1677.18, tl:1610.62},{bl:1854.12, br:1947.36, tr:1612.58, tl:1543.15},{bl:1932.91, br:1864.94, tr:1511.14, tl:1645.13},{bl:1857.67, br:1785.64, tr:1579.75, tl:1708.61},{bl:1780.28, br:1706.20, tr:1654.33, tl:1777.92},{bl:1706.50, br:1628.06, tr:1733.89, tl:1852.42},{bl:1634.53, br:1552.99, tr:1817.98, tl:1931.48},{bl:1566.77, br:1480.19, tr:1905.83, tl:2014.66},{bl:1673.30, br:1382.57, tr:1828.62, tl:2100.61},{bl:1735.83, br:1460.49, tr:1736.74, tl:2020.91},{bl:1805.43, br:1540.48, tr:1648.51, tl:1945.49},{bl:1875.89, br:1622.34, tr:1564.63, tl:1874.75},{bl:1949.78, br:1706.37, tr:1485.66, tl:1809.14},{bl:2021.79, br:1789.17, tr:1412.45, tl:1749.31},{bl:2117.39, br:1722.12, tr:1317.26, tl:1855.48},{bl:2046.46, br:1634.90, tr:1395.53, tl:1911.98},{bl:1976.13, br:1547.28, tr:1479.30, tl:1974.20},{bl:1908.44, br:1459.79, tr:1567.85, tl:2041.47},{bl:1843.84, br:1374.33, tr:1660.31, tl:2113.51},{bl:1781.80, br:1291.69, tr:1756.16, tl:2189.77},]

```

…

```auto
Fitness: 0.2992778 in 300

WARNING FITNESS TOO LOW. DO NOT USE THESE CALIBRATION VALUES!
Calibration complete
Calibration values:
Fitness: 0.2992777589698333
Maslow_tlX: -61.5
Maslow_tlY: 2226.1
Maslow_trX: 2617.9
Maslow_trY: 2223.2
Maslow_blX: 0.0
Maslow_blY: 0.0
Maslow_brX: 2614.3
Maslow_brY: 0.0

```

[cal-04-19-2.txt](https://forums.maslowcnc.com/uploads/short-url/8YArAjckK5WZ9Eh3tf7J9oi0qsU.txt) (7.3 KB)

---

<div class="post-metadata">

**Author:** ![bar](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/bar/32/10_2.png) [@bar](https://forums.maslowcnc.com/u/bar)\
**Post date:** [April 20, 2024, 12:05am UTC](https://forums.maslowcnc.com/t/m4-calibration-fail-observations-large-portrait-vertical/20473/137 "2024-04-20T00:05:38Z")

</div>

Will you give

> [@Interstitial Firmware Releases](https://forums.maslowcnc.com/t/interstitial-firmware-releases/20215/64):
>
> 0.69.1

A try? It should work in vertical orientation and I would love to hear your feedback 😀 …You are the target audience.

---

<div class="post-metadata">

**Author:** ![ronlawrence3](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/ronlawrence3/32/7886_2.png) [@ronlawrence3](https://forums.maslowcnc.com/u/ronlawrence3)\
**Post date:** [April 20, 2024, 12:10am UTC](https://forums.maslowcnc.com/t/m4-calibration-fail-observations-large-portrait-vertical/20473/138 "2024-04-20T00:10:01Z")

</div>

installing now… then dinner… then another try with it!

---

<div class="post-metadata">

**Author:** ![ronlawrence3](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/ronlawrence3/32/7886_2.png) [@ronlawrence3](https://forums.maslowcnc.com/u/ronlawrence3)\
**Post date:** [April 20, 2024, 12:45am UTC](https://forums.maslowcnc.com/t/m4-calibration-fail-observations-large-portrait-vertical/20473/139 "2024-04-20T00:45:11Z")

</div>

Before I say anything else, thanks for all your hard work. I appreciate your efforts and think you are doing a great job managing this chaos 🙂

Installed:

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/maslowcnc/original/3X/c/f/cf717b4545728fa1ac220567410b58dff8ee4b15.png)

Complete.

Here is the computer web browser’s serial log (the tablet came out differently so not sure what that is all about…)

[cal-04-19-3-new.txt](https://forums.maslowcnc.com/uploads/short-url/jASMoMfUGj0JOrQ3YBtA7FdYcLr.txt) (15.6 KB)

tablet log picture I’ll see if I can figure out how to copy it all out.

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/maslowcnc/original/3X/4/1/41879b3e6aadde22e215662033d23ed532e4b361.jpeg)

Observations:

Still not great result for me, but much nicer to manage! still need to tend belts on the first part, but the second was great.

I’ll look more at the results and your calibration code after a bit and give more feedback. I’d like to run these numbers again in the ui tool, but probably need updates for that.

Also I still need to get dinner. I couldn’t wait to try this, lol

---

<div class="post-metadata">

**Author:** ![bar](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/bar/32/10_2.png) [@bar](https://forums.maslowcnc.com/u/bar)\
**Post date:** [April 20, 2024, 12:55am UTC](https://forums.maslowcnc.com/t/m4-calibration-fail-observations-large-portrait-vertical/20473/140 "2024-04-20T00:55:05Z")

</div>

Darn, I was hoping that this would fix it. It’s an improvement in a lot of ways still, but hmmm

I’ll dig into the log and see what I can learn.

[Previous page](https://forums.maslowcnc.com/t/m4-calibration-fail-observations-large-portrait-vertical/20473.md?page=6)

[Next page](https://forums.maslowcnc.com/t/m4-calibration-fail-observations-large-portrait-vertical/20473.md?page=8)
