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... | |
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.
| BalancingFunctionalityAttempt.lengthpast = 0 |
previous length
Where the ball was along the length of the screen during the past reading
| 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
| 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
| 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
| 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
| BalancingFunctionalityAttempt.widthpast = 0 |
previous width
Where the ball was along the width of the screen during the past reading
| 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
| tuple BalancingFunctionalityAttempt.xduty = 0 |
Y motor duty cycle.
Slightly confusing, but it pushes or puls the x axis to a new angle
| tuple BalancingFunctionalityAttempt.yduty = 0 |
X motor duty cycle.
Slightly confusing, but it pushes or puls the y axis to a new angle