# No. 160 (Brown 1868): "Alternating curvilinear motion into alternating circular. When the treadle has been depressed, the spring at the top elevates it for the next stroke; the connecting band passes once round the pulley, to which it gives motion."
#
# Model (cm, a plan: no gravity): the treadle, a lever hinged at the left and pressed to and fro by the foot (the one driven joint, a soft drive swinging it +-18 degrees at 0.5 a second), has the band tied to its eye. The band is a real cord: up the right of the 3.5 cm pulley, over its top and down the left to the spring, a block on a sprung slide (30 N/m).
# Nothing but the band's grip turns the pulley: the foot's down-stroke pulls it one way and the spring draws the band back, and the pulley, the other way, as the treadle rises. Generator: opencode-runs/batch11/gen160.py.
number: 160
slug: treadle-spring-band-pulley
name: A treadle with a spring, turning a pulley by a band
brown: "Alternating curvilinear motion into alternating circular. When the treadle has been depressed, the spring at the top elevates it for the next stroke; the connecting band passes once round the pulley, to which it gives motion."
units: cm
sim: {timestep: 0.0001, integrator: implicitfast, iterations: 60, duration_s: 6.5, gravity: 0, floor: false}
bodies:
  - id: wheel
    shape: pulley
    radius: 3.5
    width: 2.4
    pos: [0, 0, 0]
    mass: 0.15
    spokes: 4
    hub: 1.2
    flange: 0.5
    color: "#e6dcc6"
  - id: treadle
    shape: part
    pos: [-8.2, 0, -22.0]
    mass: 0.3
    color: "#a89a7e"
    pieces:
      - {kind: poly, points: [[-8.2, -21.2], [10.8, -21.2], [10.8, -22.8], [-8.2, -22.8]], y: [-0.6, 0.6]}
      - {kind: poly, points: [[7.3, -23.6], [11.8, -23.6], [11.8, -20.4], [7.3, -20.4]], y: [-1.4, 0.6], color: "#b8ad97"}
      - {kind: disc, center: [3.8, -22.0], radius: 0.9, inner: 0.3, y: [-0.5, 0.5]}
      - {kind: disc, center: [-8.2, -22.0], radius: 1.4, y: [-0.9, 0.9], color: "#8f8a80"}
  - id: spring
    shape: part
    pos: [-3.8, 0, -8.0]
    mass: 0.05
    color: "#b8ad97"
    pieces:
      - {kind: poly, points: [[-4.7, -8.8], [-2.9, -8.8], [-2.9, -7.2], [-4.7, -7.2]], y: [-0.5, 0.5], color: "#b8ad97"}
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#cfc6b4"
    pieces:
      - {kind: rod, from: [0, 1.2, 0], to: [0, 4.0, 0], radius: 0.8, color: "#8f8a80"}
      - {kind: poly, points: [[-2.0, -2.0], [2.0, -2.0], [2.0, 2.0], [-2.0, 2.0]], y: [3.4, 4.2]}
      - {kind: poly, points: [[-9.2, -28.5], [15.8, -28.5], [15.8, -27.5], [-9.2, -27.5]], y: [-2.5, 3.0], color: "#b9b09c"}
      - {kind: poly, points: [[-9.1, -27.5], [-7.3, -27.5], [-7.3, -23.0], [-9.1, -23.0]], y: [0.9, 1.9], color: "#cfc6b4"}
      - {kind: poly, points: [[-9.8, -22.0], [-8.8, -22.0], [-8.8, -5.0], [-9.8, -5.0]], y: [0.9, 1.9], color: "#cfc6b4"}
joints:
  - {id: j_p, type: hinge, body: wheel, axis: [0, 1, 0], damping: 0.0005}   # the pulley; + : clockwise
  - {id: j_t, type: hinge, body: treadle, axis: [0, 1, 0], damping: 0.0002}   # the treadle (the one driven joint); + : clockwise, the foot end goes down
  - {id: j_s, type: slide, body: spring, axis: [0, 0, 1], range: [-6, 6], stiffness: 30.0, springref: -12.0, damping: 0.3}   # the spring's block: + up
cords:
  - id: band
    from: {body: treadle, at: [3.8, 0, -22.0]}
    to: {body: spring, at: [-3.8, 0, -8.0]}
    over: [wheel]
    links: 64
    thickness: 0.6
    density: 1400
    stiffness: 20000.0
    pretension: 2.0
    damping: 2.0
    friction: 0.5
contact: {solref: [0.001, 1], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_t, kind: velocity, rpm: 0, swing: {amplitude: 0.3142, hz: 0.5}, kv: 60.0, max_torque: 30.0}
checks:
  - {type: follow, out: j_p, in: j_t, expect: -2.855, tol: 0.15, min_r2: 0.995, settle_s: 1.0, window_s: 1.0}   # the pulley goes through the band's travel, the treadle's eye over the band's centre-line radius, the other way as the foot goes down
  - {type: follow, out: j_p, in: j_t, expect: -2.855, tol: 0.15, min_r2: 0.995, settle_s: 3.0, window_s: 1.0}
  - {type: follow, out: j_p, in: j_t, expect: -2.855, tol: 0.15, min_r2: 0.995, settle_s: 5.0, window_s: 1.0}
  - {type: position, joint: j_p, min: -0.62, max: 1.5, settle_s: 0.3, window_s: 6.0}   # the pulley swings about one and a half radians to and fro
  - {type: position, joint: j_t, min: -0.42, max: 0.4, settle_s: 0.3, window_s: 6.0}
  - {type: penetration, max: 0.0015, settle_s: 0.5}
camera: {target: [0.0, 0, -11.0], position: [0.0, -100.0, -11.0], fov: 34}
display:
  output: j_p
  labels: {j_t: "Treadle (driver)", j_p: "Pulley", j_s: "Spring"}
  proof: {label: "Band not gripping the pulley", sub: "the treadle swings but the pulley stands"}

