Components of Chain Length Calculation
At any time, the position of the sled on the MaslowCNC workspace is set by
 the amount of chain that extends beyond the 12 o’Clock sprocket top position,
 the geometry (or shape) of the frame,
 and the weigth of the suspended machine components.
Sledposition accuracy is controlled by two things:
 The fitness of the calculation model built into the firmware
 The accuracy of values for the machine parameters used by the model.
Note: This article discusses only the triangular kinematics model based upon usage of the ring kit or one of the linkage kits. We’ve seemed to have moved on from the original quadrilateral system (though a few still use it).
The following diagram summarizes the main parameters for sled position behavior:
Note1: Although it shows a triangular ring kit, this would be the same for all triangular kits.
Note2: There is also an older quadrilateral more complex approach to hanging the sled. It however is getting progressively obsolete.
The idea is that to move the router to a specific location, the firmware calculates how much chain to feed out from each side and the math is based upon a triangular relationship between the motors and the router (hence, triangular kinematics)
Calibration Process related to chain calculation
Calibration  This is performed in Ground Control, then stored into the Arduino besides the firmware.
Currently, the control model considers the following primary factors that are subject to calibration:

Distance between motors (truly: The straight distance between the gear boxes sprocket center. mm)

Distance from the router bit center position to the position of the chains links used for the 12 o’Clock reference:
 For a triangular kit, parameter is the rotational radius (mm) . Not considered are x and y offsets from the router bit to the chains crossing “center” if they were reaching each other.
 For a trapezoidal kit (original mounting) there are several different parameters

Chain sag ( a numeric factor for sag correction)

Vertical height of motors above worksurface (mm)

Sprocket teeth count (qty) and nominal chain pitch (mm) (hence effective radius)
Some other factors were identified as key to improve accuracy and are in development:
 Chain stretch (lenght change per length unit per tension unit) , and sled weight ()
 Each of Left and Right chains link pitch tolerance (% of lenght increase (decrease if negative))
There exists a Calibration Benchmark Test that provides a measurable calibration performance for a given MaslowCNC.
Note there are other factors that cannot be considered in chain length calculation due to their variability:
 Static and dynamic friction of the sled to the workspace and frame flex. But these can be minimized and not affect the sled position in a significant way.
 Router bit forces applied while cuting material. This is always true on CNC machines and depends on gantry stiffness. On the MaslowCNC, there is no gantry, and positioning is more “flexible” when chains are close to vertical in lower corners.
So these are not part of chain length calculations
While the chain extent is under computer control and represent the state of the cnc, the geometry and weights are set by fabrication.
Note that if the frame is not stiff, the frame may flex enough to create noticeable position errors. The control model assumes a stiff frame. It is also a problem if the frame is not level from left to right. A stiff and level frame is achievable, improves accuracy and simplifies calibration.
Chain Length Calculation does not require a workspace to be defined. But not all positions around the sprockets are reachable.
 There is a limit on chain tension and gearbox forces. Balance to limit forces will likely increase parts life and improve cut accurary. So there is a minimal sled vertical distance under the gearboxes. This is actually related to the chain angle to horizontal at sled middle top position on the workspace.
 When chains are getting close to vertical, lateral displacement cannot be controlled and is simply subject to gravity.
 It is practical to use a rectangular workspace and to set the coordinate system origin in the middle ofthe workspace rectangle.
As a result, chain calculations also include 3 more parameters for practical reasons : a workspace height, workspace width, and a distance from workspace top to gearbox sprocket.
There are other internal machine setttings like gearbox reduction ratios and such, but these are known by design and not directly involved into chain Length Calculation. Documenting how the gearbox sprocket rotates and how to prevent exceeding available chain length are for other topics.
The current calculations model are shown into the firmware Kinematics.cpp module
–Here under to be improved–
The following information is based upon an old message from @rjon17469. if there are mistakes/errors, edit it or post a comment regardinging it.
Components that Make Up the Firmware Chain Length Calculation
Maslow has only one mechanism to move the sled to where it needs to go and that is by extending or shortening the chain length between the sled and the two motors. Everything reduces down to determining how long each chain needs to be to perform a certain operation. The current software (as of 8/21/18) currently performs the following to determine the chain length:
(Note: this sction might need an update as the firmware improves and includes more parameters)
 Calculate the straight distance between the center of the motor and the center of the router bit based upon the coordinates of the motor and the target coordinates (Motor1Distance)
 Calculate the amount of chain, starting from the 12 o’clock position, that wraps around the sprocket based upon the coordinates of the motor and the the target coordinates (Chain1AroundSprocket)
 Calculate the straight chain length from the point the chain leaves the sprocket to the center of the router bit (Chain1Straight)
 Increase the straight chain length to account for chain sag.
 Sum the straight chain length and amount of chain wrapped around sprocket and subtract the rotational radius of the ring/linkage kit (Chain1)
