405 Documentation  9.0
BalancingFunctionalityAttempt.py File Reference

Attempt to balance the ball. More...

Variables

 BalancingFunctionalityAttempt.var = MotorDriver(pyb.Pin.board.PA15, pyb.Pin.board.PB4, pyb.Pin.board.PB5, 3, 1, 2)
 X axis motor. More...
 
 BalancingFunctionalityAttempt.var2 = MotorDriver(pyb.Pin.board.PA15, pyb.Pin.board.PB0, pyb.Pin.board.PB1, 3, 3, 4)
 X axis Motor encoder. More...
 
 BalancingFunctionalityAttempt.touch = touchy(pyb.Pin.board.PA1, pyb.Pin.board.PA7, pyb.Pin.board.PA0, pyb.Pin.board.PA6, 400, 200, 270, 100)
 Touchy pin. More...
 
int BalancingFunctionalityAttempt.lengthpast = 0
 previous length More...
 
int BalancingFunctionalityAttempt.widthpast = 0
 previous width More...
 
int BalancingFunctionalityAttempt.yduty = 0
 X motor duty cycle. More...
 
int BalancingFunctionalityAttempt.xduty = 0
 Y motor duty cycle. More...
 
 BalancingFunctionalityAttempt.spot = touch.allread()
 
 BalancingFunctionalityAttempt.onoff = spot[2]
 
 BalancingFunctionalityAttempt.length = -spot[0]
 
int BalancingFunctionalityAttempt.lspeed = lengthpast-length
 Speed of the ball. More...
 
 BalancingFunctionalityAttempt.width = -spot[1]
 
int BalancingFunctionalityAttempt.wspeed = widthpast-width
 Speed of the ball. More...
 

Detailed Description

Attempt to balance the ball.

Once the table was essentially balanced, it was time to try to balance the ball. However, at this point Jacob realized that something was broken with my touch pad setup. It was the exact same code he used for lab 7 which worked like a charm, and Hunter and Jacob swapped screens and it still didn't work, so we figured it must've been the wiring. For that Reason Jacob could not really test this code. It is based on the same concept as the initial goal for the balancing proportionality. The farther the ball is away from the origin the higher the duty cycle. Also, the speed of the ball changes that too. Duty cycle calc multiplies them by the gains we found from analysis, adds them together and applies that duty to the motor. So if the ball is on the right side but rolling towards the center, the platform will begin to settle back down towards being flat. This was an attempt at a proportional plus derivative controller.

Author
Jacob Everest
Hunter Morse
Date
Mar. 15, 2021

Variable Documentation

◆ lengthpast

BalancingFunctionalityAttempt.lengthpast = 0

previous length

Where the ball was along the length of the screen during the past reading

◆ lspeed

int BalancingFunctionalityAttempt.lspeed = lengthpast-length

Speed of the ball.

Speed with which the ball is moving along the length of the screen. As it increases, so does the duty cycle

◆ touch

BalancingFunctionalityAttempt.touch = touchy(pyb.Pin.board.PA1, pyb.Pin.board.PA7, pyb.Pin.board.PA0, pyb.Pin.board.PA6, 400, 200, 270, 100)

Touchy pin.

Touchy object to read where the touch screen is being touch

◆ var

BalancingFunctionalityAttempt.var = MotorDriver(pyb.Pin.board.PA15, pyb.Pin.board.PB4, pyb.Pin.board.PB5, 3, 1, 2)

X axis motor.

Creates an object that controls the motor that pushes the table Around its widthwise axis

◆ var2

BalancingFunctionalityAttempt.var2 = MotorDriver(pyb.Pin.board.PA15, pyb.Pin.board.PB0, pyb.Pin.board.PB1, 3, 3, 4)

X axis Motor encoder.

Encoder object that outputs position of the X axis motor

◆ widthpast

BalancingFunctionalityAttempt.widthpast = 0

previous width

Where the ball was along the width of the screen during the past reading

◆ wspeed

int BalancingFunctionalityAttempt.wspeed = widthpast-width

Speed of the ball.

Speed with which the ball is moving along the width of the screen. As it increases, so does the duty cycle

◆ xduty

tuple BalancingFunctionalityAttempt.xduty = 0

Y motor duty cycle.

Slightly confusing, but it pushes or puls the x axis to a new angle

◆ yduty

tuple BalancingFunctionalityAttempt.yduty = 0

X motor duty cycle.

Slightly confusing, but it pushes or puls the y axis to a new angle