GeminiMotorDrive

This is the GeminiMotorDrive package, a Python package for controlling a Parker Hannifin Gemini GV-6 and GT-6 servo and stepper motor drives.

Version 0.2

CommandError Exception executing a command.
GeminiError Base exception class for this module.
get_driver([driver]) Gets a driver for a Parker Motion Gemini drive.
GeminiG6(driver) Controller for a Parker Motion Gemini GV-6 or GT-6.

GeminiError

class GeminiMotorDrive.GeminiError[source]

Bases: OSError

Base exception class for this module.

CommandError

class GeminiMotorDrive.CommandError[source]

Bases: GeminiMotorDrive.GeminiError

Exception executing a command.

get_driver

GeminiMotorDrive.get_driver(driver='ASCII_RS232', *args, **keywords)[source]

Gets a driver for a Parker Motion Gemini drive.

Gets and connects a particular driver in drivers to a Parker Motion Gemini GV-6 or GT-6 servo/stepper motor drive.

The only driver currently supported is the 'ASCII_RS232' driver which corresponds to drivers.ASCII_RS232.

Parameters:
  • driver (str, optional) – The driver to communicate to the particular driver with, which includes the hardware connection and possibly the communications protocol. The only driver currently supported is the 'ASCII_RS232' driver which corresponds to drivers.ASCII_RS232.
  • *args (additional positional arguments) – Additional positional arguments to pass onto the constructor for the driver.
  • **keywords (additional keyword arguments) – Additional keyword arguments to pass onto the constructor for the driver.
Returns:

drivers (drivers) – The connected drivers class that is connected to the drive.

Raises:

NotImplementedError – If the driver is not supported.

GeminiG6

class GeminiMotorDrive.GeminiG6(driver)[source]

Bases: object

Controller for a Parker Motion Gemini GV-6 or GT-6.

An object to connect to and control a Parker Motion Gemini GV-6 or GT-6 servo/stepper motor drive already connected to with a particular driver.

Parameters:

driver (driver) – Connected instance of a class in drivers. Use get_driver to load one. Is stored in the attribute driver.

Raises:

GeminiError – If the attached device is not a Gemini GV-6 or GT-6.

Variables:

See also

get_driver

denergize_on_kill

De-energize motor when the drive is killed.

bool with True meaning that whenever the drive is given the kill signal, the motor will de-energize.

Setting it sends an immediate command to the drive to set it.

Notes

This uses the ‘KDRIVE’ command.

See also

energized
Get/set the motor energized state.
kill
Kill the drive.
driver = None

Driver for communicating to the drive.

driver

A class from GeminiMotorDriver.drivers. Can be loaded using get_driver.

See also

get_driver

electrical_pitch

The motor’s electrical pitch.

float with units of mm

It gives the spacing between two magnets (full magnetic cycle) on a linear motor. Velocities and accelerations are in units of pitches/s and pitches/s^2, so it is important.

Setting it sends an immediate command to the drive to change the electrical pitch.

Notes

This uses the ‘DMEPIT’ command.

encoder_resolution

Encoder/Resolver resolution.

int with units counts/rev (servo) or counts/pitch (linear)

Setting it sends an immediate command to the drive to change the encoder/resolver resolution.

Notes

This uses the ‘ERES’ command.

energized

Energized state of the motor.

bool with energized being True.

Setting it sends an immediate command to the drive to energize the motor.

Notes

This uses the ‘DRIVE’ command.

get_program(n, timeout=2.0, max_retries=2)[source]

Get a program from the drive.

Gets program ‘n’ from the drive and returns its commands.

Parameters:
  • n (int) – Which program to get.
  • timeout (number, optional) – Optional timeout in seconds to use when reading the response. A negative value or None indicates that the an infinite timeout should be used.
  • max_retries (int, optional) – Maximum number of retries to do per command in the case of errors.
Returns:

commands (list of str) – list of str commands making up the program. The trailing ‘END’ is removed. Empty if there was an error.

Notes

The command sent to the drive is ‘!TPROG PROGn’.

See also

set_program_profile()
Sets a program or profile.
run_program_profile()
Runs a program or profile.
kill(max_retries=0)[source]

Kills the drive.

The drive stops the motor and any running program. The motor will de-energize depending on the state of denergize_on_kill.

Parameters:max_retries (int, optional) – Maximum number of retries to do to kill the drive in the case of errors.
Returns:success (bool) – Whether the last kill command (last try or retry) was successful (True) or not (False meaning it had an error).

Notes

The command sent to the drive is ‘!K’.

See also

denergize_on_kill()
Controls whether the motor de-energizes after the drive is killed or not.
max_velocity

