single current only

Dependencies:   Watchdog mbed

Revision:
2:156af70e6f15
Parent:
1:31e63b43238f
Child:
3:bd056c7b3498
--- a/main.cpp	Thu Jan 26 12:08:23 2017 +0000
+++ b/main.cpp	Thu Jan 26 14:37:07 2017 +0000
@@ -8,6 +8,8 @@
 //  - 32/16 Amp Charging                //
 //  - 9V & 6V timers not applied        //
 //    in this revision, line 315&325    //
+//  - error when voltage out of range   //
+//    cp_check_voltage();               //
 //////////////////////////////////////////
 
 #include "mbed.h"
@@ -85,6 +87,7 @@
 int TESTCOUNTER = 0;                                            // Variable to count number of cycles of main loop. Used to determine when to switch the pwm in this test version.
 
 int stateB_COUNTER = 0;                                         // Variable to count number of cycles of main loop. Used to reset charger from state B - 9V to state A and re-initiate charging.
+
 // ************************************************************
 // *   New Acquisition Routine for Capturing CP Signal Data   *                                    
 // ************************************************************
@@ -226,9 +229,12 @@
     
     // If the measured cp voltage is within a range of +/- ACCEPTABLE_VOLTAGE_RANGE around the 
     // value (12V, 9V, 6V) then we change the flag state to true.
-    if (cp_voltage < (v + ACCEPTABLE_VOLTAGE_RANGE) && cp_voltage > (v - ACCEPTABLE_VOLTAGE_RANGE)) voltage_in_range = true;
-                            
-    return voltage_in_range;                                    // The function then returns the value of the flag state.
+    if (cp_voltage < (v + ACCEPTABLE_VOLTAGE_RANGE) && cp_voltage > (v - ACCEPTABLE_VOLTAGE_RANGE))
+    {
+        voltage_in_range = true;
+        return voltage_in_range;
+    }
+    else{ return PILOT_NOK;}                                    // The function then returns the value of the flag state.
 }
 
 
@@ -287,7 +293,7 @@
                 control_pilot = PILOT_12V;
                 reset_charger = false;
             }
-            if (cp_check_voltage(12) == false && cp_check_voltage(-12) == false)control_pilot = PILOT_NOK;  // voltage not at 12 or -12, error accured
+            //if (cp_check_voltage(12) == false && cp_check_voltage(-12) == false)control_pilot = PILOT_NOK;  // voltage not at 12 or -12, error accured
         }
         
         if (cable_connected == true)
@@ -298,6 +304,7 @@
             if (reset_charger == true) control_pilot = PILOT_RESET;
             //if (cp_check_voltage(9) == false && cp_check_voltage(6) == false && cp_check_voltage(12) == false && reset_charger == false )control_pilot = PILOT_NOK;   // voltage not at expected values, error accured
         }
+       
 // ************************************************************
 // *        Switching PWM Cycle & TEST Counter Timer          *                                                                                                    
 // ************************************************************        
@@ -374,7 +381,7 @@
                     my_pwm.write(pwm_duty_cycle);
                     pwm_state = true;
                 }
-                pc.printf("PWM duty cycle is at: %.1f  %% \r\n", 100-pwm_duty_cycle*100);
+                pc.printf("PWM duty cycle is at: ------------------------------------------- %.1f  %% \r\n", 100-pwm_duty_cycle*100);
                 pc.printf("Charger in STATE:------------------------------------------------ C. \r\n");
                 pc.printf("PILOT_6V - Pilot at 6 V. \r\n");
 //              TESTCOUNTER+=1;