# No. 305 (Brown 1868): "A single-pin pendulum escapement. The escape-wheel is a very small disk with single eccentric pin; it makes half a revolution for every beat of the pendulum, giving the impulse on the upright faces of the pallets, the horizontal faces of which are dead ones. This can also be adapted to watches."
#
# Model (cm, gravity on). The escape-wheel is a little disc on an axis along y at the origin, with one pin at r 1, turned clockwise by a constant torque (the weight).
# The pendulum hangs from a pivot 6 above it; on the pendulum, round the disc, is a frame with two pallets. The upper pallet's top face is dead: the pin, coming over
# the top, comes down on it 40 degrees past the top and rests there while the pendulum swings on (the face slides under it, square to the pin's push).
# When the pendulum, coming back, carries the face's left end past the pin, the pin drops off and drives the pallet's upright left face before it, to the right: the
# impulse. The pin runs on round and comes up under the lower pallet (the same turned half round), rests on its dead under face, and drives its upright right face to the
# left. At rest the dead faces stop just short of the pin, so the pin falls on an impulse face and sets the pendulum going by itself; once swinging, the
# pin lands on a dead face each half turn. Half a turn a beat. The only input is the torque on the disc; the pendulum is kept going only by the pin. Generator: opencode-runs/batch12/gen305.py.
number: 305
slug: single-pin-escapement
name: A single-pin pendulum escapement
brown: "A single-pin pendulum escapement. The escape-wheel is a very small disk with single eccentric pin; it makes half a revolution for every beat of the pendulum, giving the impulse on the upright faces of the pallets, the horizontal faces of which are dead ones. This can also be adapted to watches."
units: cm
sim: {timestep: 0.0002, integrator: implicitfast, iterations: 50, duration_s: 10, floor: false}
bodies:
  - id: disc
    shape: part
    pos: [0, 0, 0]
    mass: 0.01
    friction: 0.1
    color: "#e6d7b0"
    pieces:
      - {kind: disc, center: [0, 0], radius: 1.35, y: [-0.1, 0.1]}   # the little disc
      - {kind: disc, center: [0, 0], radius: 0.2, y: [-0.15, 0.6], color: "#8f8a80"}   # its arbor
      - {kind: disc, center: [0, 1.0], radius: 0.15, y: [-0.6, -0.1], collide: 2, color: "#5c5348"}   # the pin
  - id: pendulum
    shape: part
    pos: [0, 0, 6.0]
    friction: 0.1
    color: "#9aa3ad"
    pieces:
      - {kind: poly, points: [[0.94279, 0.6604], [1.13566, 0.69807], [1.13566, 0.54807], [0.94279, 0.5104]], y: [-0.6, -0.15], collide: 1, color: "#b85c38"}   # the upper pallet: dead face on top, impulse face at its left end
      - {kind: poly, points: [[1.13566, 0.69807], [1.32853, 0.74308], [1.32853, 0.59308], [1.13566, 0.54807]], y: [-0.6, -0.15], collide: 1, color: "#b85c38"}
      - {kind: poly, points: [[1.32853, 0.74308], [1.52139, 0.79563], [1.52139, 0.64563], [1.32853, 0.59308]], y: [-0.6, -0.15], collide: 1, color: "#b85c38"}
      - {kind: poly, points: [[1.52139, 0.79563], [1.71426, 0.85593], [1.71426, 0.70593], [1.52139, 0.64563]], y: [-0.6, -0.15], collide: 1, color: "#b85c38"}
      - {kind: poly, points: [[1.71426, 0.85593], [1.90713, 0.92427], [1.90713, 0.77427], [1.71426, 0.70593]], y: [-0.6, -0.15], collide: 1, color: "#b85c38"}
      - {kind: poly, points: [[1.90713, 0.92427], [2.1, 1.00098], [2.1, 0.85098], [1.90713, 0.77427]], y: [-0.6, -0.15], collide: 1, color: "#b85c38"}
      - {kind: poly, points: [[-0.94279, -0.43], [-2.1, -0.15676], [-2.1, -0.30676], [-1.90713, -0.36774], [-1.71426, -0.42235], [-1.52139, -0.47075], [-1.32853, -0.51308], [-1.13566, -0.54947], [-0.94279, -0.58]], y: [-0.6, -0.15], collide: 1, color: "#b85c38"}   # the lower pallet: dead face underneath, impulse face at its right end
      - {kind: poly, points: [[2.1, -0.91604], [2.4, -0.91604], [2.4, 0.61604], [2.1, 0.61604]], y: [-0.6, -0.15]}   # the frame's right side
      - {kind: poly, points: [[-2.4, -0.91604], [-2.1, -0.91604], [-2.1, 0.61604], [-2.4, 0.61604]], y: [-0.6, -0.15]}   # the frame's left side
      - {kind: poly, points: [[-2.4, -0.91604], [2.4, -0.91604], [2.4, -1.21604], [-2.4, -1.21604]], y: [-0.6, -0.15]}   # the frame's foot
      - {kind: poly, points: [[-2.4, 0.61604], [-2.1, 0.61604], [0.15, 5.4], [-0.15, 5.4]], y: [-0.6, -0.15]}   # a stay to the pivot
      - {kind: poly, points: [[2.1, 0.61604], [2.4, 0.61604], [0.15, 5.4], [-0.15, 5.4]], y: [-0.6, -0.15]}   # and the other
      - {kind: disc, center: [0, 6.0], radius: 0.7, y: [-0.7, 1.2]}   # the pendulum's boss
      - {kind: rod, from: [0, 1.0, 6.0], to: [0.0, 1.0, -4.4], radius: 0.2, color: "#8f8a80"}   # the pendulum rod, behind the disc
      - {kind: disc, center: [0.0, -6.0], radius: 1.8, y: [0.7, 1.3], density: 60000.0, color: "#e6d7b0"}   # the bob
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#cfc6b4"
    pieces:
      - {kind: disc, center: [0, 6.0], radius: 0.3, y: [-0.9, 1.4], color: "#5c5348"}   # the pendulum's pin
      - {kind: poly, points: [[-0.6, -0.6], [0.6, -0.6], [0.6, 0.6], [-0.6, 0.6]], y: [0.6, 0.8]}   # the cock behind the disc
