# No. 168 (Brown 1868): "The slotted crank at the left hand of the figure is on the main shaft of an engine, and the pitman which connects it with the reciprocating moving power is furnished with a pin which works in the slot of the crank. Intermediate between the first crank and the moving power is a shaft carrying a second crank, of an invariable radius, connected with the same pitman. While the first crank moves in a circular orbit, the pin at the end of the pitman is compelled to move in an elliptical orbit, thereby increasing the leverage of the main crank at those points which are most favorable for the transmission of power."
#
# Model (cm, no gravity; a plan): the slotted main crank (the one driven joint, 20 turns a minute, clockwise in the view) carries the pin of the pitman in its slot (1.44 cm wide, by real contact). The pitman, 14.61 cm long, is also pinned to the second crank of
# invariable radius (3.11 cm) on its own shaft 5.1 cm from the main shaft, and its far end works the reciprocating moving power, drawn as a slide in fixed guides. The pin runs 2.7 to 6.2 cm from the main shaft (the slot's length) as the cranks go round,
# the second crank turns once to each turn of the first, and the slide goes 6.2 cm. Generator: opencode-runs/batch11/gen168.py.
number: 168
slug: slotted-crank-pitman-second-crank
name: A slotted crank and a second crank working one pitman
brown: "The slotted crank at the left hand of the figure is on the main shaft of an engine, and the pitman which connects it with the reciprocating moving power is furnished with a pin which works in the slot of the crank. Intermediate between the first crank and the moving power is a shaft carrying a second crank, of an invariable radius, connected with the same pitman. While the first crank moves in a circular orbit, the pin at the end of the pitman is compelled to move in an elliptical orbit, thereby increasing the leverage of the main crank at those points which are most favorable for the transmission of power."
units: cm
sim:
  timestep: 0.0002
  integrator: implicitfast
  iterations: 100
  solver: PGS
  multiccd: true
  duration_s: 9.0
  floor: false
  gravity: 0
bodies:
  - id: crank
    shape: part
    pos: [0, 0, 0]
    mass: 0.3
    friction: 0.05
    color: "#d9cfb6"
    pieces:
      - {kind: poly, points: [[-1.22, -1.0], [1.22, -1.0], [1.22, 1.3439], [-1.22, 1.3439]], y: [-1.2, -0.4], collide: 2, color: "#d9cfb6"}
      - {kind: poly, points: [[0.72, 1.3439], [0.72, 7.5995], [1.22, 7.5995], [1.22, 1.3439]], y: [-1.2, -0.4], collide: 2, color: "#d9cfb6"}
      - {kind: poly, points: [[-0.72, 1.3439], [-0.72, 7.5995], [-1.22, 7.5995], [-1.22, 1.3439]], y: [-1.2, -0.4], collide: 2, color: "#d9cfb6"}
      - {kind: poly, points: [[-1.22, 7.5995], [1.22, 7.5995], [1.22, 8.0995], [-1.22, 8.0995]], y: [-1.2, -0.4], collide: 2, color: "#d9cfb6"}
      - {kind: rod, from: [0, -0.5, 0], to: [0, 1.5, 0], radius: 1.1, collide: 0, color: "#8f8a80"}
  - id: slide
    shape: part
    pos: [14.0017, 0, -0.72]
    mass: 0.3
    color: "#cfc6b4"
    pieces:
      - {kind: rod, from: [12.8017, -2.3, -0.72], to: [21.0017, -2.3, -0.72], radius: 0.7, collide: 0, color: "#a89a7e"}   # the moving-power rod
      - {kind: poly, points: [[12.8017, -1.92], [15.2017, -1.92], [15.2017, 0.48], [12.8017, 0.48]], y: [-2.9, -1.7], collide: 0}
  - id: pitman
    shape: part
    pos: [14.0017, 0, -0.72]
    mount: slide
    mass: 0.4
    friction: 0.05
    color: "#a89a7e"
    pieces:
      - {kind: rod, from: [0.0, -1.7, 3.4517], to: [14.0017, -1.7, -0.72], radius: 0.5, collide: 0, color: "#a89a7e"}
      - {kind: rod, from: [0.0, -1.7, 3.4517], to: [0.0, -0.3, 3.4517], radius: 0.6, collide: 1, capsule: true, color: "#8f8a80"}   # the pitman's pin, in the slot
      - {kind: rod, from: [14.0017, -2.4, -0.72], to: [14.0017, -1.5, -0.72], radius: 0.6, collide: 0, color: "#8f8a80"}
      - {kind: rod, from: [4.9739, -2.6, 1.9698], to: [4.9739, -1.5, 1.9698], radius: 0.55, collide: 0, color: "#8f8a80"}
  - id: crank2
    shape: part
    pos: [5.01, 0, -1.14]
    mass: 0.25
    color: "#d9cfb6"
    pieces:
      - {kind: rod, from: [5.01, -2.3, -1.14], to: [4.9739, -2.3, 1.9698], radius: 0.6, collide: 0, color: "#a89a7e"}
      - {kind: rod, from: [5.01, -2.0, -1.14], to: [5.01, 1.5, -1.14], radius: 1.1, collide: 0, color: "#8f8a80"}
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#cfc6b4"
    pieces:
      - {kind: poly, points: [[-1.4, -9], [1.4, -9], [1.0, 0], [-1.0, 0]], y: [1.8, 2.8], collide: 0}   # the main shaft's standard, behind
      - {kind: poly, points: [[3.61, -8.14], [6.41, -8.14], [6.01, -1.14], [4.01, -1.14]], y: [1.8, 2.8], collide: 0}   # and the second shaft's
      - {kind: poly, points: [[8.0017, -3.12], [28.0017, -3.12], [28.0017, -2.12], [8.0017, -2.12]], y: [-3.4, -1.4], collide: 0, color: "#b9b09c"}   # the guides
      - {kind: poly, points: [[8.0017, 0.6799999999999999], [28.0017, 0.6799999999999999], [28.0017, 1.68], [8.0017, 1.68]], y: [-3.4, -1.4], collide: 0, color: "#b9b09c"}
      - {kind: poly, points: [[-15, -10.4], [29.0017, -10.4], [29.0017, -9.4], [-15, -9.4]], y: [-3, 3], collide: 0, color: "#b9b09c"}
