![](/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:
- 44:51fadd7414b1
- Parent:
- 43:cf574cc8b74f
- Child:
- 45:9764758d3433
diff -r cf574cc8b74f -r 51fadd7414b1 main.cpp --- a/main.cpp Fri Nov 25 23:26:58 2016 +0000 +++ b/main.cpp Tue Nov 29 09:04:51 2016 +0000 @@ -268,6 +268,17 @@ } */ +void t_alarm(){ //envio de mensagem de alarme devido a temperatura + txMsg.clear(); + txMsg.id = 8; //BMS1=>ID:11; BMS2=>ID:12; BMS3=>ID:13. + txMsg.len = 1; + txMsg.data[0] = 0b00000001; + if(!(can.write(txMsg))) { //se nao conseguiu transmitir continua a tentar transmitir a tensão dessa celula + pec_error(); + } + } + + float temp; void check_temperatures() { @@ -345,17 +356,25 @@ temp_codes[i] = MUXB_Read.read()*3300; } - //-------------------------- temp=temp_codes[i]/1000; 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 + } + } + //-------------------------- } temps_left = 32; } - void onMsgReceived() { msgAvailable = true; @@ -444,7 +463,7 @@ if(cells_left>0){ txMsg.clear(); - txMsg.id = 13; //BMS1=>ID:11; BMS2=>ID:12; BMS3=>ID:13. + txMsg.id = 11; //BMS1=>ID:11; BMS2=>ID:12; BMS3=>ID:13. txMsg.len = 5; data.f[0] = cell_codes[0][cells_left-1]*0.0001; txMsg.data[0] = data.bytes[0]; @@ -466,7 +485,7 @@ if(temps_left>0){ txMsg.clear(); - txMsg.id = 23; //BMS1=>ID:21; BMS2=>ID:22; BMS3=>ID:23. + txMsg.id = 21; //BMS1=>ID:21; BMS2=>ID:22; BMS3=>ID:23. txMsg.len = 5; data.f[0] = temp_codes[temps_left-1];