Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: CANnucleo LTC68041 mbed
Fork of BMS_4 by
Revision 26:c55656391a29, committed 2016-10-24
- Comitter:
- Crazyaboutmachines
- Date:
- Mon Oct 24 21:38:14 2016 +0000
- Parent:
- 25:6f4f7510db24
- Child:
- 27:db96e99e37c9
- Commit message:
- BMS a activar e desactivar balanceamento
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Oct 24 13:10:45 2016 +0000
+++ b/main.cpp Mon Oct 24 21:38:14 2016 +0000
@@ -176,9 +176,9 @@
tx_cfg[0][5] = tx_cfg[0][5] | 0x01; // 00000001
case 9:
tx_cfg[0][5] = tx_cfg[0][5] | 0x10; // 00000010
- }
- }else{
- switch (i){
+ }
+ } else {
+ switch (i) {
case 0:
tx_cfg[0][4] = tx_cfg[0][4] & 0xFE ; // 11111110
case 1:
@@ -198,8 +198,8 @@
case 8:
tx_cfg[0][5] = tx_cfg[0][5] & 0xFE; // 11111110
case 9:
- tx_cfg[0][5] = tx_cfg[0][5] & 0xFD; // 11111101
- }
+ tx_cfg[0][5] = tx_cfg[0][5] & 0xFD; // 11111101
+ }
}
}
}
@@ -239,6 +239,9 @@
//print_cells2();
cells_left = 12;
+tx_cfg[0][4] = tx_cfg[0][4] & 0b00000000; //para desactivar balanceamento durante a descarga
+tx_cfg[0][5] = tx_cfg[0][5] & 0b11110000;
+
//print_cells2();
LTC6804_wrcfg(TOTAL_IC,tx_cfg);
}
@@ -249,7 +252,7 @@
}
-bool to_charge_or_not_to_charge=true; // false = discharge
+bool to_charge_or_not_to_charge=false; // false = discharge
bool charging = false;
bool discharging = false;
@@ -266,9 +269,11 @@
}
+uint8_t motostate=0;
+
int main()
{
- data data;
+ data data;
//printf("starting\n\r");
led =1;
@@ -322,8 +327,8 @@
sender.attach(&message_trigger,0.1);
}
if(to_send) {
-
-
+
+
to_send=0;
txMsg.clear();
txMsg.id = 11; //BMS1=>ID:11; BMS2=>ID:12; BMS3=>ID:13.
@@ -342,6 +347,18 @@
}
}
+
+ if(msgAvailable) {
+ int len = can.read(rxMsg);
+ if(rxMsg.id==9){
+
+ motostate = rxMsg.data[0];
+
+ //motostate: (0|0|0|0|0|0|to_charge_or_not_to_charge|key_switch)
+ to_charge_or_not_to_charge=((motostate & 0b00000010)>>1);
+ msgAvailable = false;
+ }
+ }
}
}
