# No. 8, Variable Speed Stepped Pulleys (Brown 1868, p. 1).
#
# "Speed-pulleys used for lathes and other mechanical tools, for varying the speed according to the work
# operated upon."
#
# Layout, as in the plate: two shafts side by side, each carrying a pulley cast as four steps of
# different diameter. The upper cone steps DOWN from left to right and the lower one steps UP, so the
# steps facing each other at any one station are always a big one against a small one. A band of one
# fixed length fits the pair at every station, and moving the band to another station changes the
# speed: 2.45 : 1.36 : 0.73 : 0.41. The plate draws the band on the second station from the left; the
# shafts are seen from the side, both stubbed out beyond their pulleys, and the cones almost touch.
#
# Nothing is coupled: the upper shaft alone is motor-driven, and the band carries motion to the lower
# shaft by friction, so the four speeds are measured, not imposed. Which station the band is on is a
# passive configuration (`variants`), and all four are simulated and checked.
#
# Proportions (cm): steps of 5.4 / 4.53 / 3.33 / 2.2 in radius, 5 apart along each shaft, on
# centres 11 apart. Two numbers in there are forced rather than drawn:
#   - the steps are spaced widely along the shaft (5) because a band's link lying on one step is a
#     solid pill, and it has to stay clear of its neighbours' rims: any closer and it reaches inside
#     the bigger neighbour by a few mm and drags on it, which costs 10% of the ratio and jams the cone;
#   - the middle steps are spaced unevenly (0.87 / 1.2 / 1.13) so that the band's path round station 1
#     (radii 5.4 + 2.2) and round station 2 (4.53 + 3.33) is the same 47.91 cm to a millimetre. That is
#     what "one belt length fits every pair" has to mean in practice: the band wraps the bigger step of
#     a pair past 180 deg and the smaller one short of it, so the outer pair would otherwise need
#     1.1 cm more band than the middle pair.
number: 8
slug: variable-speed-stepped-pulleys
name: Variable Speed Stepped Pulleys
brown: "Speed-pulleys used for lathes and other mechanical tools, for varying the speed according to the work operated upon."
units: cm
sim: {timestep: 0.0002, integrator: implicitfast, iterations: 60, duration_s: 8}
bodies:
  # One body per shafting: the shaft itself and the four steps keyed to it are one casting.
  - {id: shaft_top, shape: assembly, pos: [0, 0, 47], color: "#e6dcc2"}   # the driving cone
  - {id: shaft_bot, shape: assembly, pos: [0, 0, 36], color: "#d9cfb6"}   # the driven cone (the spindle)
joints:
  - {id: j_top, type: hinge, body: shaft_top, axis: [0, 1, 0], damping: 0.002}
  - {id: j_bot, type: hinge, body: shaft_bot, axis: [0, 1, 0], damping: 0.02}   # the load: the spindle
