Polargraph#

class QPolargraph.hardware.Polargraph.Polargraph(pitch=2.0, circumference=25, steps=200, ell=1.0, y0=0.1, speed=100.0, **kwargs)[source]#

Bases: Motors

Base implementation for a polargraph scanner.

Extends Motors with the belt-drive geometry to convert between motor step-index space and Cartesian coordinates in metres. The payload hangs from the midpoint of a GT2 timing belt whose ends are wound on toothed gears driven by two Nema-17 stepper motors mounted above and to either side of the scan area.

Properties#

ellfloat

Separation between the two motor pulleys [m].

y0float

Vertical distance from the pulleys to the home position [m].

pitchfloat

Tooth pitch of the GT2 timing belt [mm]. Default: 2.

circumferenceint

Number of belt teeth per full revolution of the gear. Default: 25.

stepsint

Motor steps per revolution. Default: 200.

speedfloat

Maximum translation speed [steps/s].

dsfloat

Distance travelled per motor step [m]. Read-only.

s0float

Belt length from pulley to payload at home position [m]. Read-only.

positionnumpy.ndarray

Current Cartesian coordinates (x, y, running) [m, m, flag]. Read-only.

moveTo(x, y)[source]#

Move the payload to coordinates (x, y) [m] measured from the home position, adjusting motor speeds so both arrive simultaneously.

References

H. W. Gao, K. I. Mishra, A. Winters, S. Wolin, and D. G. Grier, “Flexible wide-field high-resolution scanning camera for continuous-wave acoustic holography,” Rev. Sci. Instrum. 89, 114901 (2018). https://doi.org/10.1063/1.5053666

property pitch: float#

Tooth pitch of the GT2 timing belt [mm].

property circumference: int#

Number of belt teeth per full revolution of the gear.

property steps: int#

Motor steps per revolution.

property ell: float#

Separation between the two motor pulleys [m].

property y0: float#

Vertical distance from the pulleys to the home position [m].

property speed: float#

Maximum translation speed [steps/s].

property ds: float#

Distance travelled per motor step [m].

property s0: float#

Belt length from pulley to payload at the home position [m].

r2f(x, y)[source]#

Convert Cartesian coordinates to continuous step indexes.

This is the exact (non-rounded) inverse of i2r(), useful for trajectory interpolation. To obtain integer motor targets suitable for goto(), round the result.

Parameters:
  • x (float) – Horizontal coordinate [m].

  • y (float) – Vertical coordinate [m].

Return type:

tuple[float, float]

Returns:

tuple(m, n) step indexes as floats.

r2i(x, y)[source]#

Convert Cartesian coordinates to integer motor step indexes.

Parameters:
  • x (float) – Horizontal coordinate [m].

  • y (float) – Vertical coordinate [m].

Return type:

tuple[int, int]

Returns:

tuple(m, n) step indexes as integers.

i2r(m, n, *args)[source]#

Convert motor step indexes to Cartesian coordinates [m].

Works with scalar or array inputs for m and n. When called with arrays, *args must be empty or also array-valued with a matching shape.

Parameters:
  • m (int, float, or numpy.ndarray) – Step index (or array of indexes) for motor 1.

  • n (int, float, or numpy.ndarray) – Step index (or array of indexes) for motor 2.

  • *args – Extra values appended to the result array (e.g. running flag). len(result) == 2 + len(args).

Return type:

ndarray

Returns:

numpy.ndarray[x, y, *args] Cartesian position [m] plus any extra payload supplied via *args.

property position: ndarray#

Returns current Cartesian coordinates and a running flag

moveTo(x, y)[source]#

Move the payload to position (x, y) [m].

Computes the target step indexes and adjusts both motor speeds so they complete their moves simultaneously, accounting for AccelStepper trapezoidal ramp times.

Parameters:
  • x (float) – Target horizontal coordinate [m].

  • y (float) – Target vertical coordinate [m].

Return type:

None