Mechatronics
Documentation for ME 405 labs
Lab0xFF

Files

file  axis.py
 Defines a container class to hold state for a single axis on the ME 405 platform.
 
file  controller.py
 A controller object that updates a single motor with full-state feedback.
 
file  Encoder.py
 Driver for US Digital E4T-1000 type encoder.
 
file  Motor.py
 Drivers for bushed DC motors and Texas Instruments DRV8847 motor driver.
 
file  TouchPanel.py
 Driver for the Adafruit 8.75" touch panel.
 
file  main.py
 Entry point to the ball balancing test bench activity.
 
file  serial_codes.py
 Definitions for all of the serial line codes to be passed back and forth between the frontend and the nucleo.
 
file  test_Encoder-timing.py
 Calculate the average time of encoder updating.
 
file  test_Main-timing.py
 Calculate the average time of main loop.
 
file  test_TouchPanel-timing.py
 Compare the timing of individually scanning each coordinate vs scanning all at once.
 
file  UI_front.py
 Contains the front-end User Interface for interacting with the ME 405 board.
 

Classes

class  axis.Profile
 A container class for state variables of a given axis. More...
 
class  axis.Axis
 _brief_description More...
 
class  controller.Controller
 A controller object operating with full-state feedback. More...
 
class  drivers.Encoder.Encoder
 A Quadrature Encoder class to be used with the ME 405 test bench. More...
 
class  drivers.Motor.Motor
 This class implements a motor driver for the ME405 board. More...
 
class  drivers.Motor.MotorDriver
 A driver class for interacting with two motors while also protecting against over-current. More...
 
class  drivers.TouchPanel.TouchPanel
 A class for collecting information from the touch panel over I2C. More...
 
class  main.State
 A class to hold the current state of the FSM. More...
 

Functions

def main.now (epoch, units)
 Get the difference between the epoch and now. More...
 
def main.check_for_command (command, buffer)
 Checks if a certain command was read on the serial input line. More...
 
def test_Main-timing.test_timing ()
 Test how long an update cycle takes.
 
def test_TouchPanel-timing.main ()
 Compare the timing of individually scanning each coordinate vs scanning all at once.
 
def UI_front.main (args)
 Start and run the UI frontend. More...
 
def UI_front.collect_data (serial, raw_data)
 Read a data point from the serial line, handling a fault if necessary. More...
 
def UI_front.synthesize_data (raw_data)
 
def UI_front.plot_response (resp, loc="plots")
 Create a plot for each state variable vs time for the whole response. More...
 

Variables

float axis.PLATFORM_PIVOT_OFFSET = 0.110
 Distance from the platform pivot to the U-joint [m].
 
float axis.LEVER_ARM_RADIUS = 0.060
 Length of the lever arm [m].
 
list controller.K = [-1.9230949511259, -0.817604962125815, -0.617011551699976, -0.07079210481062]
 Controller gains as calculated in Homework0x05 .
 
float controller.TORQUE_CONVERSION_FACTOR = 800.72
 Constant multiple to convert torque from [N-m] to [PWM%] Click Here for calculations.
 
int drivers.Motor.MAX_CHANNEL_NUM = 4
 Set a limit for the board for maximum number of channels.
 
list drivers.TouchPanel.INTERCEPT = [2008.5, 2120.3]
 Offsets to center of resistive touch panel. More...
 
list drivers.TouchPanel.SLOPE = [20.364, -30.05]
 Slope (adc counts per mm) for each coordinate.
 
int drivers.TouchPanel.LOW_THRESHOLD = 100
 Threshold for digital 'LOW' in adc counts.
 
string serial_codes.CALIBRATE = "CALIBRATE\n".encode("ascii")
 Defines a constant for calibration mode.
 
string serial_codes.RUN = "RUN\n".encode("ascii")
 Defines a constant to signal the board to start the controller.
 
string serial_codes.HALT = "HALT\n".encode("ascii")
 Defines a constant to signal the board to terminate operation.
 
string serial_codes.START_DATA_COLLECTION = "START_DATA_COLLECTION\n".encode("ascii")
 Defines a constant for data collection start.
 
string serial_codes.STOP_DATA_COLLECTION = "STOP_DATA_COLLECTION\n".encode("ascii")
 Defines a constant for data collection stop.
 

Detailed Description

Function Documentation

◆ check_for_command()

def main.check_for_command (   command,
  buffer 
)

Checks if a certain command was read on the serial input line.

Parameters
commandThe command to search for
bufferThe serial buffer, as a string

◆ collect_data()

def UI_front.collect_data (   serial,
  raw_data 
)

Read a data point from the serial line, handling a fault if necessary.

Parameters
serialA serial object used to communicate with the nucleo.
raw_dataA container for all of the data collected so far.

◆ main()

def UI_front.main (   args)

Start and run the UI frontend.

Parameters
argsAccepts a commandline argument vector of 2 arguments: the first is the program name, the second is the name of the serial port.

Waits for the user to enter any valid command. When data collection is complete, generates both an image (using matplotlib) and a .CSV file of data (timestamps and data readings). Image and Data files are timestamped. c Halt the system so the user can re-calibrate encoder positions with a level (default state). r Activate the controller to start running. s Stop the controller and process data. q Halt the system and exit.

     If there is a motor fault, the user will be prompted to either clear the fault and resume normal operation
     or to terminate the program.  If the program is terminated, data collection is terminated.

◆ now()

def main.now (   epoch,
  units 
)

Get the difference between the epoch and now.

Parameters
epochThe starting time from which to measure the difference.
unitsThe units that the starting time is represented in.
Returns
The time passed since the epoch in the units provided.

◆ plot_response()

def UI_front.plot_response (   resp,
  loc = "plots" 
)

Create a plot for each state variable vs time for the whole response.

Parameters
respThe response to plot. Expects a dictionary of lists of equal size as generated by clean_data().
locThe folder in which to save the plots. If unspecified, they will be saved to the directory this was called in.

Variable Documentation

◆ INTERCEPT

list drivers.TouchPanel.INTERCEPT = [2008.5, 2120.3]

Offsets to center of resistive touch panel.

These offsets do not necessarily coincide with the geometric center of every platform.