joints:
  - {id: j_disc, type: hinge, body: disc, axis: [0, 1, 0], damping: 0.0001}   # the escape-disc; + : clockwise (its way)
  - {id: j_pend, type: hinge, body: pendulum, axis: [0, 1, 0], damping: 0.002}   # the pendulum; + : clockwise
contact: {solref: [0.002, 1], solimp: [0.95, 0.99, 0.0005], margin: 0}
# The weight: a constant torque on the disc, clockwise. Nothing else is driven.
driver: {joint: j_disc, kind: torque, torque: 0.003, max_torque: 1}
checks:
  - {type: period, joint: j_pend, tol: 0.04, settle_s: 3, window_s: 6}
  # half a turn a beat
  - {type: advance, joint: j_disc, beat: j_pend, expect: 3.14159, tol: 0.03, settle_s: 3, window_s: 6.7}
  # dead faces: the disc stands while the pin rests on one, never turning back beyond contact compliance
  - {type: monotonic, joint: j_disc, direction: 1, max_back: 0.04, settle_s: 2, window_s: 7}
  - {type: amplitude, joint: j_pend, min: 0.05, max: 0.2, sustain: 0.9, settle_s: 3, window_s: 6}
  - {type: penetration, max: 0.0005, settle_s: 1}
camera: {target: [0, 0, 0.6], position: [0, -17.0, 0.6], fov: 30}
display:
  output: j_pend
  swing: j_pend
  labels: {j_disc: "Pin disc (weight)", j_pend: "Pendulum and pallets"}
  proof: {label: "Pallets out of contact", sub: "nothing makes good the pendulum's losses, so its swing dies away, and the weight spins the disc freely"}

