![]() |
Mechatronics Portfolio
Logan Williamson's Mechatronics Portfolio and Documentation Repository
|
Implimentation of User Interface task as an FSM. More...
Functions | |
def | Lab0x03_taskUser.taskUserFcn (taskName, period, zFlag, timDATA, posDATA, delDATA, DATA, speedDATA, faultFlag, duty1, duty2) |
A generator to implement the UI task as an FSM. More... | |
Variables | |
Lab0x03_taskUser.S0_INIT = micropython.const(0) | |
Creates object S0_INIT connected to constant 0. More... | |
Lab0x03_taskUser.S1_Wait = micropython.const(1) | |
Creates object S1_Wait connected to constant 1. More... | |
Lab0x03_taskUser.S2_zZeroEnc1 = micropython.const(2) | |
Creates object S2_zZeroEnc1 connected to constant 2. More... | |
Lab0x03_taskUser.S3_pPrintPos = micropython.const(3) | |
Creates object S3_pPrintPos connected to constant 3. More... | |
Lab0x03_taskUser.S4_dDelta = micropython.const(4) | |
Creates object S4_dDelta connected to constant 4. More... | |
Lab0x03_taskUser.S5_vVelocity = micropython.const(5) | |
Creates object S5_vVelocity connected to constant 5. More... | |
Lab0x03_taskUser.S6_mDutyCtrl = micropython.const(6) | |
Creates object S6_mDutyCtrl connected to constant 6. More... | |
Lab0x03_taskUser.S7_clrFault = micropython.const(7) | |
Creates object S8_clrFault connected to constant 8. More... | |
Lab0x03_taskUser.S8_gCollectThirtySec = micropython.const(8) | |
Creates object S8_gCollectThirtySec connected to constant 9. More... | |
Lab0x03_taskUser.S9_tTestInt = micropython.const(9) | |
Creates object S9_tTestInt connected to constant 9. More... | |
Lab0x03_taskUser.S10_PrintData = micropython.const(10) | |
Creates object S10_PrintData connected to constant 10. More... | |
Lab0x03_taskUser.S11_testingDutySet = micropython.const(11) | |
Creates object S11_testingDutySet connected to constant 11. More... | |
Lab0x03_taskUser.S12_testingDataCrunch = micropython.const(12) | |
Creates object S12_testingDataCrunch connected to constant 12. More... | |
Implimentation of User Interface task as an FSM.
The task uses the USB VCP (Virtual COM Port) to take character input from the user working at a serial terminal such as PuTTY. It uses this input with Finite State Machine logic to determine which functionality should be executed based on that user input. This file works cooperatively with taskEncoder.py to allow both files' functionality to be executed quasi- simultaneously.
def Lab0x03_taskUser.taskUserFcn | ( | taskName, | |
period, | |||
zFlag, | |||
timDATA, | |||
posDATA, | |||
delDATA, | |||
DATA, | |||
speedDATA, | |||
faultFlag, | |||
duty1, | |||
duty2 | |||
) |
A generator to implement the UI 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. |
zFlag | Shared flag variable which causes FSM to enter zeroing state. |
timDATA | Shared data for the time during a data recording session. This is not currently utilized by taskUser.py (instead, it is immediately fed into DATA); however, this is shared to taskUser for debugging purposes. |
posDATA | Shared data for printing the position of the encoder upon 'p' or 'P' press. |
delDATA | Shared data for printing the delta value of the encoder upon 'd' or 'D' press. |
DATA | Shared data for data recording upon 'g' or 'G' press. |
speedDATA | Shared data for printing the velocity of the encoder upon 't' or 'T' press. |
faultFlag | Shared flag variable for indicating when a fault condition has occurred. |
duty1 | Shared data for controlling the duty cycle of the motor_1 object, effectively controlling its speed. |
duty2 | Shared data for controlling the duty cycle of the motor_2 object, effectively controlling its speed. |
Lab0x03_taskUser.S0_INIT = micropython.const(0) |
Creates object S0_INIT connected to constant 0.
S0_INIT is used as an initialization state it prints the help interface block and sends FSM to state 1 (S1_Wait)
Lab0x03_taskUser.S10_PrintData = micropython.const(10) |
Creates object S10_PrintData connected to constant 10.
S10_PrintData is used to print the compiled data that has been collected from both Encoder data or Testing data.
Lab0x03_taskUser.S11_testingDutySet = micropython.const(11) |
Creates object S11_testingDutySet connected to constant 11.
S11_testingDutySet is used to set the duty cycle of motor 1 while in the testing interface. Upon 't' press, the program is sent to this state which prompts the user to input their desired duty cycle. Uses variable duty1 to pass the desired duty cycle to taskMotor.py
Lab0x03_taskUser.S12_testingDataCrunch = micropython.const(12) |
Creates object S12_testingDataCrunch connected to constant 12.
S12_testingDataCrunch is the state used to collect a sample of velocity data points and use them to compute the average velocity of that set. This duty cycle is then written to posArray and the averaged velocity value is written to velArray before being used to print a dataset representing speed as a function of duty cycle.
Lab0x03_taskUser.S1_Wait = micropython.const(1) |
Creates object S1_Wait connected to constant 1.
S1_Wait is used as an wait state. Used to decode what the user is inputting. sends user to respective states given specific keyboard inputs
Lab0x03_taskUser.S2_zZeroEnc1 = micropython.const(2) |
Creates object S2_zZeroEnc1 connected to constant 2.
S2_zZeroEnc1 is used as a zeroing state. If user inputs z or Z, they are sent to this state which zero's the encoder from the taskEncoder uses zFlag to communicate between all files
Lab0x03_taskUser.S3_pPrintPos = micropython.const(3) |
Creates object S3_pPrintPos connected to constant 3.
S3_pPrintPos is used as a printing state. If user inputs p or P, they are sent to this state which prints ONE value of the current position from the encoder. uses POS to connect between files
Lab0x03_taskUser.S4_dDelta = micropython.const(4) |
Creates object S4_dDelta connected to constant 4.
S4_dDelta is used as a delta state. If user inputs d or D, they are sent to this state which prints ONE value of the current delta value from the encoder. uses DEL to connect between files
Lab0x03_taskUser.S5_vVelocity = micropython.const(5) |
Creates object S5_vVelocity connected to constant 5.
S5_vVelocity is used as a velocity state. If user inputs v or V, they are sent to this state which prints ONE value of the current velocity value from the encoder. uses speedDATA to connect between files
Lab0x03_taskUser.S6_mDutyCtrl = micropython.const(6) |
Creates object S6_mDutyCtrl connected to constant 6.
S6_mDutyCtrl is used to set the duty cycle of motor 1. If user inputs m, they are sent to this state which prompts the user to input their desired duty cycle. Uses variable duty1 to connect between files
Lab0x03_taskUser.S7_clrFault = micropython.const(7) |
Creates object S8_clrFault connected to constant 8.
S8_clrFault is used to check if there is a fault detected by the driver. Uses flag variable with boolean logic. flag used is faultFlag
Lab0x03_taskUser.S8_gCollectThirtySec = micropython.const(8) |
Creates object S8_gCollectThirtySec connected to constant 9.
S8_gCollectThirtySec is used to collect data from encoder continuously for 30 seconds. The values are then printed out all together in an array. If the user decides to end data collection early, they may do this by entering s or S on the keyboard.
Lab0x03_taskUser.S9_tTestInt = micropython.const(9) |
Creates object S9_tTestInt connected to constant 9.
S9_tTestInt is used to repeatedly prompt the user for duty cycles for motor 1. Determines average velocity for each prompted duty cycle. these values (duty cycle, average velocity) are then printed out in array once user is done testing, in which they type s or S on the keyboard.