# No. 63 (Brown 1868): "Jumping or intermittent rotary motion, used for meters and revolution-counters."
#
# As drawn (cm; the drawing plane is x-z, depth y): the star-wheel (12 points) at the left; the disk
# at the right (the one motor-driven shaft) with three pins; the drop, a lever pivoted above at the
# left and pressed down by its spring (the joint's spring), reaching over to the disk; and the pawl,
# hung from a pin in the drop, its own light spring keeping its point in the star-wheel. A pin lifts
# the drop, and with it the pawl, whose point rides up over the next point of the star-wheel and drops
# into the next space. When the pin escapes from the drop's nose, the spring throws the drop down
# suddenly, and the pawl drives the star-wheel round by one space: a jump for each pin.
# Generator: opencode-runs/batch7/gen063.py.
number: 63
slug: jumping-star-wheel
name: Jumping motion by a drop, pawl and star-wheel
brown: "Jumping or intermittent rotary motion, used for meters and revolution-counters. The drop and attached pawl, carried by a spring at the left, are lifted by pins in the disk at the right. Pins escape first from pawl, which drops into next space of the star-wheel. When pin escapes from drop, spring throws down suddenly the drop, the pin on which strikes the pawl, which, by its action on star-wheel, rapidly gives it a portion of a revolution. This is repeated as each pin passes."
units: cm
sim:
  timestep: 0.0002
  integrator: implicitfast
  iterations: 100
  solver: PGS
  multiccd: true
  duration_s: 16
  floor: false
bodies:
  - id: star
    shape: part
    pos: [0, 0, 0]
    friction: 0.2
    color: "#e8dec6"
    pieces:
      - {kind: disc, center: [0, 0], radius: 0.8, y: [-0.6, 0.6], color: "#8f8a80"}
      - {kind: poly, points: [[2.6, 0.0], [3.8637, 1.0353], [2.2517, 1.3], [0, 0]], y: [-0.5, 0.5], collide: 2}
      - {kind: poly, points: [[2.2517, 1.3], [2.8284, 2.8284], [1.3, 2.2517], [0, 0]], y: [-0.5, 0.5], collide: 2}
      - {kind: poly, points: [[1.3, 2.2517], [1.0353, 3.8637], [0.0, 2.6], [0, 0]], y: [-0.5, 0.5], collide: 2}
      - {kind: poly, points: [[-0.0, 2.6], [-1.0353, 3.8637], [-1.3, 2.2517], [0, 0]], y: [-0.5, 0.5], collide: 2}
      - {kind: poly, points: [[-1.3, 2.2517], [-2.8284, 2.8284], [-2.2517, 1.3], [0, 0]], y: [-0.5, 0.5], collide: 2}
      - {kind: poly, points: [[-2.2517, 1.3], [-3.8637, 1.0353], [-2.6, 0.0], [0, 0]], y: [-0.5, 0.5], collide: 2}
      - {kind: poly, points: [[-2.6, 0.0], [-3.8637, -1.0353], [-2.2517, -1.3], [0, 0]], y: [-0.5, 0.5], collide: 2}
      - {kind: poly, points: [[-2.2517, -1.3], [-2.8284, -2.8284], [-1.3, -2.2517], [0, 0]], y: [-0.5, 0.5], collide: 2}
      - {kind: poly, points: [[-1.3, -2.2517], [-1.0353, -3.8637], [-0.0, -2.6], [0, 0]], y: [-0.5, 0.5], collide: 2}
      - {kind: poly, points: [[-0.0, -2.6], [1.0353, -3.8637], [1.3, -2.2517], [0, 0]], y: [-0.5, 0.5], collide: 2}
      - {kind: poly, points: [[1.3, -2.2517], [2.8284, -2.8284], [2.2517, -1.3], [0, 0]], y: [-0.5, 0.5], collide: 2}
      - {kind: poly, points: [[2.2517, -1.3], [3.8637, -1.0353], [2.6, -0.0], [0, 0]], y: [-0.5, 0.5], collide: 2}
  - id: disk
    shape: part
    pos: [7.5, 0, 4.0]
    friction: 0.1
    color: "#e4d9bf"
    pieces:
      - {kind: disc, center: [7.5, 4.0], radius: 4.9, y: [2.0, 2.6]}   # the disk, behind its pins
      - {kind: disc, center: [7.5, 4.0], radius: 3.0, y: [2.6, 4.0], color: "#9c958a"}   # a pulley behind it (inertia for the drive)
      - {kind: rod, from: [9.5602, 0.8, 7.4287], to: [9.5602, 2.0, 7.4287], radius: 0.4, capsule: true, collide: 1, color: "#6b5a44"}
      - {kind: rod, from: [9.4392, 0.8, 0.5015], to: [9.4392, 2.0, 0.5015], radius: 0.4, capsule: true, collide: 1, color: "#6b5a44"}
      - {kind: rod, from: [3.5006, 0.8, 4.0698], to: [3.5006, 2.0, 4.0698], radius: 0.4, capsule: true, collide: 1, color: "#6b5a44"}
  - id: drop
    shape: part
    pos: [-7.0, 1.4, 5.0]
    friction: 0.1
    mass: 0.25
    color: "#cfc4ad"
    pieces:
      - {kind: poly, points: [[-7.0, 4.4], [8.7, 4.7], [8.7, 5.3], [-7.0, 5.6]], y: [1.0, 1.8], collide: 2}   # the drop's bar; its nose over the disk
      - {kind: rod, from: [8.7, 1.0, 5.0], to: [8.7, 1.8, 5.0], radius: 0.3, capsule: true, collide: 2}   # its rounded nose
      - {kind: disc, center: [-7.0, 5.0], radius: 1.0, y: [1.0, 1.8]}
      - {kind: rod, from: [3.45, -0.6, 4.6], to: [3.45, 1.8, 4.6], radius: 0.3, color: "#8f8a80"}   # the pawl's pin
  - id: pawl
    shape: part
    pos: [3.45, 0, 4.6]
    mount: drop
    friction: 0.1
    mass: 0.04
    color: "#b9ab8e"
    pieces:
      - {kind: poly, points: [[3.1, 4.95], [3.8, 4.25], [3.65, -0.2], [3.25, 0.2]], y: [-0.4, 0.4]}   # the pawl
      - {kind: rod, from: [3.45, -0.4, 0.0], to: [3.45, 0.4, 0.0], radius: 0.3, capsule: true, collide: 1}   # its point
  - {id: frame, shape: frame, color: "#8f8a80", rods: [{from: [0, -1.2, 0], to: [0, 1.2, 0], radius: 0.5}, {from: [-7.0, 0.6, 5.0], to: [-7.0, 2.4, 5.0], radius: 0.4}, {from: [7.5, 1.0, 4.0], to: [7.5, 4.6, 4.0], radius: 0.5}]}
