qmi.instruments.parallax.usb_propeller

Instrument driver for the Parallax USB Propeller, for servo control.

Classes

Parallax_UsbPropeller(context, name, transport)

Instrument driver for the Parallax USB Propeller for servo control.

class qmi.instruments.parallax.usb_propeller.Parallax_UsbPropeller(context: QMI_Context, name: str, transport: str)

Instrument driver for the Parallax USB Propeller for servo control.

open() None

Connect to the instrument hardware.

When this method returns, the instrument must be ready for interaction via calls to instrument-specific methods.

Subclasses can extend this method to implement instrument-specific initialization. If they do, they should call super().open() as a last statement.

close() None

Close the connection to the instrument hardware and release associated resources.

When this method returns, the instrument must not be used again unless it is first re-opened by calling the open() method.

Subclasses can extend this method if they have specific resources to close. If they do, they should call super().close() as a last statement.

get_idn() QMI_InstrumentIdentification

Read instrument type and version and return QMI_InstrumentIdentification instance.

set_target_value(channel: int, value: int) None

Set Servo channel to move given value time with certain ramp speed. The time value represents a pulse width with 2us increments. For example, to send a 1 ms pulse to a channel you would use a pulse width value of 500 (500 x 2 us = 1000 us = 1 ms).

Parameters:
  • channel – The channel number.

  • value – The servo target move value [1-1024], in 2us increments.

set_default_move(channel: int, value: int) None

Set Servo channel default move time at start-up. This value is then stored in EEPROM. The time value represents a pulse width with 2us increments. For example, to send a 1 ms pulse to a channel you would use a pulse width value of 500 (500 x 2 us = 1000 us = 1 ms).

Parameters:
  • channel – The channel number.

  • value – The servo target move value [1-1024].

get_target_values() List[int]

Return the current target values list.

get_value(channel: int) int

Return current value of a servo channel.

Parameters:

channel – The channel number.

Returns:

The channel position.

set_speed(channel: int, speed: int) None

Set speed of channel in steps between 0 and 64. This option specifies the speed of the servo.

Parameters:
  • channel – The channel number.

  • speed – The servo ramp speed value [0-63].

Raises:

ValueError if speed not in range 0-1000.

get_speed(channel: int) int

Get ramp speed of a channel.

Parameters:

channel – The channel number.

Returns:

The servo ramp speed value of the channel [0-63].

Return type:

speed

set_baud_rate(baud_rate: int) None

Set the servo baud rate.

Parameters:

baud_rate – The new baud rate, either as 0, 1, 2400 or 38400. 0 == 2400 and 1 == 38400

Raises:
  • ValueError if input baud_rate is not valid.

  • AssertionError if returned baud_rate_set is not the same as the set baud rate.

set_software_port_range(port_range: int) None

Set software port range to 0-15 or 16-31.

Parameters:

port_range – The new port range, either as 0 for 0-15 or 1 for 16-31.

Raises:
  • ValueError if input port_range is not valid.

  • AssertionError if returned port_range_set is not the same as the set port range.

disable_servo_channel(channel: int) None

Disable a servo channel. This will cause any connected servo to become lax and not try to hold its position.

Parameters:

channel – The channel number.

enable_servo_channel(channel: int) None

Enable a servo channel. Enabling a channel will cause it to move to the last position it was commanded to, or the startup default if no other position commands have been sent since power up/reset.

Parameters:

channel – The channel number.

set_startup_servo_mode(servo_mode: int) None

Set startup servo mode to either center at startup or to use custom positions stored in EEPROM.

Parameters:

servo_mode – The new servo mode, either as 0 for center or 1 for custom from EEPROM.

Raises:
  • ValueError if input servo_mode is not valid.

  • AssertionError if returned servo_mode_set is not the same as the set servo mode.

clear() None

This command will set all custom settings, like Port Mode, Servo Disabled, Startup Mode and Default Positions, of the servo back to default.

Raises:

AssertionError if returned message after clear is not "CLR".

move_up(channel: int) None

Moves the servo to maximal value.

Parameters:

channel – The channel number.

move_down(channel: int) None

Moves the servo to minimal value.

Parameters:

channel – The channel number.

is_moving(channel: int) bool

This method checks if the servo is still moving.

Returns:

True if servo is still moving, otherwise False.

set_min(channel: int, value: int) None

Replace the minimum value for a channel.

Parameters:
  • channel – The channel number.

  • value – The new minimum target value.

set_max(channel: int, value: int) None

Replace the maximum value for a channel.

Parameters:
  • channel – The channel number.

  • value – The new maximum target value.

force_unlock() None

Forcefully unlock the remote object.

This unlocks the object, regardless of who owns the lock. This allows you to unlock an object if the locking proxy has been destroyed without unlocking.

Use this with care.

Do not override this stub method in subclasses. It has already been implemented in QMI_RpcProxy.

classmethod get_category() str | None

Return the optional name of the category this object belongs to.

A category name is a free-form string that has no special significance. Its purpose is to distinguish between groups of RPC objects that fulfill similar roles.

get_name() str

Return the name of this object.

Returns:

name attribute.

get_signals() list[SignalDescription]

Return a list of signals that can be published by this object.

Returns:

List consisting of qmi_signals attributes.

is_locked() bool

Query if the remote object is locked.

Do not override this stub method in subclasses. It has already been implemented in QMI_RpcProxy.

is_open() bool

Return True if the instrument is open (ready for interaction).

lock(timeout: float = 0.0, lock_token: str | None = None) bool

Lock the remote object. If timeout is given, try every 0.1s within the given timeout value. The remote object can be locked with an optional custom lock token by giving a string into lock_token keyword argument.

If successful, this proxy is the only proxy that can invoke RPC methods on the remote object; other proxies will receive an “object is locked” response. The return value indicates if the lock was granted; a denied lock means the object was already locked by another proxy.

Do not override this stub method in subclasses. It has already been implemented in QMI_RpcProxy.

release_rpc_object() None

Give a warning if the instrument is removed while still open.

unlock(lock_token: str | None = None) bool

Unlock the remote object.

Without optional parameters, this is only allowed by the proxy that initially locked the object. By giving the lock token as an input parameter, the specific object locked by this token can be unlocked. The return value indicates if the unlocking was successful.

Do not override this stub method in subclasses. It has already been implemented in QMI_RpcProxy.