StepperDriver
robodyno.components.can_bus.stepper_driver
Stepper develop board driver.
The stepper develop board provides a stepper motor driver with a CAN bus interface. It can be used to configure the stepper motor driver and control the stepper motor.
Examples:
>>> from robodyno.components import StepperDriver
>>> from robodyno.interfaces import CanBus
>>> can = CanBus()
>>> stepper = StepperDriver(can)
>>> stepper.enable()
>>> stepper.set_vel(1)
>>> can.disconnect()
StepperDriver
Bases: CanBusDevice
Stepper develop board driver.
Attributes:
Name | Type | Description |
---|---|---|
id |
int
|
Device id. |
type |
Model
|
Device type. |
fw_ver |
float
|
Firmware version. |
__init__(can, id_=34, reduction=1)
Initializes the stepper develop board driver.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
can |
CanBus
|
Can bus interface. |
required |
id_ |
int
|
Device id. |
34
|
reduction |
float
|
The reduction ratio of the stepper motor. |
1
|
Raises:
Type | Description |
---|---|
ValueError
|
If the device is not a stepper develop board. |
config_can_bus(new_id)
Configures the CAN bus.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
new_id |
int
|
New device id. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
If the new id is not in the range of 0x01-0x3f. |
set_subdivision(subdivision)
Sets the subdivision of the stepper motor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
subdivision |
int
|
The subdivision of the stepper motor. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
If the subdivision is not 8, 16, 32 or 64. |
set_vel_acc_limit(max_vel, acc=None)
Sets the maximum velocity and acceleration of the stepper motor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
max_vel |
float
|
The maximum velocity of the stepper motor. |
required |
acc |
float
|
The acceleration of the stepper motor. If None, the acceleration is set to 4 times the maximum velocity. |
None
|
enable()
Enables the stepper motor.
disable()
Disables the stepper motor.
stop()
Stops the stepper motor.
set_pos(pos)
Sets the position of the stepper motor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pos |
float
|
The position of the stepper motor in radians. |
required |
set_vel(vel)
Sets the velocity of the stepper motor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vel |
float
|
The velocity of the stepper motor in rad/s. |
required |
get_pos(timeout=None)
Reads the position of the stepper motor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
timeout |
float
|
Timeout in seconds. |
None
|
Returns:
Type | Description |
---|---|
float | None
|
The position of the stepper motor in radians. Returns None if the read times out. |
get_vel(timeout=None)
Reads the velocity of the stepper motor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
timeout |
float
|
Timeout in seconds. |
None
|
Returns:
Type | Description |
---|---|
float | None
|
The velocity of the stepper motor in rad/s. Returns None if the read times out. |