Compare commits
No commits in common. "de2fb8134e3229048426e7807a294a57c2362021" and "fba3f20861e791f4d1d0076aaa39dd4dcf466f3c" have entirely different histories.
de2fb8134e
...
fba3f20861
|
@ -23,8 +23,6 @@
|
||||||
"hd_adc.h": "c",
|
"hd_adc.h": "c",
|
||||||
"hd_tim.h": "c",
|
"hd_tim.h": "c",
|
||||||
"checktime.h": "c",
|
"checktime.h": "c",
|
||||||
"test.h": "c",
|
"test.h": "c"
|
||||||
"task.h": "c",
|
|
||||||
"other.h": "c"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
|
||||||
|
#ifndef APP_TASK_H_
|
||||||
|
#define APP_TASK_H_
|
||||||
|
|
||||||
|
#include "timeSliceOffset.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
|
@ -2,17 +2,27 @@
|
||||||
#include "chargControl.h"
|
#include "chargControl.h"
|
||||||
#include "parameter.h"
|
#include "parameter.h"
|
||||||
#include "comm_types.h"
|
#include "comm_types.h"
|
||||||
#include "abnormalManage.h"
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 完成滤波和充电控制
|
* @brief 完成充电控制
|
||||||
* @param
|
* @param
|
||||||
* @retval
|
* @retval
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void chargControl(void)
|
void chargControl(void)
|
||||||
{
|
{
|
||||||
checkAbnormal();
|
// getCVData();
|
||||||
bl_chargControl();
|
judgeYNBattery();
|
||||||
|
|
||||||
|
chargControlMode();
|
||||||
|
|
||||||
|
if (getMPPT_Mode() == noWork) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getBatteryState()) {
|
||||||
|
BatteryChargControl();
|
||||||
|
} else {
|
||||||
|
noBatteryChargControl();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
|
|
||||||
#include "start.h"
|
#include "start.h"
|
||||||
|
#include "inFlash.h"
|
||||||
#include "TimeSliceOffset.h"
|
#include "TimeSliceOffset.h"
|
||||||
#include "Init.h"
|
|
||||||
#include "task.h"
|
|
||||||
|
|
||||||
|
|
||||||
void start(void)
|
void start(void)
|
||||||
{
|
{
|
||||||
Init();
|
config_info_start();
|
||||||
|
|
||||||
|
|
||||||
TimeSliceOffset_Start();
|
TimeSliceOffset_Start();
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
|
||||||
|
#include "task.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,12 @@
|
||||||
|
|
||||||
#include "chargControlEnum.h"
|
#include "chargControlEnum.h"
|
||||||
#include "FM_TIM.h"
|
#include "FM_TIM.h"
|
||||||
#include "comm_types.h"
|
|
||||||
|
|
||||||
|
void getCVData(void);
|
||||||
void setChargControlFlag(BOOL state);
|
void judgeYNBattery(void);
|
||||||
void bl_chargControl(void);
|
void chargControlMode(void);
|
||||||
|
void BatteryChargControl(void);
|
||||||
|
void noBatteryChargControl(void);
|
||||||
|
|
||||||
extern void chargControl(void);
|
extern void chargControl(void);
|
||||||
|
|
||||||
|
|
|
@ -1,54 +0,0 @@
|
||||||
|
|
||||||
#ifndef BL_TASK_H_
|
|
||||||
#define BL_TASK_H_
|
|
||||||
|
|
||||||
#include "timeSliceOffset.h"
|
|
||||||
|
|
||||||
void task_Init(void);
|
|
||||||
|
|
||||||
/* 控制运行指示灯和喂狗 */
|
|
||||||
#define runled_reloadVal 1000 /* 任务执行间隔 */
|
|
||||||
#define runled_offset 0 /* 任务执行偏移量 */
|
|
||||||
extern STR_TimeSliceOffset m_runled;
|
|
||||||
void Task_Runled(void);
|
|
||||||
|
|
||||||
/* 喂狗 */
|
|
||||||
#define wdi_reloadVal 1000 /* 任务执行间隔 */
|
|
||||||
#define wdi_offset 100 /* 任务执行偏移量 */
|
|
||||||
extern STR_TimeSliceOffset m_wdi;
|
|
||||||
void Task_wdi(void);
|
|
||||||
|
|
||||||
/* 刷新寄存器中的数据 */
|
|
||||||
#define refreshJudgeData_reloadVal 1000 /* 任务执行间隔 */
|
|
||||||
#define refreshJudgeData_offset 0 /* 任务执行偏移量 */
|
|
||||||
extern STR_TimeSliceOffset m_refreshJudgeData;
|
|
||||||
void Task_refreshJudgeData(void);
|
|
||||||
|
|
||||||
/* 启动任务 */
|
|
||||||
#define startControl_reloadVal 5000 /* 任务执行间隔 */
|
|
||||||
#define startControl_offset 100 /* 任务执行偏移量 */
|
|
||||||
extern STR_TimeSliceOffset g_startControl;
|
|
||||||
void Task_startControl(void);
|
|
||||||
|
|
||||||
/* 软启动 */
|
|
||||||
#define softStart_reloadVal 10 /* 任务执行间隔 */
|
|
||||||
#define softStart_offset 0 /* 任务执行偏移量 */
|
|
||||||
extern STR_TimeSliceOffset m_softStart;
|
|
||||||
void Task_softStart(void);
|
|
||||||
|
|
||||||
/* 回路阻抗检测 */
|
|
||||||
#define impedanceCalculation_reloadVal 100 /* 任务执行间隔 */
|
|
||||||
#define impedanceCalculation_offset 0 /* 任务执行偏移量 */
|
|
||||||
extern STR_TimeSliceOffset m_impedanceCalculation;
|
|
||||||
void Task_impedanceCalculation(void);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -6,16 +6,9 @@
|
||||||
#include "parameter.h"
|
#include "parameter.h"
|
||||||
#include "FM_GPIO.h"
|
#include "FM_GPIO.h"
|
||||||
#include "FM_TIM.h"
|
#include "FM_TIM.h"
|
||||||
#include "uart_dev.h"
|
|
||||||
|
|
||||||
extern int getMPPT_Mode(void);
|
extern int getMPPT_Mode(void);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief 初始化外设,同时通过配置文件初始化系统参数
|
|
||||||
* @param None
|
|
||||||
* @retval None
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
void Init(void)
|
void Init(void)
|
||||||
{
|
{
|
||||||
config_info_start();
|
config_info_start();
|
||||||
|
@ -25,9 +18,6 @@ void Init(void)
|
||||||
FM_GPIO_Init();
|
FM_GPIO_Init();
|
||||||
tim_Init();
|
tim_Init();
|
||||||
|
|
||||||
Init_debug_uart();
|
|
||||||
Init_BAT485_uart();
|
|
||||||
Init_GW485_uart();
|
|
||||||
start_gw485Rx_It();
|
|
||||||
start_bat485Rx_It();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,13 +2,12 @@
|
||||||
#include "abnormalManage.h"
|
#include "abnormalManage.h"
|
||||||
#include "parameter.h"
|
#include "parameter.h"
|
||||||
#include "capture.h"
|
#include "capture.h"
|
||||||
#include "checkTime.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void checkAbnormal(void)
|
void checkAbnormal(void)
|
||||||
{
|
{
|
||||||
// checkTimeInit();
|
|
||||||
/* 滤波 */
|
/* 滤波 */
|
||||||
adcCaptureFir();
|
adcCaptureFir();
|
||||||
|
|
||||||
|
@ -21,6 +20,6 @@ void checkAbnormal(void)
|
||||||
/* 判断异常状态 */
|
/* 判断异常状态 */
|
||||||
|
|
||||||
|
|
||||||
// checkAbnormalTime = getCheckTime();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
#include "bl_chargControl.h"
|
#include "bl_chargControl.h"
|
||||||
#include "parameter.h"
|
#include "parameter.h"
|
||||||
#include "comm_types.h"
|
#include "comm_types.h"
|
||||||
#include "FM_GPIO.h"
|
|
||||||
|
|
||||||
|
|
||||||
static void stopChargWork(void);
|
static void stopChargWork(void);
|
||||||
static BOOL stopChargConditions(void);
|
static BOOL stopChargConditions(void);
|
||||||
|
@ -13,387 +11,6 @@ static BOOL constantVChargConditions(void);
|
||||||
static void mpptCharge(void);
|
static void mpptCharge(void);
|
||||||
static void constantVoltageCharge(void);
|
static void constantVoltageCharge(void);
|
||||||
static void floatCharge(void);
|
static void floatCharge(void);
|
||||||
static void mppt_constantVoltage(float InVoltage);
|
|
||||||
static void mppt_constantVoltageNoBatteryO(float OutVoltage);
|
|
||||||
static void mppt_constantVoltageO(float OutVoltage);
|
|
||||||
|
|
||||||
static void judgeYNBattery(void);
|
|
||||||
static void chargControlMode(void);
|
|
||||||
static void BatteryChargControl(void);
|
|
||||||
static void noBatteryChargControl(void);
|
|
||||||
|
|
||||||
static BOOL chargControlFlag = FALSE;
|
|
||||||
static BOOL getChargControlFlag(void);
|
|
||||||
void setChargControlFlag(BOOL state);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief 恒定输入电压
|
|
||||||
* @param InVoltage 需要控制到的输入电压
|
|
||||||
* @retval
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
void mppt_constantVoltage(float InVoltage)
|
|
||||||
{
|
|
||||||
static float kp = 0.005;
|
|
||||||
static float ki = 0.00001;
|
|
||||||
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;
|
|
||||||
|
|
||||||
setDutyRatio((getDutyRatio() + stepPwm));
|
|
||||||
set_pwmDutyRatio(getDutyRatio());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief 恒定输出电压(无电池)
|
|
||||||
* @param
|
|
||||||
* @retval
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
void mppt_constantVoltageNoBatteryO(float OutVoltage)
|
|
||||||
{
|
|
||||||
static float kp = 0.005;
|
|
||||||
static float ki = 0.00001;
|
|
||||||
static float outVolt;
|
|
||||||
static float error;
|
|
||||||
static float stepPwm;
|
|
||||||
|
|
||||||
outVolt = getOutputVoltage();
|
|
||||||
error = OutVoltage - outVolt;
|
|
||||||
stepPwm = kp * error + ki * outVolt;
|
|
||||||
|
|
||||||
setDutyRatio((getDutyRatio() + stepPwm));
|
|
||||||
set_pwmDutyRatio(getDutyRatio());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief 恒定输出电压(输出检测端)
|
|
||||||
* @param
|
|
||||||
* @retval
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
void mppt_constantVoltageO(float OutVoltage)
|
|
||||||
{
|
|
||||||
// static float lastVolt = 0;
|
|
||||||
// static float lastStepPwm = 0;
|
|
||||||
static float lastDutyRatio = 0;
|
|
||||||
static float kp = 0.005;
|
|
||||||
static float ki = 0.00001;
|
|
||||||
static float outVolt;
|
|
||||||
static float error;
|
|
||||||
static float StepPwm;
|
|
||||||
|
|
||||||
outVolt = getOutputVoltage();
|
|
||||||
error = OutVoltage - outVolt;
|
|
||||||
StepPwm = kp * error + ki * outVolt;
|
|
||||||
|
|
||||||
/* 当有电池时,输出电压的曲线是先上升后下降 */
|
|
||||||
if (lastDutyRatio >= getDutyRatio()) {
|
|
||||||
// if (lastVolt >= outVolt) {
|
|
||||||
setDutyRatio((getDutyRatio() - StepPwm));
|
|
||||||
// } else {
|
|
||||||
// g_controlParameter.dutyRatio -= StepPwm;
|
|
||||||
// }
|
|
||||||
} else {
|
|
||||||
// if (lastVolt >= outVolt) {
|
|
||||||
// g_controlParameter.dutyRatio -= StepPwm;
|
|
||||||
// } else {
|
|
||||||
// g_controlParameter.dutyRatio += StepPwm;
|
|
||||||
// }
|
|
||||||
setDutyRatio((getDutyRatio() + StepPwm));
|
|
||||||
}
|
|
||||||
|
|
||||||
// lastVolt = outVolt;
|
|
||||||
// lastStepPwm = StepPwm;
|
|
||||||
lastDutyRatio = getDutyRatio();
|
|
||||||
set_pwmDutyRatio(getDutyRatio());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief 通过扰动干扰法追踪最大功率点
|
|
||||||
* @param
|
|
||||||
* @retval
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
void mppt_readJust(void)
|
|
||||||
{
|
|
||||||
/* 调节占空比 */
|
|
||||||
// static float_t step1 = 0.01;
|
|
||||||
// static float_t step2 = 0.003;
|
|
||||||
// static float_t tempV = 0.2;
|
|
||||||
// static float_t i = 0.005;
|
|
||||||
// static uint16_t flag = 0;
|
|
||||||
// static float_t lastSolarInCircuitVoltage = 0;
|
|
||||||
// static float_t lastPower = 0;
|
|
||||||
// flag++;
|
|
||||||
// if (flag < 500) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// flag = 0;
|
|
||||||
//
|
|
||||||
// float_t SolarInCircuitVoltage = get_PV1_VOLT_IN();
|
|
||||||
// float_t power = g_otherParameter.Output_Voltage * g_otherParameter.Charg_Current;
|
|
||||||
//
|
|
||||||
// float_t voltageDifference = SolarInCircuitVoltage - lastSolarInCircuitVoltage;
|
|
||||||
//
|
|
||||||
// /* 输出电压随占空比增加电压减小 */
|
|
||||||
// if (power <= lastPower) {
|
|
||||||
// if (lastSolarInCircuitVoltage <= SolarInCircuitVoltage) {
|
|
||||||
// if (voltageDifference > tempV) {
|
|
||||||
// g_controlParameter.dutyRatio += step2 + voltageDifference / i;
|
|
||||||
// } else {
|
|
||||||
// g_controlParameter.dutyRatio += step1 + voltageDifference / i;
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// if (voltageDifference < -tempV) {
|
|
||||||
// g_controlParameter.dutyRatio -= step2 + voltageDifference / i;
|
|
||||||
// } else {
|
|
||||||
// g_controlParameter.dutyRatio -= step1 + voltageDifference / i;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// if (lastSolarInCircuitVoltage <= SolarInCircuitVoltage) {
|
|
||||||
// if (voltageDifference > tempV) {
|
|
||||||
// g_controlParameter.dutyRatio -= step2 - voltageDifference / i;
|
|
||||||
// } else {
|
|
||||||
// g_controlParameter.dutyRatio -= step1 - voltageDifference / i;
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// if (voltageDifference < -tempV) {
|
|
||||||
// g_controlParameter.dutyRatio += step2 - voltageDifference / i;
|
|
||||||
// } else {
|
|
||||||
// g_controlParameter.dutyRatio += step1 - voltageDifference / i;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// lastPower = power;
|
|
||||||
// lastSolarInCircuitVoltage = SolarInCircuitVoltage;
|
|
||||||
//
|
|
||||||
// Set_duty_ratio(&g_controlParameter.dutyRatio);
|
|
||||||
|
|
||||||
|
|
||||||
/* 调节电压,变步长调节 */
|
|
||||||
// static float_t Power3 = 0; //上上次功率
|
|
||||||
// static float_t Power2 = 0; //上次功率
|
|
||||||
// static float_t Power1 = 0; //当前功率
|
|
||||||
// static float_t power23 = 0; //上次和上上次功率的绝对值
|
|
||||||
// static float_t power12 = 0; //当前功率和上次功率的绝对值
|
|
||||||
//// static float_t SolarInCircuitVoltage3 = 0; //上上次太阳能板电压
|
|
||||||
// static float_t SolarInCircuitVoltage2 = 0; //上次太阳能板电压
|
|
||||||
// static float_t SolarInCircuitVoltage1 = 0; //当前太阳能板电压
|
|
||||||
// static float_t SolarInCircuitVoltage12 = 0; //当前太阳能板电压和上次太阳能板电压的绝对值
|
|
||||||
// SolarInCircuitVoltage1 = get_PV1_VOLT_IN();
|
|
||||||
// Power1 = g_otherParameter.Output_Voltage * g_otherParameter.Charg_Current;
|
|
||||||
// static float_t power12Abs = 0;
|
|
||||||
// static float_t power23Abs = 0;
|
|
||||||
// static float_t SolarInCircuitVoltage12Abs = 0;
|
|
||||||
// static float_t dk = 0; //变步长因子
|
|
||||||
// static float_t stepV = 0;
|
|
||||||
// static float_t SolarInCircuitV = 18; //控制太阳能板的输出电压稳定在该值
|
|
||||||
//
|
|
||||||
// static float_t kp = 0.005;
|
|
||||||
// static float_t ki = 0.00001;
|
|
||||||
//
|
|
||||||
// /* 延时一段时间才判断 */
|
|
||||||
// static uint16_t flag = 0;
|
|
||||||
// flag++;
|
|
||||||
// if (flag < 1000) {
|
|
||||||
//// float_t pv1Volt = g_otherParameter.Solar_In_Circuit_Voltage;
|
|
||||||
// float_t pv1Volt = SolarInCircuitVoltage1;
|
|
||||||
// float_t error = pv1Volt - SolarInCircuitV;
|
|
||||||
// float_t stepPwm = kp * error + ki * pv1Volt;
|
|
||||||
//
|
|
||||||
// g_controlParameter.dutyRatio += stepPwm;
|
|
||||||
//
|
|
||||||
// /* 过温保护 */
|
|
||||||
// if (g_otherParameter.overTemperature == 0) {
|
|
||||||
//
|
|
||||||
// } else if (g_otherParameter.overTemperature == 1) {
|
|
||||||
// g_controlParameter.dutyRatio -= 0.1;
|
|
||||||
// } else if (g_otherParameter.overTemperature == 2) {
|
|
||||||
// g_controlParameter.dutyRatio -= 0.2;
|
|
||||||
// } else if (g_otherParameter.overTemperature == 3) {
|
|
||||||
// g_controlParameter.dutyRatio -= 0.3;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// Set_duty_ratio(&g_controlParameter.dutyRatio);
|
|
||||||
//
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// flag = 0;
|
|
||||||
//
|
|
||||||
// power23 = Power2 - Power3;
|
|
||||||
// if (power23 < 0) {
|
|
||||||
// power23Abs = -power23;
|
|
||||||
// } else {
|
|
||||||
// power23Abs = power23;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// power12 = Power1 - Power2;
|
|
||||||
// if (power12 < 0) {
|
|
||||||
// power12Abs = -power12;
|
|
||||||
// } else {
|
|
||||||
// power12Abs = power12;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//// SolarInCircuitVoltage23 = SolarInCircuitVoltage2 - SolarInCircuitVoltage3;
|
|
||||||
//
|
|
||||||
// SolarInCircuitVoltage12 = SolarInCircuitVoltage1 - SolarInCircuitVoltage2;
|
|
||||||
//
|
|
||||||
// dk = power12Abs / power23Abs;
|
|
||||||
// stepV = dk * SolarInCircuitVoltage12Abs;
|
|
||||||
//
|
|
||||||
//// printf(" dk : %d/10000 \n", (int)(dk * 10000));
|
|
||||||
//
|
|
||||||
// if (power12 > 0) {
|
|
||||||
// if (SolarInCircuitVoltage12 > 0) {
|
|
||||||
// SolarInCircuitV = SolarInCircuitVoltage1 + stepV;
|
|
||||||
// } else {
|
|
||||||
// SolarInCircuitV = SolarInCircuitVoltage1 - stepV;
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// if (SolarInCircuitVoltage12 > 0) {
|
|
||||||
// SolarInCircuitV = SolarInCircuitVoltage1 - stepV;
|
|
||||||
// } else {
|
|
||||||
// SolarInCircuitV = SolarInCircuitVoltage1 + stepV;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// printf(" SolarInCircuitV : %d/100 \n", (int)(SolarInCircuitV * 100));
|
|
||||||
//
|
|
||||||
// if (SolarInCircuitV > 21) {
|
|
||||||
// SolarInCircuitV = 21;
|
|
||||||
// }
|
|
||||||
// else if (SolarInCircuitV < 15) {
|
|
||||||
// SolarInCircuitV = 15;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// printf(" SolarInCircuitV : %d/100 \n", (int)(SolarInCircuitV * 100));
|
|
||||||
//
|
|
||||||
// Power3 = Power2;
|
|
||||||
// Power2 = Power1;
|
|
||||||
//// SolarInCircuitVoltage3 = SolarInCircuitVoltage2;
|
|
||||||
// SolarInCircuitVoltage2 = SolarInCircuitVoltage1;
|
|
||||||
//
|
|
||||||
//// float_t pv1Volt = g_otherParameter.Solar_In_Circuit_Voltage;
|
|
||||||
// float_t pv1Volt = SolarInCircuitVoltage1;
|
|
||||||
// float_t error = pv1Volt - SolarInCircuitV;
|
|
||||||
// float_t stepPwm = kp * error + ki * pv1Volt;
|
|
||||||
//
|
|
||||||
// g_controlParameter.dutyRatio += stepPwm;
|
|
||||||
//
|
|
||||||
// /* 过温保护 */
|
|
||||||
// if (g_otherParameter.overTemperature == 0) {
|
|
||||||
//
|
|
||||||
// } else if (g_otherParameter.overTemperature == 1) {
|
|
||||||
// g_controlParameter.dutyRatio -= 0.1;
|
|
||||||
// } else if (g_otherParameter.overTemperature == 2) {
|
|
||||||
// g_controlParameter.dutyRatio -= 0.2;
|
|
||||||
// } else if (g_otherParameter.overTemperature == 3) {
|
|
||||||
// g_controlParameter.dutyRatio -= 0.3;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// Set_duty_ratio(&g_controlParameter.dutyRatio);
|
|
||||||
//
|
|
||||||
// return;
|
|
||||||
|
|
||||||
/* 调节电压,两个电压步调节 */
|
|
||||||
static float Power = 0;
|
|
||||||
Power = getOutputVoltage() * getChargCurrent();
|
|
||||||
static float lPower = 0;
|
|
||||||
// static float lLPower = 0;
|
|
||||||
// static float lLLPower = 0;
|
|
||||||
|
|
||||||
static float SolarInCircuitV = 17; //控制太阳能板的输出电压稳定在该值,初始为17V
|
|
||||||
// static float kp = 0.005;
|
|
||||||
// static float ki = 0.00001;
|
|
||||||
|
|
||||||
static float stepV1 = 0.5;
|
|
||||||
static float stepV2 = 0.2;
|
|
||||||
|
|
||||||
static uint8_t flag1 = 0; //表明上次运算是加还是减
|
|
||||||
|
|
||||||
/* 延时一段时间才判断 */
|
|
||||||
static uint16_t flag = 0;
|
|
||||||
flag++;
|
|
||||||
if (flag < 150) {
|
|
||||||
// float pv1Volt = getSolarInCircuitVoltage();
|
|
||||||
// float error = pv1Volt - SolarInCircuitV;
|
|
||||||
// float stepPwm = kp * error + ki * pv1Volt;
|
|
||||||
|
|
||||||
// setDutyRatio((getDutyRatio() + stepPwm));
|
|
||||||
// set_pwmDutyRatio(getDutyRatio());
|
|
||||||
|
|
||||||
mppt_constantVoltage(SolarInCircuitV);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
flag = 0;
|
|
||||||
|
|
||||||
static float powerT = 0;
|
|
||||||
powerT = Power - lPower;
|
|
||||||
if (powerT < 0) {
|
|
||||||
powerT = -powerT;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if ((lPower + 0.7 < Power) && (lLPower + 0.7 < Power) && (lLLPower + 0.7 < Power)) {
|
|
||||||
// if ((lPower + 0.7 < Power) && (lLPower + 0.7 < Power)) {
|
|
||||||
if ((lPower + 0.3f < Power)) {
|
|
||||||
if (powerT > 5) {
|
|
||||||
if (flag1) {
|
|
||||||
SolarInCircuitV += stepV1;
|
|
||||||
flag1 = 1;
|
|
||||||
} else {
|
|
||||||
SolarInCircuitV -= stepV1;
|
|
||||||
flag1 = 0;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (flag1) {
|
|
||||||
SolarInCircuitV += stepV2;
|
|
||||||
flag1 = 1;
|
|
||||||
} else {
|
|
||||||
SolarInCircuitV -= stepV2;
|
|
||||||
flag1 = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// } else if ((lPower - 0.7 > Power) && (lLPower - 0.7 > Power) && (lLLPower - 0.7 > Power)) {
|
|
||||||
// } else if ((lPower - 0.7 > Power) && (lLPower - 0.7 > Power)) {
|
|
||||||
} else if ((lPower - 0.3f > Power)) {
|
|
||||||
if (powerT > 5) {
|
|
||||||
if (flag1) {
|
|
||||||
SolarInCircuitV -= stepV1;
|
|
||||||
flag1 = 0;
|
|
||||||
} else {
|
|
||||||
SolarInCircuitV += stepV1;
|
|
||||||
flag1 = 1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (flag1) {
|
|
||||||
SolarInCircuitV -= stepV2;
|
|
||||||
flag1 = 0;
|
|
||||||
} else {
|
|
||||||
SolarInCircuitV += stepV2;
|
|
||||||
flag1 = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (SolarInCircuitV > 18.5f) {
|
|
||||||
SolarInCircuitV = 18.5f;
|
|
||||||
}
|
|
||||||
else if (SolarInCircuitV < 16.0f) {
|
|
||||||
SolarInCircuitV = 16.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
lPower = Power;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 停止充电
|
* @brief 停止充电
|
||||||
|
@ -403,8 +20,7 @@ void mppt_readJust(void)
|
||||||
*/
|
*/
|
||||||
void stopChargWork(void)
|
void stopChargWork(void)
|
||||||
{
|
{
|
||||||
EN_PWMOUT_Diseable();
|
|
||||||
pwm_Stop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -416,10 +32,7 @@ void stopChargWork(void)
|
||||||
*/
|
*/
|
||||||
BOOL stopChargConditions(void)
|
BOOL stopChargConditions(void)
|
||||||
{
|
{
|
||||||
if (getSolarInCircuitVoltage() < g_cfgParameter.stopSolarOpenCircuitV
|
|
||||||
&& getChargCurrent() < 0.1f) {
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -433,12 +46,7 @@ BOOL stopChargConditions(void)
|
||||||
*/
|
*/
|
||||||
BOOL floatChargConditions(void)
|
BOOL floatChargConditions(void)
|
||||||
{
|
{
|
||||||
if (g_cfgParameter.constantVoltageChargeV < getBatteryVoltage()
|
|
||||||
&& g_cfgParameter.floatI > getChargCurrent()) {
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -484,16 +92,27 @@ void chargControlMode(void)
|
||||||
if (floatChargConditions()) {
|
if (floatChargConditions()) {
|
||||||
setMPPT_Mode(floatCharg);
|
setMPPT_Mode(floatCharg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mpptChargConditions()) {
|
if (mpptChargConditions()) {
|
||||||
setMPPT_Mode(MPPT);
|
setMPPT_Mode(MPPT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (constantVChargConditions()) {
|
if (constantVChargConditions()) {
|
||||||
setMPPT_Mode(constantVoltage);
|
setMPPT_Mode(constantVoltage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 得到充电控制器控制所需的电流电压
|
||||||
|
* @param
|
||||||
|
* @retval
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void getCVData(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 判断有无电池
|
* @brief 判断有无电池
|
||||||
* @param
|
* @param
|
||||||
|
@ -502,10 +121,7 @@ void chargControlMode(void)
|
||||||
*/
|
*/
|
||||||
void judgeYNBattery(void)
|
void judgeYNBattery(void)
|
||||||
{
|
{
|
||||||
if (getBatteryVoltage() > 16 || getBatteryVoltage() < 10) {
|
|
||||||
setBatteryState(FALSE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -516,7 +132,7 @@ void judgeYNBattery(void)
|
||||||
*/
|
*/
|
||||||
void noBatteryChargControl(void)
|
void noBatteryChargControl(void)
|
||||||
{
|
{
|
||||||
mppt_constantVoltageNoBatteryO(g_cfgParameter.FloatV);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -527,7 +143,7 @@ void noBatteryChargControl(void)
|
||||||
*/
|
*/
|
||||||
void mpptCharge(void)
|
void mpptCharge(void)
|
||||||
{
|
{
|
||||||
mppt_readJust();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -538,7 +154,8 @@ void mpptCharge(void)
|
||||||
*/
|
*/
|
||||||
void constantVoltageCharge(void)
|
void constantVoltageCharge(void)
|
||||||
{
|
{
|
||||||
mppt_constantVoltageO(g_cfgParameter.constantVoltageChargeV);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -549,7 +166,7 @@ void constantVoltageCharge(void)
|
||||||
*/
|
*/
|
||||||
void floatCharge(void)
|
void floatCharge(void)
|
||||||
{
|
{
|
||||||
mppt_constantVoltageO(g_cfgParameter.FloatV);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -581,44 +198,3 @@ void BatteryChargControl(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL getChargControlFlag(void)
|
|
||||||
{
|
|
||||||
return chargControlFlag;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void setChargControlFlag(BOOL state)
|
|
||||||
{
|
|
||||||
if (state == TRUE || state == FALSE) {
|
|
||||||
chargControlFlag = state;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief 完成充电控制
|
|
||||||
* @param
|
|
||||||
* @retval
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
void bl_chargControl(void)
|
|
||||||
{
|
|
||||||
if (getChargControlFlag() == FALSE) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// getCVData();
|
|
||||||
judgeYNBattery();
|
|
||||||
|
|
||||||
chargControlMode();
|
|
||||||
|
|
||||||
if (getMPPT_Mode() == noWork) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getBatteryState()) {
|
|
||||||
BatteryChargControl();
|
|
||||||
} else {
|
|
||||||
noBatteryChargControl();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
#include "capture.h"
|
#include "capture.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
config_parameter g_cfgParameter = {0};
|
config_parameter g_cfgParameter = {0};
|
||||||
static otherParameter g_otherParameter = {0};
|
static otherParameter g_otherParameter = {0};
|
||||||
|
|
||||||
|
@ -12,6 +14,7 @@ static BOOL batteryState = FALSE; /* 有无电池(估计) */
|
||||||
static float dutyRatio; /* 占空比 */
|
static float dutyRatio; /* 占空比 */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 获取电池状态
|
* @brief 获取电池状态
|
||||||
* @param
|
* @param
|
||||||
|
|
|
@ -1,212 +0,0 @@
|
||||||
|
|
||||||
#include "task.h"
|
|
||||||
#include "inFlash.h"
|
|
||||||
#include "parameter.h"
|
|
||||||
#include "FM_GPIO.h"
|
|
||||||
#include "chargControlEnum.h"
|
|
||||||
#include "bl_chargControl.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief 启动时初始化各任务
|
|
||||||
* @param None
|
|
||||||
* @retval None
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
void task_Init(void)
|
|
||||||
{
|
|
||||||
TimeSliceOffset_Register(&m_runled, Task_Runled, runled_reloadVal, runled_offset);
|
|
||||||
TimeSliceOffset_Register(&m_wdi, Task_wdi, wdi_reloadVal, wdi_offset);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief 运行指示灯任务
|
|
||||||
* @param None
|
|
||||||
* @retval None
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
STR_TimeSliceOffset m_runled;
|
|
||||||
void Task_Runled(void)
|
|
||||||
{
|
|
||||||
RUN_LED();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief 喂狗任务
|
|
||||||
* @param None
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
STR_TimeSliceOffset m_wdi;
|
|
||||||
void Task_wdi(void)
|
|
||||||
{
|
|
||||||
/* 每天复位一次,复位前将电量信息写入flash中 */
|
|
||||||
static uint32_t temp = 60 * 60 * 24;
|
|
||||||
if (!(--temp)) {
|
|
||||||
temp = 0;
|
|
||||||
float tempF;
|
|
||||||
tempF = getTotalElectricityConsumption();
|
|
||||||
savetotalElectricityConsumption(&tempF);
|
|
||||||
tempF = getTotalChargCapacity();
|
|
||||||
savetotalChargCapacity(&tempF);
|
|
||||||
NVIC_SystemReset();
|
|
||||||
}
|
|
||||||
|
|
||||||
feedDog();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief 刷新并判断数据
|
|
||||||
* @param None
|
|
||||||
* @retval None
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
STR_TimeSliceOffset m_refreshJudgeData;
|
|
||||||
void Task_refreshJudgeData(void)
|
|
||||||
{
|
|
||||||
/* 获取数据 */
|
|
||||||
setInputVoltage();
|
|
||||||
setHighSideMosTemperature();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* 判断有无电池 */
|
|
||||||
if (getBatteryState() == FALSE && (getChargBatteryCurrent() > 1 || getChargBatteryCurrent() < -1)
|
|
||||||
&& getOutputVoltage() < 14.2f) {
|
|
||||||
setBatteryState(TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 温度检测 */
|
|
||||||
if () {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief 停止充电或系统启动时后开启该任务,每隔一段时间检测开路电压
|
|
||||||
* 检测电池电压是否大于充电电压,大于则开启充电,否则关闭充电
|
|
||||||
* 能否达到充电标准,达到后检测电压判断系统中是否有电池同时启
|
|
||||||
* 动软启动任务
|
|
||||||
* @param None
|
|
||||||
* @retval None
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
STR_TimeSliceOffset g_startControl;
|
|
||||||
void Task_startControl(void)
|
|
||||||
{
|
|
||||||
if (getSolarInCircuitVoltage() > g_cfgParameter.startSolarOpenCircuitV) {
|
|
||||||
TimeSliceOffset_Unregister(&g_startControl);
|
|
||||||
g_startControl.runFlag = 0;
|
|
||||||
if (getOutputVoltage() > 10) {
|
|
||||||
setBatteryState(TRUE);
|
|
||||||
} else {
|
|
||||||
setBatteryState(FALSE);
|
|
||||||
}
|
|
||||||
TimeSliceOffset_Register(&m_softStart, Task_softStart, softStart_reloadVal, softStart_offset);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief 软启动
|
|
||||||
* @param
|
|
||||||
* @retval
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
STR_TimeSliceOffset m_softStart;
|
|
||||||
void Task_softStart(void)
|
|
||||||
{
|
|
||||||
static uint16_t num = 0;
|
|
||||||
static float dutyRatio = 0;
|
|
||||||
num++;
|
|
||||||
|
|
||||||
if (num < 5) {
|
|
||||||
set_pwmPulse(100);
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (num > 70 || dutyRatio > 0.75f) {
|
|
||||||
TimeSliceOffset_Unregister(&m_softStart);
|
|
||||||
m_softStart.runFlag = 0;
|
|
||||||
|
|
||||||
dutyRatio = 0;
|
|
||||||
num = 0;
|
|
||||||
setDutyRatio(0.75);
|
|
||||||
set_pwmDutyRatio(getDutyRatio());
|
|
||||||
|
|
||||||
if (getBatteryState() == TRUE) {
|
|
||||||
setMPPT_Mode(MPPT);
|
|
||||||
} else {
|
|
||||||
setMPPT_Mode(floatCharg);
|
|
||||||
}
|
|
||||||
setChargControlFlag(TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
else {
|
|
||||||
setDutyRatio(getDutyRatio() + 0.05f);
|
|
||||||
set_pwmDutyRatio(getDutyRatio());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief 满足一定条件后启动该任务,测量回路阻抗
|
|
||||||
* @param
|
|
||||||
* @retval
|
|
||||||
*/
|
|
||||||
STR_TimeSliceOffset m_impedanceCalculation;
|
|
||||||
void Task_impedanceCalculation(void)
|
|
||||||
{
|
|
||||||
static uint8_t num = 0;
|
|
||||||
static float currOne = 0;
|
|
||||||
static float voltOne = 0;
|
|
||||||
static float currTwo = 0;
|
|
||||||
static float voltTwo = 0;
|
|
||||||
|
|
||||||
num++;
|
|
||||||
|
|
||||||
if (num == 1) {
|
|
||||||
setChargControlFlag(FALSE);
|
|
||||||
setDutyRatio(0.7);
|
|
||||||
set_pwmDutyRatio(getDutyRatio());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (num == 11) {
|
|
||||||
currOne = getChargCurrent() - getDischargCurrent();
|
|
||||||
voltOne = getOutputVoltage();
|
|
||||||
setDutyRatio(0.85);
|
|
||||||
set_pwmDutyRatio(getDutyRatio());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (num == 21) {
|
|
||||||
TimeSliceOffset_Unregister(&m_impedanceCalculation);
|
|
||||||
m_impedanceCalculation.runFlag = 0;
|
|
||||||
|
|
||||||
currTwo = getChargCurrent() - getDischargCurrent();
|
|
||||||
voltTwo = getOutputVoltage();
|
|
||||||
float tempLoopImpedance = 0;
|
|
||||||
tempLoopImpedance = (voltOne - voltTwo) / (currOne - currTwo);
|
|
||||||
|
|
||||||
/* 判断回路阻抗是否合理 */
|
|
||||||
if (tempLoopImpedance < 1.0f && tempLoopImpedance > 0.05f) {
|
|
||||||
g_cfgParameter.loopImpedance = tempLoopImpedance;
|
|
||||||
saveLoopImpedance(&g_cfgParameter.loopImpedance);
|
|
||||||
}
|
|
||||||
num = 0;
|
|
||||||
|
|
||||||
setMPPT_Mode(MPPT);
|
|
||||||
setChargControlFlag(TRUE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,22 +4,17 @@
|
||||||
#include "uart_dev.h"
|
#include "uart_dev.h"
|
||||||
#include "HD_TIM.h"
|
#include "HD_TIM.h"
|
||||||
#include "pDebug.h"
|
#include "pDebug.h"
|
||||||
#include "parameter.h"
|
|
||||||
#include "FM_TIM.h"
|
|
||||||
|
|
||||||
void test(void)
|
void test(void)
|
||||||
{
|
{
|
||||||
tim_Init();
|
|
||||||
Init_debug_uart();
|
Init_debug_uart();
|
||||||
|
HD_time_Init();
|
||||||
|
HAL_TIM_Base_Start_IT(&htim15);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
checkTimeInit();
|
||||||
HAL_Delay(1000);
|
HAL_Delay(1000);
|
||||||
debug_printf("time:%f\r\n", checkAbnormalTime);
|
debug("time:%f\r\n", getCheckTime());
|
||||||
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());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@ void POW_OUT_PCON_Close(void);
|
||||||
|
|
||||||
void RUN_LEN_Open(void);
|
void RUN_LEN_Open(void);
|
||||||
void RUN_LEN_Close(void);
|
void RUN_LEN_Close(void);
|
||||||
void RUN_LED(void);
|
|
||||||
|
|
||||||
void FFMOS_CON_Open(void);
|
void FFMOS_CON_Open(void);
|
||||||
void FFMOS_CON_Close(void);
|
void FFMOS_CON_Close(void);
|
||||||
|
@ -21,8 +20,6 @@ void FFMOS_CON_Close(void);
|
||||||
void EN_PWMOUT_Eable(void);
|
void EN_PWMOUT_Eable(void);
|
||||||
void EN_PWMOUT_Diseable(void);
|
void EN_PWMOUT_Diseable(void);
|
||||||
|
|
||||||
void feedDog(void);
|
|
||||||
|
|
||||||
BOOL readOnlyPowerOutputState(void);
|
BOOL readOnlyPowerOutputState(void);
|
||||||
BOOL readOutputState(void);
|
BOOL readOutputState(void);
|
||||||
|
|
||||||
|
|
|
@ -4,14 +4,11 @@
|
||||||
|
|
||||||
#include "arm_math.h"
|
#include "arm_math.h"
|
||||||
|
|
||||||
#define indata16_size 10
|
|
||||||
#define IODataF_size 4
|
|
||||||
#pragma pack(push,4)
|
#pragma pack(push,4)
|
||||||
typedef struct _adcCapture
|
typedef struct _adcCapture
|
||||||
{
|
{
|
||||||
int16_t inData16[indata16_size];
|
float32_t inDataF[6];
|
||||||
uint32_t totalInData;
|
|
||||||
float32_t IODataF[IODataF_size];
|
|
||||||
int16_t outData;
|
int16_t outData;
|
||||||
}adcCapture;
|
}adcCapture;
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include "HD_TIM.h"
|
#include "HD_TIM.h"
|
||||||
#include "FM_TIM.h"
|
#include "FM_TIM.h"
|
||||||
|
|
||||||
extern float checkAbnormalTime;
|
|
||||||
|
|
||||||
void hw_inc_tick(void);
|
void hw_inc_tick(void);
|
||||||
void checkTimeInit(void);
|
void checkTimeInit(void);
|
||||||
|
|
|
@ -66,16 +66,6 @@ void RUN_LEN_Close(void)
|
||||||
HAL_GPIO_WritePin(RUN_LED_GPIO_Port, RUN_LED_Pin, GPIO_PIN_RESET);
|
HAL_GPIO_WritePin(RUN_LED_GPIO_Port, RUN_LED_Pin, GPIO_PIN_RESET);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief 翻转LED状态
|
|
||||||
* @param None
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void RUN_LED(void)
|
|
||||||
{
|
|
||||||
HAL_GPIO_TogglePin(RUN_LED_GPIO_Port, RUN_LED_Pin);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 打开mppt电感后的输出mos管
|
* @brief 打开mppt电感后的输出mos管
|
||||||
* @param None
|
* @param None
|
||||||
|
@ -116,17 +106,6 @@ void EN_PWMOUT_Diseable(void)
|
||||||
HAL_GPIO_WritePin(EN_PWMOUT_GPIO_Port, EN_PWMOUT_Pin, GPIO_PIN_SET);
|
HAL_GPIO_WritePin(EN_PWMOUT_GPIO_Port, EN_PWMOUT_Pin, GPIO_PIN_SET);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief 喂狗
|
|
||||||
* @param None
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void feedDog(void)
|
|
||||||
{
|
|
||||||
HAL_GPIO_WritePin(WDI_INPUT_GPIO_Port, WDI_INPUT_Pin, GPIO_PIN_SET);
|
|
||||||
HAL_GPIO_WritePin(WDI_INPUT_GPIO_Port, WDI_INPUT_Pin, GPIO_PIN_RESET);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 仅有充电控制器时,判断输出开关是否打开
|
* @brief 仅有充电控制器时,判断输出开关是否打开
|
||||||
* @param None
|
* @param None
|
||||||
|
|
|
@ -16,27 +16,29 @@ void tim_Init(void)
|
||||||
HD_PWM_Init();
|
HD_PWM_Init();
|
||||||
/* 得到pwm的分辨率 */
|
/* 得到pwm的分辨率 */
|
||||||
PWM_RESOLUTION = HAL_RCC_GetHCLKFreq() / 100000;
|
PWM_RESOLUTION = HAL_RCC_GetHCLKFreq() / 100000;
|
||||||
HAL_TIM_Base_Start(&htim3);
|
|
||||||
|
|
||||||
HD_controlTim_Init();
|
HD_controlTim_Init();
|
||||||
HAL_TIM_Base_Start_IT(&htim7);
|
|
||||||
|
|
||||||
HD_taskBaseTim_Init();
|
HD_taskBaseTim_Init();
|
||||||
HAL_TIM_Base_Start_IT(&htim16);
|
HD_checkAbnormalTim_Init();
|
||||||
|
|
||||||
HD_time_Init();
|
HD_time_Init();
|
||||||
HAL_TIM_Base_Start_IT(&htim15);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 停止PWM信号输出
|
* @brief 停止PWM信号输出
|
||||||
|
*
|
||||||
|
* 本函数通过设置PWM脉冲宽度为0来停止PWM信号输出,然后调用HAL库函数进行PWM相关的硬件资源初始化。
|
||||||
|
* 注意:这里使用了硬件抽象层(HAL)库提供的函数,特定于STM32微控制器。
|
||||||
*/
|
*/
|
||||||
void pwm_Stop(void)
|
void pwm_Stop(void)
|
||||||
{
|
{
|
||||||
// 设置PWM脉冲宽度为0, effectively停止PWM信号输出
|
// 设置PWM脉冲宽度为0, effectively停止PWM信号输出
|
||||||
set_pwmPulse(0);
|
set_pwmPulse(0);
|
||||||
HAL_TIM_Base_Stop(&htim3);
|
|
||||||
|
// HAL_TIM_OC_MspDeInit(&htim3);
|
||||||
|
|
||||||
|
// 调用HAL库函数进行PWM相关的硬件资源De初始化
|
||||||
|
HAL_TIM_PWM_MspDeInit(&htim3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -95,6 +97,10 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
|
||||||
TimeSliceOffset_Produce();
|
TimeSliceOffset_Produce();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (htim->Instance == TIM17) {
|
||||||
|
checkAbnormal();
|
||||||
|
}
|
||||||
|
|
||||||
else if (htim->Instance == TIM15) {
|
else if (htim->Instance == TIM15) {
|
||||||
hw_inc_tick();
|
hw_inc_tick();
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,8 +99,6 @@ enum {
|
||||||
CHG_CURR_NUM = 3,
|
CHG_CURR_NUM = 3,
|
||||||
};
|
};
|
||||||
int16_t adcBuff[4];
|
int16_t adcBuff[4];
|
||||||
/* 指向adcCapture中的inData16数组中的第一位也是最后一位 */
|
|
||||||
uint8_t pointer;
|
|
||||||
|
|
||||||
adcCapture WORK_VOLT_capture = {0};
|
adcCapture WORK_VOLT_capture = {0};
|
||||||
adcCapture DSG_CURR_capture = {0};
|
adcCapture DSG_CURR_capture = {0};
|
||||||
|
@ -119,20 +117,12 @@ static float P_PV_VOLT_IN1 = 0;
|
||||||
const float32_t Proportion = 3.0 / 4095.0;
|
const float32_t Proportion = 3.0 / 4095.0;
|
||||||
|
|
||||||
/* matlab生成的5阶滤波器系数 */
|
/* matlab生成的5阶滤波器系数 */
|
||||||
// const int firLen = 6;
|
const int firLen = 6;
|
||||||
// const float firLP[6] = {
|
const float firLP[6] = {
|
||||||
// 0.01861755922, -0.1146286726, 0.5962908864, 0.5962908864, -0.1146286726,
|
0.01861755922, -0.1146286726, 0.5962908864, 0.5962908864, -0.1146286726,
|
||||||
// 0.01861755922
|
0.01861755922
|
||||||
// };
|
|
||||||
|
|
||||||
/* matlab生成的3阶滤波器系数 */
|
|
||||||
const int firLen = 4;
|
|
||||||
const float firLP[4] = {
|
|
||||||
0.178709805, 0.3671073616, 0.3671073616, 0.178709805
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void captureFirInit(void);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 初始化adc
|
* @brief 初始化adc
|
||||||
* @param
|
* @param
|
||||||
|
@ -149,9 +139,6 @@ void ADC_Capture_Init(void)
|
||||||
HAL_ADCEx_Calibration_Start(&hadc1, ADC_SINGLE_ENDED);
|
HAL_ADCEx_Calibration_Start(&hadc1, ADC_SINGLE_ENDED);
|
||||||
HAL_ADCEx_Calibration_Start(&hadc2, ADC_SINGLE_ENDED);
|
HAL_ADCEx_Calibration_Start(&hadc2, ADC_SINGLE_ENDED);
|
||||||
|
|
||||||
/* 初始化滤波器 */
|
|
||||||
captureFirInit();
|
|
||||||
|
|
||||||
HAL_TIM_Base_Start(&htim6);
|
HAL_TIM_Base_Start(&htim6);
|
||||||
HAL_ADC_Start_DMA(&hadc1, (uint32_t *)adcBuff, 4);
|
HAL_ADC_Start_DMA(&hadc1, (uint32_t *)adcBuff, 4);
|
||||||
|
|
||||||
|
@ -400,54 +387,18 @@ float get_MOSFET_Temper(void)
|
||||||
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hdma)
|
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hdma)
|
||||||
{
|
{
|
||||||
if (hdma->Instance == ADC1) {
|
if (hdma->Instance == ADC1) {
|
||||||
WORK_VOLT_capture.totalInData -= WORK_VOLT_capture.inData16[pointer];
|
arm_copy_f32(WORK_VOLT_capture.inDataF, WORK_VOLT_capture.inDataF + 1, 5);
|
||||||
DSG_CURR_capture.totalInData -= DSG_CURR_capture.inData16[pointer];
|
arm_copy_f32(DSG_CURR_capture.inDataF, DSG_CURR_capture.inDataF + 1, 5);
|
||||||
PV_VOLT_IN_capture.totalInData -= PV_VOLT_IN_capture.inData16[pointer];
|
arm_copy_f32(PV_VOLT_IN_capture.inDataF, PV_VOLT_IN_capture.inDataF + 1, 5);
|
||||||
CHG_CURR_capture.totalInData -= CHG_CURR_capture.inData16[pointer];
|
arm_copy_f32(CHG_CURR_capture.inDataF, CHG_CURR_capture.inDataF + 1, 5);
|
||||||
|
|
||||||
WORK_VOLT_capture.inData16[pointer] = adcBuff[WORK_VOLT_NUM];
|
WORK_VOLT_capture.inDataF[5] = (float32_t)adcBuff[WORK_VOLT_NUM];
|
||||||
DSG_CURR_capture.inData16[pointer] = adcBuff[DSG_CURR_NUM];
|
DSG_CURR_capture.inDataF[5] = (float32_t)adcBuff[DSG_CURR_NUM];
|
||||||
PV_VOLT_IN_capture.inData16[pointer] = adcBuff[PV_VOLT_IN_NUM];
|
PV_VOLT_IN_capture.inDataF[5] = (float32_t)adcBuff[PV_VOLT_IN_NUM];
|
||||||
CHG_CURR_capture.inData16[pointer] = adcBuff[CHG_CURR_NUM];
|
CHG_CURR_capture.inDataF[5] = (float32_t)adcBuff[CHG_CURR_NUM];
|
||||||
|
|
||||||
WORK_VOLT_capture.totalInData += WORK_VOLT_capture.inData16[pointer];
|
|
||||||
DSG_CURR_capture.totalInData += DSG_CURR_capture.inData16[pointer];
|
|
||||||
PV_VOLT_IN_capture.totalInData += PV_VOLT_IN_capture.inData16[pointer];
|
|
||||||
CHG_CURR_capture.totalInData += CHG_CURR_capture.inData16[pointer];
|
|
||||||
|
|
||||||
pointer++;
|
|
||||||
if (pointer >= indata16_size) {
|
|
||||||
pointer = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
arm_copy_f32(WORK_VOLT_capture.IODataF + 1, WORK_VOLT_capture.IODataF, 3);
|
|
||||||
arm_copy_f32(DSG_CURR_capture.IODataF + 1, DSG_CURR_capture.IODataF, 3);
|
|
||||||
arm_copy_f32(PV_VOLT_IN_capture.IODataF + 1, PV_VOLT_IN_capture.IODataF, 3);
|
|
||||||
arm_copy_f32(CHG_CURR_capture.IODataF + 1, CHG_CURR_capture.IODataF, 3);
|
|
||||||
|
|
||||||
WORK_VOLT_capture.IODataF[3] = (float32_t)WORK_VOLT_capture.totalInData / indata16_size;
|
|
||||||
DSG_CURR_capture.IODataF[3] = (float32_t)DSG_CURR_capture.totalInData / indata16_size;
|
|
||||||
PV_VOLT_IN_capture.IODataF[3] = (float32_t)PV_VOLT_IN_capture.totalInData / indata16_size;
|
|
||||||
CHG_CURR_capture.IODataF[3] = (float32_t)CHG_CURR_capture.totalInData / indata16_size;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 将采集得到的adc进行滤波
|
* @brief 将采集得到的adc进行滤波
|
||||||
* @param None
|
* @param None
|
||||||
|
@ -455,26 +406,39 @@ void captureFirInit(void)
|
||||||
*/
|
*/
|
||||||
void adcCaptureFir(void)
|
void adcCaptureFir(void)
|
||||||
{
|
{
|
||||||
|
static arm_fir_instance_f32 armFirInstanceF32;
|
||||||
|
static float32_t *inputF32, *outputF32;
|
||||||
|
static uint32_t blockSize = 1;
|
||||||
|
static float32_t firStateF32[6]; /* 状态缓存 */
|
||||||
|
static float32_t outputf;
|
||||||
|
|
||||||
|
/* 初始化结构体 */
|
||||||
|
arm_fir_init_f32(&armFirInstanceF32,
|
||||||
|
firLen,
|
||||||
|
(float_t *)&firLP[0],
|
||||||
|
&firStateF32[0],
|
||||||
|
blockSize);
|
||||||
|
|
||||||
/* 初始化输入输出缓存指针 */
|
/* 初始化输入输出缓存指针 */
|
||||||
inputF32 = &WORK_VOLT_capture.IODataF[0];
|
inputF32 = &WORK_VOLT_capture.inDataF[0];
|
||||||
outputF32 = &outputf;
|
outputF32 = &outputf;
|
||||||
arm_fir_f32(&armFirInstanceF32, inputF32, outputF32, blockSize);
|
arm_fir_f32(&armFirInstanceF32, inputF32, outputF32, blockSize);
|
||||||
WORK_VOLT_capture.outData = (int16_t)outputf;
|
WORK_VOLT_capture.outData = (int16_t)outputf;
|
||||||
|
|
||||||
/* 初始化输入输出缓存指针 */
|
/* 初始化输入输出缓存指针 */
|
||||||
inputF32 = &DSG_CURR_capture.IODataF[0];
|
inputF32 = &DSG_CURR_capture.inDataF[0];
|
||||||
outputF32 = &outputf;
|
outputF32 = &outputf;
|
||||||
arm_fir_f32(&armFirInstanceF32, inputF32, outputF32, blockSize);
|
arm_fir_f32(&armFirInstanceF32, inputF32, outputF32, blockSize);
|
||||||
DSG_CURR_capture.outData = (int16_t)outputf;
|
DSG_CURR_capture.outData = (int16_t)outputf;
|
||||||
|
|
||||||
/* 初始化输入输出缓存指针 */
|
/* 初始化输入输出缓存指针 */
|
||||||
inputF32 = &PV_VOLT_IN_capture.IODataF[0];
|
inputF32 = &PV_VOLT_IN_capture.inDataF[0];
|
||||||
outputF32 = &outputf;
|
outputF32 = &outputf;
|
||||||
arm_fir_f32(&armFirInstanceF32, inputF32, outputF32, blockSize);
|
arm_fir_f32(&armFirInstanceF32, inputF32, outputF32, blockSize);
|
||||||
PV_VOLT_IN_capture.outData = (int16_t)outputf;
|
PV_VOLT_IN_capture.outData = (int16_t)outputf;
|
||||||
|
|
||||||
/* 初始化输入输出缓存指针 */
|
/* 初始化输入输出缓存指针 */
|
||||||
inputF32 = &CHG_CURR_capture.IODataF[0];
|
inputF32 = &CHG_CURR_capture.inDataF[0];
|
||||||
outputF32 = &outputf;
|
outputF32 = &outputf;
|
||||||
arm_fir_f32(&armFirInstanceF32, inputF32, outputF32, blockSize);
|
arm_fir_f32(&armFirInstanceF32, inputF32, outputF32, blockSize);
|
||||||
CHG_CURR_capture.outData = (int16_t)outputf;
|
CHG_CURR_capture.outData = (int16_t)outputf;
|
||||||
|
|
|
@ -21,9 +21,6 @@ static timeData checkTimeData;
|
||||||
|
|
||||||
volatile static uint32_t hw_sys_tick_ms = 0; //ms 自增计数变量
|
volatile static uint32_t hw_sys_tick_ms = 0; //ms 自增计数变量
|
||||||
|
|
||||||
float checkAbnormalTime;
|
|
||||||
|
|
||||||
|
|
||||||
#define tim TIM15
|
#define tim TIM15
|
||||||
#define timLard 36000.0
|
#define timLard 36000.0
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,16 @@ void HD_taskBaseTim_Init(void)
|
||||||
MX_TIM16_Init();
|
MX_TIM16_Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 该定时器中断中检测异常情况,并完成数据的采集
|
||||||
|
* @param None
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void HD_checkAbnormalTim_Init(void)
|
||||||
|
{
|
||||||
|
MX_TIM17_Init();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 该定时器用来计时从而判断执行时间
|
* @brief 该定时器用来计时从而判断执行时间
|
||||||
* @param None
|
* @param None
|
||||||
|
|
|
@ -58,6 +58,7 @@ void SysTick_Handler(void);
|
||||||
void DMA1_Channel1_IRQHandler(void);
|
void DMA1_Channel1_IRQHandler(void);
|
||||||
void TIM1_BRK_TIM15_IRQHandler(void);
|
void TIM1_BRK_TIM15_IRQHandler(void);
|
||||||
void TIM1_UP_TIM16_IRQHandler(void);
|
void TIM1_UP_TIM16_IRQHandler(void);
|
||||||
|
void TIM1_TRG_COM_TIM17_IRQHandler(void);
|
||||||
void USART2_IRQHandler(void);
|
void USART2_IRQHandler(void);
|
||||||
void USART3_IRQHandler(void);
|
void USART3_IRQHandler(void);
|
||||||
void EXTI15_10_IRQHandler(void);
|
void EXTI15_10_IRQHandler(void);
|
||||||
|
|
|
@ -42,6 +42,8 @@ extern TIM_HandleTypeDef htim15;
|
||||||
|
|
||||||
extern TIM_HandleTypeDef htim16;
|
extern TIM_HandleTypeDef htim16;
|
||||||
|
|
||||||
|
extern TIM_HandleTypeDef htim17;
|
||||||
|
|
||||||
/* USER CODE BEGIN Private defines */
|
/* USER CODE BEGIN Private defines */
|
||||||
|
|
||||||
/* USER CODE END Private defines */
|
/* USER CODE END Private defines */
|
||||||
|
@ -51,6 +53,7 @@ void MX_TIM6_Init(void);
|
||||||
void MX_TIM7_Init(void);
|
void MX_TIM7_Init(void);
|
||||||
void MX_TIM15_Init(void);
|
void MX_TIM15_Init(void);
|
||||||
void MX_TIM16_Init(void);
|
void MX_TIM16_Init(void);
|
||||||
|
void MX_TIM17_Init(void);
|
||||||
|
|
||||||
void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
|
void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
|
||||||
|
|
||||||
|
|
|
@ -93,19 +93,20 @@ int main(void)
|
||||||
/* USER CODE END SysInit */
|
/* USER CODE END SysInit */
|
||||||
|
|
||||||
/* Initialize all configured peripherals */
|
/* Initialize all configured peripherals */
|
||||||
MX_GPIO_Init();
|
// MX_GPIO_Init();
|
||||||
MX_DMA_Init();
|
// MX_DMA_Init();
|
||||||
MX_ADC1_Init();
|
// MX_ADC1_Init();
|
||||||
MX_ADC2_Init();
|
// MX_ADC2_Init();
|
||||||
MX_SPI1_Init();
|
// MX_SPI1_Init();
|
||||||
MX_TIM3_Init();
|
// MX_TIM3_Init();
|
||||||
MX_TIM6_Init();
|
// MX_TIM6_Init();
|
||||||
MX_UART4_Init();
|
// MX_UART4_Init();
|
||||||
MX_USART2_UART_Init();
|
// MX_USART2_UART_Init();
|
||||||
MX_USART3_UART_Init();
|
// MX_USART3_UART_Init();
|
||||||
MX_TIM7_Init();
|
// MX_TIM7_Init();
|
||||||
MX_TIM16_Init();
|
// MX_TIM16_Init();
|
||||||
MX_TIM15_Init();
|
// MX_TIM17_Init();
|
||||||
|
// MX_TIM15_Init();
|
||||||
/* USER CODE BEGIN 2 */
|
/* USER CODE BEGIN 2 */
|
||||||
|
|
||||||
test();
|
test();
|
||||||
|
|
|
@ -60,6 +60,7 @@ extern TIM_HandleTypeDef htim6;
|
||||||
extern TIM_HandleTypeDef htim7;
|
extern TIM_HandleTypeDef htim7;
|
||||||
extern TIM_HandleTypeDef htim15;
|
extern TIM_HandleTypeDef htim15;
|
||||||
extern TIM_HandleTypeDef htim16;
|
extern TIM_HandleTypeDef htim16;
|
||||||
|
extern TIM_HandleTypeDef htim17;
|
||||||
extern UART_HandleTypeDef huart2;
|
extern UART_HandleTypeDef huart2;
|
||||||
extern UART_HandleTypeDef huart3;
|
extern UART_HandleTypeDef huart3;
|
||||||
extern TIM_HandleTypeDef htim1;
|
extern TIM_HandleTypeDef htim1;
|
||||||
|
@ -255,6 +256,20 @@ void TIM1_UP_TIM16_IRQHandler(void)
|
||||||
/* USER CODE END TIM1_UP_TIM16_IRQn 1 */
|
/* USER CODE END TIM1_UP_TIM16_IRQn 1 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function handles TIM1 trigger and commutation interrupts and TIM17 global interrupt.
|
||||||
|
*/
|
||||||
|
void TIM1_TRG_COM_TIM17_IRQHandler(void)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN TIM1_TRG_COM_TIM17_IRQn 0 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM1_TRG_COM_TIM17_IRQn 0 */
|
||||||
|
HAL_TIM_IRQHandler(&htim17);
|
||||||
|
/* USER CODE BEGIN TIM1_TRG_COM_TIM17_IRQn 1 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM1_TRG_COM_TIM17_IRQn 1 */
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles USART2 global interrupt / USART2 wake-up interrupt through EXTI line 26.
|
* @brief This function handles USART2 global interrupt / USART2 wake-up interrupt through EXTI line 26.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -29,6 +29,7 @@ TIM_HandleTypeDef htim6;
|
||||||
TIM_HandleTypeDef htim7;
|
TIM_HandleTypeDef htim7;
|
||||||
TIM_HandleTypeDef htim15;
|
TIM_HandleTypeDef htim15;
|
||||||
TIM_HandleTypeDef htim16;
|
TIM_HandleTypeDef htim16;
|
||||||
|
TIM_HandleTypeDef htim17;
|
||||||
|
|
||||||
/* TIM3 init function */
|
/* TIM3 init function */
|
||||||
void MX_TIM3_Init(void)
|
void MX_TIM3_Init(void)
|
||||||
|
@ -155,9 +156,9 @@ void MX_TIM15_Init(void)
|
||||||
|
|
||||||
/* USER CODE END TIM15_Init 1 */
|
/* USER CODE END TIM15_Init 1 */
|
||||||
htim15.Instance = TIM15;
|
htim15.Instance = TIM15;
|
||||||
htim15.Init.Prescaler = 10;
|
htim15.Init.Prescaler = 1;
|
||||||
htim15.Init.CounterMode = TIM_COUNTERMODE_UP;
|
htim15.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||||
htim15.Init.Period = 7199;
|
htim15.Init.Period = 35999;
|
||||||
htim15.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
htim15.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||||
htim15.Init.RepetitionCounter = 0;
|
htim15.Init.RepetitionCounter = 0;
|
||||||
htim15.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
htim15.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
||||||
|
@ -207,6 +208,33 @@ void MX_TIM16_Init(void)
|
||||||
|
|
||||||
/* USER CODE END TIM16_Init 2 */
|
/* USER CODE END TIM16_Init 2 */
|
||||||
|
|
||||||
|
}
|
||||||
|
/* TIM17 init function */
|
||||||
|
void MX_TIM17_Init(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* USER CODE BEGIN TIM17_Init 0 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM17_Init 0 */
|
||||||
|
|
||||||
|
/* USER CODE BEGIN TIM17_Init 1 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM17_Init 1 */
|
||||||
|
htim17.Instance = TIM17;
|
||||||
|
htim17.Init.Prescaler = 71;
|
||||||
|
htim17.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||||
|
htim17.Init.Period = 199;
|
||||||
|
htim17.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||||
|
htim17.Init.RepetitionCounter = 0;
|
||||||
|
htim17.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
||||||
|
if (HAL_TIM_Base_Init(&htim17) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
/* USER CODE BEGIN TIM17_Init 2 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM17_Init 2 */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* tim_pwmHandle)
|
void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* tim_pwmHandle)
|
||||||
|
@ -288,6 +316,21 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle)
|
||||||
|
|
||||||
/* USER CODE END TIM16_MspInit 1 */
|
/* USER CODE END TIM16_MspInit 1 */
|
||||||
}
|
}
|
||||||
|
else if(tim_baseHandle->Instance==TIM17)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN TIM17_MspInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM17_MspInit 0 */
|
||||||
|
/* TIM17 clock enable */
|
||||||
|
__HAL_RCC_TIM17_CLK_ENABLE();
|
||||||
|
|
||||||
|
/* TIM17 interrupt Init */
|
||||||
|
HAL_NVIC_SetPriority(TIM1_TRG_COM_TIM17_IRQn, 0, 0);
|
||||||
|
HAL_NVIC_EnableIRQ(TIM1_TRG_COM_TIM17_IRQn);
|
||||||
|
/* USER CODE BEGIN TIM17_MspInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM17_MspInit 1 */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void HAL_TIM_MspPostInit(TIM_HandleTypeDef* timHandle)
|
void HAL_TIM_MspPostInit(TIM_HandleTypeDef* timHandle)
|
||||||
{
|
{
|
||||||
|
@ -392,6 +435,20 @@ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* tim_baseHandle)
|
||||||
|
|
||||||
/* USER CODE END TIM16_MspDeInit 1 */
|
/* USER CODE END TIM16_MspDeInit 1 */
|
||||||
}
|
}
|
||||||
|
else if(tim_baseHandle->Instance==TIM17)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN TIM17_MspDeInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM17_MspDeInit 0 */
|
||||||
|
/* Peripheral clock disable */
|
||||||
|
__HAL_RCC_TIM17_CLK_DISABLE();
|
||||||
|
|
||||||
|
/* TIM17 interrupt Deinit */
|
||||||
|
HAL_NVIC_DisableIRQ(TIM1_TRG_COM_TIM17_IRQn);
|
||||||
|
/* USER CODE BEGIN TIM17_MspDeInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM17_MspDeInit 1 */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* USER CODE BEGIN 1 */
|
/* USER CODE BEGIN 1 */
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1439,6 +1439,9 @@
|
||||||
<file>
|
<file>
|
||||||
<name>$PROJ_DIR$\..\APP\application\Src\start.c</name>
|
<name>$PROJ_DIR$\..\APP\application\Src\start.c</name>
|
||||||
</file>
|
</file>
|
||||||
|
<file>
|
||||||
|
<name>$PROJ_DIR$\..\APP\application\Src\task.c</name>
|
||||||
|
</file>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<name>businessLogic</name>
|
<name>businessLogic</name>
|
||||||
|
@ -1460,9 +1463,6 @@
|
||||||
<file>
|
<file>
|
||||||
<name>$PROJ_DIR$\..\APP\businessLogic\Src\parameter.c</name>
|
<name>$PROJ_DIR$\..\APP\businessLogic\Src\parameter.c</name>
|
||||||
</file>
|
</file>
|
||||||
<file>
|
|
||||||
<name>$PROJ_DIR$\..\APP\businessLogic\Src\task.c</name>
|
|
||||||
</file>
|
|
||||||
<file>
|
<file>
|
||||||
<name>$PROJ_DIR$\..\APP\businessLogic\Src\test.c</name>
|
<name>$PROJ_DIR$\..\APP\businessLogic\Src\test.c</name>
|
||||||
</file>
|
</file>
|
||||||
|
|
|
@ -69,9 +69,10 @@ Mcu.IP0=ADC1
|
||||||
Mcu.IP1=ADC2
|
Mcu.IP1=ADC2
|
||||||
Mcu.IP10=TIM15
|
Mcu.IP10=TIM15
|
||||||
Mcu.IP11=TIM16
|
Mcu.IP11=TIM16
|
||||||
Mcu.IP12=UART4
|
Mcu.IP12=TIM17
|
||||||
Mcu.IP13=USART2
|
Mcu.IP13=UART4
|
||||||
Mcu.IP14=USART3
|
Mcu.IP14=USART2
|
||||||
|
Mcu.IP15=USART3
|
||||||
Mcu.IP2=DMA
|
Mcu.IP2=DMA
|
||||||
Mcu.IP3=NVIC
|
Mcu.IP3=NVIC
|
||||||
Mcu.IP4=RCC
|
Mcu.IP4=RCC
|
||||||
|
@ -80,7 +81,7 @@ Mcu.IP6=SYS
|
||||||
Mcu.IP7=TIM3
|
Mcu.IP7=TIM3
|
||||||
Mcu.IP8=TIM6
|
Mcu.IP8=TIM6
|
||||||
Mcu.IP9=TIM7
|
Mcu.IP9=TIM7
|
||||||
Mcu.IPNb=15
|
Mcu.IPNb=16
|
||||||
Mcu.Name=STM32G431R(6-8-B)Tx
|
Mcu.Name=STM32G431R(6-8-B)Tx
|
||||||
Mcu.Package=LQFP64
|
Mcu.Package=LQFP64
|
||||||
Mcu.Pin0=PC13
|
Mcu.Pin0=PC13
|
||||||
|
@ -114,14 +115,15 @@ Mcu.Pin33=VP_TIM6_VS_ClockSourceINT
|
||||||
Mcu.Pin34=VP_TIM7_VS_ClockSourceINT
|
Mcu.Pin34=VP_TIM7_VS_ClockSourceINT
|
||||||
Mcu.Pin35=VP_TIM15_VS_ClockSourceINT
|
Mcu.Pin35=VP_TIM15_VS_ClockSourceINT
|
||||||
Mcu.Pin36=VP_TIM16_VS_ClockSourceINT
|
Mcu.Pin36=VP_TIM16_VS_ClockSourceINT
|
||||||
Mcu.Pin37=VP_STMicroelectronics.X-CUBE-ALGOBUILD_VS_DSPOoLibraryJjLibrary_1.4.0_1.4.0
|
Mcu.Pin37=VP_TIM17_VS_ClockSourceINT
|
||||||
|
Mcu.Pin38=VP_STMicroelectronics.X-CUBE-ALGOBUILD_VS_DSPOoLibraryJjLibrary_1.4.0_1.4.0
|
||||||
Mcu.Pin4=PC2
|
Mcu.Pin4=PC2
|
||||||
Mcu.Pin5=PA0
|
Mcu.Pin5=PA0
|
||||||
Mcu.Pin6=PA1
|
Mcu.Pin6=PA1
|
||||||
Mcu.Pin7=PA2
|
Mcu.Pin7=PA2
|
||||||
Mcu.Pin8=PA3
|
Mcu.Pin8=PA3
|
||||||
Mcu.Pin9=PA4
|
Mcu.Pin9=PA4
|
||||||
Mcu.PinsNb=38
|
Mcu.PinsNb=39
|
||||||
Mcu.ThirdParty0=STMicroelectronics.X-CUBE-ALGOBUILD.1.4.0
|
Mcu.ThirdParty0=STMicroelectronics.X-CUBE-ALGOBUILD.1.4.0
|
||||||
Mcu.ThirdPartyNb=1
|
Mcu.ThirdPartyNb=1
|
||||||
Mcu.UserConstants=
|
Mcu.UserConstants=
|
||||||
|
@ -141,6 +143,7 @@ NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
|
||||||
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||||
NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:false
|
NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:false
|
||||||
NVIC.TIM1_BRK_TIM15_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
NVIC.TIM1_BRK_TIM15_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
||||||
|
NVIC.TIM1_TRG_COM_TIM17_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
||||||
NVIC.TIM1_UP_TIM16_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:true
|
NVIC.TIM1_UP_TIM16_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:true
|
||||||
NVIC.TIM6_DAC_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
NVIC.TIM6_DAC_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
||||||
NVIC.TIM7_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
NVIC.TIM7_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
||||||
|
@ -374,6 +377,9 @@ TIM15.Prescaler=10
|
||||||
TIM16.IPParameters=Prescaler,PeriodNoDither
|
TIM16.IPParameters=Prescaler,PeriodNoDither
|
||||||
TIM16.PeriodNoDither=999
|
TIM16.PeriodNoDither=999
|
||||||
TIM16.Prescaler=71
|
TIM16.Prescaler=71
|
||||||
|
TIM17.IPParameters=Prescaler,PeriodNoDither
|
||||||
|
TIM17.PeriodNoDither=199
|
||||||
|
TIM17.Prescaler=71
|
||||||
TIM3.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4
|
TIM3.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4
|
||||||
TIM3.IPParameters=PeriodNoDither,Channel-PWM Generation4 CH4
|
TIM3.IPParameters=PeriodNoDither,Channel-PWM Generation4 CH4
|
||||||
TIM3.PeriodNoDither=720
|
TIM3.PeriodNoDither=720
|
||||||
|
@ -401,6 +407,8 @@ VP_TIM15_VS_ClockSourceINT.Mode=Internal
|
||||||
VP_TIM15_VS_ClockSourceINT.Signal=TIM15_VS_ClockSourceINT
|
VP_TIM15_VS_ClockSourceINT.Signal=TIM15_VS_ClockSourceINT
|
||||||
VP_TIM16_VS_ClockSourceINT.Mode=Enable_Timer
|
VP_TIM16_VS_ClockSourceINT.Mode=Enable_Timer
|
||||||
VP_TIM16_VS_ClockSourceINT.Signal=TIM16_VS_ClockSourceINT
|
VP_TIM16_VS_ClockSourceINT.Signal=TIM16_VS_ClockSourceINT
|
||||||
|
VP_TIM17_VS_ClockSourceINT.Mode=Enable_Timer
|
||||||
|
VP_TIM17_VS_ClockSourceINT.Signal=TIM17_VS_ClockSourceINT
|
||||||
VP_TIM6_VS_ClockSourceINT.Mode=Enable_Timer
|
VP_TIM6_VS_ClockSourceINT.Mode=Enable_Timer
|
||||||
VP_TIM6_VS_ClockSourceINT.Signal=TIM6_VS_ClockSourceINT
|
VP_TIM6_VS_ClockSourceINT.Signal=TIM6_VS_ClockSourceINT
|
||||||
VP_TIM7_VS_ClockSourceINT.Mode=Enable_Timer
|
VP_TIM7_VS_ClockSourceINT.Mode=Enable_Timer
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
/*
|
|
||||||
* Filter Coefficients (C Source) generated by the Filter Design and Analysis Tool
|
|
||||||
* Generated by MATLAB(R) 9.13 and Signal Processing Toolbox 9.1.
|
|
||||||
* Generated on: 09-Dec-2024 10:57:55
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 离散时间 FIR 滤波器(实数)
|
|
||||||
* ----------------
|
|
||||||
* 滤波器结构 : 直接型 FIR
|
|
||||||
* 滤波器长度 : 4
|
|
||||||
* 稳定 : 是
|
|
||||||
* 线性相位 : 是 (Type 2)
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* General type conversion for MATLAB generated C-code */
|
|
||||||
// #include "tmwtypes.h"
|
|
||||||
/*
|
|
||||||
* Expected path to tmwtypes.h
|
|
||||||
* C:\Program Files\MATLAB\R2022b\extern\include\tmwtypes.h
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* Warning - Filter coefficients were truncated to fit specified data type.
|
|
||||||
* The resulting response may not match generated theoretical response.
|
|
||||||
* Use the Filter Design & Analysis Tool to design accurate
|
|
||||||
* single-precision filter coefficients.
|
|
||||||
*/
|
|
||||||
// const int BL = 4;
|
|
||||||
// const real32_T B[4] = {
|
|
||||||
// 0.178709805, 0.3671073616, 0.3671073616, 0.178709805
|
|
||||||
// };
|
|
Loading…
Reference in New Issue