reflow.ino 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* reflow.ino handles reflow procedures */
  2. void handleReflowProcedures() {
  3. /* Currently is in reflow stage */
  4. bool tempReached = updateHeaterPowerState(); //This action takes 100ms
  5. if (tempReached) {
  6. //This stage temperature reached. Move to next stage
  7. if (reflowStages == 1) {
  8. //Preheat stage completed. Enter soaking stage
  9. USBSerial_println("Preheat temperature reached. Soaking started");
  10. targetTempADC = PREHEAT_TEMP_ADC; //Set temperature to soaking end temp
  11. reflowStages = 2; //Set reflow stage to soaking
  12. soakingCountdown = SOAKING_TIME;
  13. fastblinkRed = true;
  14. } else if (reflowStages == 3) {
  15. //Reflowing target temperature reached. Start cooldown and shut down heater
  16. USBSerial_println("Reflow completed. Cooling down");
  17. reflowStages = 4;
  18. blinkYellow = false;
  19. blinkRed = true;
  20. targetTempADC = COOLDOWN_TEMP_ADC;
  21. targetPwrPWM = 0;
  22. //Reflow ended. Wait until stop being press to exit this state
  23. }
  24. }
  25. if (reflowStages == 2) {
  26. //Wait for the soaking to complete and enter reflow stage
  27. soakingCountdown--;
  28. if (soakingCountdown <= 0) {
  29. //Soaking completed. Enter reflow stage
  30. USBSerial_println("Soaking time ended. Reflow started");
  31. //Set Reflow LED to high
  32. fastblinkRed = false;
  33. digitalWrite(LED_REFLOW, HIGH);
  34. //Set to reflow temperature
  35. targetTempADC = REFLOW_TEMP_ADC; //Set the target temp to reflow
  36. targetPwrPWM = REFLOW_PWR_PWM; //Set power rating to reflow
  37. //Update the reflow stage to 3
  38. reflowStages = 3;
  39. } else if (soakingCountdown % 100 == 0) {
  40. USBSerial_print("Soaking cycles left: ");
  41. USBSerial_println(soakingCountdown);
  42. }
  43. }
  44. delay(1);
  45. }