Ultima versão da banca de ensaios BMS Fev2017

Dependencies:   CANnucleo LTC68041 mbed

Fork of BMS_4 by Gerardo Antonio

Revision:
31:1fab4bb4e9ee
Parent:
30:9c9f2d789153
Child:
32:a52605800210
--- a/main.cpp	Fri Oct 28 14:43:46 2016 +0000
+++ b/main.cpp	Fri Oct 28 15:47:39 2016 +0000
@@ -151,20 +151,24 @@
     }
 }
 
+
+
+
+
 void check_charging_voltage()
 {
     wakeup_idle();
-    __disable_irq();
     LTC6804_adcv();
-    __enable_irq();
+    
     wait_ms(10);
     wakeup_idle();
-    __enable_irq();
     err = LTC6804_rdcv(0, TOTAL_IC,cell_codes);
-    __disable_irq();
     if (err == -1) {
         pec_error();
     }
+    
+    cells_left = 12;
+    
     for (int current_ic = 0 ; current_ic < TOTAL_IC; current_ic++) {
         for (int i=0; i<12; i++) {
             if(cell_codes[current_ic][i]*0.0001  > 3.6) {
@@ -213,13 +217,13 @@
         }
     }
     //print_cells2();
-    __disable_irq();
     LTC6804_wrcfg(TOTAL_IC,tx_cfg);
-    __enable_irq();
 }
 
 
 
+
+
 void check_discharging_voltage()
 {
     wakeup_idle();
@@ -288,6 +292,8 @@
     led =1;
     wait(1);
     pec_error();
+    to_charge_or_not_to_charge=0;
+    charging = 0;
     discharging = 1;
 
     ticker.attach(&monitor, 5);
@@ -328,7 +334,7 @@
         if(charging) {
             charging = 0;
             check_charging_voltage();
-
+            sender.attach(&message_trigger,0.1);
         }
         if(discharging) {
             discharging = 0;