Attempt to balance the table with Touchscreen functionality. More...
Functions | |
| def | mainWithTouchPad.fault_isr (fault) |
| Fault pin. More... | |
| def | mainWithTouchPad.fix_isr (fix) |
| Fix ISR. More... | |
Variables | |
| mainWithTouchPad.touch = touchy(pyb.Pin.board.PA1, pyb.Pin.board.PA7, pyb.Pin.board.PA0, pyb.Pin.board.PA6, 180, 90, 90, 45) | |
| Touchy pin. More... | |
| int | mainWithTouchPad.faultflag = 0 |
| Flag for faulting. More... | |
| mainWithTouchPad.extint = pyb.ExtInt(pyb.Pin.board.PB2, pyb.ExtInt.IRQ_RISING, pyb.Pin.PULL_UP, fault_isr) | |
| External Interrupt Object. More... | |
| mainWithTouchPad.fix = pyb.Pin.board.PC13 | |
| Fix pin @Pin to be pressed that would fix the faults. | |
| mainWithTouchPad.fixtint = pyb.ExtInt(pyb.Pin.board.PC13, pyb.ExtInt.IRQ_RISING, pyb.Pin.PULL_UP, fix_isr) | |
| External Interrupt Object. More... | |
| mainWithTouchPad.var = MotorDriver(pyb.Pin.board.PA15, pyb.Pin.board.PB4, pyb.Pin.board.PB5, 3, 1, 2) | |
| X axis motor. More... | |
| mainWithTouchPad.var2 = MotorDriver(pyb.Pin.board.PA15, pyb.Pin.board.PB0, pyb.Pin.board.PB1, 3, 3, 4) | |
| Y axis motor. More... | |
| mainWithTouchPad.balancer = EncoderDriver(pyb.Pin.board.PB6, pyb.Pin.board.PB7, 1, 2, pyb.Timer(4, prescaler = 7, period = 0x7fffffff)) | |
| X axis Motor encoder. More... | |
| mainWithTouchPad.balancer2 = EncoderDriver(pyb.Pin.board.PC6, pyb.Pin.board.PC7, 1, 2, pyb.Timer(8, prescaler = 7, period = 0x7fffffff)) | |
| Y axis Motor encoder. More... | |
| int | mainWithTouchPad.state = 0 |
| State flag. More... | |
| int | mainWithTouchPad.start = 300 |
| Fault ignore. More... | |
| mainWithTouchPad.adc = pyb.ADC(pyb.Pin.board.A0) | |
| ADC object. More... | |
| int | mainWithTouchPad.duty = 0 |
| Duty cycle value. More... | |
| int | mainWithTouchPad.duty2 = 0 |
| Duty cycle value. More... | |
| int | mainWithTouchPad.dut = 75 |
| New Duty cycle value. More... | |
| int | mainWithTouchPad.balanceval = 0 |
| Distance to go. More... | |
| int | mainWithTouchPad.balanceval2 = 0 |
| Distance to go. More... | |
| mainWithTouchPad.onoff = touch.allread() | |
Attempt to balance the table with Touchscreen functionality.
This is essentially the same as mainWithnFault.py just with a bit of the touch screen added in. We started by adding the touch screen to shut off the motors entirely. This was easy, just examine the list sent by the touchy.py class and if the zboolean was 1, disable the motors. That worked like a charm. Then we tried to set the x motor to run and push up when the screen was touched to offset the distance and roll the ball back to center. This kind of worked but in combination with the past proportional control and some broken touch screen wiring it actually became very difficult. I should mention that I worked on this between mainWithnFault and mainThatBalancedtheTable when I needed a break from trying to balance the table.
| def mainWithTouchPad.fault_isr | ( | fault | ) |
Fault pin.
Pin that the faults are dependent upon
Fault ISR
Sets the faultflag to one if a fault isr has been triggered. Stops all functionality until resolved.
| def mainWithTouchPad.fix_isr | ( | fix | ) |
Fix ISR.
Was meant to allow the user to press the blue button on the microcontroller to fix the fault interrupt. Didnt end up working
| mainWithTouchPad.adc = pyb.ADC(pyb.Pin.board.A0) |
ADC object.
allowed us to connect PC13 to A0 and use the blue button to end the fault state
| mainWithTouchPad.balancer = EncoderDriver(pyb.Pin.board.PB6, pyb.Pin.board.PB7, 1, 2, pyb.Timer(4, prescaler = 7, period = 0x7fffffff)) |
X axis Motor encoder.
Encoder object that outputs position of the X axis motor
| mainWithTouchPad.balancer2 = EncoderDriver(pyb.Pin.board.PC6, pyb.Pin.board.PC7, 1, 2, pyb.Timer(8, prescaler = 7, period = 0x7fffffff)) |
Y axis Motor encoder.
Encoder object that outputs position of the Y axis motor
| mainWithTouchPad.balanceval = 0 |
Distance to go.
Value computed later that represents how far we are from where we need to be for balance around the x axis
| mainWithTouchPad.balanceval2 = 0 |
Distance to go.
Value computed later that represents how far we are from where we need to be for balance around the y axis
| int mainWithTouchPad.dut = 75 |
New Duty cycle value.
Value used for duty cycle when proportionality became unwieldy
| int mainWithTouchPad.duty = 0 |
Duty cycle value.
Percent of time X motor is receiving energy from PWM
| int mainWithTouchPad.duty2 = 0 |
Duty cycle value.
Percent of time Y motor is receiving energy from PWM
| mainWithTouchPad.extint = pyb.ExtInt(pyb.Pin.board.PB2, pyb.ExtInt.IRQ_RISING, pyb.Pin.PULL_UP, fault_isr) |
External Interrupt Object.
Allows the Fault interrupt to be called
| int mainWithTouchPad.faultflag = 0 |
Flag for faulting.
when high, there has been a fault, when low, it's been resolved
| mainWithTouchPad.fixtint = pyb.ExtInt(pyb.Pin.board.PC13, pyb.ExtInt.IRQ_RISING, pyb.Pin.PULL_UP, fix_isr) |
External Interrupt Object.
Allows the Fix interrupt to be called
| int mainWithTouchPad.start = 300 |
Fault ignore.
Set number of cycles for which we will ignore the fault flag in order to give the motors time to get running before a real fault
| int mainWithTouchPad.state = 0 |
State flag.
What else do you want? It's the state flag
| mainWithTouchPad.touch = touchy(pyb.Pin.board.PA1, pyb.Pin.board.PA7, pyb.Pin.board.PA0, pyb.Pin.board.PA6, 180, 90, 90, 45) |
Touchy pin.
Touchy object to read where the touch screen is being touch
| mainWithTouchPad.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
| mainWithTouchPad.var2 = MotorDriver(pyb.Pin.board.PA15, pyb.Pin.board.PB0, pyb.Pin.board.PB1, 3, 3, 4) |
Y axis motor.
Creates an object that controls the motor that pushes the table Around its lengthwise axis