number: 360
slug: beam-drum-pawl-ratchet
name: Continuous rotary motion from an oscillating beam
brown: "Continuous rotary motion from oscillating. The beam being made to vibrate, the drum to which the cord is attached, working loose on fly-wheel shaft, gives motion to said shaft through the pawl and ratchet-wheel, the pawl being attached to drum and the ratchet-wheel fast on shaft."
units: cm
sim: {timestep: 0.0001, integrator: implicitfast, iterations: 80, solver: PGS, multiccd: false, duration_s: 10.0, floor: false}
bodies:
  # the fly-wheel shaft: the ratchet-wheel and the fly-wheel, fast on it
  - id: shaft
    shape: part
    pos: [0, 0, 0]
    friction: 0.1
    color: "#d9cfb6"
    pieces:
      - {kind: disc, center: [0, 0], radius: 7.0, inner: 0.6, y: [-0.5, 0.5]}
      - {kind: poly, points: [[0.4073, 6.888], [-1.1984, 7.9097], [-1.0337, 6.8221]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[-1.0337, 6.8221], [-2.8168, 7.4877], [-2.4295, 6.4581]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[-2.4295, 6.4581], [-4.312, 6.7384], [-3.7191, 5.8119]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[-3.7191, 5.8119], [-5.6188, 5.6947], [-4.8462, 4.9117]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[-4.8462, 4.9117], [-6.68, 4.402], [-5.7615, 3.7967]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[-5.7615, 3.7967], [-7.4492, 2.917], [-6.425, 2.5159]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[-6.425, 2.5159], [-7.8929, 1.3044], [-6.8077, 1.1251]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[-6.8077, 1.1251], [-7.9917, -0.3651], [-6.8928, -0.3149]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[-6.8928, -0.3149], [-7.7411, -2.0187], [-6.6767, -1.7411]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[-6.6767, -1.7411], [-7.1523, -3.584], [-6.1688, -3.0912]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[-6.1688, -3.0912], [-6.2508, -4.9927], [-5.3913, -4.3062]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[-5.3913, -4.3062], [-5.0762, -6.1833], [-4.3782, -5.3331]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[-4.3782, -5.3331], [-3.6797, -7.1035], [-3.1737, -6.1268]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[-3.1737, -6.1268], [-2.1223, -7.7133], [-1.8305, -6.6528]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[-1.8305, -6.6528], [-0.4723, -7.986], [-0.4073, -6.888]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[-0.4073, -6.888], [1.1984, -7.9097], [1.0337, -6.8221]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[1.0337, -6.8221], [2.8168, -7.4877], [2.4295, -6.4581]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[2.4295, -6.4581], [4.312, -6.7384], [3.7191, -5.8119]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[3.7191, -5.8119], [5.6188, -5.6947], [4.8462, -4.9117]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[4.8462, -4.9117], [6.68, -4.402], [5.7615, -3.7967]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[5.7615, -3.7967], [7.4492, -2.917], [6.425, -2.5159]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[6.425, -2.5159], [7.8929, -1.3044], [6.8077, -1.1251]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[6.8077, -1.1251], [7.9917, 0.3651], [6.8928, 0.3149]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[6.8928, 0.3149], [7.7411, 2.0187], [6.6767, 1.7411]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[6.6767, 1.7411], [7.1523, 3.584], [6.1688, 3.0912]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[6.1688, 3.0912], [6.2508, 4.9927], [5.3913, 4.3062]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[5.3913, 4.3062], [5.0762, 6.1833], [4.3782, 5.3331]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[4.3782, 5.3331], [3.6797, 7.1035], [3.1737, 6.1268]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[3.1737, 6.1268], [2.1223, 7.7133], [1.8305, 6.6528]], y: [-0.5, 0.5], collide: 1}
      - {kind: poly, points: [[1.8305, 6.6528], [0.4723, 7.986], [0.4073, 6.888]], y: [-0.5, 0.5], collide: 1}
      - {kind: rod, from: [0, -5.0, 0], to: [0, 6.5, 0], radius: 0.6, collide: 0, color: "#8f8a80"}
      - {kind: disc, center: [0, 0], radius: 24.0, inner: 22.4, y: [2.6, 3.8], collide: 0, density: 3700, color: "#9a917f"}
      - {kind: disc, center: [0, 0], radius: 1.8, inner: 0.6, y: [2.4, 4.0], collide: 0, color: "#9a917f"}
      - {kind: rod, from: [1.433, 3.2, 0.4433], to: [21.5906, 3.2, 6.6787], radius: 0.45, collide: 0}
      - {kind: rod, from: [0.3326, 3.2, 1.4627], to: [5.0113, 3.2, 22.0374], radius: 0.45, collide: 0}
      - {kind: rod, from: [-1.1004, 3.2, 1.0194], to: [-16.5793, 3.2, 15.3587], radius: 0.45, collide: 0}
      - {kind: rod, from: [-1.433, 3.2, -0.4433], to: [-21.5906, 3.2, -6.6787], radius: 0.45, collide: 0}
      - {kind: rod, from: [-0.3326, 3.2, -1.4627], to: [-5.0113, 3.2, -22.0374], radius: 0.45, collide: 0}
      - {kind: rod, from: [1.1004, 3.2, -1.0194], to: [16.5793, 3.2, -15.3587], radius: 0.45, collide: 0}
  # the drum, loose on the shaft, and the arm on its back that carries the pawl
  - {id: drum, shape: assembly, pos: [0, 0, 0], color: "#c9b48a"}
  - id: drum_arm
    shape: part
    pos: [0, 0, 0]
    mount: drum
    friction: 0.1
    color: "#b8ad97"
    pieces:
      - {kind: poly, points: [[0.9858, -0.4453], [-0.0319, -1.0812], [-6.1472, 8.894], [-5.2991, 9.4239]], y: [-1.6, -1.0]}
      - {kind: disc, center: [0, 0], radius: 1.3, inner: 0.6, y: [-2.0, -0.8]}
      - {kind: disc, center: [-5.4052, 8.6501], radius: 0.65, y: [-1.6, -1.0]}
      - {kind: rod, from: [-5.4052, -1.0, 8.6501], to: [-5.4052, 0.6, 8.6501], radius: 0.18, color: "#8f8a80"}
  - id: pawl
    shape: part
    pos: [-5.4052, 0, 8.6501]
    mount: drum_arm
    friction: 0.1
    color: "#6b5a44"
    pieces:
      - {kind: disc, center: [-5.4052, 8.6501], radius: 0.45, inner: 0.18, y: [-0.4, 0.4], collide: 0}
      - {kind: rod, from: [-5.4052, 0, 8.6501], to: [-1.9605, 0, 7.5498], radius: 0.3, collide: 0}
      - {kind: rod, from: [-1.9605, 0, 7.5498], to: [-1.2937, 0, 7.3368], radius: 0.15, capsule: true, collide: 2}
  # the beam
  - id: beam
    shape: part
    pos: [-28.3, 0, 18.0]
    mass: 1.5
    color: "#a8884f"
    pieces:
      - {kind: poly, points: [[-36.3, 17.1], [-3.0999999999999996, 17.3], [-3.0999999999999996, 18.7], [-36.3, 18.9]], y: [-3.8, -2.2], collide: 0}
      - {kind: disc, center: [-28.3, 18.0], radius: 1.4, inner: 0.4, y: [-3.9, -2.1], collide: 0}
      - {kind: rod, from: [-4.3, -3.9, 18.0], to: [-4.3, -2.1, 18.0], radius: 0.3, collide: 0, color: "#6f6a60"}
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#cfc6b4"
    pieces:
      - {kind: poly, points: [[-1.6, -26], [1.6, -26], [0.9, 0], [-0.9, 0]], y: [5.0, 6.5]}
      - {kind: poly, points: [[-1.6, -26], [1.6, -26], [0.9, 0], [-0.9, 0]], y: [-6.5, -5.0]}
      - {kind: poly, points: [[-29.9, -26], [-26.7, -26], [-27.400000000000002, 18.0], [-29.2, 18.0]], y: [-1.6, -0.6]}
      - {kind: rod, from: [-28.3, -2.1, 18.0], to: [-28.3, -0.6, 18.0], radius: 0.4, color: "#8f8a80"}
      - {kind: poly, points: [[-38.3, -27.2], [27, -27.2], [27, -26], [-38.3, -26]], y: [-7, 7], color: "#b9b09c"}
