控制方面大体框架完成

This commit is contained in:
起床就犯困 2024-12-11 17:51:48 +08:00
parent 0a1ae49530
commit 26c786e3f6
21 changed files with 1655 additions and 1451 deletions

View File

@ -8,7 +8,7 @@
void start(void)
{
Init();
task_Init();
TimeSliceOffset_Start();
}

View File

@ -8,6 +8,9 @@
void setChargControlFlag(BOOL state);
void bl_chargControl(void);
void endChargWork(void);
void stopChargWork(void);
void startChargWork(void);
extern void chargControl(void);

View File

@ -79,6 +79,10 @@ void setBatteryState(BOOL state);
float getDutyRatio(void);
void setDutyRatio(float DutyRatio);
void setDutyRatioToZero(void);
uint8_t getMosTemperState(void);
void setMosTemperState(uint8_t state);
BOOL getCheckImpedanceState(void);
void setCheckImpedanceState(void);
float getBatteryVoltage(void);
void setBatteryVoltage(void);

View File

@ -9,7 +9,7 @@ void task_Init(void);
void beginStartControlTask(void);
void beginSoftStartTask(void);

View File

@ -30,4 +30,8 @@ void Init(void)
Init_GW485_uart();
start_gw485Rx_It();
start_bat485Rx_It();
POW_FF_PCON_Open();
POW_OUT_PCON_Open();
}

View File

@ -3,7 +3,7 @@
#include "parameter.h"
#include "capture.h"
#include "checkTime.h"
#include "FM_GPIO.h"
void checkAbnormal(void)
@ -18,7 +18,16 @@ void checkAbnormal(void)
setOutputVoltage();
setSolarInCircuitVoltage();
/* 判断异常状态 */
/* 判断 */
/* 是否打开充电理想二极管 */
if (get_CHG_CURR() > 2.0f) {
FFMOS_CON_Open();
}
else if (get_CHG_CURR() < 1.0f) {
FFMOS_CON_Close();
}
// checkAbnormalTime = getCheckTime();

View File

