number: 328
slug: cartwrights-parallel-motion
name: Cartwright's Parallel Motion
brown: "A parallel motion invented by Dr. Cartwright in the year 1787. The toothed wheels, C, C, have equal diameters and numbers of teeth; and the cranks, A, A, have equal radii, and are set in opposite directions, and consequently give an equal obliquity to the connecting-rods during the revolution of the wheels. The cross-head on the piston-rod being attached to the two connecting-rods, the piston-rod is caused to move in a right line."
units: cm
sim: {timestep: 0.0002, integrator: implicitfast, iterations: 100, solver: CG, multiccd: true, duration_s: 8, floor: false}
bodies:
  # the toothed wheels C, C, equal, on their shafts in the frame; the frame's gland under the cylinder
  - {id: g1, shape: assembly, pos: [-6.0, 0, 0], color: "#e4d9bf"}
  - {id: g2, shape: assembly, pos: [6.0, 0, 0], color: "#e8dec6"}
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#9a9284"
    pieces:
      - {kind: poly, points: [[-14.0000, -10.0000], [14.0000, -10.0000], [14.0000, -9.0000], [-14.0000, -9.0000]], y: [-1.5, 4.5], collide: 0}
      - {kind: poly, points: [[-6.8000, -9.0000], [-5.2000, -9.0000], [-5.2000, 0.0000], [-6.8000, 0.0000]], y: [2.0, 3.0], collide: 0}
      - {kind: poly, points: [[5.2000, -9.0000], [6.8000, -9.0000], [6.8000, 0.0000], [5.2000, 0.0000]], y: [2.0, 3.0], collide: 0}
      - {kind: rod, from: [-6.0, 1.2, 0], to: [-6.0, 3.0, 0], radius: 0.6, collide: 0}
      - {kind: rod, from: [6.0, 1.2, 0], to: [6.0, 3.0, 0], radius: 0.6, collide: 0}
      - {kind: poly, points: [[-13.0000, -9.0000], [-12.0000, -9.0000], [-12.0000, 25.4164], [-13.0000, 25.4164]], y: [2.0, 3.0], collide: 0}
      - {kind: poly, points: [[12.0000, -9.0000], [13.0000, -9.0000], [13.0000, 25.4164], [12.0000, 25.4164]], y: [2.0, 3.0], collide: 0}
      - {kind: poly, points: [[-13.0000, 25.4164], [-1.2000, 25.4164], [-1.2000, 26.4164], [-13.0000, 26.4164]], y: [-1.5, 3.0], collide: 0}
      - {kind: poly, points: [[1.2000, 25.4164], [13.0000, 25.4164], [13.0000, 26.4164], [1.2000, 26.4164]], y: [-1.5, 3.0], collide: 0}
      - {kind: poly, points: [[-1.2000, 25.4164], [-0.4200, 25.4164], [-0.4200, 26.4164], [-1.2000, 26.4164]], y: [-1.8, -0.6], collide: 1}
      - {kind: poly, points: [[0.4200, 25.4164], [1.2000, 25.4164], [1.2000, 26.4164], [0.4200, 26.4164]], y: [-1.8, -0.6], collide: 1}
      - {kind: poly, points: [[-3.5000, 26.4164], [3.5000, 26.4164], [3.5000, 34.4164], [-3.5000, 34.4164]], y: [-1.5, 1.5], collide: 0, color: "#7d776c"}
  # crank A on wheel C1: its pin, at 3.0 cm, set opposite to the other crank (mirrored)
  - id: K1
    shape: part
    fixed: true
    pos: [-6.0000, 0, 0]
    mount: g1
    density: 7800
    color: "#8f8a80"
    pieces:
      - {kind: poly, points: [[-6.8000, 0], [-5.2000, 0], [-5.4000, 3.0], [-6.6000, 3.0]], y: [-1.9, -1.3], collide: 0}
      - {kind: disc, center: [-6.0000, 3.0], radius: 0.4, y: [-1.9, -3.4], collide: 2, color: "#6f6a60"}
  # crank B on wheel C2: its pin, at 3.0 cm, set opposite to the other crank (mirrored)
  - id: K2
    shape: part
    fixed: true
    pos: [6.0000, 0, 0]
    mount: g2
    density: 7800
    color: "#8f8a80"
    pieces:
      - {kind: poly, points: [[5.2000, 0], [6.8000, 0], [6.6000, 3.0], [5.4000, 3.0]], y: [-1.9, -1.3], collide: 0}
      - {kind: disc, center: [6.0000, 3.0], radius: 0.4, y: [-1.9, -2.6], collide: 2, color: "#6f6a60"}
  # the cross-head on the piston-rod: free to move across, up and down and to turn; nothing guides it
  # but the two connecting-rods
  - {id: Cx, shape: part, pos: [0, 0, 16.4164], mount: frame, mass: 0.01, color: "#8f8a80", pieces: [{kind: disc, center: [0, 16.4164], radius: 0.1, y: [1.0, 1.05], collide: 0}]}
  - {id: Cz, shape: part, pos: [0, 0, 16.4164], mount: Cx, mass: 0.01, color: "#8f8a80", pieces: [{kind: disc, center: [0, 16.4164], radius: 0.1, y: [1.0, 1.05], collide: 0}]}
  - id: C
    shape: part
    pos: [0, 0, 16.4164]
    mount: Cz
    density: 7800
    color: "#b8ad96"
    pieces:
      - {kind: poly, points: [[-10.7000, 15.8164], [10.7000, 15.8164], [10.7000, 17.0164], [-10.7000, 17.0164]], y: [-1.5, -0.9], collide: 0}
      - {kind: rod, from: [0, -1.2, 17.0164], to: [0, -1.2, 33.4164], radius: 0.4, collide: 2, capsule: true, color: "#8f8a80"}
      - {kind: rod, from: [-10.0, -3.4, 16.4164], to: [-10.0, -0.9, 16.4164], radius: 0.3, collide: 0, color: "#6f6a60"}
      - {kind: rod, from: [10.0, -3.4, 16.4164], to: [10.0, -0.9, 16.4164], radius: 0.3, collide: 0, color: "#6f6a60"}
  # connecting-rod 1, on its cross-head pin; its big end is a bearing on crank A's pin
  - id: R1
    shape: part
    pos: [-10.0000, 0, 16.4164]
    mount: C
    density: 7800
    color: "#a39a88"
    pieces:
      - {kind: rod, from: [-10.0000, -2.9000000000000004, 16.4164], to: [-6.0000, -2.9000000000000004, 3.0], radius: 0.3, collide: 0}
      - {kind: disc, center: [-10.0000, 16.4164], radius: 0.6, y: [-3.2, -2.6], collide: 0}
      - {kind: band, center: [-6.0000, 3.0], r: [0.42, 0.95], a: [0, 6.2832], y: [-3.2, -2.6], slices: 36, collide: 1}
  # connecting-rod 2, on its cross-head pin; its big end is a bearing on crank B's pin
  - id: R2
    shape: part
    pos: [10.0000, 0, 16.4164]
    mount: C
    density: 7800
    color: "#a39a88"
    pieces:
      - {kind: rod, from: [10.0000, -2.175, 16.4164], to: [6.0000, -2.175, 3.0], radius: 0.3, collide: 0}
      - {kind: disc, center: [10.0000, 16.4164], radius: 0.6, y: [-2.4, -1.95], collide: 0}
      - {kind: band, center: [6.0000, 3.0], r: [0.42, 0.95], a: [0, 6.2832], y: [-2.4, -1.95], slices: 36, collide: 1}