joints:
  - {id: j_disk, type: hinge, body: disk, axis: [0, 1, 0], damping: 0.05}
  - {id: j_star, type: hinge, body: star, axis: [0, 1, 0], damping: 0.02, frictionloss: 0.05}   # the arbor's friction holds it between jumps
  - {id: j_drop, type: hinge, body: drop, axis: [0, 1, 0], damping: 0.01, stiffness: 4, springref: 0.4, range: [-0.3, 0.0]}   # the spring at the left: presses the drop down onto its stop
  - {id: j_pawl, type: hinge, body: pawl, axis: [0, 1, 0], damping: 0.002, stiffness: 0.05, springref: 0.15, range: [-0.5, 0.3]}   # the pawl's light spring: its point into the star-wheel
contact: {solref: [0.002, 1.0], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_disk, kind: velocity, rpm: 6, kv: 40, max_torque: 30}
checks:
  - {type: ratio, out: j_star, in: j_disk, expect: 0.25, tol: 0.025, settle_s: 4.6, window_s: 10.0}   # a twelfth of a turn for each of 3 pins
  - {type: monotonic, joint: j_star, direction: 1, max_back: 0.1, settle_s: 0.5, window_s: 15}       # the pawl, riding up over a point, barely drags it back
  - {type: still, joint: j_star, max: 0.05, settle_s: 4.7, window_s: 1.8}                              # it stands while the drop is lifted
  - {type: penetration, max: 0.001, settle_s: 0.5}
camera: {target: [3, 0, 3], position: [3, -60, 8], fov: 34}
display:
  output: j_star
  labels: {j_disk: "Disk with pins (driver)", j_star: "Star-wheel", j_drop: "Drop", j_pawl: "Pawl"}
  proof: {label: "Pawl's point out of contact", sub: "the drop rises and falls, but the star-wheel stands"}
