HAPI- Tech / Mbed 2 deprecated PreHeater

Dependencies:   PID QEI SB1602E mbed-rtos mbed

Fork of PreHeater by Kazu Zamasu

Files at this revision

API Documentation at this revision

Comitter:
kazu_zamasu
Date:
Sat Jun 13 00:05:45 2015 +0000
Child:
1:f974481c37b6
Commit message:
?????

Changed in this revision

PID.lib Show annotated file Show diff for this revision Revisions of this file
QEI.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PID.lib	Sat Jun 13 00:05:45 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/aberk/code/PID/#6e12a3e5af19
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/QEI.lib	Sat Jun 13 00:05:45 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/aberk/code/QEI/#5c2ad81551aa
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Jun 13 00:05:45 2015 +0000
@@ -0,0 +1,87 @@
+#include "mbed.h"
+#include "PID.h"
+#include "QEI.h"
+#include "rtos.h"
+#include "math.h"
+
+#define ROTATE_PER_REVOLUTIONS  24 //QEI 1 rotate by count
+#define THR 560  /PTH pull up register value
+#define THB 3380  //PTH B number
+#define THCR 10000 //25C PTH register
+#define OV_LL 0.0 //PID calcurate output value 0.0 = 0%
+#define OV_HL 1.0 //PID calcurate output value 1.0 = 100%
+#define SV_LL 0.0 //PID setpoint % value for lo limit
+#define SV_HL 100.0 //PID setpoint % value for high limit
+#define P 1.0
+#define I 0.2
+#define D 0.1
+#define RATE 0.1
+#define Bias 0.2
+#define InitialSP 50.0 // PID initial setpoint
+#define RangeSPL 30.0
+#define RangeSPH 120.0
+
+//Kc, Ti, Td, interval
+PID TIC(P, I, D, RATE);
+
+AnalogIn THAI(dp4);
+PwmOut   out(dp1);
+DigitalOut led1(dp14),led2(dp28);
+DigitalIn Run(dp17,PullUp);
+QEI wheel(dp11, PullUp, dp13,PullUp, NC, ROTATE_PER_REVOLUTIONS, QEI::X2_ENCODING);
+float temp_sv_input;
+double temp_pv,temp_cal;
+
+void LCD_thread(void const *args) {
+    while (true) {
+        led2 = !led2;
+        Thread::wait(1000);
+    }
+}
+ 
+
+int main(){
+ //input for change to 0 to 100% range by 50C to 120C
+ temp_sv_input = wheel.getPulses() * 0.5 + RangeSPL;
+
+ if (temp_sv_input <= RangeSPL){
+     temp_sv_input = RangeSPL;
+     }
+     else if (temp_sv_input >= RangeSPH){
+              temp_sv_input = RangeSPH;
+                                        } 
+
+
+ temp_cal = THAI.read();
+//six order polynomial
+ 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;
+
+  //Analog input from 50.0C to 120.0C
+  TIC.setInputLimits(SV_LL, SV_HL);
+  //Pwm output from 0.0 to 1.0
+  TIC.setOutputLimits(OV_LL, OV_HL);
+  //If there's a bias.
+  TIC.setBias(Bias);
+  TIC.setMode(Run);
+  //We want the process variable to be 1.7V
+  TIC.setSetPoint(temp_sv_input);
+ 
+  while(Run == 1){
+    //Update the process variable.
+    TIC.setProcessValue(temp_cal);
+    //Set the new output.
+    out = TIC.compute();
+    //Wait for another loop calculation.
+    wait(RATE);
+
+    Thread thread(LCD_thread);
+    
+/*    while (true) {
+        led1 = !led1;
+        Thread::wait(500);
+                }  */
+
+out = OV_LL; 
+                }
+ 
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Sat Jun 13 00:05:45 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-rtos/#ed4ff3bea947
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Jun 13 00:05:45 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/7cff1c4259d7
\ No newline at end of file