integrate the hardware to the software, change the UI and truncate
This commit is contained in:
parent
ecd19e582e
commit
81d1b12079
|
@ -44,9 +44,19 @@ def read():
|
|||
writer.writerow(header)
|
||||
f.close()
|
||||
while True:
|
||||
dat_list = np.random.randint(0, v_in * 1000, SENSORS_MAX) # create a randomized voltage data
|
||||
#dat_list = np.random.randint(0, v_in * 1000, SENSORS_MAX) # create a randomized voltage data
|
||||
# take only the nonzero indices, and truncated to two decimal places to "filter" out some hardware errors
|
||||
dat_sel = np.trunc((np.take(dat_list, sensor_ports) / 1000) * 10**2) / 10**2
|
||||
#dat_sel = np.trunc((np.take(dat_list, sensor_ports) / 1000) * 10**2) / 10**2
|
||||
'''ser = serial.Serial(port)
|
||||
ser.flushInput()
|
||||
while True:
|
||||
try:
|
||||
ser_bytes = ser.readline()
|
||||
decoded_bytes = float(ser_bytes[0:len(ser_bytes)-2].decode("utf-8"))
|
||||
except:
|
||||
print("Keyboard Interrupt")
|
||||
break'''
|
||||
#dat_sel = np.trunc((np.take(decoded_bytes, sensor_ports) / 1000) * 10**2) / 10**2
|
||||
r_arr = np.take(refRes, sensor_ports) * (v_in / dat_sel - 1) # *2 <-- change with actual formula for ammonia concentration
|
||||
# created a new array to convert resistance values to sci notation
|
||||
r_arr2 = np.empty(len(r_arr), dtype=object)
|
||||
|
@ -81,15 +91,19 @@ def read():
|
|||
f.close()
|
||||
while controller.isOpen():
|
||||
try:
|
||||
#controller.flushInput()
|
||||
read_data = controller.readline().decode("utf-8")
|
||||
# use numpy so it can make list calculations easier (and possibly faster)
|
||||
dat_list = np.asarray(json.loads(read_data), dtype=np.uint32)[:SENSORS_MAX]
|
||||
|
||||
dat_list = np.asarray(json.loads(read_data), dtype=np.float32)[:SENSORS_MAX]
|
||||
#ser_bytes = controller.readline()
|
||||
#decoded_bytes = float(ser_bytes[0:len(ser_bytes)-2].decode("utf-8"))
|
||||
#dat_sel = np.trunc((np.take(dat_list, sensor_ports) / 1000) * 10**2) / 10**2
|
||||
dat_sel = np.take(dat_list, sensor_ports)
|
||||
# if we decided to switch back to analogRead(), replace this line of comment to the algorithm to something like the commented line below
|
||||
# dat_sel = np.take(dat_list, sensor_ports) * v_in / resolution
|
||||
|
||||
# take only the nonzero indices, and truncated to two decimal places to "filter" out some hardware errors
|
||||
dat_sel = np.trunc((np.take(dat_list, sensor_ports) / 1000) * 10**2) / 10**2
|
||||
#dat_sel = np.trunc((np.take(dat_list, sensor_ports) / 1000) * 10**2) / 10**2
|
||||
r_arr = np.take(refRes, sensor_ports) * (v_in / dat_sel - 1) # *2 <-- change with actual formula for ammonia concentration
|
||||
# created a new array to convert resistance values to sci notation
|
||||
r_arr2 = np.empty(len(r_arr), dtype=object)
|
||||
|
|
|
@ -232,7 +232,7 @@
|
|||
<property name="gripper">0</property>
|
||||
<property name="hidden">0</property>
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="label">Resistor 3</property>
|
||||
<property name="label">Resistor 2</property>
|
||||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
|
@ -240,7 +240,7 @@
|
|||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">r3_prompt</property>
|
||||
<property name="name">r2_prompt</property>
|
||||
<property name="pane_border">1</property>
|
||||
<property name="pane_position"></property>
|
||||
<property name="pane_size"></property>
|
||||
|
@ -315,7 +315,7 @@
|
|||
<property name="gripper">0</property>
|
||||
<property name="hidden">0</property>
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="label">Resistor 2</property>
|
||||
<property name="label">Resistor 3</property>
|
||||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
|
@ -323,7 +323,7 @@
|
|||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">r2_prompt</property>
|
||||
<property name="name">r3_prompt</property>
|
||||
<property name="pane_border">1</property>
|
||||
<property name="pane_position"></property>
|
||||
<property name="pane_size"></property>
|
||||
|
|
10
ui.py
10
ui.py
|
@ -32,14 +32,14 @@ class Frame ( wx.Frame ):
|
|||
self.r1_prompt = wx.StaticText( ref_entre.GetStaticBox(), wx.ID_ANY, u"Resistor 1", wx.DefaultPosition, wx.DefaultSize, 0 )
|
||||
self.r1_prompt.Wrap( -1 )
|
||||
res_grid.Add( self.r1_prompt, 0, wx.ALIGN_BOTTOM|wx.ALIGN_CENTER_HORIZONTAL, 5 )
|
||||
|
||||
self.r3_prompt = wx.StaticText( ref_entre.GetStaticBox(), wx.ID_ANY, u"Resistor 3", wx.DefaultPosition, wx.DefaultSize, 0 )
|
||||
self.r3_prompt.Wrap( -1 )
|
||||
res_grid.Add( self.r3_prompt, 0, wx.ALIGN_BOTTOM|wx.ALIGN_CENTER_HORIZONTAL, 5 )
|
||||
|
||||
|
||||
self.r2_prompt = wx.StaticText( ref_entre.GetStaticBox(), wx.ID_ANY, u"Resistor 2", wx.DefaultPosition, wx.DefaultSize, 0 )
|
||||
self.r2_prompt.Wrap( -1 )
|
||||
res_grid.Add( self.r2_prompt, 0, wx.ALIGN_BOTTOM|wx.ALIGN_CENTER_HORIZONTAL, 5 )
|
||||
|
||||
self.r3_prompt = wx.StaticText( ref_entre.GetStaticBox(), wx.ID_ANY, u"Resistor 3", wx.DefaultPosition, wx.DefaultSize, 0 )
|
||||
self.r3_prompt.Wrap( -1 )
|
||||
res_grid.Add( self.r3_prompt, 0, wx.ALIGN_BOTTOM|wx.ALIGN_CENTER_HORIZONTAL, 5 )
|
||||
|
||||
self.r4_prompt = wx.StaticText( ref_entre.GetStaticBox(), wx.ID_ANY, u"Resistor 4", wx.DefaultPosition, wx.DefaultSize, 0 )
|
||||
self.r4_prompt.Wrap( -1 )
|
||||
|
|
Loading…
Reference in New Issue