rainbow

Dependencies:   mbed FastPWM

Revision:
252:3ffd78cbd029
Parent:
251:a08f301231f1
Child:
253:c53d4c26b04a
--- a/main.cpp	Wed Jul 06 08:08:15 2022 +0000
+++ b/main.cpp	Wed Jul 20 07:50:48 2022 +0000
@@ -358,7 +358,7 @@
     Vout.ref = VALVE_PWM_RAW_FF + VALVE_PWM_RAW_FB;
     int R_FET = 1.5f;
     int R_Motor = 5.4f;
-    Vout.ref = Vout.ref + Vout.ref/R_Motor*R_FET;
+    Vout.ref = Vout.ref + Vout.ref/R_Motor*R_FET*2.0f;
 }
 
 // Valve feedforward for SW valve
@@ -392,7 +392,7 @@
     Vout.ref = VALVE_PWM_RAW_FF + VALVE_PWM_RAW_FB;
     int R_FET = 1.5f;
     int R_Motor = 5.4f;
-    Vout.ref = Vout.ref + Vout.ref/R_Motor*R_FET;
+    Vout.ref = Vout.ref + Vout.ref/R_Motor*R_FET*2.0f;
 }
 
 // PWM duty vs. voltage output of L6205 in STM board
@@ -799,7 +799,7 @@
                     Vout.ref = 1000.0f*(ID_index_array[ID_index]);
                     int R_FET = 1.5f;
                     int R_Motor = 5.4f;
-                    Vout.ref = Vout.ref + Vout.ref/R_Motor*R_FET;
+                    Vout.ref = Vout.ref + Vout.ref/R_Motor*R_FET*2.0f;
                 } else if(VALVE_ID_timer == TMR_FREQ_5k*2) {
                     VALVE_POS_TMP = 0;
                     data_num = 0;
@@ -1394,8 +1394,13 @@
 
         } else {            //////////////////////////sw valve
             // Output Voltage Linearization & Dead Zone Cancellation (Electrical dead-zone) by SW
-            if (V_out > 0 ) V_out = (V_out + 180.0f)/0.8588f;
-            else if (V_out < 0) V_out = (V_out - 200.0f)/0.8651f;
+            // L6205PD
+//            if (V_out > 0 ) V_out = (V_out + 180.0f)/0.8588f;
+//            else if (V_out < 0) V_out = (V_out - 200.0f)/0.8651f;
+//            else V_out = 0.0f;
+            // IRSM836-45MA
+            if (V_out > 0 ) V_out = V_out*1.654f + 200.0f;
+            else if (V_out < 0) V_out = V_out*1.654f - 200.0f;
             else V_out = 0.0f;
         }