diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..89cc49c --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.pio +.vscode/.browse.c_cpp.db* +.vscode/c_cpp_properties.json +.vscode/launch.json +.vscode/ipch diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..080e70d --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,10 @@ +{ + // See http://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": [ + "platformio.platformio-ide" + ], + "unwantedRecommendations": [ + "ms-vscode.cpptools-extension-pack" + ] +} diff --git a/BREAD-Local-Software.code-workspace b/BREAD-Local-Software.code-workspace new file mode 100644 index 0000000..139ddfe --- /dev/null +++ b/BREAD-Local-Software.code-workspace @@ -0,0 +1,10 @@ +{ + "folders": [ + { + "path": "." + } + ], + "settings": { + "liveServer.settings.multiRootWorkspaceName": "BREAD-Local-Software" + } +} \ No newline at end of file diff --git a/DCMT_R1/DCMT_R1.ino b/DCMT_R1/DCMT_R1.ino index fd519e5..35ce172 100644 --- a/DCMT_R1/DCMT_R1.ino +++ b/DCMT_R1/DCMT_R1.ino @@ -207,6 +207,7 @@ void loop() { } else if(DCMT.turbPump1 || DCMT.turbPump2){ // run as turbidity pump measureTurbidity(); + calculateTurbidity(); }else{ // run as continuous motor/pump actuateMotors(); } @@ -292,15 +293,20 @@ void measureTurbidity() } } +//Maybe needs to change to: Output Voltage (V)= -0.0008× (Turbidity of Water (NTU)) + 3.9994 +//Needs testing and calibration with known NTU values // need to change once biomass is calibrated void calculateTurbidity(){ - float x; - if(DCMT.turbVoltage[1] >= 2.5){ - x = DCMT.turbVoltage[1]; - }else{ - x = 2.5; + for(int i = 0; i < 2; i++){ + float x; + if(DCMT.turbVoltage[i] >= 2.5){ + x = DCMT.turbVoltage[i]; + }else{ + x = 2.5; + } + DCMT.currentTurbidity[i] = (5742.3 - 1120.4*x) * x - 4352.9 - TURBIDITY_OFFSET; + //DCMT.currentTurbidity[i] = (x-3.9994)/(-0.0008); //Potential equation replacement } - DCMT.currentTurbidity[1] = (5742.3 - 1120.4*x) * x - 4352.9 - TURBIDITY_OFFSET; } void setPIDTunings() @@ -415,12 +421,12 @@ void requestEvent() { if(isnan(DCMT.turbVoltage[0]) || !(DCMT.turbPump1)) turb1.number = 0; else - turb1.number = DCMT.turbVoltage[0]; + turb1.number = DCMT.currentTurbidity[0]; if(isnan(DCMT.turbVoltage[1]) || !(DCMT.turbPump2)) turb2.number = 0; else - turb2.number = DCMT.turbVoltage[1]; + turb2.number = DCMT.currentTurbidity[1]; for (int i = 0; i < 4; i++) Wire.write(turb1.bytes[i]); for (int i = 0; i < 4; i++) Wire.write(turb2.bytes[i]); diff --git a/RLHT_R2/RLHT_R2.ino b/RLHT_R2/RLHT_R2.ino index c45c821..c0dda6d 100644 --- a/RLHT_R2/RLHT_R2.ino +++ b/RLHT_R2/RLHT_R2.ino @@ -20,6 +20,10 @@ long lastThermoRead = 0; long lastSerialPrint = 0; +//Edit these offsets to calibrate thermocouples as needed +double thermo1_offset = -4.0; +double thermo2_offset = -4.0; + bool E_STOP = false; CRGB led; @@ -224,8 +228,8 @@ void measureThermocouples() { if(millis() - lastThermoRead >= THERMO_UPDATE_TIME_MS) { - RLHT.thermo1 = CH1.readCelsius(); - RLHT.thermo2 = CH2.readCelsius(); + RLHT.thermo1 = CH1.readCelsius() + thermo1_offset; + RLHT.thermo2 = CH2.readCelsius() + thermo2_offset; lastThermoRead = millis(); } } @@ -356,5 +360,16 @@ void setParametersRLHT(char *in_data) RLHT.Kd_2 = (double)float3.number; } break; + case 'O': + for(int i=0; i<4; i++) float1.bytes[i] = in_data[i+2]; + if(in_data[1] == 1) + { + thermo1_offset = (double)float1.number; + } + if(in_data[1] == 2) + { + thermo2_offset = (double)float1.number; + } + break; } -} \ No newline at end of file +} diff --git a/Website Code on SD Card/css/style.css b/Website Code on SD Card/css/style.css new file mode 100644 index 0000000..c830531 --- /dev/null +++ b/Website Code on SD Card/css/style.css @@ -0,0 +1,72 @@ +/* Set height of body and the document to 100% to enable "full page tabs" */ +body, html { + /* height: 100%; */ + margin: 0; + font-family: Arial; + } + + /* Style tab links */ + .tablink { + background-color: #555; + color: white; + float: left; + border: none; + outline: none; + cursor: pointer; + padding: 14px 16px; + font-size: 17px; + width: 25%; + } + .tabnav { + width: 100%; + background-color: #777; + display: flex; + } + + .tablink:hover { + background-color: #777; + } + + /* Style the tab content (and add height:100% for full page content) */ + .tabcontent { + color: black; + display: grid; + padding: 100px 20px; + height: 100%; + } + + /* Ensure grid containers have explicit sizes */ + .grid-container { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); + gap: 10px; + width: 100%; + max-width: 1200px; + margin: 0 auto; +} + +/* Set heights to prevent overlap */ +.graph-container, .gauge-container { + height: 350px; + position: relative; +} + +/* Prevent graph overlap */ +.graph-container { + z-index: 1; +} + +/* Ensure gauges are on top */ +.gauge-container { + z-index: 2; +} + +/* Tab content visibility */ +.tabcontent { + display: none; + padding: 20px; +} + +.tabcontent.active { + display: block; +} \ No newline at end of file diff --git a/Website Code on SD Card/favicon.ico b/Website Code on SD Card/favicon.ico new file mode 100644 index 0000000..45bd893 Binary files /dev/null and b/Website Code on SD Card/favicon.ico differ diff --git a/Website Code on SD Card/index.html b/Website Code on SD Card/index.html index 7bef873..d7cc3ae 100644 --- a/Website Code on SD Card/index.html +++ b/Website Code on SD Card/index.html @@ -1,2019 +1,2036 @@ -
- - - - - -Connection to ESP32:
- -Thermocouple #:
-Heater #:
+Thermocouple #:
-Heater #:
+Thermocouple #:
-Heater #:
+Thermocouple #:
-Heater #:
+ +Connection to ESP32:
+Thermocouple #:
+Heater #:
+Thermocouple #:
-Heater #:
-Thermocouple #:
+Heater #:
+Thermocouple #:
+Heater #:
+Thermocouple #:
-Heater #:
-Thermocouple #:
+Heater #:
+Thermocouple #:
+Heater #:
+Thermocouple #:
-Heater #:
-Thermocouple #:
-Heater #:
-Thermocouple #:
+Heater #:
+Thermocouple #:
+Heater #:
+Thermocouple #:
-Heater #:
-Thermocouple #:
+Heater #:
+Thermocouple #:
+Heater #:
+Thermocouple #:
-Heater #:
+ +Thermocouple #:
+Heater #:
+