joints:
  - {id: j_s, type: hinge, body: crank, axis: [0, 1, 0], damping: 0.002}   # the one driven joint: the slotted main crank; + : clockwise
  - {id: j_e, type: slide, body: slide, axis: [1, 0, 0], damping: 0.05}   # the moving power's rod in its guides; + : to the right
  - {id: j_p, type: hinge, body: pitman, axis: [0, 1, 0], damping: 0.002}
  - {id: j_2, type: hinge, body: crank2, axis: [0, 1, 0], damping: 0.002}   # the second crank; + : clockwise
pins:
  - {"id": "pin_q", "a": "crank2", "b": "pitman", "at": [4.9739, 0, 1.9698]}
contact: {solref: [0.002, 1.0], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_s, kind: velocity, rpm: 20, kv: 2.0, max_torque: 20}
checks:
  - {type: follow, out: j_e, in: j_s, expect: -0.0591, tol: 0.0047, min_r2: 0.99, settle_s: 1.3333, window_s: 0.2917}
  - {type: follow, out: j_2, in: j_s, expect: 1.9441, tol: 0.1555, min_r2: 0.99, settle_s: 1.3333, window_s: 0.2917}
  - {type: follow, out: j_e, in: j_s, expect: 0.0316, tol: 0.0025, min_r2: 0.99, settle_s: 2.7917, window_s: 0.3333}
  - {type: follow, out: j_2, in: j_s, expect: 1.0631, tol: 0.085, min_r2: 0.99, settle_s: 2.7917, window_s: 0.3333}
  - {type: follow, out: j_e, in: j_s, expect: -0.0591, tol: 0.0047, min_r2: 0.99, settle_s: 4.3333, window_s: 0.2917}
  - {type: follow, out: j_2, in: j_s, expect: 1.9441, tol: 0.1555, min_r2: 0.99, settle_s: 4.3333, window_s: 0.2917}
  - {type: follow, out: j_e, in: j_s, expect: 0.0316, tol: 0.0025, min_r2: 0.99, settle_s: 5.7917, window_s: 0.3333}
  - {type: follow, out: j_2, in: j_s, expect: 1.0631, tol: 0.085, min_r2: 0.99, settle_s: 5.7917, window_s: 0.3333}
  - {type: position, joint: j_e, min: -2.9957, max: 3.8312, settle_s: 0.0, window_s: 8.5}
  - {type: penetration, max: 0.003, settle_s: 0.5}
camera: {target: [3.0, 0, -4.0], position: [3.0, -52.0, -4.0], fov: 34}
display:
  output: j_e
  labels: {j_s: "Slotted crank (driver)", j_e: "Moving power (slide)", j_p: "Pitman", j_2: "Second crank"}