@ -6,7 +6,6 @@
#include "task.h"
static void stopChargWork(void);
static BOOL stopChargConditions(void);
static BOOL floatChargConditions(void);
static BOOL mpptChargConditions(void);
@ -37,18 +36,17 @@ void mppt_constantVoltage(float InVoltage)
{
static float kp = 0.005;
static float ki = 0.00001;
static float solarInCircuitVoltage;
// static float solarInCircuitVoltage;
static float error;
static float stepPwm;
solarInCircuitVoltage = getSolarInCircuitVoltage();
error = solarInCircuitVoltage - InVoltage;
// float error = InVoltage - g_otherParameter.Solar_In_Circuit_Voltage;
stepPwm = kp * error + ki * solarInCircuitVoltage;
// solarInCircuitVoltage = getSolarInCircuitVoltage();
// error = InVoltage - getSolarInCircuitVoltage();
error = getSolarInCircuitVoltage() - InVoltage;
stepPwm = kp * error + ki * getSolarInCircuitVoltage();
setDutyRatio((getDutyRatio() + stepPwm));
set_pwmDutyRatio(getDutyRatio());
}
/**
@ -70,7 +68,6 @@ void mppt_constantVoltageNoBatteryO(float OutVoltage)
stepPwm = kp * error + ki * outVolt;
setDutyRatio((getDutyRatio() + stepPwm));
set_pwmDutyRatio(getDutyRatio());
}
/**
@ -113,7 +110,6 @@ void mppt_constantVoltageO(float OutVoltage)
// lastVolt = outVolt;
// lastStepPwm = StepPwm;
lastDutyRatio = getDutyRatio();
set_pwmDutyRatio(getDutyRatio());
}
/**
@ -397,7 +393,21 @@ void mppt_readJust(void)
}
/**
* @brief
* @brief
* @param
* @retval
*
*/
void endChargWork(void)
{
EN_PWMOUT_Diseable();
pwm_Stop();
setMPPT_Mode(noWork);
beginStartControlTask();
}
/**
* @brief
* @param
* @retval
*
@ -407,9 +417,23 @@ void stopChargWork(void)
EN_PWMOUT_Diseable();
pwm_Stop();
setMPPT_Mode(noWork);
beginStartControlTask();
}
/**
* @brief
* @param
* @retval
*
*/
void startChargWork(void)
{
beginSoftStartTask();
}
/**
* @brief
* @param
@ -470,7 +494,7 @@ BOOL mpptChargConditions(void)
BOOL constantVChargConditions(void)
{
if ((g_cfgParameter.constantVoltageChargeV < getBatteryVoltage())
&& ((g_cfgParameter.floatI + 0.1) <= getChargBatteryCurrent())) {
&& ((g_cfgParameter.floatI + 0.1f) <= getChargBatteryCurrent())) {
return TRUE;
}
@ -486,7 +510,7 @@ BOOL constantVChargConditions(void)
void chargControlMode(void)
{
if (stopChargConditions()) {
stopChargWork();
endChargWork();
}
if (floatChargConditions()) {
@ -510,7 +534,11 @@ void chargControlMode(void)
*/
void judgeYNBattery(void)
{
if (getBatteryVoltage() > 16 || getBatteryVoltage() < 10) {
// if (getBatteryVoltage() > 16 || getBatteryVoltage() < 10) {
// setBatteryState(FALSE);
// return;
// }
if (getOutputVoltage() > 16 || getOutputVoltage() < 10) {
setBatteryState(FALSE);
return;
}
@ -572,6 +600,7 @@ void BatteryChargControl(void)
case MPPT:
mpptCharge();
// mppt_constantVoltage(17.0f);
break;
case constantVoltage:

View File

@ -78,19 +78,19 @@ static void read_backups_config_info(config_info *output_config_info)
*/
static void readFlashContent(config_info *config_info)
{
read_config_info(config_info);
// read_config_info(config_info);
/* 配置文件正确就返回 */
if (config_info->crc == configCheckFunc((uint8_t *)config_info, CONFIG_INFO_SIZE - 2)) {
return;
}
// /* 配置文件正确就返回 */
// if (config_info->crc == configCheckFunc((uint8_t *)config_info, CONFIG_INFO_SIZE - 2)) {
// return;
// }
/* 更深处的配置文件正确就返回 */
read_backups_config_info(config_info);
if (config_info->crc == configCheckFunc((uint8_t *)config_info, CONFIG_INFO_SIZE - 2)) {
save_config_info(config_info);
return;
}
// /* 更深处的配置文件正确就返回 */
// read_backups_config_info(config_info);
// if (config_info->crc == configCheckFunc((uint8_t *)config_info, CONFIG_INFO_SIZE - 2)) {
// save_config_info(config_info);
// return;
// }
/* 配置文件错误使用默认配置 */
config_info->address[0] = 0x11;

View File

@ -3,14 +3,15 @@
#include "FM_TIM.h"
#include "FM_GPIO.h"
#include "capture.h"
#include "chargControlEnum.h"
config_parameter g_cfgParameter = {0};
static otherParameter g_otherParameter = {0};
static BOOL batteryState = FALSE; /* 有无电池(估计) */
static float dutyRatio; /* 占空比 */
static uint8_t mosTemperState = mosTemperStop; /* mos管温度状态 */
static BOOL checkImpedanceState = FALSE; /* 启动后是否进行了回路阻抗检测 */
/**
* @brief
@ -78,6 +79,50 @@ void setDutyRatioToZero(void)
set_pwmDutyRatio(dutyRatio);
}
/**
* @brief mos管温度状态
* @param
* @retval mosTemperState mos管温度状态
*/
uint8_t getMosTemperState(void)
{
return mosTemperState;
}
/**
* @brief mos管温度状态
* @param state mos管状态
* @retval
*/
void setMosTemperState(uint8_t state)
{
if (state == mosTemperStart || state == mosTemperEnd || state == mosTemperStop) {
mosTemperState = state;
}
}
/**
* @brief
* @param
* @retval checkImpedanceState FALSE
* TRUE
*/
BOOL getCheckImpedanceState(void)
{
return checkImpedanceState;
}
/**
* @brief
* @param
* @retval
*
*/
void setCheckImpedanceState(void)
{
checkImpedanceState = TRUE;
}
/**
* @brief
* @param
@ -176,7 +221,7 @@ float getInputVoltage(void)
*/
void setInputVoltage(void)
{
g_otherParameter.Discharg_Current = get_PV_VOLT_IN1();
g_otherParameter.Input_Voltage = get_PV_VOLT_IN1();
}
/**

View File

@ -15,7 +15,7 @@ static void Task_Runled(void);
/* 喂狗 */
#define wdi_reloadVal 1000 /* 任务执行间隔 */
#define wdi_offset 100 /* 任务执行偏移量 */
#define wdi_offset 0 /* 任务执行偏移量 */
static STR_TimeSliceOffset m_wdi;
static void Task_wdi(void);
@ -38,7 +38,7 @@ static STR_TimeSliceOffset m_softStart;
static void Task_softStart(void);
/* 回路阻抗检测 */
#define impedanceCalculation_reloadVal 100 /* 任务执行间隔 */
#define impedanceCalculation_reloadVal 20 /* 任务执行间隔 */
#define impedanceCalculation_offset 0 /* 任务执行偏移量 */
static STR_TimeSliceOffset m_impedanceCalculation;
static void Task_impedanceCalculation(void);
@ -56,7 +56,8 @@ void task_Init(void)
{
TimeSliceOffset_Register(&m_runled, Task_Runled, runled_reloadVal, runled_offset);
TimeSliceOffset_Register(&m_wdi, Task_wdi, wdi_reloadVal, wdi_offset);
beginStartControlTask();
TimeSliceOffset_Register(&m_refreshJudgeData, Task_refreshJudgeData, refreshJudgeData_reloadVal, refreshJudgeData_offset);
}
/**
@ -77,6 +78,18 @@ void Task_Runled(void)
*/
void Task_wdi(void)
{
feedDog();
debug_printf("chargCurrent:%f \n", getChargCurrent());
debug_printf("outputVoltage:%f \n", getOutputVoltage());
debug_printf("dischargCurrent:%f \n", getDischargCurrent());
debug_printf("solarInCircuitVoltage:%f \n", getSolarInCircuitVoltage());
debug_printf("HighSideMosTemperature:%f \n", getHighSideMosTemperature());
debug_printf("InputVoltage:%f \n", getInputVoltage());
debug_printf("DischargMosState:%d \n", getDischargMosState());
debug_printf("MPPT_Mode:%d \n", getMPPT_Mode());
debug_printf("DutyRatio:%f \n", getDutyRatio());
/* 每天复位一次复位前将电量信息写入flash中 */
static uint32_t temp = 60 * 60 * 24;
if (!(--temp)) {
@ -89,7 +102,6 @@ void Task_wdi(void)
NVIC_SystemReset();
}
feedDog();
}
/**
@ -110,9 +122,34 @@ void Task_refreshJudgeData(void)
setBatteryState(TRUE);
}
/* 温度检测 */
if (1) {
/* 有电池,太阳能输出功率大,同时回路阻抗未测试或需要重新测试 */
if ((getCheckImpedanceState() == FALSE || g_cfgParameter.loopImpedance == 0.0f)
&& (getBatteryState() == TRUE) && (getChargCurrent() > 3.0f)
&& (getOutputVoltage() > 9) && (getSolarInCircuitVoltage() > 14)) {
TimeSliceOffset_Register(&m_impedanceCalculation, Task_impedanceCalculation
, impedanceCalculation_reloadVal, impedanceCalculation_reloadVal);
}
/* 温度检测 */
if ((getMosTemperState() != mosTemperStart)
&& (getHighSideMosTemperature() < g_cfgParameter.HighSideMosTemperature_start)) {
/* 状态处于停止运行则打开充电开关 */
if (getMosTemperState() == mosTemperStop) {
}
setMosTemperState(mosTemperStart);
}
else if ((getMosTemperState() == mosTemperStart)
&& getHighSideMosTemperature() > g_cfgParameter.HighSideMosTemperature_end) {
setMosTemperState(mosTemperEnd);
}
else if ((getMosTemperState() == mosTemperEnd)
&& getHighSideMosTemperature() > g_cfgParameter.HighSideMosTemperature_stop) {
setMosTemperState(mosTemperStop);
/* 停止充电 */
EN_PWMOUT_Diseable();
pwm_Stop();
setMPPT_Mode(noWork);
}
@ -154,7 +191,7 @@ void Task_startControl(void)
*/
void beginStartControlTask(void)
{
TimeSliceOffset_Register(&m_wdi, Task_startControl, startControl_reloadVal, startControl_offset);
TimeSliceOffset_Register(&m_startControl, Task_startControl, startControl_reloadVal, startControl_offset);
}
/**
@ -170,7 +207,8 @@ void Task_softStart(void)
num++;
if (num < 5) {
set_pwmPulse(100);
set_pwmDutyRatio(0.1f);
EN_PWMOUT_Eable();
}
else if (num > 70 || dutyRatio > 0.75f) {
@ -179,7 +217,7 @@ void Task_softStart(void)
dutyRatio = 0;
num = 0;
setDutyRatio(0.75);
setDutyRatio(0.75f);
set_pwmDutyRatio(getDutyRatio());
if (getBatteryState() == TRUE) {
@ -195,6 +233,15 @@ void Task_softStart(void)
set_pwmDutyRatio(getDutyRatio());
}
}
/**
* @brief
* @param
* @retval
*/
void beginSoftStartTask(void)
{
TimeSliceOffset_Register(&m_softStart, Task_softStart, softStart_reloadVal, softStart_offset);
}
/**
* @brief
@ -239,6 +286,7 @@ void Task_impedanceCalculation(void)
if (tempLoopImpedance < 1.0f && tempLoopImpedance > 0.05f) {
g_cfgParameter.loopImpedance = tempLoopImpedance;
saveLoopImpedance(&g_cfgParameter.loopImpedance);
setCheckImpedanceState();
}
num = 0;

View File

@ -15,11 +15,11 @@ void test(void)
while (1) {
HAL_Delay(1000);
debug_printf("time:%f\r\n", checkAbnormalTime);
debug_printf("chargCurrent:%f\r\n", getChargCurrent());
debug_printf("outputVoltage:%f\r\n", getOutputVoltage());
debug_printf("dischargCurrent:%f\r\n", getDischargCurrent());
debug_printf("solarInCircuitVoltage:%f\r\n", getSolarInCircuitVoltage());
// debug_printf("time:%f\r\n", checkAbnormalTime);
// debug_printf("chargCurrent:%f\r\n", getChargCurrent());
// debug_printf("outputVoltage:%f\r\n", getOutputVoltage());
// debug_printf("dischargCurrent:%f\r\n", getDischargCurrent());
// debug_printf("solarInCircuitVoltage:%f\r\n", getSolarInCircuitVoltage());
}
}

View File

@ -7,7 +7,7 @@
void tim_Init(void);
void pwm_Stop(void);
void set_pwmDutyRatio(float DutyRatio);
void set_pwmPulse(uint32_t Pulse);
// void set_pwmPulse(uint32_t Pulse);
extern void chargControl(void);
extern void checkAbnormal(void);

View File

@ -16,10 +16,10 @@ typedef struct _adcCapture
}adcCapture;
#pragma pack(pop)
extern adcCapture WORK_VOLT_capture;
extern adcCapture DSG_CURR_capture;
extern adcCapture PV_VOLT_IN_capture;
extern adcCapture CHG_CURR_capture;
// extern adcCapture WORK_VOLT_capture;
// extern adcCapture DSG_CURR_capture;
// extern adcCapture PV_VOLT_IN_capture;
// extern adcCapture CHG_CURR_capture;
void ADC_Capture_Init(void);
void proportionalInt(int mode);

View File

@ -150,7 +150,8 @@ BOOL readOnlyPowerOutputState(void)
*/
BOOL readOutputState(void)
{
if (1) {
if (HAL_GPIO_ReadPin(POW_OUT_CON_GPIO_Port, POW_OUT_CON_Pin)
&& HAL_GPIO_ReadPin(DSG_PROT_GPIO_Port, DSG_PROT_Pin)) {
return TRUE;
}

View File

@ -16,7 +16,8 @@ void tim_Init(void)
HD_PWM_Init();
/* 得到pwm的分辨率 */
PWM_RESOLUTION = HAL_RCC_GetHCLKFreq() / 100000;
HAL_TIM_Base_Start(&htim3);
// HAL_TIM_Base_Start(&htim3);
HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_4);
HD_controlTim_Init();
HAL_TIM_Base_Start_IT(&htim7);
@ -28,17 +29,6 @@ void tim_Init(void)
HAL_TIM_Base_Start_IT(&htim15);
}
/**
* @brief PWM信号输出
*/
void pwm_Stop(void)
{
// 设置PWM脉冲宽度为0 effectively停止PWM信号输出
set_pwmPulse(0);
HAL_TIM_Base_Stop(&htim3);
}
/**
* @brief
* @param Pulse
@ -52,6 +42,17 @@ void set_pwmPulse(uint32_t Pulse)
__HAL_TIM_SetCompare(&htim3, TIM_CHANNEL_4, Pulse);
}
/**
* @brief PWM信号输出
*/
void pwm_Stop(void)
{
// 设置PWM脉冲宽度为0 effectively停止PWM信号输出
set_pwmPulse(0);
// HAL_TIM_Base_Stop(&htim3);
}
/**
* @brief
* @param DutyRatio

View File

@ -95,8 +95,8 @@ const uint16_t mosTemperADC[mosTemperADCLen] = {
enum {
WORK_VOLT_NUM = 0,
DSG_CURR_NUM = 1,
PV_VOLT_IN_NUM = 2,
CHG_CURR_NUM = 3,
CHG_CURR_NUM = 2,
PV_VOLT_IN_NUM = 3,
};
int16_t adcBuff[4];
/* 指向adcCapture中的inData16数组中的第一位也是最后一位 */
@ -125,13 +125,20 @@ const float32_t Proportion = 3.0 / 4095.0;
// 0.01861755922
// };
/* matlab生成的3阶滤波器系数 */
// /* matlab生成的3阶滤波器系数 */
// const int firLen = 4;
// const float32_t firLP[4] = {
// 0.178709805, 0.3671073616, 0.3671073616, 0.178709805
// };
/* matlab生成的3阶滤波器系数,乘比例使和接近为1 */
const int firLen = 4;
const float firLP[4] = {
0.178709805, 0.3671073616, 0.3671073616, 0.178709805
const float32_t firLP[4] = {
0.163708486, 0.336291513, 0.336291513, 0.163708486
};
void captureFirInit(void);
// void captureFirInit(void);
/**
* @brief adc
@ -149,8 +156,8 @@ void ADC_Capture_Init(void)
HAL_ADCEx_Calibration_Start(&hadc1, ADC_SINGLE_ENDED);
HAL_ADCEx_Calibration_Start(&hadc2, ADC_SINGLE_ENDED);
/* 初始化滤波器 */
captureFirInit();
// /* 初始化滤波器 */
// captureFirInit();
HAL_TIM_Base_Start(&htim6);
HAL_ADC_Start_DMA(&hadc1, (uint32_t *)adcBuff, 4);
@ -201,6 +208,17 @@ void proportionalInt(int mode)
/* 系统电源电压比例 */
P_PV_VOLT_IN1 = ((47 + 4.7) / 4.7) * Proportion;
}
/* 光伏充电输出电流比例,放大倍数*电阻 */
P_CHG_CURR = (1.0 / (50 * (1 / (1 / 0.01 + 1 / 0.002)))) * Proportion;
/* 充电控制盒输出电压比例,分压系数 */
P_PV_VOLT_OUT = ((47.0 + 10.0) / 10.0) * Proportion;
/* 放电电流采集电流倍数 */
P_DSG_CURR = (1.0 / (50 * (1 / (1 / 0.002 * 2)))) * Proportion;
/* 光伏板输出电压比例 */
P_PV1_VOLT_IN = ((47.0 + 4.7) / 4.7) * Proportion;
/* 系统电源电压比例 */
P_PV_VOLT_IN1 = ((47 + 4.7) / 4.7) * Proportion;
}
#define N 4
@ -416,7 +434,7 @@ void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hdma)
CHG_CURR_capture.totalInData += CHG_CURR_capture.inData16[pointer];
pointer++;
if (pointer >= indata16_size) {
if (pointer >= 10) {
pointer = 0;
}
@ -432,20 +450,20 @@ void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hdma)
}
}
static arm_fir_instance_f32 armFirInstanceF32;
static float32_t *inputF32, *outputF32;
static uint32_t blockSize = 1;
static float32_t firStateF32[4]; /* 状态缓存 */
static float32_t outputf;
void captureFirInit(void)
{
/* 初始化结构体 */
arm_fir_init_f32(&armFirInstanceF32,
firLen,
(float_t *)&firLP[0],
&firStateF32[0],
blockSize);
}
// static arm_fir_instance_f32 armFirInstanceF32;
// static float32_t *inputF32, *outputF32;
// static uint32_t blockSize = 4;
// static float32_t firStateF32[4]; /* 状态缓存 */
// static float32_t outputf;
// void captureFirInit(void)
// {
// /* 初始化结构体 */
// arm_fir_init_f32(&armFirInstanceF32,
// firLen,
// (float_t *)&firLP[0],
// &firStateF32[0],
// blockSize);
// }
/**
@ -455,28 +473,62 @@ void captureFirInit(void)
*/
void adcCaptureFir(void)
{
/* 初始化输入输出缓存指针 */
inputF32 = &WORK_VOLT_capture.IODataF[0];
outputF32 = &outputf;
arm_fir_f32(&armFirInstanceF32, inputF32, outputF32, blockSize);
// static arm_fir_instance_f32 armFirInstanceF32;
// static volatile float32_t *inputF32;
// static volatile float32_t *outputF32;
// static uint32_t blockSize = 4;
// static float32_t firStateF32[4]; /* 状态缓存 */
// static volatile float32_t outputf;
// /* 初始化结构体 */
// arm_fir_init_f32(&armFirInstanceF32,
// firLen,
// &firLP[0],
// &firStateF32[0],
// blockSize);
// /* 初始化输入输出缓存指针 */
// inputF32 = &WORK_VOLT_capture.IODataF[0];
// outputF32 = &outputf;
// // arm_fir_f32(&armFirInstanceF32, inputF32, outputF32, blockSize);
// arm_fir_f32(&armFirInstanceF32, (const float32_t *)inputF32, (float32_t *)outputF32, 1);
// WORK_VOLT_capture.outData = (int16_t)outputf;
// /* 初始化输入输出缓存指针 */
// inputF32 = &DSG_CURR_capture.IODataF[0];
// outputF32 = &outputf;
// // arm_fir_f32(&armFirInstanceF32, inputF32, outputF32, blockSize);
// arm_fir_f32(&armFirInstanceF32, (const float32_t *)inputF32, (float32_t *)outputF32, 1);
// DSG_CURR_capture.outData = (int16_t)outputf;
// /* 初始化输入输出缓存指针 */
// inputF32 = &PV_VOLT_IN_capture.IODataF[0];
// outputF32 = &outputf;
// // arm_fir_f32(&armFirInstanceF32, inputF32, outputF32, blockSize);
// arm_fir_f32(&armFirInstanceF32, (const float32_t *)inputF32, (float32_t *)outputF32, 1);
// PV_VOLT_IN_capture.outData = (int16_t)outputf;
// /* 初始化输入输出缓存指针 */
// inputF32 = &CHG_CURR_capture.IODataF[0];
// outputF32 = &outputf;
// // arm_fir_f32(&armFirInstanceF32, inputF32, outputF32, blockSize);
// arm_fir_f32(&armFirInstanceF32, (const float32_t *)inputF32, (float32_t *)outputF32, 1);
// CHG_CURR_capture.outData = (int16_t)outputf;
// WORK_VOLT_capture.outData = 1;
// DSG_CURR_capture.outData = 1;
// PV_VOLT_IN_capture.outData = 1;
// CHG_CURR_capture.outData = 1;
static float32_t outputf;
arm_dot_prod_f32(WORK_VOLT_capture.IODataF, firLP, firLen, &outputf);
WORK_VOLT_capture.outData = (int16_t)outputf;
/* 初始化输入输出缓存指针 */
inputF32 = &DSG_CURR_capture.IODataF[0];
outputF32 = &outputf;
arm_fir_f32(&armFirInstanceF32, inputF32, outputF32, blockSize);
arm_dot_prod_f32(DSG_CURR_capture.IODataF, firLP, firLen, &outputf);
DSG_CURR_capture.outData = (int16_t)outputf;
/* 初始化输入输出缓存指针 */
inputF32 = &PV_VOLT_IN_capture.IODataF[0];
outputF32 = &outputf;
arm_fir_f32(&armFirInstanceF32, inputF32, outputF32, blockSize);
arm_dot_prod_f32(PV_VOLT_IN_capture.IODataF, firLP, firLen, &outputf);
PV_VOLT_IN_capture.outData = (int16_t)outputf;
/* 初始化输入输出缓存指针 */
inputF32 = &CHG_CURR_capture.IODataF[0];
outputF32 = &outputf;
arm_fir_f32(&armFirInstanceF32, inputF32, outputF32, blockSize);
arm_dot_prod_f32(CHG_CURR_capture.IODataF, firLP, firLen, &outputf);
CHG_CURR_capture.outData = (int16_t)outputf;
}