joints:
  - {id: j_beam, type: hinge, body: beam, axis: [0, -1, 0], damping: 0.01}   # the one driven joint; + : its end over the drum up
  - {id: j_d, type: hinge, body: drum, axis: [0, -1, 0], damping: 0.002, stiffness: 0.5, springref: 1.2}   # the drum's spring winds the cord back (counter-clockwise)
  - {id: j_da, type: hinge, body: drum_arm, axis: [0, -1, 0]}
  - {id: j_pawl, type: hinge, body: pawl, axis: [0, -1, 0], damping: 0.0002, stiffness: 0.02, springref: -0.2, range: [-0.6, 0.6]}   # a light spring keeps the pawl to the teeth
  - {id: j_s, type: hinge, body: shaft, axis: [0, -1, 0], damping: 0.004, frictionloss: 0.005}   # + : counter-clockwise; driven clockwise
wheels:
  - {id: drum_rim, body: drum, pos: [0, -3.0, 0], radius: 4.0, width: 1.6, rim_width: 1.2, mass: 0.3, spokes: 0, hub: 1.0, flange: 0.6}
pins:
  - {id: arm_pin, a: drum, b: drum_arm, at: [0, -1.3, 2.0]}   # the arm is the drum's own
cords:
  - id: cord
    from: {body: beam, at: [-4.3, -3.0, 18.0]}
    to: {body: drum, at: [3.7681, -3.0, -2.6385]}
    over: [drum_rim]
    under: [drum_rim]
    links: 70
    thickness: 0.6
    density: 1400
    stiffness: 40000.0
    pretension: 13.9535
    damping: 12.0
    friction: 0.5
contact: {solref: [0.002, 1.0], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_beam, kind: velocity, rpm: 0, swing: {amplitude: 0.085, hz: 0.5}, kv: 5000, max_torque: 200}
checks:
  - {type: turning, joint: j_s, direction: -1, min_mean: 0.3, slow: 0.5, min_fraction: 0.9, settle_s: 4.0, window_s: 5.8}
  - {type: monotonic, joint: j_s, direction: -1, max_back: 0.03, settle_s: 1.0, window_s: 8.8}
  - {type: penetration, max: 0.001, settle_s: 0.5}
camera: {target: [-6, 0, -2], position: [-6, -205, 2], fov: 30}
display:
  output: j_s
  labels: {j_beam: "Beam (driver)", j_d: Drum, j_pawl: Pawl, j_s: "Fly-wheel shaft"}

