Dryer timer with analogue input from a dew point sensor.
Revision 3:559e8c72212a, committed 2019-11-29
- Comitter:
- koosvanderwat
- Date:
- Fri Nov 29 09:27:44 2019 +0000
- Parent:
- 2:ad0b044d0a10
- Child:
- 4:e8ba2070b69e
- Commit message:
- Dryer timer with analogue input signal from dew point sensor
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HYT.lib Fri Nov 29 09:27:44 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/koosvanderwat/code/HYT1/#2d50976e2506
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Millis.lib Fri Nov 29 09:27:44 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/koosvanderwat/code/Millis1/#7e932d6cc068
--- a/TextLCD.lib Sat Dec 04 11:31:07 2010 +0000 +++ b/TextLCD.lib Fri Nov 29 09:27:44 2019 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/simon/code/TextLCD/#e4cb7ddee0d3 +http://mbed.org/users/simon/code/TextLCD/#308d188a2d3a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Watchdog.lib Fri Nov 29 09:27:44 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/koosvanderwat/code/Watchdog2/#deef711d4a8a
--- a/main.cpp Sat Dec 04 11:31:07 2010 +0000
+++ b/main.cpp Fri Nov 29 09:27:44 2019 +0000
@@ -1,10 +1,193 @@
-// Hello World! for the TextLCD
-
#include "mbed.h"
#include "TextLCD.h"
+#include "Watchdog.h"
+#include "millis.h"
-TextLCD lcd(p15, p16, p17, p18, p19, p20); // rs, e, d4-d7
+//Dryer Cycle
+int PT = 120; // Purge time in seconds
+int RT = 60; // Repressurisation time in seconds
+
+//Dew Point Setpoint
+float SetPoint = -3; // Dew Point Set Point
+
+//Watchdog
+Watchdog wd;
+
+//Screen Setup
+TextLCD lcd(D6, D9, D2, D3, D4, D5); // rs, e, d4-d7
+
+Ticker timeKeeping;
+
+//Pin Allocation
+DigitalOut my_RHPV(A0);
+DigitalOut my_RHMV(A1);
+DigitalOut my_RV(A2);
+DigitalOut my_LHMV(A6);
+DigitalOut my_LHPV(A7);
+DigitalOut my_led(D13);
+DigitalIn my_Dip2(D11); //Dip 2
+DigitalIn my_Dip1(D12); //Dip 1
+AnalogIn DP_In(A3);
+
+unsigned long previousMillis = 0; // will store last time LED was updated
+long OnTime = 1000; // milliseconds of on-time
+int secondscounter = 0;
+int Counter = 0;
+int sensorbroken =0;
+
+int LHCT = PT + RT; // LH cycle time
+int LHPT = PT + RT + PT; // LH purge time
+int CT = PT + RT + PT + RT; // Cycle Time
+
+float RHValue = 0;
+float TempValue = 0;
+float A = 0;
+float DewPoint = 0;
+float Value1 = 0;
+float Value2 = 0;
+float Value3 = 0;
+
+int Valuecounter = 0;
+
+int main()
+{
+
+ my_RHMV = 1;//0
+ my_LHMV = 0;//1
+ my_RHPV = 0;//1
+ my_LHPV = 0;//1
+ my_RHPV = 1;//0
+ my_LHPV = 0;//1
+ my_RV = 0;//1
+
+ wd.Configure(4.0);
+
+ wait_ms(100);
+ lcd.printf("TegnonEfficiency\n");
+ lcd.locate(0,1);
+ lcd.printf(" DP Control \n");
+
+ wait_ms(1000);
+ lcd.cls();
+ lcd.printf("Dew Point:");
+ lcd.locate(0,1);
+ lcd.printf("Set Point:");
+
+ millisStart();
+
+ while(1) {
+ unsigned long currentMillis = millis(); // Get current time
+
+ if(my_Dip2 ==0) {
+ if(my_Dip1 ==0) {
+ SetPoint = -3;
+ }
+ if(my_Dip1 ==1) {
+ SetPoint = -20;
+ }
+ }
+ if(my_Dip2 ==1) {
+ if(my_Dip1 ==0) {
+ SetPoint = -40;
+ }
+ if(my_Dip1 ==1) {
+ SetPoint = -60;
+ }
+ }
-int main() {
- lcd.printf("Hello World!\n");
-}
+ if ((currentMillis - previousMillis) >= OnTime) {
+ previousMillis = currentMillis;
+ wd.Service();
+ my_led = !my_led;
+
+ secondscounter = secondscounter + 1;
+ Counter = Counter + 1;
+
+ if(Counter == 10) {
+ lcd.cls();
+ lcd.printf("Dew Point:");
+ lcd.locate(0,1);
+ lcd.printf("Set Point:");
+ Counter = 0;
+ }
+
+
+ if(Valuecounter ==0) {
+ Value1 = DP_In.read()*100 - 80;
+ }
+ if(Valuecounter ==1) {
+ Value2 = DP_In.read()*100 - 80;
+ }
+ if(Valuecounter ==2) {
+ Value3 = DP_In.read()*100 - 80;
+ Valuecounter=0;
+ }
+
+ Valuecounter = Valuecounter + 1;
+
+ DewPoint = (Value1+Value2+Value3)/3;
+
+ //DewPoint = DP_In.read()*100.0f;
+
+ lcd.locate(10,0);
+ lcd.printf(" ");
+ lcd.locate(10,0);
+ lcd.printf("%3.1f%", DewPoint);
+ lcd.locate(10,1);
+ lcd.printf(" ");
+ lcd.locate(10,1);
+ lcd.printf("%3.1f%", SetPoint);
+
+
+ if ((DewPoint < SetPoint) && (secondscounter == LHCT)) {
+ secondscounter = secondscounter - 1;
+ }
+
+ if ((DewPoint < SetPoint) && (secondscounter == CT)) {
+ secondscounter = secondscounter - 1;
+ }
+
+ //} else {
+ // lcd.locate(0,0);
+ // lcd.printf(" Standard ");
+ // lcd.locate(0,1);
+ // lcd.printf(" Cycle ");
+ //}
+ }
+
+ if (secondscounter < PT) {
+ my_RHMV = 1;//0
+ my_LHMV = 0;//1
+ my_RHPV = 1;//0
+ my_LHPV = 0;//1
+ my_RV = 0;//1
+ }
+ if (secondscounter >= PT && secondscounter < LHCT) {
+ my_RHMV = 1;//0
+ my_LHMV = 0;//1
+ my_RHPV = 0;//1
+ my_LHPV = 0;//1
+ my_RV = 1;//0
+
+ }
+
+ if ((secondscounter > LHCT) && (secondscounter < LHPT)) {
+ my_RHMV = 0;//1
+ my_LHMV = 1;//0
+ my_RHPV = 0;//1
+ my_LHPV = 1;//0
+ my_RV = 0;//1
+ }
+ if (secondscounter >= LHPT && (secondscounter < CT)) {
+ my_RHMV = 0;//1
+ my_LHMV = 1;//0
+ my_RHPV = 0;//1
+ my_LHPV = 0;//1
+ my_RV = 1;//0
+ }
+
+ if (secondscounter == (CT + 1)) {
+ secondscounter = 0;
+ }
+ } // While(1)
+} //Void Main
--- a/mbed.bld Sat Dec 04 11:31:07 2010 +0000 +++ b/mbed.bld Fri Nov 29 09:27:44 2019 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/e2ac27c8e93e +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file