Function generator mechanism design: Find a four-bar linkage whose output angle follows y = f(x) at precision points
A function generator mechanism implements y = f(x) with a four-bar linkage, treating the input link angle as x and the output link angle as the y scale. The dimensions that match exactly at three precision points are found by solving a system of linear equations.
The example implements y = x² (0 ≤ x ≤ 1) with input 150°–240° and output 60°–120° scales. The link lengths are a 80.6, b 167.3, c 49.4, and d 100 mm (non-Grashof (triple rocker)). Use the experiment below to redesign it with a different function and scales.
Function-generating mechanism: a four-bar linkage whose output angle follows y = f(x)
Diagram and graph with the initial values (y = x², 0 ≤ x ≤ 1, 3 precision points). Enable JavaScript to redesign by changing the function, scales, and number of precision points.
Kinematics based only on dimensions and angles. Joint clearance, deflection, and manufacturing errors are not included.
Function y and mechanism output y
- Function (target)
- Mechanism output y
Mechanism error
Three things to try
- Play it as is and view the error graph The error is 0 at the precision points x = 0.067, 0.500, 0.933 and remains between them (the maximum is 0.13% at x = 0.70). A mechanism matched at 3 points approximates the function; it does not match it for every x.
- Set the number of precision points to 5 With 5 points, the values are chosen to minimize the sum of squared residuals in the equation, so the maximum error is not always smaller. For y = √x, it is 0.47% with 3 points and 0.51% with 5 points, so it actually gets larger.
- Change the scale angles Set the output link angle to 60°, its range of motion to 90°, and the input link angle to 30°. The experiment reports that the mechanism cannot be designed because one precision point can only be reached with the other assembly configuration (branch). It cannot be used because it cannot pass through all the points without disassembling the mechanism (singular poses and dead points).
Freudenstein's equation
Place the ground link on the x axis (O2 is at the origin, and O4 is a distance d away). Let the input link a have angle θ2 and the output link c have angle θ4. Because the length of the coupler b is constant, the following equation holds.
Choose three pairs of θ2 and θ4 values to get a system of linear equations for K1, K2, and K3, then solve for a, b, and c. If the solved value of a or c is negative, interpret it as the link pointing in the opposite direction (an angle 180° greater).
Move the resulting mechanism across the entire x range (120 intervals) using a closed-form equation. Read y back from the output angle and measure the error.
Choosing precision points (Chebyshev spacing)
Place the precision points slightly inside the ends of the x range, rather than at the ends. Chebyshev spacing is commonly used.
This is a good first estimate that makes the error peaks roughly equal in height. There is no guarantee that it is optimal.
Move the precision points to reduce the maximum error
Set the experiment's “Precision point placement” to “Position that minimizes the maximum error” to move the three precision points and reduce the maximum error across the entire range (minimax optimization).
With the initial values for y = x², the precision points move to x = 0.113, 0.495, 0.827, and the maximum error changes from 0.13% to 0.10%.
You can check whether the result is optimal in the error graph. Four error peaks appear at the same height, with alternating signs. This is the same pattern as the condition for the maximum error to be minimized with three precision points (the Chebyshev alternation theorem).
The search uses a derivative-free method (the Nelder-Mead method) and does not use random numbers. The mechanism still matches exactly at the precision points after they move.
Match position, velocity, and acceleration at one point
The three conditions do not have to be positions at three separate points. You can also match the output angle, the velocity ratio dθ4/dθ2, and its rate of change d²θ4/dθ2² at a single point.
The equations obtained by differentiating Freudenstein's equation once and twice with respect to the input angle are also linear in K1, K2, and K3. Together with the position equation, they form the same system of linear equations.
Set the experiment's “Precision point placement” to “Match position, velocity, and acceleration at the middle point” to get the following result for y = x².
| Matching method | Maximum error in the middle 1/4 | Error at the end of the range (x = 0) |
|---|---|---|
| Position, velocity, and acceleration at the middle point | 0.024% | 0.53% |
| Three Chebyshev points | 0.112% | 0.13% |
The error is much smaller at the middle and increases farther away. This matching method is useful when you want accurate motion only near a particular point, such as when you want to set the velocity ratio at the center of the range of use.
When creating this page, we confirmed that the same trend occurs for every sample function.
Also adjust the starting angle of the scale
The error depends not only on the positions of the precision points, but also on the angles at which the scales start. The experiment's “Also search for the starting angle of the scale” keeps the range of motion (the scale resolution) unchanged while adjusting the starting angles and the three precision points together.
The link lengths change as well because they are determined by the angle combinations. To avoid selecting a mechanism that is difficult to use based only on its error, the following conditions apply.
- Transmission angle at least 40° (excludes mechanisms that transmit force poorly)
- Link length ratio the longest link is no more than 8 times the shortest link
The method tests all starting angles in 15° increments, selects several good candidates, then refines them together with the precision points using the Nelder-Mead method (no random numbers are used). The found angles are rounded to 0.1° and entered, then the design is recalculated from those values.
For y = x², the result is as follows. The link lengths a, b, and c are 109.5, 194.8, 58.6 mm.
Sample settings for each function
Switch the experiment's “Function” setting to load the following scales. We tested angles in 15° increments and selected settings with a transmission angle of at least 45° and no extreme link length ratios.
| Function | x range | Input (start, range) | Output (start, range) | a, b, c (mm) | Maximum error (3 points, 5 points, optimized 3 points) | Also search for starting angles (input, output, maximum error) |
|---|---|---|---|---|---|---|
| y = x² | 0–1 | 150°, 90° | 60°, 60° | 80.6, 167.3, 49.4 | 0.13%, 0.12%, 0.10% | 144.7°, 238.4°, 0.04% |
| y = √x | 1–4 | 45°, 90° | 120°, 60° | 272.8, 205.4, 225.5 | 0.47%, 0.51%, 0.40% | 213.9°, 107.1°, 0.15% |
| y = log₁₀ x | 1–2 | 105°, 60° | 30°, 60° | 120.9, 227.6, 99.8 | 0.24%, 0.25%, 0.23% | 86.7°, 27.7°, 0.10% |
| y = sin x (x in degrees) | 0–90 | 120°, 90° | 90°, 60° | 101.4, 152.3, 71.1 | 0.95%, 0.84%, 0.81% | 291.9°, 93.3°, 0.15% |
| y = 1/x | 1–2 | 30°, 90° | 105°, 60° | 213.1, 144.3, 175.5 | 0.29%, 0.33%, 0.27% | 42°, 280.9°, 0.03% |
The ground link d is 100 mm in every case. All lengths can be scaled up or down by the same ratio (the angle relationships do not change).
What this page does not cover
- Joint clearance, link flex, and angle deviations caused by manufacturing errors are not included. The error here is only the “design error” when the dimensions are exact.
- The optimization adjusts the positions of the three precision points and the starting angles of the scales. It does not adjust the range of motion (the scale resolution) or the ground link length d (which only determines the overall size).
- The result is a good solution within the searched range. There is no guarantee that it is the best solution among all possible angles.
- The velocity ratio and its rate of change can only be matched at the “middle point.” There is no interface for specifying velocity at an arbitrary point or freely combining conditions (the calculation engine supports this).
How the numbers are calculated
The coefficients of Freudenstein's equation are found from the angle combinations at the precision points (a system of linear equations for 3 points, least squares for 5 and 7 points), then converted to link lengths. The calculation then checks whether the assembly configuration (branch) is the same at every precision point and whether the loop closes throughout the x range, and solves each pose using a closed-form equation to measure the error and transmission angle. The calculation engine's automated tests check that the dimensions of a known four-bar linkage are recovered exactly from three angle combinations read from that mechanism. The values in this text were recalculated and checked when this page was created (we also confirmed that Freudenstein's equation holds for every pose). The calculation engine version is 0.1.0.
References: F. Freudenstein, “Approximate Synthesis of Four-Bar Linkages”, Trans. ASME (1955). R. L. Norton, Design of Machinery (analytical synthesis).