![](/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:
- 45:9764758d3433
- Parent:
- 44:51fadd7414b1
- Child:
- 46:9bc58ec85bd5
--- a/main.cpp Tue Nov 29 09:04:51 2016 +0000 +++ b/main.cpp Tue Nov 29 11:20:16 2016 +0000 @@ -268,11 +268,11 @@ } */ -void t_alarm(){ //envio de mensagem de alarme devido a temperatura +void alarm(char alarm_code){ txMsg.clear(); txMsg.id = 8; //BMS1=>ID:11; BMS2=>ID:12; BMS3=>ID:13. txMsg.len = 1; - txMsg.data[0] = 0b00000001; + txMsg.data[0] = alarm_code; //alarm_code if(!(can.write(txMsg))) { //se nao conseguiu transmitir continua a tentar transmitir a tensão dessa celula pec_error(); } @@ -360,17 +360,16 @@ temp=(temp*10000)/(3.3-temp); temp = 3380/log(temp/0.119228); temp_codes[i] = temp-273.15; - //-------------------------- - if(i==14||i==30){ - if(temp_codes[i]>30){ - // if(temp_codes[i]>30||temp_codes[i]<-20){ - //disable interrupts - t_alarm();//temperature alarm - //enable interrupts - } - } - - //-------------------------- +// //-------------------------- +// if(i==0||i==1||i==2||i==3||i==4||i==5||i==6||i==7||i==8||i==9||i==10||i==11||i==14||i==30){ +// if(temp_codes[i]>23){ +// // if(temp_codes[i]>30||temp_codes[i]<-20){ +// //disable interrupts +// alarm();//temperature alarm +// //enable interrupts +// } +// } +// //-------------------------- } temps_left = 32; } @@ -484,13 +483,29 @@ if(temps_left>0){ +//------------------------------ + +if(temps_left==1||temps_left==2||temps_left==3||temps_left==4||temps_left==5|| +temps_left==6||temps_left==7||temps_left==8||temps_left==9||temps_left==10|| +temps_left==11||temps_left==12||temps_left==15||temps_left==31){ + if(temp_codes[temps_left-1]>49||temp_codes[temps_left-1]<4){ //4-49(ambiente) + // if(temp_codes[i]>30||temp_codes[i]<-20){ + __disable_irq(); // Disable Interrupts + alarm('t'); //temperature alarm + __enable_irq(); + } + } + + +//------------------------------ txMsg.clear(); txMsg.id = 21; //BMS1=>ID:21; BMS2=>ID:22; BMS3=>ID:23. txMsg.len = 5; data.f[0] = temp_codes[temps_left-1]; // data.f[0] = temp_codes[14]; - + + txMsg.data[0] = data.bytes[0]; txMsg.data[1] = data.bytes[1]; txMsg.data[2] = data.bytes[2];