Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Elcon interface to YAMCAN #111

Merged
merged 1 commit into from
Feb 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion components/bms_boss/include/CANIO_componentSpecific.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
******************************************************************************/

uint8_t CANIO_tx_getNLG513ControlByte(void);
uint8_t CANIO_tx_getElconControlByte(void);
CAN_prechargeContactorState_E CANIO_tx_getContactorState(void);

/******************************************************************************
Expand All @@ -48,11 +49,15 @@ CAN_prechargeContactorState_E CANIO_tx_getContactorState(void);
#define set_nlg513MaxMainsCurrent(m,b,n,s) set(m,b,n,s, 16.0f)
#define set_nlg513MaxChargeVoltage(m,b,n,s) set(m,b,n,s, BMS_CONFIGURED_PACK_MAX_VOLTAGE)
#define set_nlg513MaxChargeCurrent(m,b,n,s) set(m,b,n,s, BMS.pack_charge_limit)
#define transmit_BMSB_brusaChargeCommand (SYS_SFT_checkChargerTimeout() == false)
#define transmit_BMSB_brusaChargeCommand (SYS_SFT_checkBrusaChargerTimeout() == false)
#define set_taskUsage1kHz(m,b,n,s) set(m,b,n,s, Module_getTotalRuntimePercentage(MODULE_1kHz_TASK));
#define set_taskUsage100Hz(m,b,n,s) set(m,b,n,s, Module_getTotalRuntimePercentage(MODULE_100Hz_TASK));
#define set_taskUsage10Hz(m,b,n,s) set(m,b,n,s, Module_getTotalRuntimePercentage(MODULE_10Hz_TASK));
#define set_taskUsage1Hz(m,b,n,s) set(m,b,n,s, Module_getTotalRuntimePercentage(MODULE_1Hz_TASK));
#define set_taskUsageIdle(m,b,n,s) set(m,b,n,s, Module_getTotalRuntimePercentage(MODULE_IDLE_TASK));
#define set_elconMaxChargeVoltage(m,b,n,s) set(m,b,n,s, BMS_CONFIGURED_PACK_MAX_VOLTAGE)
#define set_elconMaxChargeCurrent(m,b,n,s) set(m,b,n,s, BMS.pack_charge_limit)
#define set_elconControlByte(m,b,n,s) set(m,b,n,s, CANIO_tx_getElconControlByte())
#define transmit_BMSB_elconChargeCommand (SYS_SFT_checkElconChargerTimeout() == false)

#include "TemporaryStubbing.h"
3 changes: 2 additions & 1 deletion components/bms_boss/include/Sys.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ void SYS_SFT_closeShutdown(void);
void SYS_SFT_openContactors(void);
void SYS_SFT_cycleContacts(void);
bool SYS_SFT_checkMCTimeout(void);
bool SYS_SFT_checkChargerTimeout(void);
bool SYS_SFT_checkBrusaChargerTimeout(void);
bool SYS_SFT_checkElconChargerTimeout(void);
void SYS_stopCharging(void);
void SYS_continueCharging(void);
2 changes: 1 addition & 1 deletion components/bms_boss/src/BMS.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ static void BMS100Hz_PRD(void)
{
BMS.pack_current = IO.current / CURRENT_SENSE_V_per_A;

if (BMS.fault || (SYS_SFT_checkMCTimeout() && SYS_SFT_checkChargerTimeout()))
if (BMS.fault || (SYS_SFT_checkMCTimeout() && SYS_SFT_checkElconChargerTimeout() && SYS_SFT_checkBrusaChargerTimeout()))
{
SYS_SFT_openShutdown();
}
Expand Down
11 changes: 11 additions & 0 deletions components/bms_boss/src/CANIO_componentSpecific.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,14 @@ CAN_prechargeContactorState_E CANIO_tx_getContactorState(void)

return ret;
}

uint8_t CANIO_tx_getElconControlByte(void)
{
uint8_t ret = 0x01;
if (SYS.contacts == SYS_CONTACTORS_HVP_CLOSED)
{
ret = 0x00;
}

return ret;
}
7 changes: 6 additions & 1 deletion components/bms_boss/src/Sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ bool SYS_SFT_checkMCTimeout(void)
return (CANRX_validate(VEH, PM100DX_criticalData) != CANRX_MESSAGE_VALID);
}

bool SYS_SFT_checkChargerTimeout(void)
bool SYS_SFT_checkBrusaChargerTimeout(void)
{
return (CANRX_validate(VEH, BRUSA513_criticalData) != CANRX_MESSAGE_VALID);
}
Expand All @@ -152,3 +152,8 @@ void SYS_continueCharging(void)
{
BMS.charging_paused = false;
}

bool SYS_SFT_checkElconChargerTimeout(void)
{
return (CANRX_validate(PRIVBMS, ELCON_criticalData) != CANRX_MESSAGE_VALID);
}
11 changes: 11 additions & 0 deletions network/definition/data/components/bmsb/bmsb-message.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,14 @@ messages:
id: 0x550
sourceBuses: veh
template: rtosTaskInfo

elconChargeCommand:
description: Elcon Charge Command
cycleTimeMs: 1000
sourceBuses: privbms
id: 0x1806E5F4
lengthBytes: 8
signals:
elconMaxChargeVoltage:
elconMaxChargeCurrent:
elconControlByte:
2 changes: 2 additions & 0 deletions network/definition/data/components/bmsb/bmsb-rx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ messages:
sourceBuses: veh
BRUSA513_criticalData:
sourceBuses: veh
ELCON_criticalData:
sourceBuses: privbms
PM100DX_criticalData:
sourceBuses: veh
UDSCLIENT_bmsbUdsRequest:
Expand Down
39 changes: 39 additions & 0 deletions network/definition/data/components/bmsb/bmsb-signals.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,42 @@ signals:
packContactorState:
description: Pack Contactor Status
discreteValues: prechargeContactorState

udsPayload:
unit: ''
description: UDS payload data
nativeRepresentation:
bitWidth: 64
resolution: 1
range:
min: 0
max: 18446744073709551615

elconControlByte:
description: Elcon Control Byte
nativeRepresentation:
bitWidth: 8

elconMaxChargeVoltage:
unit: 'V'
description: Elcon Max Battery Voltage During Charging
nativeRepresentation:
endianness: 0
bitWidth: 16
resolution: 0.1
range:
min: 0
max: 450
continuous: true

elconMaxChargeCurrent:
unit: 'A'
description: Elcon Max Battery Voltage During Charging
nativeRepresentation:
endianness: 0
bitWidth: 16
resolution: 0.1
range:
min: 0
max: 25
continuous: true
10 changes: 10 additions & 0 deletions network/definition/data/components/elcon/elcon-message.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
messages:
criticalData:
description: Elcon Critical Data
cycleTimeMs: 1000
id: 0x18FF50E5
lengthBytes: 8
signals:
busVoltage:
busCurrent:
busStatusFlags:
3 changes: 3 additions & 0 deletions network/definition/data/components/elcon/elcon-rx.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
messages:
BMSB_elconChargeCommand:
signals:
32 changes: 32 additions & 0 deletions network/definition/data/components/elcon/elcon-signals.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
signals:
busVoltage:
unit: 'V'
description: Charger DC Bus Voltage
nativeRepresentation:
endianness: 0
bitWidth: 16
resolution: 0.1
range:
min: 0
max: 1000
continuous: true
busCurrent:
unit: 'A'
description: Charger DC BUS Current
nativeRepresentation:
endianness: 0
bitWidth: 16
resolution: 0.1
range:
min: 0
max: 150
continuous: true
busStatusFlags:
description: Charger Bus Status Flags
nativeRepresentation:
endianness: 0
bitWidth: 8
range:
min: 0
max: 256
continuous: true
3 changes: 3 additions & 0 deletions network/definition/data/components/elcon/elcon.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
description: "Elcon HK-J charger"
onBuses:
- "privbms"