The motor’s velocity limit.

float in motor units

Notes

This uses the ‘DMVLIM’ command.

motion_commanded

Whether motion is commanded or not.

bool

Can’t be set.

Notes

It is the value of the first bit of the ‘TAS’ command.

pause(max_retries=0)[source]

Pauses the drive (execution of commands).

Causes the drive to pause execution of commands till it is unpaused. Commands will be queued until it is unpaused. Motion is not stopped.

Parameters:max_retries (int, optional) – Maximum number of retries to do to pause the drive in the case of errors.
Returns:success (bool) – Whether the last pause command (last try or retry) was successful (True) or not (False meaning it had an error).

Notes

The command sent to the drive is ‘!C’.

See also

unpause()
Unpause the drive.
reset(max_retries=0)[source]

Resets the drive.

Resets the drive, which is equivalent to a power cycling.

Parameters:max_retries (int, optional) – Maximum number of retries to do to reset the drive in the case of errors.
Returns:success (bool) – Whether the last reset command (last try or retry) was successful (True) or not (False meaning it had an error).

Notes

The command sent to the drive is ‘!RESET’.

run_program_profile(n, program_or_profile='program', timeout=10.0)[source]

Runs a program/profile on the drive.

Runs program or profile ‘n’ on the drive, grabs its output, and processes the output. The response from the drive is broken down into the echoed command (drive echoes it back), any error returned by the drive (leading ‘*’ is stripped), and the different lines of the response; which are all returned.

It is VERY IMPORTANT that ‘timeout’ is long enough for the program to run if all the output from the drive is to be collected.

Parameters:
  • n (int) – Which program to get.
  • program_or_profile ({‘program’, ‘profile’}, optional) – Whether to read a program or a profile. Anything other than these two values implies the default.
  • timeout (number, optional) – Optional timeout in seconds to use when reading the response for running a program (set to 1.0 for a profile regardless of what is given). A negative value or None indicates that the an infinite timeout should be used.
Returns:

output (list) – A 5-element list. The elements, in order, are the sanitized command (str), the full response (str), the echoed command (str), any error response (None if none, or the str of the error), and the lines of the response that are not the echo or error line (list of str with newlines stripped).

Notes

Sends ‘RUN PROGn’ (program) or ‘PRUN PROFn’ (profile) as the command to the drive. For a profile, the only output is that command echoed back. For a program, it will echo back each command in the program (preceeded by an ‘*’ and followed by a line feed as opposed to a carriage return).

See also

get_program()
Gets a program.
set_program_profile()
Sets a program or profile.
set_program_profile(n, commands, program_or_profile='program', timeout=1.0, max_retries=0)[source]

Sets a program/profile on the drive.

Sets program or profile ‘n’ on the drive to the sequence of commands in ‘commands’. If the existing program is identical, it is not overwritten (can’t check this for a profile). Returns whether the program or profile was successfully set or not (if the existing one is identical, it is considered a success).

Parameters:
  • n (int) – Which program to set.
  • commands (list or tuple of strings) – list or tuple of commands to send to the drive. Each command must be a string.
  • program_or_profile ({‘program’, ‘profile’}, optional) – Whether to read a program or a profile. Anything other than these two values implies the default.
  • timeout (number, optional) – Optional timeout in seconds to use when reading the response. A negative value or None indicates that the an infinite timeout should be used.
  • max_retries (int, optional) – Maximum number of retries to do per command in the case of errors.
Returns:

success (bool) – Whether the program or profile was successfully set or not (an identical program already existing on the drive is considered a success).

Notes

‘commands’ gets wrapped between [‘DEL PROGn’, ‘DEF PROGn’] and ‘END’ or the equivalent profile ones.

See also

get_program()
Gets a program.
run_program_profile()
Runs a program or profile.
stop(max_retries=0)[source]

Stops motion.

The drive stops the motor.

Parameters:max_retries (int, optional) – Maximum number of retries to do to kill the drive in the case of errors.
Returns:success (bool) – Whether the last stop command (last try or retry) was successful (True) or not (False meaning it had an error).

Notes

The command sent to the drive is ‘!S1’.

unpause(max_retries=0)[source]

Unpauses the drive.

Unpauses the drive. Commands queued while it is paused will then be executed.

Parameters:max_retries (int, optional) – Maximum number of retries to do to unpause the drive in the case of errors.
Returns:success (bool) – Whether the last unpause command (last try or retry) was successful (True) or not (False meaning it had an error).

Notes

The command sent to the drive is ‘!C’.

See also

pause()
Pause the drive.