Bläddra i källkod

Add fan control

Abhinav Sinha 3 år sedan
förälder
incheckning
71e6720279
3 ändrade filer med 33 tillägg och 6 borttagningar
  1. 3 0
      .vscode/extensions.json
  2. 5 1
      platformio.ini
  3. 25 5
      src/main.cpp

+ 3 - 0
.vscode/extensions.json

@@ -3,5 +3,8 @@
     // for the documentation about the extensions.json format
     "recommendations": [
         "platformio.platformio-ide"
+    ],
+    "unwantedRecommendations": [
+        "ms-vscode.cpptools-extension-pack"
     ]
 }

+ 5 - 1
platformio.ini

@@ -12,4 +12,8 @@
 platform = atmelavr
 board = nanoatmega328
 framework = arduino
-lib_deps = evert-arias/EasyButton@^2.0.1
+lib_deps = 
+	evert-arias/EasyButton@^2.0.1
+	olikraus/U8g2@^2.33.11
+	br3ttb/PID@^1.2.1
+	zhenek-kreker/MAX6675 with hardware SPI@^1.0.0

+ 25 - 5
src/main.cpp

@@ -11,6 +11,7 @@
 #define DONE_LED_PIN 5
 #define SSR_PIN 4
 #define BUTTON_PIN 3
+#define FAN_PIN 6
 
 const char* lcdMessagesReflowStatus[] = {
   "Ready",
@@ -44,13 +45,14 @@ struct reflowProfile{
   const char* profileName;
   int soakTemp;
   unsigned long soakPeriodMS;
+  const char* timeInSeconds;
 };
 
 #define NUM_REFLOW_PROFILES 3
 reflowProfile profiles[NUM_REFLOW_PROFILES] = {
-  {"Sanitize Masks", 70, 1800000}, // 30*60*1000 30 minutes
-  {"Dry PLA", 45, 1800000*8},
-  {"Dry PETG", 70, 1800000*4}
+  {"Sanitize Masks", 70, 1800000, "1800"}, // 30*60*1000 30 minutes in ms
+  {"Dry PLA", 45, 1800000*8, "14400"}, // 4 hours
+  {"Dry PETG", 70, 1800000*4, "7200"} // 2 hours
 };
 
 // ***** CONSTANTS *****
@@ -154,7 +156,6 @@ void buttonHeld(void) {
     reflowStatus = REFLOW_STATUS_OFF;
     // Reinitialize state machine
     reflowState = REFLOW_STATE_IDLE;
-    activeReflowProfile = 0;
   } else {
     activeReflowProfile++;
     if (activeReflowProfile >= NUM_REFLOW_PROFILES) {
@@ -302,6 +303,7 @@ void drawScreen(void) {
   u8g2.drawStr( 0, rowOffset, "Temp: ");
   u8g2.drawStr( 60, rowOffset, temperatureStr);
   u8g2.drawStr( 100, rowOffset, "C");
+
   rowOffset += rowSize;
 
   // Current Profile
@@ -318,18 +320,34 @@ void drawScreen(void) {
     itoa((millis() - soakStartTime)/1000, soakSecondsStr, 10);
     u8g2.drawStr( 0, rowOffset, "Time: ");
     u8g2.drawStr( 40, rowOffset, soakSecondsStr);
-    u8g2.drawStr( 80, rowOffset, "/1800");
+    u8g2.drawStr( 80, rowOffset, profiles[activeReflowProfile].timeInSeconds);
   }
   rowOffset += rowSize;
 
+  char *targetTempStr = "Target Temp:    ";
+  itoa(profiles[activeReflowProfile].soakTemp, &targetTempStr[13], 10);
+  u8g2.drawStr( 0, rowOffset, targetTempStr);
+  rowOffset += rowSize;
+  
   u8g2.sendBuffer();
 }
 
+void handleFan() {
+  if(reflowStatus == REFLOW_STATUS_ON || reflowState != REFLOW_STATE_IDLE) {
+    digitalWrite(FAN_PIN, HIGH);
+  } else {
+    digitalWrite(FAN_PIN, LOW);
+  }
+}
+
 void setup(void) {
   // Turn off SSR.
   digitalWrite(SSR_PIN, LOW);
   pinMode(SSR_PIN, OUTPUT);
 
+  digitalWrite(FAN_PIN, LOW);
+  pinMode(FAN_PIN, OUTPUT);
+
   pinMode(BUTTON_PIN, INPUT_PULLUP);
   button.begin();
   button.onPressed(buttonPressed);
@@ -359,5 +377,7 @@ void loop(void) {
 
   handleSSR();
 
+  handleFan();
+
   drawScreen();
 }