mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-04 02:09:30 +02:00
Add initial Pylon mappings
This commit is contained in:
parent
7bb165cdc1
commit
26f7250f1e
2 changed files with 42 additions and 1 deletions
|
@ -19,7 +19,45 @@ CAN_frame_t PYLON_4290 = {.FIR = {.B = {.DLC = 8,.FF = CAN_frame_ext,}},.MsgID =
|
|||
|
||||
void update_values_can_pylon()
|
||||
{ //This function maps all the values fetched from battery CAN to the correct CAN messages
|
||||
//TODO, add mappings
|
||||
//There are more mappings that could be added, but this should be enough to use as a starting point
|
||||
|
||||
//Charge / Discharge allowed
|
||||
PYLON_4280.data.u8[0] = 0;
|
||||
PYLON_4280.data.u8[1] = 0;
|
||||
PYLON_4280.data.u8[2] = 0;
|
||||
PYLON_4280.data.u8[3] = 0;
|
||||
|
||||
//Voltage (370.0)
|
||||
PYLON_4210.data.u8[0] = (battery_voltage >> 8);
|
||||
PYLON_4210.data.u8[1] = (battery_voltage & 0x00FF);
|
||||
|
||||
//Current (TODO, SIGNED? Or looks like it could be just offset, in that case the below line wont work)
|
||||
PYLON_4210.data.u8[2] = (battery_current >> 8);
|
||||
PYLON_4210.data.u8[3] = (battery_current & 0x00FF);
|
||||
|
||||
//SOC (100.00%)
|
||||
PYLON_4210.data.u8[6] = (SOC*0.01); //Remove decimals
|
||||
|
||||
//StateOfHealth (100.00%)
|
||||
PYLON_4210.data.u8[7] = (StateOfHealth*0.01);
|
||||
|
||||
//Minvoltage (eg 300.0V = 3000 , 16bits long) Charge Cutoff Voltage
|
||||
PYLON_4220.data.u8[0] = (min_volt_pylon_can >> 8);
|
||||
PYLON_4220.data.u8[1] = (min_volt_pylon_can & 0x00FF);
|
||||
|
||||
//Maxvoltage (eg 400.0V = 4000 , 16bits long) Discharge Cutoff Voltage
|
||||
PYLON_4220.data.u8[2] = (max_volt_pylon_can >> 8);
|
||||
PYLON_4220.data.u8[3] = (max_volt_pylon_can & 0x00FF);
|
||||
|
||||
//In case we run into any errors/faults, we can set charge / discharge forbidden
|
||||
if(bms_status == FAULT)
|
||||
{
|
||||
PYLON_4280.data.u8[0] = 0xAA;
|
||||
PYLON_4280.data.u8[1] = 0xAA;
|
||||
PYLON_4280.data.u8[2] = 0xAA;
|
||||
PYLON_4280.data.u8[3] = 0xAA;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void receive_can_pylon(CAN_frame_t rx_frame)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue