# No. 155 (Brown 1868): "Reciprocating rectilinear motion into intermittent circular motion by means of the pawl attached to the elbow-lever, and operating in the toothed wheel. Motion is given to the wheel in either direction according to the side on which the pawl works. This is used in giving the feed-motion to planing machines and other tools."
#
# Model (cm): A, a 24-tooth ratchet wheel, turns on a fixed centre and is held by its bearing friction. A rod C (the reciprocating input: a crank, the one driven joint,
# 30 turns a minute, working in a yoke on its lower end, slides it 1.7 cm up and down) has a pin in a slot in one arm (5 cm) of an elbow-lever; the other arm (5.5 cm) carries the
# pawl on a pin, held onto the teeth on A's lower side by its spring. As the rod falls the lever swings the pawl to the right and its tip pushes a tooth on; as the rod rises the pawl slides back over the next
# tooth and drops behind it. A turns a tooth every double stroke, always the same way; worked on the other side of A (the pawl's mirror image) it would turn the other way. Generator: opencode-runs/batch10/gen155.py.
number: 155
slug: elbow-lever-pawl-toothed-wheel
name: An elbow-lever pawl feeding a toothed wheel
brown: "Reciprocating rectilinear motion into intermittent circular motion by means of the pawl attached to the elbow-lever, and operating in the toothed wheel. Motion is given to the wheel in either direction according to the side on which the pawl works. This is used in giving the feed-motion to planing machines and other tools."
units: cm
sim:
  timestep: 0.0002
  integrator: implicitfast
  iterations: 100
  solver: PGS
  multiccd: false
  duration_s: 13.0
  floor: false
