Output logic implemented
This commit is contained in:
@@ -139,10 +139,19 @@ typedef struct {
|
|||||||
char GSM_PWD[50];
|
char GSM_PWD[50];
|
||||||
|
|
||||||
uint64_t serialNumber;
|
uint64_t serialNumber;
|
||||||
|
|
||||||
uint64_t PC_Time;
|
uint64_t PC_Time;
|
||||||
|
|
||||||
|
bool chargeBatteryOutputChecked;
|
||||||
|
bool brushOrShuntOutputChecked;
|
||||||
|
bool brushOrShuntMode; // shunt -> false, brush -> true
|
||||||
|
uint16_t brushUsageSocThreshold;
|
||||||
|
uint16_t shuntChargingContactorDelay;
|
||||||
|
bool coolingOutputChecked;
|
||||||
|
int16_t coolingStartThreshold;
|
||||||
|
int16_t coolingStopThreshold;
|
||||||
|
bool heatingOutputChecked;
|
||||||
|
int16_t heatingStartThreshold;
|
||||||
|
int16_t heatingStopThreshold;
|
||||||
} modConfigGeneralConfigStructTypedef;
|
} modConfigGeneralConfigStructTypedef;
|
||||||
|
|
||||||
modConfigGeneralConfigStructTypedef* modConfigInit(void);
|
modConfigGeneralConfigStructTypedef* modConfigInit(void);
|
||||||
|
|||||||
143
Core/Src/main.c
143
Core/Src/main.c
@@ -272,6 +272,9 @@ uint16_t load_current = 0;
|
|||||||
uint16_t charge_current = 0;
|
uint16_t charge_current = 0;
|
||||||
float float_current = 0;
|
float float_current = 0;
|
||||||
|
|
||||||
|
bool need_shunt_charging_contractor = false;
|
||||||
|
uint64_t shunt_charging_contractor_clock = 0;
|
||||||
|
|
||||||
|
|
||||||
#define __MA_WIN_SIZE (500)
|
#define __MA_WIN_SIZE (500)
|
||||||
#define __MA_ARRAY_QTY 2
|
#define __MA_ARRAY_QTY 2
|
||||||
@@ -977,19 +980,101 @@ void updateLimitsFromMem(){
|
|||||||
maxTemperature_Hyst = generalConfig->allowedTempBattChargingMin;
|
maxTemperature_Hyst = generalConfig->allowedTempBattChargingMin;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Brush_Control() {
|
//void Brush_Control() {
|
||||||
//Output_2_Pin GPIO_PIN_2
|
// //Output_2_Pin GPIO_PIN_2
|
||||||
//Output_2_GPIO_Port GPIOE
|
// //Output_2_GPIO_Port GPIOE
|
||||||
|
//
|
||||||
|
// Brush_Minimum_SoC = generalConfig->minimalPrechargePercentage;
|
||||||
|
// Brush_Default_State = generalConfig->timeoutLCPreCharge;
|
||||||
|
//
|
||||||
|
// if(packState.SoC < Brush_Minimum_SoC) {
|
||||||
|
// HAL_GPIO_WritePin(Output_2_GPIO_Port, Output_2_Pin, !Brush_Default_State);
|
||||||
|
// Brush_Status = 1; //Brush is Up
|
||||||
|
// } else {
|
||||||
|
// HAL_GPIO_WritePin(Output_2_GPIO_Port, Output_2_Pin, Brush_Default_State);
|
||||||
|
// Brush_Status = 0; //Brush is down
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
Brush_Minimum_SoC = generalConfig->minimalPrechargePercentage;
|
void outputControl()
|
||||||
Brush_Default_State = generalConfig->timeoutLCPreCharge;
|
{
|
||||||
|
// 2 output handle
|
||||||
|
if (generalConfig->chargeBatteryOutputChecked)
|
||||||
|
{
|
||||||
|
GPIO_PinState chargeContactorState = HAL_GPIO_ReadPin(GPIOE, GPIO_PIN_0);
|
||||||
|
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_2, chargeContactorState);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_2, GPIO_PIN_RESET);
|
||||||
|
}
|
||||||
|
|
||||||
if(packState.SoC < Brush_Minimum_SoC) {
|
// 3 output handle
|
||||||
HAL_GPIO_WritePin(Output_2_GPIO_Port, Output_2_Pin, !Brush_Default_State);
|
if (!generalConfig->brushOrShuntMode) // brush mode
|
||||||
Brush_Status = 1; //Brush is Up
|
{
|
||||||
} else {
|
if (packState.SoC <= generalConfig->brushUsageSocThreshold)
|
||||||
HAL_GPIO_WritePin(Output_2_GPIO_Port, Output_2_Pin, Brush_Default_State);
|
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_3, generalConfig->brushOrShuntOutputChecked ? GPIO_PIN_RESET : GPIO_PIN_SET);
|
||||||
Brush_Status = 0; //Brush is down
|
else
|
||||||
|
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_3, generalConfig->brushOrShuntOutputChecked ? GPIO_PIN_SET : GPIO_PIN_RESET);
|
||||||
|
|
||||||
|
Brush_Status = HAL_GPIO_ReadPin(GPIOE, GPIO_PIN_3);
|
||||||
|
}
|
||||||
|
else // shunt mode
|
||||||
|
{
|
||||||
|
if (generalConfig->brushOrShuntOutputChecked)
|
||||||
|
{
|
||||||
|
GPIO_PinState loadContactorState = HAL_GPIO_ReadPin(GPIOE, GPIO_PIN_1);
|
||||||
|
if (loadContactorState == GPIO_PIN_SET && !need_shunt_charging_contractor)
|
||||||
|
{
|
||||||
|
need_shunt_charging_contractor = true;
|
||||||
|
shunt_charging_contractor_clock = TIM_Clock;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (loadContactorState == GPIO_PIN_SET && need_shunt_charging_contractor &&
|
||||||
|
(TIM_Clock - shunt_charging_contractor_clock) >= generalConfig->shuntChargingContactorDelay * 1000)
|
||||||
|
{
|
||||||
|
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_3, GPIO_PIN_SET);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (loadContactorState == GPIO_PIN_RESET)
|
||||||
|
{
|
||||||
|
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_3, GPIO_PIN_RESET);
|
||||||
|
need_shunt_charging_contractor = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_3, GPIO_PIN_RESET);
|
||||||
|
need_shunt_charging_contractor = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4 output handle
|
||||||
|
if (generalConfig->coolingOutputChecked)
|
||||||
|
{
|
||||||
|
if (packState.tempBatteryHigh <= generalConfig->coolingStopThreshold)
|
||||||
|
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_4, GPIO_PIN_RESET);
|
||||||
|
|
||||||
|
if (packState.tempBatteryHigh >= generalConfig->coolingStartThreshold)
|
||||||
|
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_4, GPIO_PIN_SET);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_4, GPIO_PIN_RESET);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5 output handle
|
||||||
|
if (generalConfig->heatingOutputChecked)
|
||||||
|
{
|
||||||
|
if (packState.tempBatteryLow >= generalConfig->heatingStopThreshold)
|
||||||
|
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_5, GPIO_PIN_RESET);
|
||||||
|
|
||||||
|
if (packState.tempBatteryLow <= generalConfig->heatingStartThreshold)
|
||||||
|
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_5, GPIO_PIN_SET);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_5, GPIO_PIN_RESET);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2081,29 +2166,31 @@ int main(void)
|
|||||||
charge_switch_state = 0;
|
charge_switch_state = 0;
|
||||||
load_switch_state = 0;
|
load_switch_state = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Brush_Control();
|
//Brush_Control();
|
||||||
|
|
||||||
|
|
||||||
// try to comment out state task !!!
|
// try to comment out state task !!!
|
||||||
// modPowerStateTask();
|
// modPowerStateTask();
|
||||||
|
|
||||||
// try to comment out state task !!!
|
// try to comment out state task !!!
|
||||||
// modOperationalStateTask();
|
// modOperationalStateTask();
|
||||||
|
|
||||||
//modPowerElectronicsCellMonitorsEnableBalanceResistors(0x00);
|
//modPowerElectronicsCellMonitorsEnableBalanceResistors(0x00);
|
||||||
//modPowerElectronicsCellMonitorsEnableBalanceResistors(0x00000f80);
|
//modPowerElectronicsCellMonitorsEnableBalanceResistors(0x00000f80);
|
||||||
|
|
||||||
// balance is disable
|
// balance is disable
|
||||||
if(modPowerElectronicsTask()){
|
if(modPowerElectronicsTask()){
|
||||||
// !!! check how works eeprom save !!! // Handle power electronics task
|
// !!! check how works eeprom save !!! // Handle power electronics task
|
||||||
if (packState.serial_number!=0){
|
if (packState.serial_number!=0){
|
||||||
Battery_Serial = packState.serial_number;
|
Battery_Serial = packState.serial_number;
|
||||||
}
|
|
||||||
modStateOfChargeProcess();
|
|
||||||
}
|
}
|
||||||
// If there is new data handle SoC estimation
|
modStateOfChargeProcess();
|
||||||
// mainWatchDogReset();
|
}
|
||||||
|
// If there is new data handle SoC estimation
|
||||||
|
// mainWatchDogReset();
|
||||||
|
|
||||||
|
outputControl();
|
||||||
|
|
||||||
}
|
}
|
||||||
/* USER CODE END 3 */
|
/* USER CODE END 3 */
|
||||||
|
|||||||
@@ -277,6 +277,18 @@ void modCommandsProcessPacket(unsigned char *data, unsigned int len) {
|
|||||||
modCommandsGeneralConfig->powerDownDelay = libBufferGet_uint32(data,&ind);// 4
|
modCommandsGeneralConfig->powerDownDelay = libBufferGet_uint32(data,&ind);// 4
|
||||||
modCommandsGeneralConfig->humidityICType = libBufferGet_uint8(data,&ind); // 1
|
modCommandsGeneralConfig->humidityICType = libBufferGet_uint8(data,&ind); // 1
|
||||||
|
|
||||||
|
modCommandsGeneralConfig->chargeBatteryOutputChecked = libBufferGet_uint8(data, &ind);
|
||||||
|
modCommandsGeneralConfig->brushOrShuntOutputChecked = libBufferGet_uint8(data, &ind);
|
||||||
|
modCommandsGeneralConfig->brushOrShuntMode = libBufferGet_uint8(data, &ind);
|
||||||
|
modCommandsGeneralConfig->brushUsageSocThreshold = libBufferGet_uint16(data, &ind);
|
||||||
|
modCommandsGeneralConfig->shuntChargingContactorDelay = libBufferGet_uint16(data, &ind);
|
||||||
|
modCommandsGeneralConfig->coolingOutputChecked = libBufferGet_uint8(data, &ind);
|
||||||
|
modCommandsGeneralConfig->coolingStartThreshold = libBufferGet_int16(data, &ind);
|
||||||
|
modCommandsGeneralConfig->coolingStopThreshold = libBufferGet_int16(data, &ind);
|
||||||
|
modCommandsGeneralConfig->heatingOutputChecked = libBufferGet_uint8(data, &ind);
|
||||||
|
modCommandsGeneralConfig->heatingStartThreshold = libBufferGet_int16(data, &ind);
|
||||||
|
modCommandsGeneralConfig->heatingStopThreshold = libBufferGet_int16(data, &ind);
|
||||||
|
|
||||||
// RawSerialPtr = modCommandsGeneralConfig->displayTimeoutBatteryDead;
|
// RawSerialPtr = modCommandsGeneralConfig->displayTimeoutBatteryDead;
|
||||||
// RawSerial = *RawSerialPtr;
|
// RawSerial = *RawSerialPtr;
|
||||||
// RawSerial = RawSerial<<32;
|
// RawSerial = RawSerial<<32;
|
||||||
@@ -410,6 +422,19 @@ void modCommandsProcessPacket(unsigned char *data, unsigned int len) {
|
|||||||
libBufferAppend_uint32( modCommandsSendBuffer,modCommandsToBeSendConfig->powerDownDelay ,&ind); // 4
|
libBufferAppend_uint32( modCommandsSendBuffer,modCommandsToBeSendConfig->powerDownDelay ,&ind); // 4
|
||||||
libBufferAppend_uint8( modCommandsSendBuffer,modCommandsToBeSendConfig->humidityICType ,&ind); // 1
|
libBufferAppend_uint8( modCommandsSendBuffer,modCommandsToBeSendConfig->humidityICType ,&ind); // 1
|
||||||
//libBufferAppend_uint64( modCommandsSendBuffer,modCommandsToBeSendConfig->serialNumber , &ind); // 8
|
//libBufferAppend_uint64( modCommandsSendBuffer,modCommandsToBeSendConfig->serialNumber , &ind); // 8
|
||||||
|
|
||||||
|
libBufferAppend_uint8(modCommandsSendBuffer, modCommandsToBeSendConfig->chargeBatteryOutputChecked, &ind);
|
||||||
|
libBufferAppend_uint8(modCommandsSendBuffer, modCommandsToBeSendConfig->brushOrShuntOutputChecked, &ind);
|
||||||
|
libBufferAppend_uint8(modCommandsSendBuffer, modCommandsToBeSendConfig->brushOrShuntMode, &ind);
|
||||||
|
libBufferAppend_uint16(modCommandsSendBuffer, modCommandsToBeSendConfig->brushUsageSocThreshold, &ind);
|
||||||
|
libBufferAppend_uint16(modCommandsSendBuffer, modCommandsToBeSendConfig->shuntChargingContactorDelay, &ind);
|
||||||
|
libBufferAppend_uint8(modCommandsSendBuffer, modCommandsToBeSendConfig->coolingOutputChecked, &ind);
|
||||||
|
libBufferAppend_int16(modCommandsSendBuffer, modCommandsToBeSendConfig->coolingStartThreshold, &ind);
|
||||||
|
libBufferAppend_int16(modCommandsSendBuffer, modCommandsToBeSendConfig->coolingStopThreshold, &ind);
|
||||||
|
libBufferAppend_uint8(modCommandsSendBuffer, modCommandsToBeSendConfig->heatingOutputChecked, &ind);
|
||||||
|
libBufferAppend_int16(modCommandsSendBuffer, modCommandsToBeSendConfig->heatingStartThreshold, &ind);
|
||||||
|
libBufferAppend_int16(modCommandsSendBuffer, modCommandsToBeSendConfig->heatingStopThreshold, &ind);
|
||||||
|
|
||||||
modCommandsSendPacket(modCommandsSendBuffer, ind);
|
modCommandsSendPacket(modCommandsSendBuffer, ind);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -221,6 +221,18 @@ void modConfigLoadDefaultConfig(modConfigGeneralConfigStructTypedef *configLocat
|
|||||||
|
|
||||||
configLocation->PC_Time=0;
|
configLocation->PC_Time=0;
|
||||||
|
|
||||||
|
configLocation->chargeBatteryOutputChecked = false;
|
||||||
|
configLocation->brushOrShuntOutputChecked = false;
|
||||||
|
configLocation->brushOrShuntMode = false;
|
||||||
|
configLocation->brushUsageSocThreshold = 10;
|
||||||
|
configLocation->shuntChargingContactorDelay = 5;
|
||||||
|
configLocation->coolingOutputChecked = false;
|
||||||
|
configLocation->coolingStartThreshold = 50;
|
||||||
|
configLocation->coolingStopThreshold = 40;
|
||||||
|
configLocation->heatingOutputChecked = false;
|
||||||
|
configLocation->heatingStartThreshold = 0;
|
||||||
|
configLocation->heatingStopThreshold = 20;
|
||||||
|
|
||||||
|
|
||||||
#elif ENNOID_HV
|
#elif ENNOID_HV
|
||||||
configLocation->noOfCellsSeries = 8; // Total number of cells in series in the battery pack
|
configLocation->noOfCellsSeries = 8; // Total number of cells in series in the battery pack
|
||||||
|
|||||||
Reference in New Issue
Block a user