The NewportESP module

Driver for Newport’s ESP (and compatible) motion controllers over a serial port (RS232).

Refer to the controller’s manual for detailed operational instructions: http://assets.newport.com/webDocuments-EN/images/ESP300_User_Manual.pdf

Usage:
>>> from mewportESP import ESP
>>> esp = ESP('/dev/ttyUSB0')  # open communication with controller
>>> stage = esp.axis(1)        # open axis no 1
>>> stage.id                   # print stage ID
>>> stage.move_to(1.2)         # Move to position 1.2 mm

Revision history:

  • v. 0.3 (27 August 2015): update all methods/properties names to lowercase. Capitalised versions are still available for backward compatibility.
  • v. 0.4 (28 September 2015): added a threading.Lock() to the query() method. This should make the module thread-safe.
  • v. 1.0 (16 February 2016) clean up Sphinx documentation. Remove all capitalised names. Upload to PyPi.

exception newportESP.NewportError(string)[source]

Represents errors raised by the ESP controller.

newportESP.catch_error(func)[source]

A decorator to read error messages after calling ESP functions.

class newportESP.ESP(port)[source]

Driver for Newport’s ESP (100/300) motion controller.

Usage:
>>> esp = NewportESP.ESP('/dev/ttyUSB0') # open communication with controller
>>> stage = esp.axis(1)   # open axis no 1
Parameters:port – Serial port connected to the controller.
read()[source]

Serial read with EOL character removed.

write(string, axis=None)[source]

Serial write.

The EOL character is automatically appended

Parameters:
  • string – the string to write to the port
  • axis – index of the destination axis. If unspecified, the destination is the controller.
query(string, axis=None, check_error=False)[source]

write a command and read the reply.

Parameters:
  • string – string to write to the port
  • axis – index of the destination axis. If unspecified, the destination is the controller.
  • check_error (bool) – if True, query the controller for any error, both before writing and before reading.
Returns:

the reply string

Return type:

string

version

The controller firmware version number.

abort()[source]

Send an ‘Abort motion’ command to the controller.

read_error()[source]

Return the last error as a string.

raise_error()[source]

Check the last error message and raise a NewportError.

axis(axis_index=1)[source]

create an Axis object.

Parameters:axis_index (int) – the axis index
Return type:Axis
class newportESP.Axis(controller, axis=1)[source]

Represents a Newport actuator or motorised stage attached to the ESP controller.

Usage:
>>> esp = NewportESP.ESP('/dev/ttyUSB0') # open communication with controller
>>> stage = NewportESP.Axis(esp, axis = 1)   # open axis no 1
Parameters:
  • controller (ESP) – The axis’ Newport ESP controller
  • axis (int) – the axis index
write(string, axis=None)[source]

Send a command string to the axis.

Can be used to send commands that are not covered by class methods.

Parameters:
  • string – the command string. The axis index and EOL characters are automatically appended.
  • axis – if unspecified, the command is directed to the current axis. However, by setting axis to an empty string, the command will be directed to the controller instead.
query(string, check_error=False)[source]

write a command and read the reply.

Parameters:
  • string – string to write to the port
  • check_error (bool) – if True, query the controller for any error, both before writing and before reading.
Returns:

the reply string

Return type:

string

id

The axis model and serial number.

on()[source]

Power on the axis.

off()[source]

Power on the axis.

Search for home.

This command executes a Home search routine on the axis.

If mode is missing, the axes will search for home using the mode specified using OM command. The possible values for mode are:

  • 0, search for zero position count.
  • 1, search for combined Home and Index signal transitions.
  • 2, search for Home signal transition only.
  • 3, search for positive limit signal transition.
  • 4, search for negative limit signal transition.
  • 5, search for positive limit and index signal transition.
  • 6, search for negative limit and index signal transition.

At the end of a home search routine, the position of axes is reset to the value specified using SH command.

The home search motion status can be monitored with the Motion Done (MD) status command. If a fault condition such as E-stop occurs while home search is in progress or if this command is issued to an axis before enabling it, the controller returns error xx20, ‘HOMING ABORTED’. For a detailed description of the home search routine see the Home - The Axis Origin chapter in the Motion Control Tutorial section.

home

Define home.

This command is used to define current position, HOME position. This means that the current position will be preset to the value defined by parameter ‘nn’.

moving

Return True is motion is finished.

Return type:bool
wait()[source]

This method will block until current motion is finished.

move_to(pos, wait=False)[source]

Go to absolute position.

Parameters:
  • pos (float) – the final position (in mm)
  • wait (bool) – whether to block until the motion is finished
move_by(pos, wait=False)[source]

Go to relative position.

Parameters:
  • pos (float) – the requested step (in mm)
  • wait (bool) – whether to block until the motion is finished
position

The current position, in mm.

move_to_hardware_limit(direction)[source]

Move to hardware limit.

Parameters:direction (float) – negative or position, indicate which direction to move towards.
stop()[source]

Stop the current motion.

backlash

set backlash compensation (in mm).

This command initiates a backlash compensation algorithm when motion direction is reversed. The controller keeps track of the motion sequence and for each direction change it adds the specified nn correction. Setting nn to zero disables the backlash compensation.

NOTE: The command is affective only after a home search (OR) or define home (DH) is performed on the specified axis.

resolution

Return the encoder resolution, in mm.

unit

Return the encoder unit.

travel_limits(left=None, right=None)[source]

Set or query the axis travel limits.

Parameters:
  • left (float) – left (negative) travel limit
  • right (float) –

    right (positive) travel limit

    If both limits are unspecified, returns the current settings as a dictionary.

class newportESP.DelayedKeyboardInterrupt[source]

Context manager that capture a KeyboardInterrupt Event and ignores it for the duration of the context, triggering the interrupt when exiting. If called in a thread, does nothing.

Indices and tables