The votage can be changed by user
This commit is contained in:
parent
adf70dbd08
commit
541d6abc1f
|
@ -24,6 +24,7 @@ def read():
|
||||||
port = settings["port"]
|
port = settings["port"]
|
||||||
delay = settings["delay"]
|
delay = settings["delay"]
|
||||||
|
|
||||||
|
|
||||||
if np.any(sensor_ports >= SENSORS_MAX):
|
if np.any(sensor_ports >= SENSORS_MAX):
|
||||||
raise ValueError("Port range is 0-3!")
|
raise ValueError("Port range is 0-3!")
|
||||||
if "- No Device -" in port:
|
if "- No Device -" in port:
|
||||||
|
@ -46,9 +47,9 @@ def read():
|
||||||
while True:
|
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
|
# take only the nonzero indices, and truncated to two decimal places to "filter" out some hardware errors
|
||||||
# According to the actual req, the data in the data list should be (3.3-data)
|
# According to the actual req, the data in the data list should be (v_in-data)
|
||||||
for x in range(dat_list.size):
|
for x in range(dat_list.size):
|
||||||
np.put(dat_list, x, 3.3 - dat_list[x])
|
np.put(dat_list, x, v_in - dat_list[x])
|
||||||
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
|
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
|
# created a new array to convert resistance values to sci notation
|
||||||
|
@ -88,9 +89,9 @@ def read():
|
||||||
print(read_data) # Debug
|
print(read_data) # Debug
|
||||||
# use numpy so it can make list calculations easier (and possibly faster)
|
# use numpy so it can make list calculations easier (and possibly faster)
|
||||||
dat_list = np.asarray(json.loads(read_data), dtype=np.float32)[:SENSORS_MAX]
|
dat_list = np.asarray(json.loads(read_data), dtype=np.float32)[:SENSORS_MAX]
|
||||||
# According to the actual req, the data in the data list should be (3.3-data)
|
# According to the actual req, the data in the data list should be (votage-data)
|
||||||
for x in range(dat_list.size):
|
for x in range(dat_list.size):
|
||||||
np.put(dat_list, x, 3.3 - dat_list[x])
|
np.put(dat_list, x, v_in - dat_list[x])
|
||||||
dat_sel = np.take(dat_list, sensor_ports)
|
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
|
# 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
|
# dat_sel = np.take(dat_list, sensor_ports) * v_in / resolution
|
||||||
|
|
Loading…
Reference in New Issue