A crank mechanism basically consists of crank arm, connecting rod , piston and eccentric shaft. You can see a crank mechanism which is drawn below:

We will see in this writing displacement, velocity and acceleration graphs of a piston depend on angle of crank.
Piston is a element which translates explosives force to lineer motion. This motion occurs with while piston moving between Bottom Dead Center (BDC) and Top Dead Center (TDC).
if we need to create a crank connecting rod model, it would be simply as:

We would explain the model as: The circle is crank, BC line is connecting rod lenght and rectangular is piston also AB is crank arm. Theta is angle of crank and connecting rod.
- DISPLACEMENT OF PISTON
If we take reference of crank axis, we can calculate displacement of a piston as:

According to this formule, piston has 0° and 360° maximum position, 180° and 540° minumum position.
States encoded in Python:

for 40 mm crank arm and 193 mm connecting rod, displacement graph of a piston between 0° and 360° like this:

2. VELOCITY OF PISTON
Velocity of a piston between BDC and TDC is a function of crank angle and this can be formulize that:

in this formule, w is rotation speed which rpm and must translate to rad/sec. About 1 rpm= 0.104 rad/s
Piston has maximum velocity in 74° and increase as rpm increase velocity.
States encoded in Python:

for 40 mm lenght of crank arm, 193 mm connecting rod and 1000 rpm graph velocity of a piston between 0° and 360° like this:

3. ACCELERATION OF PISTON
we would figure out acceleration of a piston as:

According this formule, maximum acceleration of piston is 0, 360, 720 degrees (BDC), minumum acceleration is 141, 501, 579 degrees (TDC).
States encoded in Python:

for 40 mm lenght of crank, 193 mm connecting rod and 1000 rpm, the acceleration of piston like this:
