Input: green shaft linearly reciprocating.
Output: grey nut rotating interruptedly. It plays role of a ratchet wheel.
Spring pin (in pink) plays role of a pawl.
Pay attention to asymmetric profile of the nut thread.
The engagement between the pawl and the nut threads happens only when the shaft moves down.
When the shaft moves up, the pin slides on the nut threads.
If the nut inertia is large enough, it can rotates continuously.