Mechatronics Portfolio
Logan Williamson's Mechatronics Portfolio and Documentation Repository
Functions | Variables
Lab0x02_taskUser.py File Reference

Implimentation of User Interface task as an FSM. More...

Functions

def Lab0x02_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

 Lab0x02_taskUser.S0_INIT = micropython.const(0)
 creates object S0_INIT connected to constant 0 More...
 
 Lab0x02_taskUser.S1_Wait = micropython.const(1)
 creates object S1_Wait connected to constant 1 More...
 
 Lab0x02_taskUser.S2_zZeroEnc1 = micropython.const(2)
 creates object S2_zZeroEnc1 connected to constant 2 More...
 
 Lab0x02_taskUser.S3_pPrintPos = micropython.const(3)
 creates object S3_pPrintPos connected to constant 3 More...
 
 Lab0x02_taskUser.S4_dDelta = micropython.const(4)
 creates object S4_dDelta connected to constant 4 More...
 
 Lab0x02_taskUser.S5_vVelocity = micropython.const(5)
 creates object S5_vVelocity connected to constant 5 More...
 
 Lab0x02_taskUser.S6_mDutyCtrl = micropython.const(6)
 creates object S6_mDutyCtrl connected to constant 6 More...
 
 Lab0x02_taskUser.S7_clrFault = micropython.const(7)
 creates object S8_clrFault connected to constant 8 More...
 
 Lab0x02_taskUser.S8_gCollectThirtySec = micropython.const(8)
 creates object S8_gCollectThirtySec connected to constant 9 More...
 
 Lab0x02_taskUser.S9_tTestInt = micropython.const(8)
 creates object S9_tTestInt connected to constant 9 More...
 
 Lab0x02_taskUser.S10_PrintData = micropython.const(10)
 creates object S10_PrintData connected to constant 10 More...
 

Detailed Description

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.

Author
Brianna Roberts
Logan Williamson
Date
01/26/2022

Function Documentation

◆ taskUserFcn()

def Lab0x02_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.

Parameters
taskNameThe name of the task as a string.
periodThe task interval or period specified as an integer number of microseconds.
zFlagShared flag variable which causes FSM to enter zeroing state.
timDATAShared 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.
posDATAShared data for printing the position of the encoder upon 'p' or 'P' press.
delDATAShared data for printing the delta value of the encoder upon 'd' or 'D' press.
DATAShared data for data recording upon 'g' or 'G' press.

Variable Documentation

◆ S0_INIT

Lab0x02_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)

◆ S10_PrintData

Lab0x02_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.

◆ S1_Wait

Lab0x02_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

◆ S2_zZeroEnc1

Lab0x02_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

◆ S3_pPrintPos

Lab0x02_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

◆ S4_dDelta

Lab0x02_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

◆ S5_vVelocity

Lab0x02_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

◆ S6_mDutyCtrl

Lab0x02_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

◆ S7_clrFault

Lab0x02_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

◆ S8_gCollectThirtySec

Lab0x02_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.

◆ S9_tTestInt

Lab0x02_taskUser.S9_tTestInt = micropython.const(8)

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.