作成途中ですよーだ

Dependencies:   PID QEI mbed-rtos mbed PreHeater SB1602E

Dependents:   PreHeater

Revision:
6:704706b288b4
Parent:
5:bfbc802f4958
--- a/main.cpp	Fri Jul 03 11:19:56 2015 +0000
+++ b/main.cpp	Fri Jul 03 11:43:09 2015 +0000
@@ -59,13 +59,15 @@
 int rtostime;
 
 /*PB control*/
-void runmode() {
+void runmode()
+{
     Run = !Run;
 }
 
-void cal_temp(void const *argument) {
-    while(1){
-       /*input for change to 0 to 100% range by 30C to 120C */
+void cal_temp(void const *argument)
+{
+    while(1) {
+        /*input for change to 0 to 100% range by 30C to 120C */
         /*Temperature setpoint low high range */
 #define RangeSPL 30.0 //Celcius low side temperature 
         temp_sv_input = wheel.getPulses() / 20.0 + RangeSPL;
@@ -75,7 +77,7 @@
         } else if (temp_sv_input >= RangeSPH) {
             temp_sv_input = RangeSPH;
         }
-        
+
         /*six order polynomial calculation value
         Thermister pull up resiter 560R
         Thermister B value 3380K
@@ -86,36 +88,36 @@
         temp_pv =-0.7964*pow(temp_cal,6.0) - 2.5431*pow(temp_cal,5.0) +63.605*pow(temp_cal,4.0) - 274.1*pow(temp_cal,3.0) + 522.57*pow(temp_cal,2.0) - 539.26*temp_cal + 405.76;
 
         /*LCD Display section */
-            /*LCD Display section */
-            lcd.printf(0, "SP %.1f", temp_sv_input);
-            lcd.printf(0, "PV %.1f\n", temp_pv);
-            lcd.printf(1, "OUT %.2f", out.read() * 100);
-            lcd.printf(1, "PB %s\n", Run);
+        /*LCD Display section */
+        lcd.printf(0, "SP %.1f", temp_sv_input);
+        lcd.printf(0, "PV %.1f\n", temp_pv);
+        lcd.printf(1, "OUT %.2f", out.read() * 100);
+        lcd.printf(1, "PB %s\n", Run);
         /*Tenperature indicater */
         /* 1.5C high temperature */
-        if (Run == true){
-        if ((temp_pv - temp_sv_input) >= 1.5) {
-            ledR = 0;
-            ledG = 1;
-            ledB = 1;
-            /* 1.5C low temperature */
-        } else if ((temp_sv_input - temp_pv ) >= 1.5 ){
-            ledR = 1;
-            ledG = 1;
-            ledB = 0;
-        } else {
-            /* control green */
-            ledR = 1;
-            ledG = 0;
-            ledB = 1;
-        }
+        if (Run == true) {
+            if ((temp_pv - temp_sv_input) >= 1.5) {
+                ledR = 0;
+                ledG = 1;
+                ledB = 1;
+                /* 1.5C low temperature */
+            } else if ((temp_sv_input - temp_pv ) >= 1.5 ) {
+                ledR = 1;
+                ledG = 1;
+                ledB = 0;
+            } else {
+                /* control green */
+                ledR = 1;
+                ledG = 0;
+                ledB = 1;
+            }
         } else {
             ledR = 1;
             ledG = 1;
             ledB = 1;
         }
-Thread::wait(rtostime * 2);
-}
+        Thread::wait(rtostime * 2);
+    }
 }
 
 
@@ -128,14 +130,14 @@
     RunPB.rise(&runmode);
     Thread thread(cal_temp);
     rtostime = RATE * 1000;
-    while (1) {   
+    while (1) {
         /*PID control*/
 #define SV_LL 0.0 //PID setpoint % value for lo limit
 #define SV_HL 100.0 //PID setpoint % value for high limit
-            TIC.setInputLimits(SV_LL, SV_HL);
+        TIC.setInputLimits(SV_LL, SV_HL);
 #define OV_LL 0.0 //PID calcurate output value 0.0 = 0%
 #define OV_HL 100.0 //PID calcurate output value 1.0 = 100%
-            if (Run == true) {
+        if (Run == true) {
             TIC.setOutputLimits(OV_LL, OV_HL);
             TIC.setSetPoint(temp_sv_input);
             TIC.setProcessValue(temp_pv);
@@ -143,12 +145,12 @@
             TIC.setMode(1);
             out = TIC.compute() /100;
             TIC.setInterval(RATE);
-                             }else if (Run == false){
-                              TIC.setMode(0);
-                              TIC.reset();
-                              out = 0.0;
-                                                    }
-            Thread::wait(rtostime);
+        } else if (Run == false) {
+            TIC.setMode(0);
+            TIC.reset();
+            out = 0.0;
+        }
+        Thread::wait(rtostime);
 
-            }
+    }
 }
\ No newline at end of file