![]() |
Mechatronics Portfolio
Logan Williamson's Mechatronics Portfolio and Documentation Repository
|
Implementation of motor control as an FSM. More...
Functions | |
def | Lab0x03_taskMotor.taskMotorFcn (taskName, period, faultFlag, duty1, duty2) |
A generator to implement the motor task as an FSM. More... | |
Variables | |
Lab0x03_taskMotor.S0_INIT = micropython.const(0) | |
Creates object S0_INIT set to constant 0. More... | |
Lab0x03_taskMotor.S1_RUN = micropython.const(1) | |
Creates object S1_RUN set to constant 1. More... | |
Lab0x03_taskMotor.S2_FAULT = micropython.const(2) | |
Creates object S2_FAULT set to constant 2. More... | |
Implementation of motor control as an FSM.
This task instantiates and controls the behavior of a DRV8847 motor driver and its subordinate motor drivers. It does so by operating as a finite state machine in coordiantion with the taskUser.py user interface.
def Lab0x03_taskMotor.taskMotorFcn | ( | taskName, | |
period, | |||
faultFlag, | |||
duty1, | |||
duty2 | |||
) |
A generator to implement the motor task as an FSM.
The task runs as a generator function and requires a task name and interval to be specified.
taskName | The name of the task as a string. |
period | The task interval or period specified as an integer number of microseconds. |
faultFlag | Shared flag variable created so it can be passed to taskUser; this prompts the user to clear the fault before operation of the motors can be continued. |
duty1 | Shared data for control of the duty cycle for the motor 1 object. This effectively controls the speed of motor 1 because PMDC motors act as low pass filters. |
duty2 | Shared data for control of the duty cycle for the motor 2 object. This effectively controls the speed of motor 2 because PMDC motors act as low pass filters. |
Lab0x03_taskMotor.S0_INIT = micropython.const(0) |
Creates object S0_INIT set to constant 0.
S0_INIT is used to initialize the FSM. Simply transitions from S0 to S1.
Lab0x03_taskMotor.S1_RUN = micropython.const(1) |
Creates object S1_RUN set to constant 1.
S1_INIT is the running state of the FSM. In this state, the user will be able to set the duty cycle for the motor objects instantiated by the DRV8847 class. The motors will run at the set duty cycle until a new duty cycle is selected, or a fault indication is detected.
Lab0x03_taskMotor.S2_FAULT = micropython.const(2) |
Creates object S2_FAULT set to constant 2.
S2_FAULT is the fault state for the motor(s). When the fault attribute of the DRV8847 is True, this state is entered and the shared faultFlag variable is set to True. taskMotor will stay in this state until the user clears this fault i.e. resets the faultFlag to False.