20210203

Dependencies:   mbed FastPWM

Revision:
64:6f1caa0993d0
Parent:
63:3c6869477483
Child:
65:a2d7c63419c2
--- a/main.cpp	Fri Apr 03 12:48:42 2020 +0000
+++ b/main.cpp	Fri Apr 03 14:53:53 2020 +0000
@@ -8,7 +8,8 @@
 #include "function_utilities.h"
 #include "stm32f4xx_flash.h"
 #include "FlashWriter.h"
-#include "Eigen/Dense.h"
+#include "Eigen/Dense.h"        
+#include "ST_F401_84MHZ.h"
 
 using namespace std;
 using namespace Eigen;
@@ -158,6 +159,7 @@
 
 int main()
 {
+    F401_init84 myinit(1);
     /*********************************
     ***     Initialization
     *********************************/
@@ -235,6 +237,9 @@
             ID_index_array[i] =  (i+1) * 0.5f;
     }
     
+    printf("systemcoreclock  = %d Hz\n", SystemCoreClock);
+    
+    
     Input <<
        0.052414,0.066907,0.085407,0.109023,0.139169,0.177651,0.052414,0.066907,0.085407,0.109023,0.139169,0.177651,0.052414,0.066907,0.085407,0.109023,0.139169,0.177651,0.052414,0.066907,0.085407,0.109023;
 
@@ -476,22 +481,22 @@
     ***     Program is operating!
     *************************************/
     while(1) {
-        if(timer_while==1000 && OPERATING_MODE==5) {
-            //i2c
-            read_field(i2c_slave_addr1);
-            if(DIR_VALVE_ENC < 0) value = 1023 - value;
-            //            if(LED==1) {
-            //                LED=0;
-            //            } else
-            //                LED = 1;
-            timer_while = 0;
-        }
-        timer_while ++;
+//        if(timer_while==1000 && OPERATING_MODE==5) {
+//            //i2c
+//            read_field(i2c_slave_addr1);
+//            if(DIR_VALVE_ENC < 0) value = 1023 - value;
+//            //            if(LED==1) {
+//            //                LED=0;
+//            //            } else
+//            //                LED = 1;
+//            timer_while = 0;
+//        }
+//        timer_while ++;
         
-        //t.reset();
-        //t.start();
+        t.reset();
+        t.start();
         
-        
+        //X = (((Input*h1+b1.transpose())*h2+b2.transpose())*h3+b3.transpose())*hout+bout.transpose();
         
 //        Input <<
 //        input_array[0],input_array[1],input_array[2],input_array[3],input_array[4];
@@ -514,14 +519,14 @@
         X = X*hout+bout.transpose();
         NNoutput=1.0f/(1.0f+exp(-X(0,0)));
         
-        //t.stop();
+        t.stop();
         
         printf("NNoutput : %f\n", NNoutput);
         printf("time : %f\n", t.read());
         
-        //wait(1);
+        wait(1);
         
-        CAN_TX_PWM((int16_t) 78); //1500
+        //CAN_TX_PWM((int16_t) (t.read() * 1000000.0f)); //1500
         
 //        PWM_out = NNoutput * 24000.0f - 12000.0f;
 //