![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
all bms comunicating with nucleo board and balancing
Dependencies: CANnucleo LTC68041 mbed
Fork of BMS_2 by
Diff: main.cpp
- Revision:
- 38:48afc177a319
- Parent:
- 37:1776d45825ef
- Child:
- 39:1e9fdc51cd65
--- a/main.cpp Wed Nov 09 14:20:39 2016 +0000 +++ b/main.cpp Wed Nov 09 15:14:18 2016 +0000 @@ -134,7 +134,7 @@ void message_trigger() { - if(cells_left < 1) { + if((cells_left < 1)&&(temps_left < 1)) { sender.detach(); } else { to_send = 1; @@ -250,9 +250,9 @@ void check_temperatures() { int i=14; - MUXA_3=0; MUXA_2=0; MUXA_1=0; MUXA_0=1; //(escolha do NTC on board) + MUXA_3=1; MUXA_2=1; MUXA_1=1; MUXA_0=0; //(escolha do NTC on board) temp_codes[i]= MUXA_Read.read()*3300; - temps_left = 14; + temps_left = 32; } @@ -327,7 +327,8 @@ MUXB_3=1; MUXB_2=1; MUXB_1=1; MUXB_0=1; } wait_ms(10); //tempo para a tensao á saida do mux estabilisar - if(i<16){ // Converts and read the analog input value (value from 0.0 to 1.0) + + if(i<=15){ // Converts and read the analog input value (value from 0.0 to 1.0) temp_codes[i] = MUXA_Read.read()*3300; }else{ temp_codes[i] = MUXB_Read.read()*3300; @@ -336,6 +337,7 @@ temps_left = 32; } */ + void onMsgReceived() { msgAvailable = true; @@ -409,13 +411,13 @@ charging = 0; check_charging_voltage(); check_temperatures(); - sender.attach(&message_trigger,0.1); + sender.attach(&message_trigger,0.05); } if(discharging) { discharging = 0; check_discharging_voltage(); check_temperatures(); - sender.attach(&message_trigger,0.1); + sender.attach(&message_trigger,0.05); } if(to_send) { to_send=0; @@ -451,10 +453,10 @@ txMsg.data[3] = data.bytes[3]; txMsg.data[4] = temps_left; - //temps_left--; + temps_left--; if(!(can.write(txMsg))) { //se nao conseguiu transmitir continua a tentar transmitir a tensão dessa celula pec_error(); - //temps_left++; + temps_left++; //to_send=1; }