mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-03 01:39:30 +02:00
Minimize CAN sending to only contactor closing
This commit is contained in:
parent
d595367db5
commit
895fd9a9ac
2 changed files with 37 additions and 15 deletions
|
@ -170,18 +170,26 @@ void FordMachEBattery::handle_incoming_can_frame(CAN_frame rx_frame) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void FordMachEBattery::transmit_can(unsigned long currentMillis) {
|
void FordMachEBattery::transmit_can(unsigned long currentMillis) {
|
||||||
// Send 10ms CAN Message
|
// Send 20ms CAN Message
|
||||||
if (currentMillis - previousMillis10 >= INTERVAL_10_MS) {
|
if (currentMillis - previousMillis20 >= INTERVAL_20_MS) {
|
||||||
previousMillis10 = currentMillis;
|
previousMillis20 = currentMillis;
|
||||||
|
|
||||||
|
transmit_can_frame(&FORD_25B);
|
||||||
|
|
||||||
|
//Full vehicle emulation, not required
|
||||||
|
/*
|
||||||
//transmit_can_frame(&FORD_217); Not needed for contactor closing
|
//transmit_can_frame(&FORD_217); Not needed for contactor closing
|
||||||
//transmit_can_frame(&FORD_442); Not needed for contactor closing
|
//transmit_can_frame(&FORD_442); Not needed for contactor closing
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send 30ms CAN Message
|
// Send 30ms CAN Message
|
||||||
if (currentMillis - previousMillis30 >= INTERVAL_30_MS) {
|
if (currentMillis - previousMillis30 >= INTERVAL_30_MS) {
|
||||||
previousMillis30 = currentMillis;
|
previousMillis30 = currentMillis;
|
||||||
|
|
||||||
|
//Full vehicle emulation, not required
|
||||||
|
/*
|
||||||
|
|
||||||
counter_30ms = (counter_30ms + 1) % 16; // cycles 0-15
|
counter_30ms = (counter_30ms + 1) % 16; // cycles 0-15
|
||||||
|
|
||||||
// Byte 2: upper nibble = 0xF, lower nibble = (0xF - counter_10ms) % 16
|
// Byte 2: upper nibble = 0xF, lower nibble = (0xF - counter_10ms) % 16
|
||||||
|
@ -229,19 +237,24 @@ void FordMachEBattery::transmit_can(unsigned long currentMillis) {
|
||||||
//transmit_can_frame(&FORD_165); Not needed for contactor closing
|
//transmit_can_frame(&FORD_165); Not needed for contactor closing
|
||||||
//transmit_can_frame(&FORD_7F); Not needed for contactor closing
|
//transmit_can_frame(&FORD_7F); Not needed for contactor closing
|
||||||
transmit_can_frame(&FORD_200);
|
transmit_can_frame(&FORD_200);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
// Send 50ms CAN Message
|
// Send 50ms CAN Message
|
||||||
if (currentMillis - previousMillis50 >= INTERVAL_50_MS) {
|
if (currentMillis - previousMillis50 >= INTERVAL_50_MS) {
|
||||||
previousMillis50 = currentMillis;
|
previousMillis50 = currentMillis;
|
||||||
//transmit_can_frame(&FORD_42C); Not needed for contactor closing
|
//transmit_can_frame(&FORD_42C); Not needed for contactor closing
|
||||||
//transmit_can_frame(&FORD_42F); Not needed for contactor closing
|
//transmit_can_frame(&FORD_42F); Not needed for contactor closing
|
||||||
transmit_can_frame(&FORD_43D);
|
//transmit_can_frame(&FORD_43D);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send 100ms CAN Message
|
// Send 100ms CAN Message
|
||||||
if (currentMillis - previousMillis100 >= INTERVAL_100_MS) {
|
if (currentMillis - previousMillis100 >= INTERVAL_100_MS) {
|
||||||
previousMillis100 = currentMillis;
|
previousMillis100 = currentMillis;
|
||||||
|
|
||||||
|
transmit_can_frame(&FORD_185); // Required to close contactors
|
||||||
|
|
||||||
|
//Full vehicle emulation, not required
|
||||||
|
/*
|
||||||
transmit_can_frame(
|
transmit_can_frame(
|
||||||
&FORD_12F); //This message actually has checksum/counter, but it seems to close contactors without those
|
&FORD_12F); //This message actually has checksum/counter, but it seems to close contactors without those
|
||||||
transmit_can_frame(&FORD_332);
|
transmit_can_frame(&FORD_332);
|
||||||
|
@ -257,13 +270,16 @@ void FordMachEBattery::transmit_can(unsigned long currentMillis) {
|
||||||
transmit_can_frame(&FORD_203); //MANDATORY FOR CONTACTOR OPERATION
|
transmit_can_frame(&FORD_203); //MANDATORY FOR CONTACTOR OPERATION
|
||||||
transmit_can_frame(
|
transmit_can_frame(
|
||||||
&FORD_176); //This message actually has checksum/counter, but it seems to close contactors without those
|
&FORD_176); //This message actually has checksum/counter, but it seems to close contactors without those
|
||||||
transmit_can_frame(&FORD_185);
|
*/
|
||||||
}
|
}
|
||||||
// Send 1s CAN Message
|
// Send 1s CAN Message
|
||||||
if (currentMillis - previousMillis1000 >= INTERVAL_1_S) {
|
if (currentMillis - previousMillis1000 >= INTERVAL_1_S) {
|
||||||
previousMillis1000 = currentMillis;
|
previousMillis1000 = currentMillis;
|
||||||
|
//Full vehicle emulation, not required
|
||||||
|
/*
|
||||||
transmit_can_frame(&FORD_3C3);
|
transmit_can_frame(&FORD_3C3);
|
||||||
transmit_can_frame(&FORD_581);
|
transmit_can_frame(&FORD_581);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,19 @@ class FordMachEBattery : public CanBattery {
|
||||||
uint8_t counter_30ms = 0;
|
uint8_t counter_30ms = 0;
|
||||||
uint8_t counter_8_30ms = 0;
|
uint8_t counter_8_30ms = 0;
|
||||||
|
|
||||||
|
//Message needed for contactor closing
|
||||||
|
CAN_frame FORD_25B = {.FD = false,
|
||||||
|
.ext_ID = false,
|
||||||
|
.DLC = 8,
|
||||||
|
.ID = 0x25B,
|
||||||
|
.data = {0x01, 0xF4, 0x09, 0xF4, 0xE0, 0x00, 0x80, 0x00}};
|
||||||
|
CAN_frame FORD_185 = {.FD = false,
|
||||||
|
.ext_ID = false,
|
||||||
|
.DLC = 8,
|
||||||
|
.ID = 0x185,
|
||||||
|
.data = {0x03, 0x4E, 0x75, 0x32, 0x00, 0x00, 0x00, 0x00}};
|
||||||
|
//Messages to emulate full vehicle
|
||||||
|
/*
|
||||||
CAN_frame FORD_47 = {.FD = false,
|
CAN_frame FORD_47 = {.FD = false,
|
||||||
.ext_ID = false,
|
.ext_ID = false,
|
||||||
.DLC = 8,
|
.DLC = 8,
|
||||||
|
@ -116,11 +129,7 @@ class FordMachEBattery : public CanBattery {
|
||||||
.DLC = 8,
|
.DLC = 8,
|
||||||
.ID = 0x12F,
|
.ID = 0x12F,
|
||||||
.data = {0x0A, 0xF8, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}};
|
.data = {0x0A, 0xF8, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}};
|
||||||
CAN_frame FORD_185 = {.FD = false,
|
|
||||||
.ext_ID = false,
|
|
||||||
.DLC = 8,
|
|
||||||
.ID = 0x185,
|
|
||||||
.data = {0x03, 0x4E, 0x75, 0x32, 0x00, 0x00, 0x00, 0x00}};
|
|
||||||
CAN_frame FORD_200 = {.FD = false,
|
CAN_frame FORD_200 = {.FD = false,
|
||||||
.ext_ID = false,
|
.ext_ID = false,
|
||||||
.DLC = 8,
|
.DLC = 8,
|
||||||
|
@ -146,11 +155,7 @@ class FordMachEBattery : public CanBattery {
|
||||||
.DLC = 8,
|
.DLC = 8,
|
||||||
.ID = 0x230,
|
.ID = 0x230,
|
||||||
.data = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03}};
|
.data = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03}};
|
||||||
CAN_frame FORD_25B = {.FD = false,
|
|
||||||
.ext_ID = false,
|
|
||||||
.DLC = 8,
|
|
||||||
.ID = 0x25B,
|
|
||||||
.data = {0x01, 0xF4, 0x09, 0xF4, 0xE0, 0x00, 0x80, 0x00}};
|
|
||||||
CAN_frame FORD_2EC = {.FD = false,
|
CAN_frame FORD_2EC = {.FD = false,
|
||||||
.ext_ID = false,
|
.ext_ID = false,
|
||||||
.DLC = 8,
|
.DLC = 8,
|
||||||
|
@ -216,6 +221,7 @@ class FordMachEBattery : public CanBattery {
|
||||||
.DLC = 8,
|
.DLC = 8,
|
||||||
.ID = 0x4B0,
|
.ID = 0x4B0,
|
||||||
.data = {0x81, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}};
|
.data = {0x81, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}};
|
||||||
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue