|
| 1 | + |
| 2 | +StepMotorDriverModule |
| 3 | +===================== |
| 4 | + |
| 5 | +.. include:: ../refs/module.stepmotordrivermodule.ref |
| 6 | + |
| 7 | +StepMotor Driver Module 13.2 V1.1 is a stepper motor driver adapted to M5 main control, using STM32+HR8825 stepper motor drive scheme, providing 3-way bipolar stepper motor control interface. |
| 8 | + |
| 9 | +Support the following products: |
| 10 | + |
| 11 | +|StepMotorDriverModule| |
| 12 | + |
| 13 | +Micropython Example: |
| 14 | + |
| 15 | + .. literalinclude:: ../../../examples/module/step_motor_driver.py |
| 16 | + :language: python |
| 17 | + :linenos: |
| 18 | + |
| 19 | + |
| 20 | +UIFLOW2 Example: |
| 21 | + |
| 22 | + |example.png| |
| 23 | + |
| 24 | +.. only:: builder_html |
| 25 | + |
| 26 | + |step_motor_driver.m5f2| |
| 27 | + |
| 28 | +class StepMotorDriverModule |
| 29 | +--------------------------- |
| 30 | + |
| 31 | +Constructors |
| 32 | +------------ |
| 33 | + |
| 34 | +.. class:: StepMotorDriverModule(address, step_pin, dir_pin) |
| 35 | + |
| 36 | + Initialize the StepMotorDriverModule. |
| 37 | + |
| 38 | + :param hex address: The I2C address of the device. |
| 39 | + :param tuple step_pin: The step pin (X, Y, Z) of the motor. |
| 40 | + :param tuple dir_pin: The dir pin (X, Y, Z) of the motor. |
| 41 | + |
| 42 | + UIFLOW2: |
| 43 | + |
| 44 | + |init.png| |
| 45 | + |
| 46 | + |
| 47 | +Methods |
| 48 | +------- |
| 49 | + |
| 50 | +.. method:: StepMotorDriverModule.reset_motor(motor_id, state) |
| 51 | + |
| 52 | + Reset the motor. |
| 53 | + |
| 54 | + :param motor_id: The motor to reset. |
| 55 | + Options: |
| 56 | + - ``X``: StepMotorDriverModule.MOTOR_X |
| 57 | + - ``Y``: StepMotorDriverModule.MOTOR_Y |
| 58 | + - ``Z``: StepMotorDriverModule.MOTOR_Z |
| 59 | + :param bool state: The state of the motor. |
| 60 | + |
| 61 | + UIFLOW2: |
| 62 | + |
| 63 | + |reset_motor.png| |
| 64 | + |
| 65 | +.. method:: StepMotorDriverModule.set_motor_state(state) |
| 66 | + |
| 67 | + Enable or disable the motor. |
| 68 | + |
| 69 | + :param bool state: The state of the motor. |
| 70 | + |
| 71 | + UIFLOW2: |
| 72 | + |
| 73 | + |set_motor_state.png| |
| 74 | + |
| 75 | +.. method:: StepMotorDriverModule.set_microstep(step) |
| 76 | + |
| 77 | + Set the microstep. |
| 78 | + |
| 79 | + :param step: The microstep value. |
| 80 | + Options: |
| 81 | + - ``FULL``: StepMotorDriverModule.STEP_FULL |
| 82 | + - ``1/2``: StepMotorDriverModule.STEP1_2 |
| 83 | + - ``1/4``: StepMotorDriverModule.STEP1_4 |
| 84 | + - ``1/8``: StepMotorDriverModule.STEP1_8 |
| 85 | + - ``1/16``: StepMotorDriverModule.STEP1_16 |
| 86 | + - ``1/32``: StepMotorDriverModule.STEP1_32 |
| 87 | + |
| 88 | + UIFLOW2: |
| 89 | + |
| 90 | + |set_microstep.png| |
| 91 | + |
| 92 | +.. method:: StepMotorDriverModule.set_motor_pwm_freq(motor_id, freq) |
| 93 | + |
| 94 | + Set the motor pwm freq. |
| 95 | + |
| 96 | + :param motor_id: The motor to set the freq. |
| 97 | + Options: |
| 98 | + - ``X``: StepMotorDriverModule.MOTOR_X |
| 99 | + - ``Y``: StepMotorDriverModule.MOTOR_Y |
| 100 | + - ``Z``: StepMotorDriverModule.MOTOR_Z |
| 101 | + :param int freq: The freq value. |
| 102 | + |
| 103 | + UIFLOW2: |
| 104 | + |
| 105 | + |set_motor_pwm_freq.png| |
| 106 | + |
| 107 | +.. method:: StepMotorDriverModule.set_motor_direction(motor_id, direction) |
| 108 | + |
| 109 | + Set the motor direction. |
| 110 | + |
| 111 | + :param motor_id: The motor to set the direction. |
| 112 | + Options: |
| 113 | + - ``X``: StepMotorDriverModule.MOTOR_X |
| 114 | + - ``Y``: StepMotorDriverModule.MOTOR_Y |
| 115 | + - ``Z``: StepMotorDriverModule.MOTOR_Z |
| 116 | + :param bool direction: The direction value. |
| 117 | + Options: |
| 118 | + - ``Positive``: 1 |
| 119 | + - ``Negative``: 0 |
| 120 | + |
| 121 | + UIFLOW2: |
| 122 | + |
| 123 | + |set_motor_direction.png| |
| 124 | + |
| 125 | +.. method:: StepMotorDriverModule.get_all_limit_switch_state() |
| 126 | + |
| 127 | + Get all io state. |
| 128 | + |
| 129 | + |
| 130 | + UIFLOW2: |
| 131 | + |
| 132 | + |get_all_limit_switch_state.png| |
| 133 | + |
| 134 | +.. method:: StepMotorDriverModule.get_limit_switch_state(switch_id) |
| 135 | + |
| 136 | + Get the io state. |
| 137 | + |
| 138 | + :param int switch_id: The io id. |
| 139 | + |
| 140 | + UIFLOW2: |
| 141 | + |
| 142 | + |get_limit_switch_state.png| |
| 143 | + |
| 144 | +.. method:: StepMotorDriverModule.get_fault_io_state(motor_id) |
| 145 | + |
| 146 | + Get the fault io state. |
| 147 | + |
| 148 | + :param int motor_id: The motor id. |
| 149 | + Options: |
| 150 | + - ``X``: StepMotorDriverModule.MOTOR_X |
| 151 | + - ``Y``: StepMotorDriverModule.MOTOR_Y |
| 152 | + - ``Z``: StepMotorDriverModule.MOTOR_Z |
| 153 | + |
| 154 | + UIFLOW2: |
| 155 | + |
| 156 | + |get_fault_io_state.png| |
| 157 | + |
| 158 | +.. method:: StepMotorDriverModule.motor_control(motor_id, state) |
| 159 | + |
| 160 | + Control the motor to rotate/stop. |
| 161 | + |
| 162 | + :param motor_id: The motor id. |
| 163 | + Options: |
| 164 | + - ``X``: StepMotorDriverModule.MOTOR_X |
| 165 | + - ``Y``: StepMotorDriverModule.MOTOR_Y |
| 166 | + - ``Z``: StepMotorDriverModule.MOTOR_Z |
| 167 | + :param bool state: The state value. |
| 168 | + Options: |
| 169 | + - ``Rotate``: 1 |
| 170 | + - ``Stop``: 0 |
| 171 | + |
| 172 | + UIFLOW2: |
| 173 | + |
| 174 | + |motor_control.png| |
| 175 | + |
| 176 | +.. method:: StepMotorDriverModule.get_firmware_version() |
| 177 | + |
| 178 | + Get the firmware version. |
| 179 | + |
| 180 | + |
| 181 | + UIFLOW2: |
| 182 | + |
| 183 | + |get_firmware_version.png| |
| 184 | + |
| 185 | +.. method:: StepMotorDriverModule.set_i2c_address(new_address) |
| 186 | + |
| 187 | + Set the i2c address. |
| 188 | + |
| 189 | + :param int new_address: The new address. |
| 190 | + |
| 191 | + UIFLOW2: |
| 192 | + |
| 193 | + |set_i2c_address.png| |
| 194 | + |
| 195 | + |
| 196 | + |
| 197 | +Constants |
| 198 | +--------- |
| 199 | + |
| 200 | + .. data:: StepMotorDriverModule.MOTOR_X |
| 201 | + .. data:: StepMotorDriverModule.MOTOR_Y |
| 202 | + .. data:: StepMotorDriverModule.MOTOR_Z |
| 203 | + |
| 204 | + Motor IDs |
| 205 | + |
| 206 | + .. data:: StepMotorDriverModule.MOTOR_STATE_ENABLE |
| 207 | + .. data:: StepMotorDriverModule.MOTOR_STATE_DISABLE |
| 208 | + |
| 209 | + Motor states |
| 210 | + |
| 211 | + .. data:: StepMotorDriverModule.INPUT_REG |
| 212 | + .. data:: StepMotorDriverModule.OUTPUT_REG |
| 213 | + .. data:: StepMotorDriverModule.POLINV_REG |
| 214 | + .. data:: StepMotorDriverModule.CONFIG_REG |
| 215 | + .. data:: StepMotorDriverModule.FAULT_REG |
| 216 | + .. data:: StepMotorDriverModule.RESET_REG |
| 217 | + .. data:: StepMotorDriverModule.FIRM_REG |
| 218 | + .. data:: StepMotorDriverModule.I2C_REG |
| 219 | + |
| 220 | + Register addresses |
| 221 | + |
| 222 | + .. data:: StepMotorDriverModule.STEP_FULL |
| 223 | + .. data:: StepMotorDriverModule.STEP1_2 |
| 224 | + .. data:: StepMotorDriverModule.STEP1_4 |
| 225 | + .. data:: StepMotorDriverModule.STEP1_8 |
| 226 | + .. data:: StepMotorDriverModule.STEP1_16 |
| 227 | + .. data:: StepMotorDriverModule.STEP1_32 |
| 228 | + |
| 229 | + Microstep values |
| 230 | + |
0 commit comments