Régulateur de type proportionnel

Dependencies:   mbed C12832

Revision:
0:cabc061cb9e7
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Dec 18 19:16:30 2018 +0000
@@ -0,0 +1,49 @@
+#include "mbed.h"
+#include "C12832.h"
+C12832 lcd(p5,p7,p6,p8,p11);
+AnalogIn Vcapt(p17);
+AnalogOut Vcde(p18);
+AnalogIn p1(p19);
+Ticker cadence;
+float E;
+int Tc = 35;
+float T;
+float K=1;
+Serial pc(USBTX, USBRX);
+char x;
+
+void regulation() {
+    T=330*Vcapt;
+    E=Tc-T;
+    Vcde=K*E;
+    if(Vcde>1){
+        Vcde=1;
+        }
+    if(Vcde<0){
+        Vcde=0;
+        }  
+}
+
+int main(){
+    cadence.attach(&regulation,0.001);
+    while (1){
+        if (pc.readable()){
+            x= pc.getc();
+            if (x=='p'){
+                Tc++;
+                }
+            if (x=='m'){
+                Tc--;
+                }
+            }
+        K = 0.1;
+        lcd.cls();
+        lcd.locate(0,0);
+        lcd.printf("Temprature : %4.3f",T);
+        lcd.locate(0,8);
+        lcd.printf("Tc : %d",Tc);
+        lcd.locate(0,16);
+        lcd.printf("K : %4.2f",K);
+        wait(0.1);
+        }   
+}
\ No newline at end of file