Massive Gear and Piston
(\(r\) is the radius from the gear center to the connector. \(\ell\) is the length of the rod connecting the piston and gear. \(g\), \(m\), \(I\) are the gravitational acceleration, piston mass, and gear moment of inertia respectively. \(\varphi\) is the angle between the horizontal axis and gear location in the positive sense.)
The equations of motion are integrated numerically with the Euler's method. So don't expect much in terms of accuracy.
2022 TODO: plug this into Mathematica to come up with a symplectic method to integrate this. See if I can come up with a solver to automatically sort out more complex linkages than this.