north_c9.axis

Outputs

The following classes can be used to control outputs on the North Robotics C9.

Output

class north_c9.axis.Output(controller: north_c9.controller.C9Controller, output_number: int)

The Output class is used to control outputs on the North C9 with an easy-to-use interface. It provides a low-level set_state() method, along with higher-level on(), off() and toggle() methods.

>>> from north_c9.controller import C9Controller
>>> from north_c9.axis import Output
>>> c9 = C9Controller()
>>> output = Output(c9, 0)  # output number 0
>>> output.on()
>>> output.toggle()
>>> output.state
False

Create an instance of the Output class

Parameters
  • controller – connection to the C9Controller

  • output_number – the output that you would like to control (the first output is number 0)

off()

Turn off the output

on()

Turn on the output

set_state(state: bool)

Set the output state

Parameters

state – New output state, True is on, False is off

property state

Get the current state of the Output

Returns

True if the output is on, False if it is off

toggle()

Toggle the output, turning it on if it is off, and off if it is on

OpenOutput

class north_c9.axis.OpenOutput(controller: north_c9.controller.C9Controller, output_number: int, open_state: bool = True)

The OpenOutput class is a simple wrapper around the normal Output class that provides extra open and close methods that may be more intuitive in certain situations. The output state used when the output is “open” is configurable, defaulting to on / True.

Create an OpenOutput instance

Parameters
  • controller – connection to the C9Controller

  • output_number – the output that you would like to control (the first output is number 0)

  • open_state – the state to use when open is called (defaults to on / True)

close()

Close the output (sets the Output state to the opposite of open_state, defaults to False)

open()

Open the output (sets the Output state to the open_state, defaults to True)

Axes

The following classes can be used to control different types of axes connected to a C9.

Axis

class north_c9.axis.Axis(controller: north_c9.controller.C9Controller, axis_number: int, velocity_counts: Optional[int] = None, acceleration_counts: Optional[int] = None, max_position: Optional[int] = None, max_current: Optional[int] = None, home_velocity_counts: Optional[int] = None, home_acceleration_counts: Optional[int] = None, home_max_current: Optional[int] = None, home_to_block: bool = True, main: bool = False, reversed: bool = False, **kwargs)

The Axis class is a low-level class for controlling axes on the North Robotics C9. Higher-level RevoluteAxis and PrismaticAxis classes are also available.

Axis positions use counts as a (somwhat arbitrary) unit, and there are 1000 counts per revolution of the axis.

Parameters
  • controller – connection to the C9Controller

  • axis_number – the axis you would like to control

  • velocity_counts – the movement velocity in counts/s

  • acceleration_counts – the movement acceleration in counts/s^2

  • max_position – the maximum position of this axis, used when homing to a block

  • max_current – the max current to use when driving the motor for this axis in mA

  • home_velocity_counts – the velocity to use while homing in counts/s

  • home_acceleration_counts – the acceleration to use while homing in counts/s^2

  • home_max_current – the max current to use while homing in mA

  • home_to_block – if True, homing will move axis in reverse for max_position counts

  • main – if True, this will be considered a main axis that cannot be homed separate from the robot

  • reversed – if True, the position and movement of the axis will be reversed

property current_velocity

Get the current velocity of the axis in counts/s

home()

Performs a homing procedure for the axis. If home_to_block is True, the axis will be moved in reverse for max_position counts.

move(counts: int, velocity: Optional[int] = None, acceleration: Optional[int] = None, relative: bool = False, wait: bool = True)

Start moving the axis. Absolute moves (the default) will move the axis until it reaches the given counts position, while relative moves will move the axis to the current position plus the given number of counts. For relative moves, a positive counts value will move the axis “forward” and a negative counts value will move it backwards.

Parameters
  • counts – the number of counts to move

  • velocity – optional velocity during the movement in counts/s

  • acceleration – optional acceleration during the movement in counts/s^s

  • relative – performs a relative move if True, an absolute move if False (defaults to False)

  • wait – wait for the movement to complete (defaults to True)

moving() → bool

