\(\)

(\(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.