joints:
  - {id: j_g1, type: hinge, body: g1, axis: [0, 1, 0], damping: 0.0005}
  - {id: j_g2, type: hinge, body: g2, axis: [0, 1, 0], damping: 0.01}   # a bearing load that keeps the teeth in contact
  - {id: j_x, type: slide, body: Cx, axis: [1, 0, 0], damping: 0.2, range: [-3, 3]}
  - {id: j_z, type: slide, body: Cz, axis: [0, 0, 1], damping: 0.2, range: [-12, 3]}
  - {id: j_rot, type: hinge, body: C, axis: [0, -1, 0], damping: 0.001}
  - {id: j_R1, type: hinge, body: R1, axis: [0, -1, 0], damping: 0.001}
  - {id: j_R2, type: hinge, body: R2, axis: [0, -1, 0], damping: 0.001}
spurs:
  - {id: sp1, body: g1, pos: [0, 0, 0], teeth: 24, module: 0.5, width: 2.4, backlash: 0.02, phase: 0}
  - {id: sp2, body: g2, pos: [0, 0, 0], teeth: 24, module: 0.5, width: 2.4, backlash: 0.02, phase: 0.1309}
contact: {solref: [0.002, 1], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_g1, kind: velocity, rpm: 30, kv: 0.5, max_torque: 5}
checks:
  - {type: turning, joint: j_g1, direction: 1, min_mean: 2.8, min_fraction: 0.95, settle_s: 0.5, window_s: 7.0}
  # the wheels C, C are equal, so the second crank turns the other way at the same speed ...
  - {type: ratio, out: j_g2, in: j_g1, expect: -1.0, tol: 0.02, settle_s: 0.5, window_s: 7.0}
  # ... and the two equal rods, mirror images of each other, carry the cross-head up and down in a straight line
  - {type: amplitude, joint: j_z, min: 0.030, max: 0.0325, settle_s: 0.5, window_s: 7.0}
  - {type: position, joint: j_x, min: -0.04, max: 0.04, settle_s: 0.5, window_s: 7.0}
  - {type: position, joint: j_rot, min: -0.003, max: 0.003, settle_s: 0.5, window_s: 7.0}
  - {type: penetration, max: 0.001, settle_s: 0.5}
camera: {target: [0, 0, -1], position: [-67, -168, 13], fov: 30}
display:
  output: j_z
  labels: {j_g1: Wheel C and crank A (driver), j_g2: Other wheel C and crank, j_x: Cross-head across, j_z: Cross-head and piston-rod, j_rot: Turn of cross-head}

