Skip to content

Commit

Permalink
Changes include default speed, final plunger position, code cleanup
Browse files Browse the repository at this point in the history
* Apparent globals are not actualy used. Commented out.
* Default dispense/draw speeds lowered to 400/400
* Serial ports filtered to include 'USB'
* Used '+=' in command_string building
* `dispense` function had confusing unused variable
* `dispense` function always ends at closed position. (but clunky,
  always draws fully and then ejects remaining back to reservoir)
  • Loading branch information
dpk9 committed Feb 9, 2023
1 parent a3a0114 commit a5e3b3d
Showing 1 changed file with 32 additions and 25 deletions.
57 changes: 32 additions & 25 deletions SEC_GUI/octasome_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
import math
import time

plunger_position = 0
maxspeed = 6000
minspeed = 0
operating_speed = 400
dispense_volume = 2
pumpstatus = 0b0
# PLUNGER_POSITION = 0
# MAXSPEED = 6000
# MINSPEED = 0
# OPERATING_SPEED = 400
# DISPENSE_VOLUME = 2
# PUMPSTATUS = 0b0

#class definition of main window
class MainWindow(QMainWindow):
Expand Down Expand Up @@ -87,9 +87,9 @@ def __init__(self):
self.ui.dispenseSpeedSlider.setSingleStep(1)

#initial, default speed
self.ui.drawSpeedSpinBox.setValue(600)
self.ui.drawSpeedSpinBox.setValue(400)
#self.ui.drawSpeedSlider.setValue(30)
self.ui.dispenseSpeedSpinBox.setValue(1000)
self.ui.dispenseSpeedSpinBox.setValue(400)
#self.ui.dispenseSpeedSlider.setValue(30)

#serial port
Expand Down Expand Up @@ -190,7 +190,9 @@ def serialRefresh(self):
self.ui.comPortComboBox.clear()
#adds available ports to combobox list
for info in PyQt5.QtSerialPort.QSerialPortInfo.availablePorts():
self.ui.comPortComboBox.addItem(info.portName())
if "USB" in info.portName():
self.ui.comPortComboBox.addItem(info.portName())


#sends a command through the serial port (appends the R to indicate execution), returns pump response
def write(self, command):
Expand Down Expand Up @@ -362,10 +364,10 @@ def primeLines(self):
dispensespeed = int(self.ui.dispenseSpeedSpinBox.value()) #get speed from GUI
command_string = "/1I1V" + str(drawspeed) + "A800" + "V" + str(dispensespeed) + "A0V" + str(drawspeed) + "A6000"
#build command string
command_string = command_string + "V" + str(dispensespeed)
command_string += "V" + str(dispensespeed)
for column in range(8):
command_string = command_string + "I" + str(column+2) + "D" + str(750)
command_string = command_string + "I1V" + str(drawspeed) + "A6000"
command_string += "I" + str(column+2) + "D" + str(750)
command_string += "I1V" + str(drawspeed)# + "A6000"
plunger_position = 6000
print(command_string)
self.write(command_string)
Expand All @@ -380,7 +382,7 @@ def emptyLines(self):
speed = int(self.ui.drawSpeedSpinBox.value()) #get speed from GUI
command_string = "/1I1V" + str(speed)
for column in range(8):
command_string = command_string + "I" + str(column+2) + "P" + str(750)
command_string += "I" + str(column+2) + "P" + str(750)
print(command_string)
#do not send another command until pump is no longer busy
#self._waitReady()
Expand All @@ -407,8 +409,8 @@ def emptyPumpLines(self):
dispensespeed = int(self.ui.dispenseSpeedSpinBox.value()) #get speed from GUI
command_string = "/1I1V"+ str(dispensespeed)+ "A0" +"V" + str(drawspeed)
for column in range(8):
command_string = command_string + "I" + str(column+2) + "P" + str(750)
command_string = command_string + "I1V" + str(dispensespeed) + "A0"
command_string += "I" + str(column+2) + "P" + str(750)
command_string += "I1V" + str(dispensespeed) + "A0"
plunger_position = 0
print(command_string)
self.write(command_string)
Expand Down Expand Up @@ -438,10 +440,10 @@ def cleanLines(self):
dispensespeed = int(self.ui.dispenseSpeedSpinBox.value()) #get speed from GUI
command_string = "/1I1V" + str(drawspeed) + "A6000"
#build command string
command_string = command_string + "V" + str(dispensespeed)
command_string += "V" + str(dispensespeed)
for column in range(8):
command_string = command_string + "I" + str(column+2) + "D" + str(750)
command_string = command_string + "I1V" + str(drawspeed) + "A6000"
command_string += "I" + str(column+2) + "D" + str(750)
command_string += "I1V" + str(drawspeed)# + "A6000"
plunger_position = 6000
print(command_string)
self.write(command_string)
Expand Down Expand Up @@ -540,7 +542,8 @@ def enableColumnSelect(self):

#dispenses to the columns (all or individually selected)
#TODO: make sure this deals with all reasonable cases.. may want to query pump status before commands are written
def dispense(self, plunger_position):
def dispense(self):
plunger_position = 0
busy = self.queryPump()
if(busy == bin(0)):
print("Pump is busy!!!!!")
Expand All @@ -563,15 +566,18 @@ def dispense(self, plunger_position):
command_string = "/1V" + str(drawspeed) + "I1A6000V" + str(dispensespeed)
for column in range(8):
if(plunger_position - increment < 0):
command_string = command_string + "V" + str(drawspeed) + "I1A6000V" + str(dispensespeed)
command_string += "V" + str(drawspeed) + "I1A6000V" + str(dispensespeed)
plunger_position = 6000
command_string = command_string + "I" + str(column+2) + "D" + str(increment)
command_string += "I" + str(column+2) + "D" + str(increment)
plunger_position = plunger_position - increment
else:
command_string = command_string + "I" + str(column+2) + "D" + str(increment)
command_string += "I" + str(column+2) + "D" + str(increment)
plunger_position = plunger_position - increment
print(plunger_position)
print(command_string)
command_string += "I1A0"
plunger_position = 0
print(command_string)
self.write(command_string)
#if "all" check box is not selected, dispense based off of the checkboxes that are
else:
Expand All @@ -584,12 +590,12 @@ def dispense(self, plunger_position):
print(states)
if(states == True):
if(plunger_position - increment < 0):
command_string = command_string + "V" + str(drawspeed) + "I1A6000V" + str(dispensespeed)
command_string += "V" + str(drawspeed) + "I1A6000V" + str(dispensespeed)
plunger_position = 6000
command_string = command_string + "I" + str(index) + "D" + str(increment)
command_string += "I" + str(index) + "D" + str(increment)
plunger_position = plunger_position - increment
else:
command_string = command_string + "I" + str(index) + "D" + str(increment)
command_string += "I" + str(index) + "D" + str(increment)
plunger_position = plunger_position - increment
print(plunger_position)
print(command_string)
Expand Down Expand Up @@ -662,6 +668,7 @@ def _waitReady(self, polling_interval=1, timeout=10, delay=None):

#list all available com ports in comboBox on window
for info in PyQt5.QtSerialPort.QSerialPortInfo.availablePorts():
if "USB" in info.portName():
window.ui.comPortComboBox.addItem(info.portName())

#window.show()
Expand Down

0 comments on commit a5e3b3d

Please sign in to comment.