bodies:
  - id: wheel_a
    shape: part
    pos: [0, 0, 0]
    friction: 0.1
    color: "#d9cfb6"
    pieces:
      - {kind: disc, center: [0, 0], radius: 4.3, inner: 0.6, y: [-0.5, 0.9]}
      - {kind: poly, points: [[-0.6208, -4.1539], [-0.739, -4.9451], [0.4755, -4.173]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[0.4755, -4.173], [0.566, -4.9679], [1.5393, -3.9078]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[1.5393, -3.9078], [1.8325, -4.6521], [2.4983, -3.3762]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[2.4983, -3.3762], [2.9741, -4.0193], [3.287, -2.6146]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[3.287, -2.6146], [3.913, -3.1126], [3.8517, -1.6747]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[3.8517, -1.6747], [4.5853, -1.9937], [4.1539, -0.6208]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[4.1539, -0.6208], [4.9451, -0.739], [4.173, 0.4755]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[4.173, 0.4755], [4.9679, 0.566], [3.9078, 1.5393]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[3.9078, 1.5393], [4.6521, 1.8325], [3.3762, 2.4983]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[3.3762, 2.4983], [4.0193, 2.9741], [2.6146, 3.287]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[2.6146, 3.287], [3.1126, 3.913], [1.6747, 3.8517]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[1.6747, 3.8517], [1.9937, 4.5853], [0.6208, 4.1539]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[0.6208, 4.1539], [0.739, 4.9451], [-0.4755, 4.173]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[-0.4755, 4.173], [-0.566, 4.9679], [-1.5393, 3.9078]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[-1.5393, 3.9078], [-1.8325, 4.6521], [-2.4983, 3.3762]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[-2.4983, 3.3762], [-2.9741, 4.0193], [-3.287, 2.6146]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[-3.287, 2.6146], [-3.913, 3.1126], [-3.8517, 1.6747]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[-3.8517, 1.6747], [-4.5853, 1.9937], [-4.1539, 0.6208]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[-4.1539, 0.6208], [-4.9451, 0.739], [-4.173, -0.4755]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[-4.173, -0.4755], [-4.9679, -0.566], [-3.9078, -1.5393]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[-3.9078, -1.5393], [-4.6521, -1.8325], [-3.3762, -2.4983]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[-3.3762, -2.4983], [-4.0193, -2.9741], [-2.6146, -3.287]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[-2.6146, -3.287], [-3.1126, -3.913], [-1.6747, -3.8517]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[-1.6747, -3.8517], [-1.9937, -4.5853], [-0.6208, -4.1539]], y: [-0.5, 0.5], collide: 1}
  - id: lever
    shape: part
    pos: [-6.2216, 0, -13.2628]
    friction: 0.1
    color: "#b8ad97"
    pieces:
      - {kind: poly, points: [[-6.1462, -13.7065], [-2.3999, -13.0696], [-2.5507, -12.1823], [-6.297, -12.8192]], y: [-1.6, -1.0], collide: 0}
      - {kind: poly, points: [[-5.7779, -13.1874], [-6.7835, -7.2723], [-7.6708, -7.4231], [-6.6652, -13.3383]], y: [-1.6, -1.0], collide: 0}
      - {kind: disc, center: [-6.2216, -13.2628], radius: 0.9, inner: 0.35, y: [-1.6, -1.0]}
      - {kind: poly, points: [[-2.5206, -12.3598], [0.2398, -11.8905], [0.1728, -11.4962], [-2.5876, -11.9655]], y: [-1.6, -0.2], collide: 2}
      - {kind: poly, points: [[-2.363, -13.2865], [0.3974, -12.8172], [0.3303, -12.4229], [-2.4301, -12.8922]], y: [-1.6, -0.2], collide: 2}
      - {kind: poly, points: [[0.3974, -12.8172], [0.7917, -12.7502], [0.5671, -11.4291], [0.1728, -11.4962]], y: [-1.6, -0.2], collide: 0}
      - {kind: poly, points: [[-2.7574, -13.3535], [-2.363, -13.2865], [-2.5876, -11.9655], [-2.9819, -12.0325]], y: [-1.6, -0.2], collide: 0}
      - {kind: rod, from: [-7.1433, -1.0, -7.8406], to: [-7.1433, 0.5, -7.8406], radius: 0.2, collide: 0, color: "#8f8a80"}
  - id: pawl
    shape: part
    pos: [-7.1433, 0, -7.8406]
    mount: lever
    friction: 0.4
    color: "#6b5a44"
    pieces:
      - {kind: rod, from: [-7.1433, 0, -7.8406], to: [-0.9063, 0, -4.6627], radius: 0.15, capsule: true, collide: 2}
  - id: rod_c
    shape: part
    pos: [-1.2216, 0, -12.4128]
    friction: 0.1
    color: "#8f8a80"
    pieces:
      - {kind: rod, from: [-1.2216, -0.6, -12.4128], to: [-1.2216, 0.5, -12.4128], radius: 0.25, capsule: true, collide: 1}   # the pin in the lever's slot
      - {kind: rod, from: [-1.2216, -0.9, -12.0128], to: [-1.2216, -0.9, -16.1428], radius: 0.3}   # the rod
      - {kind: rod, from: [-1.2216, -0.9, -12.4128], to: [-1.2216, -0.6, -12.4128], radius: 0.3}
      - {kind: poly, points: [[-3.6216, -16.3428], [1.1784, -16.3428], [1.1784, -15.9428], [-3.6216, -15.9428]], y: [-1.2, -0.3], collide: 2}   # the yoke's upper cheek
      - {kind: poly, points: [[-3.6216, -17.2828], [1.1784, -17.2828], [1.1784, -16.8828], [-3.6216, -16.8828]], y: [-1.2, -0.3], collide: 2}   # and lower
      - {kind: poly, points: [[-4.0216, -17.2828], [-3.6216, -17.2828], [-3.6216, -15.9428], [-4.0216, -15.9428]], y: [-1.2, -0.3]}
      - {kind: poly, points: [[1.1784, -17.2828], [1.5784, -17.2828], [1.5784, -15.9428], [1.1784, -15.9428]], y: [-1.2, -0.3]}
  - id: crank
    shape: part
    pos: [-1.2216, 0, -17.4628]
    color: "#a39d90"
    pieces:
      - {kind: disc, center: [-1.2216, -17.4628], radius: 1.75, y: [-0.2, 0.8]}   # the crank disc, behind the yoke
      - {kind: rod, from: [-1.2216, -1.3, -16.6128], to: [-1.2216, -0.2, -16.6128], radius: 0.25, capsule: true, collide: 1}   # its pin, in the yoke
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#cfc6b4"
    pieces:
      - {kind: rod, from: [0, -0.8, 0], to: [0, 2.2, 0], radius: 0.6, color: "#8f8a80"}
      - {kind: poly, points: [[-1, -20.4628], [1, -20.4628], [0.8, 0], [-0.8, 0]], y: [1.4, 2.2]}   # A's standard
      - {kind: rod, from: [-6.2216, -2.4, -13.2628], to: [-6.2216, -1.0, -13.2628], radius: 0.35, color: "#8f8a80"}   # the fulcrum
      - {kind: poly, points: [[-7.2216, -13.7628], [-5.2216, -13.7628], [-5.2216, -20.4628], [-7.2216, -20.4628]], y: [-2.4, -1.8]}   # its standard, in front
      - {kind: poly, points: [[-1.7216, -20.4628], [-0.7216, -20.4628], [-0.7216, -17.4628], [-1.7216, -17.4628]], y: [0.8, 1.6]}   # the crank's standard
      - {kind: rod, from: [-1.2216, 0.8, -17.4628], to: [-1.2216, -0.2, -17.4628], radius: 0.35, color: "#8f8a80"}
      - {kind: poly, points: [[-2.2216, -14.8628], [-0.2216, -14.8628], [-0.2216, -15.2628], [-2.2216, -15.2628]], y: [-1.5, -1.25]}   # C's guide
      - {kind: poly, points: [[-9, -21.4628], [2.7784, -21.4628], [2.7784, -20.4628], [-9, -20.4628]], y: [-3, 3], color: "#b9b09c"}
