Mechatronics Portfolio
Logan Williamson's Mechatronics Portfolio and Documentation Repository
|
Implementation of motor control as an FSM. More...
Functions | |
def | taskMotor.taskMotorFcn (taskName, period, faultFlag, duty_y, duty_x, K_pi, K_di, K_po, K_do, setpoint_x, setpoint_y, wFlag, posDATA, speedDATA, DATA) |
A generator to implement the motor task as an FSM. More... | |
Variables | |
taskMotor.S0_INIT = micropython.const(0) | |
Creates object S0_INIT set to constant 0. More... | |
taskMotor.S1_RUN = micropython.const(1) | |
Creates object S1_RUN set to constant 1. More... | |
taskMotor.S2_CL = micropython.const(2) | |
Creates object S2_CL 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.
This task instantiates and controls the behavior of two motor.Motor objects. It does so by operating as a finite state machine. This task file runs cooperatively with the taskUser.py user interface, taskPanel.py touchpanel task file, and taskIMU.py inertial measurement unit task file.
def taskMotor.taskMotorFcn | ( | taskName, | |
period, | |||
faultFlag, | |||
duty_y, | |||
duty_x, | |||
K_pi, | |||
K_di, | |||
K_po, | |||
K_do, | |||
setpoint_x, | |||
setpoint_y, | |||
wFlag, | |||
posDATA, | |||
speedDATA, | |||
DATA | |||
) |
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 | Flag variable shared with taskPanel. If the touchpanel.touchpanel object controlled by the taskPanel state machine does not detect contact, faultFlag is set True and the closedLoop.ClosedLoop objects controlling the motors will return the platform to the 'home' (level) position. |
duty_y | Shared data for control of the duty cycle for the motor_y object. This effectively controls the speed of motor_y because PMDC motors act as low pass filters. |
duty_x | Shared data for control of the duty cycle for the motor_x object. This effectively controls the speed of motor_x because PMDC motors act as low pass filters. |
K_pi | Shared data used in a closedLoop.ClosedLoop controller object. This data is the closed-loop proportional gain factor for the inner loop of a cascading closed-loop controller. |
K_di | Shared data used in a closedLoop.ClosedLoop controller object. This data is the closed-loop derivative gain factor for the inner loop of a cascading closed-loop controller. |
K_po | Shared data used in a closedLoop.ClosedLoop controller object. This data is the closed-loop proportional gain factor for the outer loop of a cascading closed-loop controller. |
K_do | Shared data used in a closedLoop.ClosedLoop controller object. This data is the closed-loop derivative gain factor for the outer loop of a cascading closed-loop controller. |
setpoint_x | Shared data used in a closedLoop.ClosedLoop controller object. This data is used as the setpoint position desired by the user, which the closed loop controller uses to compute the difference between the setpoint and measured position readout from a touchpanel.touchpanel object. |
setpoint_y | Shared data used in a closedLoop.ClosedLoop controller object. This data is used as the setpoint position desired by the user, which the closed loop controller uses to compute the difference between the setpoint and measured position readout from a touchpanel.touchpanel object. |
wFlag | Shared flag variable with taskUser. Allows the user to toggle the operating state of taskMotor between manual to closed-loop operation. |
posDATA | Shared data used in a closedLoop.ClosedLoop controller object. This data represents the angular position readout from a BNO055.BNO055 object in degrees. |
speedDATA | Shared data used in a closedLoop.ClosedLoop controller object. This data is used as the measured angular velocity of a BNO055.BNO055 object which the closed loop controller uses to damp the motion generated by the controller. |
DATA | Shared data for control of the duty cycle by means of closed-loop controller. This data contains the measured x- and y-position readouts from a touchpanel.touchpanel object. |
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.
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 object(s). The motor(s) will run at the set duty cycle until a new duty cycle is selected.
taskMotor.S2_CL = micropython.const(2) |
Creates object S2_CL set to constant 2.
S2_CL is the closed loop control state for the motor(s). In this state, the user will be unable to control the duty cycle (and associated speed) of the motor directly. Instead, this state will use closedLoop.ClosedLoop object(s) to control the motors.