Maslow Home Maslow Community Garden

Chain Length Calculations


#1

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:

  1. 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.
  2. 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)

  1. 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)
  2. 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)
  3. Calculate the straight chain length from the point the chain leaves the sprocket to the center of the router bit (Chain1Straight)
  4. Increase the straight chain length to account for chain sag.
  5. 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 chain-over-top feed configuration where the chain slack drops vertically toward the floor (original design). The chain-off-bottom 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. Chain-off-bottom feed might get detailed at some time in the future.

image

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;

Chain-Over-Top vs. Chain-Off_Bottom

The following is a comparison of the formulas used between the two. Need a diagram to explain better:

Chain-Over-Top

Chain1Angle = asin((_yCordOfMotor-yTarget)/Motor1Distance)+asin(RleftChainTolerance/Motor1Distance)
Chain1AroundSprocket = RleftChainTolerance * Chain1Angle;

Chain-Off-Bottom

Chain1Angle = asin((_yCordOfMotor-yTarget)/Motor1Distance)-asin(RleftChainTolerance/Motor1Distance)
Chain1AroundSprocket = RleftChainTolerance * (3.14159 - Chain1Angle);


Accuracy Issues and Calibration Overview
The Firmware Realm : From GCode to PID or the (left,right,z) and (x,y,z) alternate worlds
Accuracy Issues and Calibration Overview
Thoughts on the Software
Discussion Regarding Triangular Calibration
Table of Contents
#2

Reserved

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque congue elementum dui, porttitor iaculis risus vestibulum sed. Aenean viverra finibus turpis in luctus. Morbi elementum nulla at dui ultricies blandit. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Morbi tincidunt lacinia augue. Integer a augue pretium, tristique dolor nec, dapibus leo. Donec enim enim, volutpat at malesuada quis, pharetra dignissim neque. Vestibulum tristique lobortis nunc. Morbi id magna vel metus dignissim egestas. Duis in arcu sed dui aliquet dignissim. Ut convallis justo sit amet dignissim finibus. Curabitur sagittis aliquet felis. Proin non ex lorem.


#3

Reserved

Vestibulum sollicitudin odio sed odio sagittis consectetur. Proin maximus magna id ex rhoncus aliquam vitae id ante. Donec odio libero, consequat a ipsum vel, dignissim aliquam ex. Phasellus viverra auctor augue et porttitor. Proin cursus tristique odio vel bibendum. Vivamus sollicitudin massa ac pellentesque euismod. Suspendisse luctus dolor leo, et semper dui facilisis vel.


#4

Reserved

Aliquam erat volutpat. Ut sapien est, lobortis ac aliquam id, vehicula dignissim magna. Etiam lectus nisl, malesuada eu pulvinar in, malesuada non metus. Cras luctus dolor sit amet enim vehicula pellentesque. Integer odio ligula, eleifend ut egestas sit amet, faucibus id elit. Suspendisse lobortis sapien augue, nec rutrum dui facilisis id. Phasellus pharetra, sem nec sodales condimentum, diam sapien porta turpis, vel ullamcorper metus lacus non nulla. Phasellus consequat mi nec imperdiet tempor.


#5

Reserved

Fusce nunc lectus, vestibulum id interdum at, mattis id erat. Sed gravida suscipit facilisis. Sed diam sem, fermentum eget ex ac, cursus placerat tellus. Cras rhoncus mauris ligula, nec blandit est pellentesque in. Cras non nulla eu magna viverra mollis et ut enim. Etiam a magna et nunc mollis consequat. Donec pretium, ante at gravida elementum, nibh ipsum faucibus est, id lacinia lectus tellus ac dui. Integer fringilla libero ut mauris fermentum sollicitudin.


#6

Reserved

Donec arcu nulla, viverra ut sagittis pellentesque, imperdiet sed ipsum. Etiam sed auctor nulla. Curabitur vel dictum ex, quis consectetur lacus. Aliquam congue felis at justo consectetur maximus. Donec dapibus nisl eros, id auctor eros posuere ac. Vestibulum sagittis consequat facilisis. Vestibulum eu odio nulla. Vivamus euismod tristique tempus. Aliquam ex mauris, vulputate sed tempor id, faucibus sed nulla. Nullam non scelerisque ligula. Morbi maximus risus pretium dui malesuada viverra.


#7

Fantastic explanation. Does it take into account the different over and under chain mount methods.

Thanks, Ed


#8

The explanation doesn’t take it into account, but the code does… It’s just a couple different steps. It was enough of a pain enough to wrap my head around over top so I wanted to just get through that. I’ll put a disclaimer in the post.


Accuracy Issues and Calibration Overview
#9

I’m pretty sure this is wrong. Everywhere else, the angles are in radians, while this calculation is based on them being in degrees.

There is another issue that you don’t get at here (that I believe is buried in the forumulas somewhere), is that it’s not only the chain length that shifts, but it’s also the x,y point at which the chain leaves the sprocket and becomes a ‘straight’ line. IIRC (from when I looked at this over a year ago), there was some trickery based on how radians are defined


#10

I’m confused… both python and c++ calculates sin, cos and tan from radian and that’s the only functions that uses the angles.


#11

What I presented is the code that’s used for the calculations. If some calculation is missing, then it was either never there or was removed by someone. I’m just trying to document what’s there now.