update300714

Dependencies:   Buffer ConfigFile DS2482 mbed monitor timer0

Fork of 11_PT1000 by Sven Schäfer

Revision:
3:72a65324d50d
Parent:
2:f48d2eb0cc55
--- a/main.cpp	Mon Jul 28 14:37:14 2014 +0000
+++ b/main.cpp	Wed Jul 30 15:04:59 2014 +0000
@@ -15,6 +15,7 @@
 timer0 down_timer;                              // Zeitsteuerung
 Serial pc(USBTX, USBRX);                        // tx, rx
 Buffer <char> buf;                              // Ringbuffer für ankommende Zeichen
+PwmOut heizung(PTA13);
 
 //        sda, scl, adr
 DS2482 ow(PTE0,PTE1,0x30);
@@ -65,11 +66,13 @@
 16  PTD6,  ADC0_SE7b, 0}, k3.1
 */
 
-float temp1, temp_neu;
+float temp1, temp_mw;
 uint16_t temp_word;
 uint8_t n, y, status, ds1820_status;
 
-float temp_float;
+
+
+float temp_float, temp_diff, temp_alt, temp_neu;
 
 ConfigFile cfg;
 char value[BUFSIZ];
@@ -142,10 +145,15 @@
 int main() 
 {
     
+    heizung.period(0.020);          //  requires a 20ms period
+    heizung.pulsewidth(0.005);
+    temp_alt = 0.0;
+    
+    
     //------------------------------------------------------------------------------
     // RS232 Schnittstellt welche auf den CMSIS-DAP (USB Port) weitergeleitet wird
     //
-    pc.baud(9600);
+    pc.baud(115200);
     pc.attach(&rx_handler, Serial::RxIrq);
     pc.printf("\n V08 was compiled on %s  %s \n", __DATE__,__TIME__);
 
@@ -210,7 +218,7 @@
     //--------------------------------------------------------------------
     // Anfangswert bestimmen
     
-    temp_neu = read_mw(0);
+    temp_mw = read_mw(0);
     
     //pc.printf("\nPT1000; DS18B20");
     status = 0;
@@ -306,7 +314,7 @@
        
        if (down_timer.GetTimerStatus(2) == 0)
        {
-            down_timer.SetCountdownTimer(2,1,1000);
+            down_timer.SetCountdownTimer(2,1,500);
             
             //------------------------------------------------------
             // PT1000 lesen und berechnen und ausgeben
@@ -314,15 +322,41 @@
             //
            
             temp_word = read_mw(0);
-            temp_float = (temp_word - 17210);
-            temp_float /= 70;
-            // pc.printf("%0.2f; ",temp_float);                     // Rohdaten ausgeben
+            temp_float = (temp_word - 28500);
+            
+            //pc.printf("%d;",temp_word);
+            
+            temp_float /= 116;
+            pc.printf("%0.2f; ",temp_float);                     // Rohdaten ausgeben
 
+            temp_diff = 40 - temp_float;
+            
+            
+  
+            temp_neu = ((temp_diff*0.0005) + (temp_alt*0.9));
+            
+            if(temp_neu > 0.02){
+                temp_neu = 0.02;
+            }            
+            //if(temp_neu < -0.001){
+            //    temp_neu = -0.001;
+            //}
+            if(temp_float > 40){
+                temp_neu = 0.0;
+                }
+            
+            heizung.pulsewidth(0.0001 + temp_neu);
+            pc.printf("%0.4f;",temp_alt);
+            pc.printf("%0.4f \n",temp_neu);
+            
+            temp_alt = temp_neu;
 
             temp_word = read_mw(1);
             temp_float = (temp_word - 17210);
             temp_float /= 70;
             // pc.printf("%0.2f\n",temp_float);                      // Rohdaten ausgeben
+
+            
              
        
             //------------------------------------------------------