Note 1: The above and below generally references only the left chain (Chain1). So where you see Motor1Distance, that’s the distance from the left motor to the center of the router bit. Unsurprisingly, Motor2Distance is the distance from the right motor to the center of the router bit, etc. Got it? Good.
Note 2: The below is based upon a chainovertop feed configuration where the chain slack drops vertically toward the floor (original design). The chainoffbottom feed configuration, where the chain slack runs horizontal along the top beam, is only different in calculation of the amount of chain that wraps around the sprocket… the formulas are very similar between the two. Chainoffbottom feed might get detailed at some time in the future.
Motor1Distance
The software knows (based upon calibration and other values) the x,y location of the center of the motor sprocket and, from the gcode for the desired move, the x,y location of the target. With this, Motor1Distance is easily calculated:float Motor1Distance = sqrt(pow((1*_xCordOfMotor  xTarget),2)+pow((_yCordOfMotor  yTarget),2));
Chain1AroundSprocket
To calculate the amount of chain that wraps around the sprocket, two individual steps are taken.
a = the angle from the target to the center of the motor sprocket.
b = the additional angle based upon the radius of the sprocket
These two angles are shown in the diagram above and are calculated as follows:
a = asin((_yCordOfMotor  yTarget)/Motor1Distance)
b = asin((RleftChainTolerance/Motor1Distance)
Currently (8/21/18), the software calculates RleftChainTolerance (“r” in the diagram) as the chain pitch * number of teeth / (2*pi) and then adjusts it to account for chain wear compensation factors. It is believed that ‘r’ should be the true pitch diameter of the sprocket and should be chain pitch / sin(180/number of teeth). Because the chain is meshed with the sprocket, there should be no adjustment made for chain wear. A proposed change to the code is forthcoming.
Once a and b are calculated, the amount of chain that wraps around the sprocket is calculated as:
Chain1Angle = a + b
Chain1AroundSprocket = RleftChainTolerance * (Chain1Angle)
As above, RleftChainTolerance is subject to a forthcoming code revision.
Chain1Straight
Knowing the the chain comes off the sprocket at a right angle, it is easy to calculate the length of chain from where it comes off the sprocket to the center of the router bit using Pythagorean’s Theorem:
Chain1Straight = sqrt ( pow(Motor1Distance,2)  pow(RleftChainTolerance,2) )
As mentioned earlier, RleftChainTolerance is subject to a forthcoming code revision
Increase Chain1Straight to Account for Chain Sag
I have no idea how this formula works, but the chainSagCorrection value that is calculated during calibration is multiplied by some glob of sines and cosines to figure out how much to increase Chain1Straight. If someone understands this math, feel free to edit the post:
Chain1Straight *= (1 + ((sysSettings.chainSagCorrection / 1000000000000) * pow(cos(Chain1Angle),2) * pow(Chain1Straight,2) * pow((tan(Chain2Angle) * cos(Chain1Angle)) + sin(Chain1Angle),2)));
Chain1
So, at the end, Chain1 is calculated simply as the sum of Chain1Straight and Chain1AroundSprocket and then , because the sorftware has calculated all of this to the center of the router bit, the rotational radius (distance from center of router bit to the end of the chain) is subtracted out to arrive at the target chain length:
Chain1 = Chain1AroundSprocket + Chain1Straight;
Chain1 = Chain1  rotationalDiskRadius;
ChainOverTop vs. ChainOff_Bottom
The following is a comparison of the formulas used between the two. Need a diagram to explain better:
ChainOverTop
Chain1Angle = asin((_yCordOfMotoryTarget)/Motor1Distance)+asin(RleftChainTolerance/Motor1Distance)
Chain1AroundSprocket = RleftChainTolerance * Chain1Angle;
ChainOffBottom
Chain1Angle = asin((_yCordOfMotoryTarget)/Motor1Distance)asin(RleftChainTolerance/Motor1Distance)
Chain1AroundSprocket = RleftChainTolerance * (3.14159  Chain1Angle);