joints:
  - {id: j_k, type: hinge, body: crank, axis: [0, -1, 0], damping: 0.0005}   # the one driven joint
  - {id: j_c, type: slide, body: rod_c, axis: [0, 0, 1], damping: 0.05}
  - {id: j_l, type: hinge, body: lever, axis: [0, -1, 0], damping: 0.0005}   # the elbow-lever; + : arm 2 swings to the left, against the clock
  - {id: j_bp, type: hinge, body: pawl, axis: [0, -1, 0], damping: 0.0002, range: [-0.6, 0.3], stiffness: 0.01, springref: 0.25}   # sprung onto the teeth
  - {id: j_a, type: hinge, body: wheel_a, axis: [0, -1, 0], damping: 0.002, frictionloss: 0.01}
contact: {solref: [0.002, 1.0], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_k, kind: velocity, rpm: 30, kv: 2.0, max_torque: 20}
checks:
  - {type: ratio, out: j_a, in: j_k, expect: 0.0417, tol: 0.0012, settle_s: 2.0, window_s: 8.0}   # a tooth a turn of the crank
  - {type: monotonic, joint: j_a, direction: 1, max_back: 0.02, settle_s: 0.5, window_s: 11}   # a ratchet: A never goes back
  - {type: clicks, joint: j_bp, lift: 0.08, min: 4, settle_s: 1.0, window_s: 10.0}   # the pawl rides over a tooth every up-stroke
  - {type: penetration, max: 0.001, settle_s: 0.5}
camera: {target: [-1.6108, 0, -12.7314], position: [-1.6108, -66.0, -12.7314], fov: 34}
display:
  output: j_a
  labels: {j_k: "Crank (driver)", j_c: "Rod C", j_l: "Elbow-lever", j_bp: "Pawl", j_a: "Toothed wheel A"}
  proof: {label: "Slot out of contact", sub: "the rod slides but the lever stays: A never moves"}