View File

@ -27,7 +27,8 @@
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "test.h"
// #include "test.h"
#include "start.h"
@ -93,22 +94,22 @@ int main(void)
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_DMA_Init();
MX_ADC1_Init();
MX_ADC2_Init();
MX_SPI1_Init();
MX_TIM3_Init();
MX_TIM6_Init();
MX_UART4_Init();
MX_USART2_UART_Init();
MX_USART3_UART_Init();
MX_TIM7_Init();
MX_TIM16_Init();
MX_TIM15_Init();
// MX_GPIO_Init();
// MX_DMA_Init();
// MX_ADC1_Init();
// MX_ADC2_Init();
// MX_SPI1_Init();
// MX_TIM3_Init();
// MX_TIM6_Init();
// MX_UART4_Init();
// MX_USART2_UART_Init();
// MX_USART3_UART_Init();
// MX_TIM7_Init();
// MX_TIM16_Init();
// MX_TIM15_Init();
/* USER CODE BEGIN 2 */
test();
start();

View File

@ -90,7 +90,7 @@ void MX_TIM6_Init(void)
htim6.Instance = TIM6;
htim6.Init.Prescaler = 71;
htim6.Init.CounterMode = TIM_COUNTERMODE_UP;
htim6.Init.Period = 29;
htim6.Init.Period = 9;
htim6.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
if (HAL_TIM_Base_Init(&htim6) != HAL_OK)
{
@ -123,7 +123,7 @@ void MX_TIM7_Init(void)
htim7.Instance = TIM7;
htim7.Init.Prescaler = 71;
htim7.Init.CounterMode = TIM_COUNTERMODE_UP;
htim7.Init.Period = 999;
htim7.Init.Period = 99;
htim7.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
if (HAL_TIM_Base_Init(&htim7) != HAL_OK)
{
@ -155,9 +155,9 @@ void MX_TIM15_Init(void)
/* USER CODE END TIM15_Init 1 */
htim15.Instance = TIM15;
htim15.Init.Prescaler = 10;
htim15.Init.Prescaler = 1;
htim15.Init.CounterMode = TIM_COUNTERMODE_UP;
htim15.Init.Period = 7199;
htim15.Init.Period = 35999;
htim15.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim15.Init.RepetitionCounter = 0;
htim15.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;

View File

@ -103,11 +103,11 @@
</option>
<option>
<name>OGUseCmsis</name>
<state>0</state>
<state>1</state>
</option>
<option>
<name>OGUseCmsisDspLib</name>
<state>0</state>
<state>1</state>
</option>
<option>
<name>GRuntimeLibThreads</name>
@ -1096,12 +1096,12 @@
<settings>
<name>BUILDACTION</name>
<archiveVersion>2</archiveVersion>
<data />
<data></data>
</settings>
<settings>
<name>Coder</name>
<archiveVersion>0</archiveVersion>
<data />
<data></data>
</settings>
</configuration>
<group>
@ -1197,36 +1197,36 @@
<name>User</name>
<group>
<name>Core</name>
<file>
<name>$PROJ_DIR$\..\Core\Src\main.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\Core\Src\gpio.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\Core\Src\adc.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\Core\Src\dma.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\Core\Src\gpio.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\Core\Src\main.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\Core\Src\spi.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\Core\Src\stm32g4xx_hal_msp.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\Core\Src\stm32g4xx_hal_timebase_tim.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\Core\Src\stm32g4xx_it.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\Core\Src\tim.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\Core\Src\usart.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\Core\Src\stm32g4xx_it.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\Core\Src\stm32g4xx_hal_msp.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\Core\Src\stm32g4xx_hal_timebase_tim.c</name>
</file>
</group>
</group>
</group>
@ -1241,7 +1241,10 @@
<group>
<name>STM32G4xx_HAL_Driver</name>
<file>
<name>$PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal.c</name>
<name>$PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_tim.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_tim_ex.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_adc.c</name>
@ -1250,16 +1253,16 @@
<name>$PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_adc_ex.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_cortex.c</name>
<name>$PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_ll_adc.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dma.c</name>
<name>$PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dma_ex.c</name>
<name>$PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_rcc.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_exti.c</name>
<name>$PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_rcc_ex.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash.c</name>
@ -1273,6 +1276,15 @@
<file>
<name>$PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_gpio.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_exti.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dma.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dma_ex.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_pwr.c</name>
</file>
@ -1280,10 +1292,7 @@
<name>$PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_pwr_ex.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_rcc.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_rcc_ex.c</name>
<name>$PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_cortex.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_spi.c</name>
@ -1291,33 +1300,12 @@
<file>
<name>$PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_spi_ex.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_tim.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_tim_ex.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_uart.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_uart_ex.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_ll_adc.c</name>
</file>
</group>
</group>
<group>
<name>Middlewares</name>
<group>
<name>Library</name>
<group>
<name>DSP Library/DSP Library</name>
<file>
<name>$PROJ_DIR$\..\Middlewares\ST\ARM\DSP\Lib\iar_cortexM4lf_math.a</name>
</file>
</group>
</group>
</group>
<group>
@ -1329,4 +1317,17 @@
<name>$PROJ_DIR$\..\tools\TimeSliceOffset\timeSliceOffset.c</name>
</file>
</group>
<group>
<name>Middlewares</name>
<group>
<name>Library</name>
<group>
<name>DSP Library/DSP Library</name>
<file>
<name>$PROJ_DIR$/../Middlewares/ST/ARM/DSP/Lib/iar_cortexM4lf_math.a</name>
</file>
</group>
</group>
</group>
</project>

View File

@ -304,7 +304,7 @@ ProjectManager.ToolChainLocation=
ProjectManager.UAScriptAfterPath=
ProjectManager.UAScriptBeforePath=
ProjectManager.UnderRoot=false
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_ADC1_Init-ADC1-false-HAL-true,5-MX_ADC2_Init-ADC2-false-HAL-true,6-MX_SPI1_Init-SPI1-false-HAL-true,7-MX_TIM3_Init-TIM3-false-HAL-true,8-MX_TIM6_Init-TIM6-false-HAL-true,9-MX_UART4_Init-UART4-false-HAL-true,10-MX_USART2_UART_Init-USART2-false-HAL-true,11-MX_USART3_UART_Init-USART3-false-HAL-true,12-MX_TIM7_Init-TIM7-false-HAL-true,13-MX_TIM16_Init-TIM16-false-HAL-true,14-MX_TIM17_Init-TIM17-false-HAL-true,15-MX_TIM15_Init-TIM15-false-HAL-true
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_ADC1_Init-ADC1-false-HAL-true,5-MX_ADC2_Init-ADC2-false-HAL-true,6-MX_SPI1_Init-SPI1-false-HAL-true,7-MX_TIM3_Init-TIM3-false-HAL-true,8-MX_TIM6_Init-TIM6-false-HAL-true,9-MX_UART4_Init-UART4-false-HAL-true,10-MX_USART2_UART_Init-USART2-false-HAL-true,11-MX_USART3_UART_Init-USART3-false-HAL-true,12-MX_TIM7_Init-TIM7-false-HAL-true,13-MX_TIM16_Init-TIM16-false-HAL-true,14-MX_TIM15_Init-TIM15-false-HAL-true
RCC.ADC12Freq_Value=72000000
RCC.AHBFreq_Value=72000000
RCC.APB1Freq_Value=72000000
@ -369,8 +369,8 @@ STMicroelectronics.X-CUBE-ALGOBUILD.1.4.0.IPParameters=LibraryCcDSPOoLibraryJjDS
STMicroelectronics.X-CUBE-ALGOBUILD.1.4.0.LibraryCcDSPOoLibraryJjDSPOoLibrary=true
STMicroelectronics.X-CUBE-ALGOBUILD.1.4.0_SwParameter=LibraryCcDSPOoLibraryJjDSPOoLibrary\:true;
TIM15.IPParameters=PeriodNoDither,Prescaler
TIM15.PeriodNoDither=7199
TIM15.Prescaler=10
TIM15.PeriodNoDither=35999
TIM15.Prescaler=1
TIM16.IPParameters=Prescaler,PeriodNoDither
TIM16.PeriodNoDither=999
TIM16.Prescaler=71
@ -378,11 +378,11 @@ TIM3.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4
TIM3.IPParameters=PeriodNoDither,Channel-PWM Generation4 CH4
TIM3.PeriodNoDither=720
TIM6.IPParameters=Prescaler,PeriodNoDither,TIM_MasterOutputTrigger
TIM6.PeriodNoDither=29
TIM6.PeriodNoDither=9
TIM6.Prescaler=71
TIM6.TIM_MasterOutputTrigger=TIM_TRGO_UPDATE
TIM7.IPParameters=Prescaler,PeriodNoDither,TIM_MasterOutputTrigger
TIM7.PeriodNoDither=999
TIM7.PeriodNoDither=99
TIM7.Prescaler=71
TIM7.TIM_MasterOutputTrigger=TIM_TRGO_RESET
USART2.IPParameters=VirtualMode-Asynchronous,VirtualMode-Hardware Flow Control (RS485)

View File

@ -2,12 +2,18 @@
#ifndef CHARG_CONTROL_ENUM_
#define CHARG_CONTROL_ENUM_
typedef enum {
typedef enum _chargMode{
noWork = 0, /* 未进行充电 */
MPPT = 1, /* 最大功率充电 */
constantVoltage = 2, /* 恒压充电 */
floatCharg = 3 /* 浮充充电 */
}_chargControlMode;
}chargMode;
typedef enum _mosTState{
mosTemperStart = 0, /* 满功率充电mos状态 */
mosTemperEnd = 1, /* 降功率充电mos状态 */
mosTemperStop = 2, /* 停止充电mos状态 */
}mosTState;
#endif