# Calibration with multilateration using W1209

A project log for RigTig's Big 3D Printer

A DIY 3D printer (big volume, inexpensive, lightweight and portable).

To calibrate RB3DP, the idea is to set up a calibration object, manually move effector to 5 points on that object (at each point, record relative lengths to each winch) and calibration is just some arithmetic to derive the x, y, and z coordinates of each motor winch. So, we need a controller, which (of course) must be very inexpensive, so the choice is W1209 board (see https://hackaday.io/project/16097-eforth-for-cheap-stm8s-value-line-gadgets ) plus an ESP8266 for WiFi.

The key for getting this to work is multilateration and the maths is on wikipedia (see https://en.wikipedia.org/wiki/Multilateration#Solution_with_limited_computational_resources). Many thanks to @Florian Festi for identifying multilateration as being a key solution to our calibration problem.

The problem was that we did not know the lengths of the strings even if we knew the location of each of the motors (by physical measurement and typing them in). We can measure changes in length however, and that is what multilateration uses; differences in lengths. If you use 5 known points then you can calculate the cartesian coordinates of 3 motor winches. The origin is the one on the calibration object, so there is no transformation needed for different reference frames; everything is referenced to the object space. Another advantage is that there is no restriction on having the motor winches on a plane parallel to the baseplate. In fact, even the orientation of the axes is independent of the physical orientation of the motor winches.

So, we need a calibration piece with points with known coordinates (P0 to P4), and we need a controller to make each motor winch move so its string is longer and shorter. Now, putting all the calibration code on the central GCODE interpreter might have been obvious, but actually putting code that is used for special purposes on a special purpose machine has the advantage of making this major function very cleanly interfaced. All we need to do at the end of the calibration is tell the GCODE interpreter the locations of the motor winches.

And there is sure to be some additional functions we can add to the controller, such as moving the effector through a maze, and ...

## Discussions

RigTig wrote 05/12/2017 at 09:33 point

Creating an inexpensive hand controller for the RB3DP has been a serious challenge. Fitting the Forth system, the multilateration calculations (including matrix manipulation) and a menu-based interface for user interaction into an 8K code space turns out to be very tight. Just a few more tests and tweaks and it'll be ready for publication, though. Of course, the task could be done on a smartphone, so if anyone wants to do it, I'll give them a hand with interface details.

The multilateration solution chosen uses 5 points to create 3 linear equations in x, y and z for each winch point. An alternative multilateration solution uses 4 points to create 3 equations using squares of x, y and z and is a candidate for a future implementation. The fun and games really kicks in when implementing these using integer-based arithmetic. It still amazes me what can be done on an 8-bit CPU, especially when it is already fitted onto a board designed to be a temperature controller (W1209).

Many thanks to my team members who have helped so much to get me this far: @Thomas and @Florian Festi. You have been a great inspiration.

Are you sure? yes | no

Florian Festi wrote 05/12/2017 at 18:44 point

I wonder if one could just use a laptop as a controller. For generating and sending over the gcode you need an laptop anyway. So why not also use it for calibration? This would also allow writing the maths in a high level language.

Are you sure? yes | no

Thomas wrote 05/12/2017 at 20:13 point

I already suggested using a mobile phone, but RigTig found a way to do it with the cheapest and least likely piece of hardware imaginable, and he's having fun making it happen. Great style - chapeau!
Today I told a colleague about it - I guess that RigTig would have liked the expression on his face :-)

Are you sure? yes | no

Florian Festi wrote 04/07/2017 at 13:52 point

I've been looking for a solution with works with only 4 points but did not find a good description (and was too lazy to do the maths on my own). Turns out it is linked in the Wikipedia article m(

https://www.hindawi.com/journals/vlsi/2002/935925/abs/