hvl_ccb.dev.newport.newport

Inheritance diagram of hvl_ccb.dev.newport.newport

Device class for Newport SMC100PP stepper motor controller with serial communication.

The SMC100PP is a single axis motion controller/driver for stepper motors up to 48 VDC at 1.5 A rms. Up to 31 controllers can be networked through the internal RS-485 communication link.

Manufacturer homepage: https://www.newport.com/f/smc100-single-axis-dc-or-stepper-motion-controller

class NewportConfigCommands(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: NameEnum

Commands predefined by the communication protocol of the SMC100PP

AC = 'acceleration'
BA = 'backlash_compensation'
BH = 'hysteresis_compensation'
FRM = 'micro_step_per_full_step_factor'
FRS = 'motion_distance_per_full_step'
HT = 'home_search_type'
JR = 'jerk_time'
OH = 'home_search_velocity'
OT = 'home_search_timeout'
QIL = 'peak_output_current_limit'
SA = 'rs485_address'
SL = 'negative_software_limit'
SR = 'positive_software_limit'
VA = 'velocity'
VB = 'base_velocity'
ZX = 'stage_configuration'
exception NewportControllerError[source]

Bases: NewportError

Error with the Newport controller.

exception NewportError[source]

Bases: DeviceError

General Error for Newport Device

exception NewportMotorError[source]

Bases: NewportError

Error with the Newport motor.

exception NewportMotorPowerSupplyWasCutError[source]

Bases: NewportError

Error with the Newport motor after the power supply was cut and then restored, without interrupting the communication with the controller.

class NewportSMC100PP(com, dev_config=None)[source]

Bases: SingleCommDevice

Device class of the Newport motor controller SMC100PP

class MotorErrors(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

Possible motor errors reported by the motor during get_state().

DC_VOLTAGE_TOO_LOW = 3
FOLLOWING_ERROR = 6
HOMING_TIMEOUT = 5
NED_END_OF_TURN = 11
OUTPUT_POWER_EXCEEDED = 2
PEAK_CURRENT_LIMIT = 9
POS_END_OF_TURN = 10
RMS_CURRENT_LIMIT = 8
SHORT_CIRCUIT = 7
WRONG_ESP_STAGE = 4
class StateMessages(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

Possible messages returned by the controller on get_state() query.

CONFIG = '14'
DISABLE_FROM_JOGGING = '3E'
DISABLE_FROM_MOVING = '3D'
DISABLE_FROM_READY = '3C'
HOMING_FROM_RS232 = '1E'
HOMING_FROM_SMC = '1F'
JOGGING_FROM_DISABLE = '47'
JOGGING_FROM_READY = '46'
MOVING = '28'
NO_REF_ESP_STAGE_ERROR = '10'
NO_REF_FROM_CONFIG = '0C'
NO_REF_FROM_DISABLED = '0D'
NO_REF_FROM_HOMING = '0B'
NO_REF_FROM_JOGGING = '11'
NO_REF_FROM_MOVING = '0F'
NO_REF_FROM_READY = '0E'
NO_REF_FROM_RESET = '0A'
READY_FROM_DISABLE = '34'
READY_FROM_HOMING = '32'
READY_FROM_JOGGING = '35'
READY_FROM_MOVING = '33'
States

alias of NewportStates

static config_cls()[source]

Return the default configdataclass class.

Returns:

a reference to the default configdataclass class

static default_com_cls()[source]

Get the class for the default communication protocol used with this device.

Returns:

the type of the standard communication protocol for this device

exit_configuration(add: int | None = None) None[source]

Exit the CONFIGURATION state and go back to the NOT REFERENCED state. All configuration parameters are saved to the device”s memory.

Parameters:

add – controller address (1 to 31)

Raises:
get_acceleration(add: int | None = None) int | float[source]

Leave the configuration state. The configuration parameters are saved to the device”s memory.

Parameters:

add – controller address (1 to 31)

Returns:

acceleration (preset units/s^2), value between 1e-6 and 1e12

Raises:
get_controller_information(add: int | None = None) str[source]

Get information on the controller name and driver version

Parameters:

add – controller address (1 to 31)

Returns:

controller information

Raises:
get_motor_configuration(add: int | None = None) dict[str, float][source]

Query the motor configuration and returns it in a dictionary.

Parameters:

add – controller address (1 to 31)

Returns:

dictionary containing the motor’s configuration

Raises:
get_move_duration(dist: int | float, add: int | None = None) float[source]

Estimate the time necessary to move the motor of the specified distance.

Parameters:
  • dist – distance to travel

  • add – controller address (1 to 31), defaults to self.address

Raises:
get_negative_software_limit(add: int | None = None) int | float[source]

Get the negative software limit (the maximum position that the motor is allowed to travel to towards the left).

Parameters:

add – controller address (1 to 31)

Returns:

negative software limit (preset units), value between -1e12 and 0

Raises:
get_position(add: int | None = None) float[source]

Returns the value of the current position.

Parameters:

add – controller address (1 to 31)

Raises:
get_positive_software_limit(add: int | None = None) int | float[source]

Get the positive software limit (the maximum position that the motor is allowed to travel to towards the right).

Parameters:

add – controller address (1 to 31)

Returns:

positive software limit (preset units), value between 0 and 1e12

Raises:
get_state(add: int | None = None) StateMessages[source]

Check on the motor errors and the controller state

Parameters:

add – controller address (1 to 31)

Raises:
Returns:

state message from the device (member of StateMessages)

go_home(add: int | None = None) None[source]

Move the motor to its home position.

Parameters:

add – controller address (1 to 31), defaults to self.address

Raises:
go_to_configuration(add: int | None = None) None[source]

This method is executed during start(). It can also be executed after a reset(). The controller is put in CONFIG state, where configuration parameters can be changed.

Parameters:

add – controller address (1 to 31)

Raises:
initialize(add: int | None = None) None[source]

Puts the controller from the NOT_REF state to the READY state. Sends the motor to its “home” position.

Parameters:

add – controller address (1 to 31)

Raises:
move_to_absolute_position(pos: int | float, add: int | None = None) None[source]

Move the motor to the specified position.

Parameters:
  • pos – target absolute position (affected by the configured offset)

  • add – controller address (1 to 31), defaults to self.address

Raises:
move_to_relative_position(pos: int | float, add: int | None = None) None[source]

Move the motor of the specified distance.

Parameters:
  • pos – distance to travel (the sign gives the direction)

  • add – controller address (1 to 31), defaults to self.address

Raises:
reset(add: int | None = None) None[source]

Resets the controller, equivalent to a power-up. This puts the controller back to NOT REFERENCED state, which is necessary for configuring the controller.

Parameters:

add – controller address (1 to 31)

Raises:
set_acceleration(acc: int | float, add: int | None = None) None[source]

Leave the configuration state. The configuration parameters are saved to the device”s memory.

Parameters:
  • acc – acceleration (preset units/s^2), value between 1e-6 and 1e12

  • add – controller address (1 to 31)

Raises:
set_motor_configuration(add: int | None = None, config: dict | None = None) None[source]

Set the motor configuration. The motor must be in CONFIG state.

Parameters:
  • add – controller address (1 to 31)

  • config – dictionary containing the motor’s configuration

Raises:
set_negative_software_limit(lim: int | float, add: int | None = None) None[source]

Set the negative software limit (the maximum position that the motor is allowed to travel to towards the left).

Parameters:
  • lim – negative software limit (preset units), value between -1e12 and 0

  • add – controller address (1 to 31)

Raises:
set_positive_software_limit(lim: int | float, add: int | None = None) None[source]

Set the positive software limit (the maximum position that the motor is allowed to travel to towards the right).

Parameters:
  • lim – positive software limit (preset units), value between 0 and 1e12

  • add – controller address (1 to 31)

Raises:
start()[source]

Opens the communication protocol and applies the config.

Raises:

SerialCommunicationIOError – when communication port cannot be opened

stop() None[source]

Stop the device. Close the communication protocol.

stop_motion(add: int | None = None) None[source]

Stop a move in progress by decelerating the positioner immediately with the configured acceleration until it stops. If a controller address is provided, stops a move in progress on this controller, else stops the moves on all controllers.

Parameters:

add – controller address (1 to 31)

Raises:
wait_until_motor_initialized(add: int | None = None) None[source]

Wait until the motor leaves the HOMING state (at which point it should have arrived to the home position).

Parameters:

add – controller address (1 to 31)

Raises:
class NewportSMC100PPConfig(address: int = 1, user_position_offset: int | float = 23.987, screw_scaling: int | float = 1, exit_configuration_wait_sec: int | float = 5, move_wait_sec: int | float = 1, acceleration: int | float = 10, backlash_compensation: int | float = 0, hysteresis_compensation: int | float = 0.015, micro_step_per_full_step_factor: int = 100, motion_distance_per_full_step: int | float = 0.01, home_search_type: int | ~hvl_ccb.dev.newport.newport.NewportSMC100PPConfig.HomeSearch = <HomeSearch.HomeSwitch: 2>, jerk_time: int | float = 0.04, home_search_velocity: int | float = 4, home_search_timeout: int | float = 27.5, home_search_polling_interval: int | float = 1, peak_output_current_limit: int | float = 0.4, rs485_address: int = 2, negative_software_limit: int | float = -23.5, positive_software_limit: int | float = 25, velocity: int | float = 4, base_velocity: int | float = 0, stage_configuration: int | ~hvl_ccb.dev.newport.newport.NewportSMC100PPConfig.EspStageConfig = <EspStageConfig.EnableEspStageCheck: 3>)[source]

Bases: object

Configuration dataclass for the Newport motor controller SMC100PP.

class EspStageConfig(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

Different configurations to check or not the motor configuration upon power-up.

DisableEspStageCheck = 1
EnableEspStageCheck = 3
UpdateEspStageInfo = 2
class HomeSearch(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

Different methods for the motor to search its home position during initialization.

CurrentPosition = 1
EndOfRunSwitch = 4
EndOfRunSwitch_and_Index = 3
HomeSwitch = 2
HomeSwitch_and_Index = 0
acceleration: int | float = 10
address: int = 1
backlash_compensation: int | float = 0
base_velocity: int | float = 0
clean_values()[source]
exit_configuration_wait_sec: int | float = 5
force_value(fieldname, value)

Forces a value to a dataclass field despite the class being frozen.

NOTE: you can define post_force_value method with same signature as this method to do extra processing after value has been forced on fieldname.

Parameters:
  • fieldname – name of the field

  • value – value to assign

home_search_polling_interval: int | float = 1
home_search_timeout: int | float = 27.5
home_search_type: int | HomeSearch = 2
home_search_velocity: int | float = 4
hysteresis_compensation: int | float = 0.015
is_configdataclass = True
jerk_time: int | float = 0.04
classmethod keys() Sequence[str]

Returns a list of all configdataclass fields key-names.

Returns:

a list of strings containing all keys.

micro_step_per_full_step_factor: int = 100
motion_distance_per_full_step: int | float = 0.01
property motor_config: dict[str, float]

Gather the configuration parameters of the motor into a dictionary.

Returns:

dict containing the configuration parameters of the motor

move_wait_sec: int | float = 1
negative_software_limit: int | float = -23.5
classmethod optional_defaults() dict[str, object]

Returns a list of all configdataclass fields, that have a default value assigned and may be optionally specified on instantiation.

Returns:

a list of strings containing all optional keys.

peak_output_current_limit: int | float = 0.4
positive_software_limit: int | float = 25
post_force_value(fieldname, value)[source]
classmethod required_keys() Sequence[str]

Returns a list of all configdataclass fields, that have no default value assigned and need to be specified on instantiation.

Returns:

a list of strings containing all required keys.

rs485_address: int = 2
screw_scaling: int | float = 1
stage_configuration: int | EspStageConfig = 3
user_position_offset: int | float = 23.987
velocity: int | float = 4
class NewportSMC100PPSerialCommunication(configuration)[source]

Bases: SerialCommunication

Specific communication protocol implementation for NewportSMC100 controller. Already predefines device-specific protocol parameters in config.

class ControllerErrors(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

Possible controller errors with values as returned by the device in response to sent commands.

ADDR_INCORRECT = 'B'
CMD_EXEC_ERROR = 'V'
CMD_NOT_ALLOWED = 'D'
CMD_NOT_ALLOWED_CC = 'X'
CMD_NOT_ALLOWED_CONFIGURATION = 'I'
CMD_NOT_ALLOWED_DISABLE = 'J'
CMD_NOT_ALLOWED_HOMING = 'L'
CMD_NOT_ALLOWED_MOVING = 'M'
CMD_NOT_ALLOWED_NOT_REFERENCED = 'H'
CMD_NOT_ALLOWED_PP = 'W'
CMD_NOT_ALLOWED_READY = 'K'
CODE_OR_ADDR_INVALID = 'A'
COM_TIMEOUT = 'S'
DISPLACEMENT_OUT_OF_LIMIT = 'G'
EEPROM_ACCESS_ERROR = 'U'
ESP_STAGE_NAME_INVALID = 'F'
HOME_STARTED = 'E'
NO_ERROR = '@'
PARAM_MISSING_OR_INVALID = 'C'
POSITION_OUT_OF_LIMIT = 'N'
check_for_error(add: int) None[source]

Ask the Newport controller for the last error it recorded.

This method is called after every command or query.

Parameters:

add – controller address (1 to 31)

Raises:
static config_cls()[source]

Return the default configdataclass class.

Returns:

a reference to the default configdataclass class

query(add: int, cmd: str, param: int | float | str | None = None) str[source]

Send a query to the controller, read the answer, and check for errors. The prefix add+cmd is removed from the answer.

Parameters:
  • add – the controller address (1 to 31)

  • cmd – the command to be sent

  • param – optional parameter (int/float/str) appended to the command

Returns:

the answer from the device without the prefix

Raises:
query_multiple(add: int, cmd: str, prefixes: list[str]) list[str][source]

Send a query to the controller, read the answers, and check for errors. The prefixes are removed from the answers.

Parameters:
  • add – the controller address (1 to 31)

  • cmd – the command to be sent

  • prefixes – prefixes of each line expected in the answer

Returns:

list of answers from the device without prefix

Raises:
read_text() str[source]

Read one line of text from the serial port, and check for presence of a null char which indicates that the motor power supply was cut and then restored. The input buffer may hold additional data afterwards, since only one line is read.

This method uses self.access_lock to ensure thread-safety.

Returns:

String read from the serial port; ‘’ if there was nothing to read.

Raises:
send_command(add: int, cmd: str, param: int | float | str | None = None) None[source]

Send a command to the controller, and check for errors.

Parameters:
  • add – the controller address (1 to 31)

  • cmd – the command to be sent

  • param – optional parameter (int/float/str) appended to the command

Raises:
send_stop(add: int) None[source]

Send the general stop ST command to the controller, and check for errors.

Parameters:

add – the controller address (1 to 31)

Returns:

ControllerErrors reported by Newport Controller

Raises:
class NewportSMC100PPSerialCommunicationConfig(terminator: bytes = b'\r\n', encoding: str = 'ascii', encoding_error_handling: str = 'replace', wait_sec_read_text_nonempty: Union[int, float] = 0.5, default_n_attempts_read_text_nonempty: int = 10, port: Optional[str] = None, baudrate: int = 57600, parity: Union[str, hvl_ccb.comm.serial.SerialCommunicationParity] = <SerialCommunicationParity.NONE: 'N'>, stopbits: Union[int, hvl_ccb.comm.serial.SerialCommunicationStopbits] = <SerialCommunicationStopbits.ONE: 1>, bytesize: Union[int, hvl_ccb.comm.serial.SerialCommunicationBytesize] = <SerialCommunicationBytesize.EIGHTBITS: 8>, timeout: Union[int, float] = 10)[source]

Bases: SerialCommunicationConfig

baudrate: int = 57600

Baudrate for NewportSMC100 controller is 57600 baud

bytesize: int | SerialCommunicationBytesize = 8

NewportSMC100 controller uses 8 bits for one data byte

encoding: str = 'ascii'

use ASCII as de-/encoding, cf. the manual

encoding_error_handling: str = 'replace'

replace bytes with � instead of raising utf-8 exception when decoding fails

force_value(fieldname, value)

Forces a value to a dataclass field despite the class being frozen.

NOTE: you can define post_force_value method with same signature as this method to do extra processing after value has been forced on fieldname.

Parameters:
  • fieldname – name of the field

  • value – value to assign

classmethod keys() Sequence[str]

Returns a list of all configdataclass fields key-names.

Returns:

a list of strings containing all keys.

classmethod optional_defaults() dict[str, object]

Returns a list of all configdataclass fields, that have a default value assigned and may be optionally specified on instantiation.

Returns:

a list of strings containing all optional keys.

parity: str | SerialCommunicationParity = 'N'

NewportSMC100 controller does not use parity

classmethod required_keys() Sequence[str]

Returns a list of all configdataclass fields, that have no default value assigned and need to be specified on instantiation.

Returns:

a list of strings containing all required keys.

stopbits: int | SerialCommunicationStopbits = 1

NewportSMC100 controller uses one stop bit

terminator: bytes = b'\r\n'

The terminator is CR/LF

timeout: int | float = 10

use 10 seconds timeout as default

exception NewportSerialCommunicationError[source]

Bases: NewportError

Communication error with the Newport controller.

class NewportStates(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: AutoNumberNameEnum

States of the Newport controller. Certain commands are allowed only in certain states.

CONFIG = 3
DISABLE = 6
HOMING = 2
JOGGING = 7
MOVING = 5
NO_REF = 1
READY = 4
exception NewportUncertainPositionError[source]

Bases: NewportError

Error with the position of the Newport motor.