# What would be the “definitive” formula to calculate chainstay length from sprocket size, chainring size and number of chain links?

How do I calculate the diameter of a chainring from the number of teeth?

So, my question tries to ellaborate over this, considering that, for single speeds, there will always be a certain unique chainlength (for a new drivetrain) given the gear sizes and the number of links in the chain. Also, for vertical dropouts, where chainstay length is fixed, there might be a "magical gear" when you have almost zero chain-slack with the right combination of sprocket teeth number, chainring teeth number, and number of chain links.

For that reason, I plan to write some app (html+javascript) to get this length. There is a program which does exactely that, but it is not possible, as far as I know, to know which formula it uses, or if it is actually correct:

http://eehouse.org/fixin/formfmu.php

Then, I think the following assumptions should be made:

• The chain perimeter is the sum of the distances between the consecutive centerlines of each pin;
• The nominal distance between centerlines, in a new chain, is half an inch, or "exactely" 12.7mm;
• The chain is considered to run a straight line between the tangent points where it touches each gear (sprocket or chainring);
• The chain is considered a regular polygon sector along the circumference of the gears, as pointed by Lantius in his answer to the linked question.

The result would be the answer to the question: "If I wrap a closed chain with N links around a spocket with S teeth and a chainring with C teeth and pull those apart, what would be the distance between the centerlines of the cog and the chainring?"

EDIT: I'm including an "updated" drawing I generated programmatically (it's quite involving!), so it would be easier to analyze the geometry of the problem: X is the chainstay length, and it is the hypotenuse of the purple triangle, the short cathetus being R-r (known), and the longer cathetus being equal to B (unknown).

EDIT: (added trig formula) The whole length L of the chain (known) is equal to A+B+C+D. Since B = D, then L = 2B + A + C, or, with all the added trig: The unknown (B) appears in both sides of the equation, and it looks like it cannot be isolated.

(To make matters worse, there are the natural limitations that teeth profile is not always the same between brands, there might be very small variations of link length between different chains even of the same brand (happens to me quite often), how much chainslack is actually necessary is debatable, and so on, but it would be nice to have a "canonical formula" which actually considers the physical nature of the pinion-and-chain engagement and allows us to calculate this, at least theoretically.)

• I think you're expecting too much. My guess is that at best you can figure the tangents to the two more or less idealized sprockets (which have a diameter slightly larger than the diameter a chain pin would follow if fully engaged between teeth), and you likely have to solve that by successive approximation. And, in any event, you have to deal with chain stretch. – Daniel R Hicks Mar 21 '12 at 2:00
• @DanielRHicks I know that, even if one gets to the perfect ideal formula, practical limitations still introduce so much error that just a fair aproximation falls inside this error margin. (but even so, I like the intellectual exercise). Also, I would be considering just new components, so stretch would be zero in this simplified case. – heltonbiker Mar 21 '12 at 2:17
• Well, now that I think about it, the formula is not that difficult. The chain describes one side of a quadrilateral with with two adjacent right angles, and the two shorter sides being the radii of the sprockets. Truncate the quadrilateral to a rectangle and the use good ole squaw on the hippo on the remaining triangle to figure the chain stay length. A dash of trig will figure the % of the circumference of the two sprockets occupied by the chain, giving you the total chain length. The hard part would be working backwards from an integral chain length. – Daniel R Hicks Mar 21 '12 at 11:37
• (In your diagram above, the trick is that your two vertical lines shouldn't be straight but should describe slight arrows pointing right, to make right angles with the chain.) – Daniel R Hicks Mar 21 '12 at 11:39
• He deleted the answer, I believe, because his formula used the chain stay length to find the ideal chain length, rather than using the chain length to find the chain stay length as you request here in your title and before your edits. By the way, if you edit, leave the original info, so people can follow in the future. – zenbike Mar 22 '12 at 13:40

Unfortunately my crummy draw tool won't let me place the lines very accurately, but this is the idea: The radii describe right angles to the two chain lines. I'm pretty sure the two wrap angles on the two sprockets will add to 360 degrees. The upper quadrilateral has been divided into a rectangle (if my lines were square) and a right triangle. The hypotenuse of the triangle is the chain stay length. The short side is the large sprocket radius minus the small sprocket radius.

From the chain stay length and the sprocket radii you can compute the straight chain length and (with a bit of trig) the two wrap angles. Given a wrap angle and a sprocket radius you can compute the amount of chain on the sprocket.

• Of course, the other way to do it is to get the two sprockets, put them in a jig, wrap the chain around, and measure the distance between sprocket centers. – Daniel R Hicks Mar 21 '12 at 22:52
• You're absolutely right, and I came out with exactely the same drawing yesterday. The only thing I couldn't figure out is that I have an UNKNOWN chainstay length, and apparently the (large) equation I get remains with a single variable (the length of straight-running chain between the sprockets) in a way that it cannot be isolated. I'll STILL keep trying, but I suspect the iterative method you described (trying to substitute values, recalculating, and guessing each time closer) could be the only possible solution. Even so I'll think there might be an algebric one. Stay in touch! – heltonbiker Mar 22 '12 at 12:52
• Just for clarity, the goal is calculate the chainstaylength (unknown) GIVEN chain length (via number of links) and sprocket sizes... – heltonbiker Mar 22 '12 at 13:22
• Yes, I know the goal is the chainstay length, but you can, in theory, have the equation for the chain length and then solve it for the chainstay length. (But if I had to do this I'd just write a simple Java program to iteratively compute chainstay length -- my algebra was never that great.) – Daniel R Hicks Mar 22 '12 at 15:41
• (Plus you still have the rather intractable problem of the chain only coming in discrete lengths.) – Daniel R Hicks Mar 22 '12 at 15:47