Get the moving status of this axis

Returns

True if the axis is moving, False otherwise

property position

Get the current position of the axis in counts

set_max_current(current, update: bool = True)

Set the max current and write it to the C9

Parameters

update – don’t update self.max_current if False

wait()

Wait for the axis to stop moving

write_axis_settings()

Write axis settings to the C9

RevoluteAxis

class north_c9.axis.RevoluteAxis(controller: north_c9.controller.C9Controller, axis: int, counts_per_revolution: float = 1000.0, zero_position_degrees: float = 0.0, position_degrees: float = 0, velocity_degrees: float = None, acceleration_degrees: float = None, inverted: bool = False, **kwargs)

The RevoluteAxis class is a higher-level class for controlling revolute axes, which are axes that can spin continuously. It inherits from the Axis class, so it can take the same parameters and provides the same methods. Additionally, the RevoluteAxis class provides additional methods to work with movements in degrees and RPM.

property acceleration_degrees
property current_velocity_degrees

Get or set the current velocity of the axis in degrees/s

property current_velocity_rpm

Get or set the current velocity of the axis in RPM

move_degrees(degrees: float, velocity_degrees: Optional[float] = None, acceleration_degrees: Optional[float] = None, relative: bool = False, wait: bool = True)

Start moving the axis using degrees as the unit. Absolute moves (the default) will move the axis until it reaches the given degrees position, while relative moves will move the axis to the current position plus the given number of degrees. For relative moves, a positive degrees value will move the axis clockwise and a negative degrees value will move it counter-clockwise.

Parameters
  • degrees – the number of degrees to move

  • velocity_degrees – optional velocity during the movement in degrees/s

  • acceleration_degrees – optional acceleration during the movement in degrees/s^s

  • relative – performs a relative move if True, an absolute move if False (defaults to False)

  • wait – wait for the movement to complete (defaults to True)

property position_degrees

Get or set the current position of the axis in degrees

spin(velocity_rpm: float, acceleration_rpm: float, duration: Optional[float] = None)

Start spinning the axis

Parameters
  • velocity_rpm – velocity to spin at in RPM

  • acceleration_rpm – acceleration to use for spinning in RPM

  • duration – optional duration to spin the axis for, defaults to spinning indefinitely

spin_stop(wait: bool = False)

Stop spinning the axis

Parameters

wait – wait for the axis to stop spinning (defaults to False)

property velocity_degrees

Get or set the velocity of the axis in degrees/s

PrismaticAxis

class north_c9.axis.PrismaticAxis(controller: north_c9.controller.C9Controller, axis: int, counts_per_mm: float = 1.0, position_mm: float = 0.0, zero_position_mm: float = 0.0, velocity_mm: Optional[float] = None, acceleration_mm: Optional[float] = None, inverted: bool = False, **kwargs)

The PrismaticAxis class is a higher-level class for controlling prismatic axes, which are axes that move linearly. It inherits from the Axis class, so it can take the same parameters and provides the same methods. Additionally, the PrismaticAxis class provides additional methods to work with movements in mm.

property acceleration_mm

Get or set the acceleration in mm

move_mm(mm: float, velocity_mm: Optional[float] = None, acceleration_mm: Optional[float] = None, relative: bool = False, wait: bool = True)

Start moving the axis using mm as the unit. Absolute moves (the default) will move the axis until it reaches the given mm position, while relative moves will move the axis to the current position plus the given number of mm. For relative moves, a positive mm value will move the axis forward and a negative mm value will move it backward.

Parameters
  • mm – the number of degrees to move

  • velocity_mm – optional velocity during the movement in mm/s

  • acceleration_mm – optional acceleration during the movement in mm/s^s

  • relative – performs a relative move if True, an absolute move if False (defaults to False)

  • wait – wait for the movement to complete (defaults to True)

property position_mm

Get the current position in mm

property velocity_mm

Get or set the velocity in mm

Exceptions

exception north_c9.axis.AxisError

Base class for Axis exceptions

exception north_c9.axis.AxisMoveError

Axis movement exception