# Four steps per cone, the upper stepping down and the lower stepping up, 5 apart along each shaft.
# Each step is drawn as a solid disc 4.4 wide, as a cast cone step is, but only the middle 1.2 of it
# collides (rim_width): that is the width of the band, and it is all the band can reach. No lips
# (flange: 0): the shoulders of a cast cone do that job, and a flange would be a solid cylinder the
# band's links could get inside. The hubs are all the same small radius, so the four steps are drawn
# on one plain shaft.
wheels:
  - {id: top1, body: shaft_top, pos: [0, -7.5, 0], radius: 5.4, width: 4.4, rim_width: 1.2, mass: 1.4, spokes: 0, hub: 0.55, flange: 0, web: true}
  - {id: top2, body: shaft_top, pos: [0, -2.5, 0], radius: 4.528, width: 4.4, rim_width: 1.2, mass: 0.98, spokes: 0, hub: 0.55, flange: 0, web: true}
  - {id: top3, body: shaft_top, pos: [0, 2.5, 0], radius: 3.328, width: 4.4, rim_width: 1.2, mass: 0.53, spokes: 0, hub: 0.55, flange: 0, web: true}
  - {id: top4, body: shaft_top, pos: [0, 7.5, 0], radius: 2.2, width: 4.4, rim_width: 1.2, mass: 0.23, spokes: 0, hub: 0.55, flange: 0, web: true}
  - {id: bot1, body: shaft_bot, pos: [0, -7.5, 0], radius: 2.2, width: 4.4, rim_width: 1.2, mass: 0.23, spokes: 0, hub: 0.55, flange: 0, web: true}
  - {id: bot2, body: shaft_bot, pos: [0, -2.5, 0], radius: 3.328, width: 4.4, rim_width: 1.2, mass: 0.53, spokes: 0, hub: 0.55, flange: 0, web: true}
  - {id: bot3, body: shaft_bot, pos: [0, 2.5, 0], radius: 4.528, width: 4.4, rim_width: 1.2, mass: 0.98, spokes: 0, hub: 0.55, flange: 0, web: true}
  - {id: bot4, body: shaft_bot, pos: [0, 7.5, 0], radius: 5.4, width: 4.4, rim_width: 1.2, mass: 1.4, spokes: 0, hub: 0.55, flange: 0, web: true}
shafts:
  - {id: sh_top, body: shaft_top, from: [0, -9.2, 0], to: [0, 9.2, 0], radius: 0.7}
  - {id: sh_bot, body: shaft_bot, from: [0, -9.2, 0], to: [0, 9.2, 0], radius: 0.7}
belts:
  - id: belt
    around: [top2, bot2]      # the station drawn in the plate
    links: 64
    thickness: 0.35
    width: 1.2
    density: 7800              # a flat steel band, as No. 7's: leather links are far too light
                              # for the band's tension at this radius (they sink into the rims and flap)
    stiffness: 30000           # N/m per link
    damping: 2
    pretension: 40             # N
    friction: 0.7              # a dressed band on iron
contact: {solref: [0.004, 1], solimp: [0.9, 0.95, 0.001], margin: 0}
driver: {joint: j_top, kind: velocity, rpm: 30, kv: 2, max_torque: 5}
# Passive configurations: the same two cones with the band on another pair of steps. This is the whole
# point of the movement, so every one of them is simulated and measured
# (test_008_band_position_sets_the_speed).
variants:
  - id: fastest
    note: "band on the big step of the driving cone and the small step of the driven one (5.4 and 2.2): 2.45 to 1"
    belt_around: {belt: [top1, bot1]}
  - id: fast
    note: "band on the next pair in (4.53 and 3.33), as drawn in the plate: 1.36 to 1"
    belt_around: {belt: [top2, bot2]}
  - id: slow
    note: "band on the pair the other way round (3.33 and 4.53): 1 to 1.36"
    belt_around: {belt: [top3, bot3]}
  - id: slowest
    note: "band on the small step of the driving cone and the big step of the driven one (2.2 and 5.4): 1 to 2.45"
    belt_around: {belt: [top4, bot4]}
variant: fast
checks:
  # Band on the pair of steps 4.528 (driving) and 3.328 (driven), open belt: the driven cone turns
  # 4.528/3.328 = 1.3606 times as fast as the driver, the same way round, less a little creep.
  - {type: ratio, out: j_bot, in: j_top, expect: 1.3606, tol: 0.05, settle_s: 1, window_s: 0.8}
  - {type: belt_on, belt: belt, max_radial_dev: 0.4, max_lateral: 0.3, duration_s: 2}
  - {type: penetration, max: 0.0012, settle_s: 1}
camera: {target: [0, 0, 41.5], position: [52, -13, 43], fov: 30}   # side view as in the plate, a little off-axis
display:
  output: j_bot
  labels: {j_top: Driving cone (input), j_bot: Driven cone (output)}
  expect: {default: 1.3606, fastest: 2.4545, fast: 1.3606, slow: 0.7350, slowest: 0.4074}