test protocole soufflerie Pid

Dependencies:   mbed LCD_DISCO_F746NG BSP_DISCO_F746NG Ecran MySerial

Files at this revision

API Documentation at this revision

Comitter:
schnf30
Date:
Sat Jun 11 11:28:02 2022 +0000
Commit message:
test protocole soufflerie Pid

Changed in this revision

BSP_DISCO_F746NG.lib Show annotated file Show diff for this revision Revisions of this file
Ecran.lib Show annotated file Show diff for this revision Revisions of this file
LCD_DISCO_F746NG.lib Show annotated file Show diff for this revision Revisions of this file
MySerial.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.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BSP_DISCO_F746NG.lib	Sat Jun 11 11:28:02 2022 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/ST/code/BSP_DISCO_F746NG/#85dbcff443aa
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Ecran.lib	Sat Jun 11 11:28:02 2022 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/schnf30/code/Ecran/#334e4751616e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LCD_DISCO_F746NG.lib	Sat Jun 11 11:28:02 2022 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/ST/code/LCD_DISCO_F746NG/#d44525b1de98
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MySerial.lib	Sat Jun 11 11:28:02 2022 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/schnf30/code/MySerial/#88efe939415b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Jun 11 11:28:02 2022 +0000
@@ -0,0 +1,85 @@
+#include "mbed.h"
+#include "MySerial.h"
+#include "ecran.h"
+
+// variable soufflerie
+float ConsVitFluxAir;  // consigne flux air
+float VitFluxAir; // vitesse de flux air
+float Frequencehelice;
+// coef correcteur PID
+float coefp,coefi,coefd;
+// interface PC attention baud 921600
+MySerial PC(USBTX,USBRX); // liaison PC
+char PCPhrase[maxdata];    // pour stocker phrase PC
+float presangle;
+volatile char EnvoiePC = 0; // INDIQUE DONNEE A ENVOYER EN PC ET CODE TRAME
+Ticker ticker;
+unsigned int Nb = 1;
+void Tenvoi(void)
+{
+    EnvoiePC = 'V';
+}
+
+DigitalOut led_green(LED1);
+
+
+Ticker tickermes;
+bool datachange = false;
+void mes(void)
+{
+    datachange = true;
+    VitFluxAir++; // vitesse de flux air
+    if (VitFluxAir>70) VitFluxAir = 0;
+    Frequencehelice++;
+    if (Frequencehelice>180) Frequencehelice = 0;
+}
+
+
+int main()
+{
+    coefp=0;
+    coefi=0;
+    coefd=100000;
+    Frequencehelice = 100;
+    ConsVitFluxAir = 57;  // consigne flux air
+    VitFluxAir =30;
+    Ecran();
+    ticker.attach(&Tenvoi,0.1); // demare ticker pour envoi trame toute les 100ms
+    tickermes.attach(&mes,10); // demare ticker pour envoi trame toute les 100ms
+    FirstEcran();
+    while(1) {
+
+// recevoir des donnees
+        if (PC.dataready()) {
+            strcpy(PCPhrase,PC.read());
+            switch (PCPhrase[1]) {
+                case 'B': // consigne de flux air
+                    ConsVitFluxAir = atof(PCPhrase+2);
+                    datachange=true;
+                    break;
+                case 'L' :  // param pid
+                    if (sscanf(PCPhrase,"$L,%f,%f,%f",&coefp,&coefi,&coefd)>=1) datachange=true;
+                    break;
+                default :
+                    ;
+            }
+        }
+// envoie des data vers PC
+        if (EnvoiePC!=0) {
+            switch (EnvoiePC) {
+                case 'V' : // angle mesure
+                    PC.printf("$V,%0.1f,%0.1f\r\n",VitFluxAir,Frequencehelice);
+                    EnvoiePC=0;
+                    break;
+                default :
+                    EnvoiePC=0;
+            }
+        }
+        if (datachange) {
+            led_green = !led_green;
+            Ecran();
+            datachange = false;
+        }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Jun 11 11:28:02 2022 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file