Compare commits
2 Commits
228f632d95
...
fbc0117da7
Author | SHA1 | Date |
---|---|---|
起床就犯困 | fbc0117da7 | |
起床就犯困 | b85fbca8e0 |
|
@ -50,14 +50,15 @@ typedef struct _config_info{
|
||||||
uint16_t floatI; /* 电压高于该(ConstantVoltageV / 100)且电流低于(FloatI / 100)进行浮充充电 */
|
uint16_t floatI; /* 电压高于该(ConstantVoltageV / 100)且电流低于(FloatI / 100)进行浮充充电 */
|
||||||
uint16_t startSolarOpenCircuitV; /* 太阳能板开路电压高于该(电压 / 100)开始充电 */
|
uint16_t startSolarOpenCircuitV; /* 太阳能板开路电压高于该(电压 / 100)开始充电 */
|
||||||
uint16_t stopSolarOpenCircuitV; /* 太阳能板开路电压高于该(电压 / 100)停止充电 */
|
uint16_t stopSolarOpenCircuitV; /* 太阳能板开路电压高于该(电压 / 100)停止充电 */
|
||||||
uint16_t noBatteryChargeV; /* 没有电池时的输出电压 */
|
uint16_t constantVoltageChargeV; /* 恒压充电时的输出电压 */
|
||||||
|
uint16_t trickleChargeC; /* 涓流充电电流 */
|
||||||
uint16_t FloatTime; /* 浮充时间(秒) */
|
uint16_t FloatTime; /* 浮充时间(秒) */
|
||||||
uint16_t checkSolarOpenCircuitVTime; /* 启动任务中太阳能板开路电压检测时间 */
|
uint16_t checkSolarOpenCircuitVTime; /* 启动任务中太阳能板开路电压检测时间 */
|
||||||
uint16_t registerRefreshTime; /* 寄存器数据刷新时间 */
|
uint16_t registerRefreshTime; /* 寄存器数据刷新时间 */
|
||||||
uint16_t resRefreshTime; /* 线阻计算间隔时长 */
|
uint16_t resRefreshTime; /* 线阻计算间隔时长 */
|
||||||
uint16_t sensorEnableBroadcastTime; /* 传感器运行再次注册的间隔 */
|
uint16_t sensorEnableBroadcastTime; /* 传感器运行再次注册的间隔 */
|
||||||
uint16_t HighSideMosTemperature_stop; /* 当上桥温度达到该值时,停止输出 */
|
uint16_t HighSideMosTemperature_stop; /* 当上桥温度达到该值时,停止输出 */
|
||||||
uint16_t HighSideMosTemperature_end; /* 当上桥温度上升到该值时,输出稳定在12V,降低功率运行 */
|
uint16_t HighSideMosTemperature_end; /* 当上桥温度上升到该值时,降低功率运行 */
|
||||||
uint16_t HighSideMosTemperature_start; /* 当上桥温度降低到该值时,按照正常情况输出 */
|
uint16_t HighSideMosTemperature_start; /* 当上桥温度降低到该值时,按照正常情况输出 */
|
||||||
uint8_t end_Flag; /* 结束标志 */
|
uint8_t end_Flag; /* 结束标志 */
|
||||||
}config_info;
|
}config_info;
|
||||||
|
|
|
@ -18,7 +18,7 @@ void MpptMode(void);
|
||||||
void mppt_constantVoltage(float InVoltage);
|
void mppt_constantVoltage(float InVoltage);
|
||||||
void test(void);
|
void test(void);
|
||||||
void printf_data(void);
|
void printf_data(void);
|
||||||
float_t get_capturedata(float_t (*fun)(void));
|
//float_t get_capturedata(float_t (*fun)(void));
|
||||||
uint16_t get_mpptMode(void);
|
uint16_t get_mpptMode(void);
|
||||||
|
|
||||||
#endif /* APP_INC_MPPT_CONTROL_H_ */
|
#endif /* APP_INC_MPPT_CONTROL_H_ */
|
||||||
|
|
|
@ -30,13 +30,14 @@ typedef enum
|
||||||
SL_Register_address = 0x0001, /* 地址 */
|
SL_Register_address = 0x0001, /* 地址 */
|
||||||
SL_Register_Access_Node_Type = 0x0002, /* 接入节点类型 */
|
SL_Register_Access_Node_Type = 0x0002, /* 接入节点类型 */
|
||||||
SL_Register_Communication_Methods = 0x0003, /* 通信方式 */
|
SL_Register_Communication_Methods = 0x0003, /* 通信方式 */
|
||||||
SL_Register_Battery_Voltage = 0x0100, /* 电池电压 */
|
SL_Register_Output_Voltage = 0x0100, /* 输出电压 */
|
||||||
SL_Register_Charg_Current = 0x0101, /* 充电电流(流向电池+负载) */
|
SL_Register_Battery_Voltage = 0x0101, /* 电池电压 */
|
||||||
SL_Register_Discharg_Current = 0x0102, /* 放电电流(流向负载) */
|
SL_Register_Charg_Current = 0x0102, /* 充电电流(流向电池+负载) */
|
||||||
SL_Register_Solar_Open_Circuit_Voltage = 0x0103, /* 太阳能开路电压 */
|
SL_Register_Discharg_Current = 0x0103, /* 放电电流(流向负载) */
|
||||||
SL_Register_HighSideMos_Temperature = 0x0104, /* 高端mos的温度 */
|
SL_Register_Solar_Open_Circuit_Voltage = 0x0104, /* 太阳能开路电压 */
|
||||||
SL_Register_DischargMos_State = 0x0105, /* 放电mos的状态 */
|
SL_Register_HighSideMos_Temperature = 0x0105, /* 高端mos的温度 */
|
||||||
SL_Register_MPPT_Mode = 0x0106, /* 工作模式 */
|
SL_Register_DischargMos_State = 0x0106, /* 放电mos的状态 */
|
||||||
|
SL_Register_MPPT_Mode = 0x0107, /* 工作模式 */
|
||||||
}SL_Mppt_MsgRegister;
|
}SL_Mppt_MsgRegister;
|
||||||
|
|
||||||
/* 注册状态 */
|
/* 注册状态 */
|
||||||
|
@ -223,9 +224,11 @@ typedef struct _SL_Mppt_para{
|
||||||
uint8_t address[7]; /* 地址 */
|
uint8_t address[7]; /* 地址 */
|
||||||
uint16_t Access_Node_Type; /* 接入节点类型 */
|
uint16_t Access_Node_Type; /* 接入节点类型 */
|
||||||
uint16_t Communication_Methods; /* 通信方式 */
|
uint16_t Communication_Methods; /* 通信方式 */
|
||||||
|
float_t Output_Voltage; /* 输出电压 */
|
||||||
float_t Battery_Voltage; /* 电池电压 */
|
float_t Battery_Voltage; /* 电池电压 */
|
||||||
float_t Charg_Current; /* 充电电流(流向电池+负载) */
|
float_t Charg_Current; /* 充电电流(流向电池+负载) */
|
||||||
float_t Discharg_Current; /* 放电电流(流向负载) */
|
float_t Discharg_Current; /* 放电电流(流向负载) */
|
||||||
|
float_t Input_Voltage; /* 太阳能开路电压 */
|
||||||
float_t Solar_Open_Circuit_Voltage; /* 太阳能开路电压 */
|
float_t Solar_Open_Circuit_Voltage; /* 太阳能开路电压 */
|
||||||
float_t HighSideMos_Temperature; /* 高端mos的温度 */
|
float_t HighSideMos_Temperature; /* 高端mos的温度 */
|
||||||
uint16_t DischargMos_State; /* 放电mos的状态 */
|
uint16_t DischargMos_State; /* 放电mos的状态 */
|
||||||
|
|
|
@ -12,6 +12,10 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
|
#include "uart_dev.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#define ONLYPOWER 1
|
||||||
|
|
||||||
#define CHG_CURR ADC_Channel_1
|
#define CHG_CURR ADC_Channel_1
|
||||||
#define PV_VOLT_OUT ADC_Channel_2
|
#define PV_VOLT_OUT ADC_Channel_2
|
||||||
|
@ -23,14 +27,38 @@
|
||||||
|
|
||||||
//#define enable_Printf_VI
|
//#define enable_Printf_VI
|
||||||
|
|
||||||
|
#ifdef ONLYPOWER
|
||||||
|
/* 光伏充电输出电流比例,放大倍数*电阻 */
|
||||||
|
const float P_CHG_CURR = (1.0 / (50 * 0.005 / 2));
|
||||||
|
/* 光伏充电输出电压比例,分压系数(放电时采集不准) */
|
||||||
|
//const float P_PV_VOLT_OUT = (47.0 + 10.0) / 10.0;
|
||||||
|
const float P_PV_VOLT_OUT = (47.0 + 4.7) / 4.7;
|
||||||
|
/* 放电电流采集电流倍数 */
|
||||||
|
const float P_DSG_CURR = (1.0 / (50 * 0.005 / 2));
|
||||||
|
///* 光伏1开路输出电压比例 */
|
||||||
|
//const float P_PV1_VOLT_IN = (100 + 4.7) / 4.7;
|
||||||
|
const float P_PV1_VOLT_IN = (100.0 + 4.7) / 4.7;
|
||||||
|
/* 光伏1开路输出电压比例 */
|
||||||
|
//const float P_PV1_VOLT_IN = (47 + 4.7) / 4.7;
|
||||||
|
/* 系统电源电压比例 */
|
||||||
|
const float P_PV_VOLT_IN1 = (47 + 4.7) / 4.7;
|
||||||
|
/* 温度采集比例 */
|
||||||
|
//const float P_MOSFET_TEMPER = 0;
|
||||||
|
/* 光伏2开路输出电压比例 */
|
||||||
|
const float P_PV2_VOLT_IN = (100.0 + 4.7) / 4.7;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ONLYPOWER
|
||||||
/* 光伏充电输出电流比例,放大倍数*电阻 */
|
/* 光伏充电输出电流比例,放大倍数*电阻 */
|
||||||
const float P_CHG_CURR = (1.0 / (50 * 0.005));
|
const float P_CHG_CURR = (1.0 / (50 * 0.005));
|
||||||
/* 光伏充电输出电压比例,分压系数(放电时采集不准) */
|
/* 光伏充电输出电压比例,分压系数(放电时采集不准) */
|
||||||
const float P_PV_VOLT_OUT = (47.0 + 10.0) / 10.0;
|
//const float P_PV_VOLT_OUT = (47.0 + 10.0) / 10.0;
|
||||||
|
const float P_PV_VOLT_OUT = (47.0 + 4.7) / 4.7;
|
||||||
/* 放电电流采集电流倍数 */
|
/* 放电电流采集电流倍数 */
|
||||||
const float P_DSG_CURR = (1.0 / (50 * 0.005));
|
const float P_DSG_CURR = (1.0 / (50 * 0.005));
|
||||||
///* 光伏1开路输出电压比例 */
|
///* 光伏1开路输出电压比例 */
|
||||||
const float P_PV1_VOLT_IN = (100 + 4.7) / 4.7;
|
//const float P_PV1_VOLT_IN = (100 + 4.7) / 4.7;
|
||||||
|
const float P_PV1_VOLT_IN = (47.0 + 4.7) / 4.7;
|
||||||
/* 光伏1开路输出电压比例 */
|
/* 光伏1开路输出电压比例 */
|
||||||
//const float P_PV1_VOLT_IN = (47 + 4.7) / 4.7;
|
//const float P_PV1_VOLT_IN = (47 + 4.7) / 4.7;
|
||||||
/* 系统电源电压比例 */
|
/* 系统电源电压比例 */
|
||||||
|
@ -39,42 +67,116 @@ const float P_PV_VOLT_IN1 = (47 + 4.7) / 4.7;
|
||||||
//const float P_MOSFET_TEMPER = 0;
|
//const float P_MOSFET_TEMPER = 0;
|
||||||
/* 光伏2开路输出电压比例 */
|
/* 光伏2开路输出电压比例 */
|
||||||
const float P_PV2_VOLT_IN = (47 + 4.7) / 4.7;
|
const float P_PV2_VOLT_IN = (47 + 4.7) / 4.7;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* 温度的adc值的个数 */
|
/* 温度的adc值的个数 */
|
||||||
#define mosTemperADCLen 241
|
#define mosTemperADCLen 241
|
||||||
|
///* 温度 */
|
||||||
|
//const uint16_t mosTemperADC[mosTemperADCLen] = {
|
||||||
|
// 3707, 3697, 3687, 3676, 3665, 3654, 3643, 3632, 3620, 3608, /* -20 - -15.5 ℃ */
|
||||||
|
// 3596, 3584, 3571, 3559, 3546, 3533, 3519, 3506, 3492, 3478, /* -15 - -10.5 ℃ */
|
||||||
|
// 3464, 3449, 3434, 3419, 3404, 3389, 3373, 3358, 3341, 3325, /* -10 - -5.5 ℃ */
|
||||||
|
// 3309, 3292, 3275, 3258, 3241, 3223, 3205, 3187, 3169, 3151, /* -5 - -0.5 ℃ */
|
||||||
|
// 3132, 3114, 3095, 3075, 3056, 3037, 3017, 2997, 2977, 2957, /* 0 - 4.5 ℃ */
|
||||||
|
// 2936, 2916, 2895, 2874, 2854, 2832, 2811, 2790, 2768, 2747, /* 9 - 9.5 ℃ */
|
||||||
|
// 2725, 2703, 2681, 2659, 2637, 2615, 2592, 2570, 2548, 2525, /* 10 - 14.5 ℃ */
|
||||||
|
// 2503, 2480, 2457, 2435, 2412, 2389, 2366, 2343, 2321, 2298, /* 15 - 19.5 ℃ */
|
||||||
|
// 2275, 2252, 2229, 2207, 2184, 2161, 2138, 2116, 2093, 2071, /* 20 - 24.5 ℃ */
|
||||||
|
// 2048, 2026, 2003, 1981, 1959, 1937, 1914, 1893, 1871, 1849, /* 25 - 29.5 ℃ */
|
||||||
|
// 1827, 1806, 1784, 1763, 1742, 1721, 1700, 1679, 1658, 1638, /* 30 - 34.5 ℃ */
|
||||||
|
// 1617, 1597, 1577, 1557, 1537, 1518, 1498, 1479, 1460, 1441, /* 35 - 39.5 ℃ */
|
||||||
|
// 1422, 1403, 1385, 1366, 1348, 1330, 1312, 1295, 1277, 1260, /* 40 - 44.5 ℃ */
|
||||||
|
// 1243, 1226, 1209, 1192, 1176, 1160, 1144, 1128, 1112, 1097, /* 45 - 49.5 ℃ */
|
||||||
|
// 1081, 1066, 1051, 1036, 1022, 1007, 993, 979, 965, 951, /* 50 - 54.5 ℃ */
|
||||||
|
// 938, 924, 911, 898, 885, 872, 860, 848, 835, 823, /* 55 - 59.5 ℃ */
|
||||||
|
// 811, 800, 788, 777, 765, 754, 743, 732, 722, 711, /* 60 - 64.5 ℃ */
|
||||||
|
// 701, 691, 681, 671, 661, 651, 642, 632, 623, 614, /* 65 - 69.5 ℃ */
|
||||||
|
// 605, 596, 588, 579, 571, 562, 554, 546, 538, 530, /* 70 - 74.5 ℃ */
|
||||||
|
// 522, 515, 507, 500, 493, 486, 478, 471, 465, 458, /* 75 - 79.5 ℃ */
|
||||||
|
// 451, 445, 438, 432, 426, 420, 414, 408, 402, 396, /* 80 - 84.5 ℃ */
|
||||||
|
// 390, 385, 379, 374, 368, 363, 358, 353, 348, 343, /* 85 - 89.5 ℃ */
|
||||||
|
// 338, 333, 328, 324, 319, 315, 310, 306, 301, 297, /* 90 - 94.5 ℃ */
|
||||||
|
// 293, 289, 285, 281, 277, 273, 269, 266, 262, 258, /* 95 - 99.5 ℃ */
|
||||||
|
// 255 /* 100 ℃ */
|
||||||
|
//};
|
||||||
/* 温度 */
|
/* 温度 */
|
||||||
const uint16_t mosTemperADC[mosTemperADCLen] = {
|
const uint16_t mosTemperADC[mosTemperADCLen] = {
|
||||||
3707, 3697, 3687, 3676, 3665, 3654, 3643, 3632, 3620, 3608, /* -20 - -15.5 ¡æ */
|
4893, 4879, 4866, 4852, 4838, 4823, 4808, 4793, 4778, 4762, /* -20 - -15.5 ℃ */
|
||||||
3596, 3584, 3571, 3559, 3546, 3533, 3519, 3506, 3492, 3478, /* -15 - -10.5 ¡æ */
|
4746, 4730, 4714, 4697, 4680, 4663, 4645, 4627, 4609, 4590, /* -15 - -10.5 ℃ */
|
||||||
3464, 3449, 3434, 3419, 3404, 3389, 3373, 3358, 3341, 3325, /* -10 - -5.5 ¡æ */
|
4571, 4552, 4533, 4513, 4493, 4473, 4452, 4431, 4410, 4389, /* -10 - -5.5 ℃ */
|
||||||
3309, 3292, 3275, 3258, 3241, 3223, 3205, 3187, 3169, 3151, /* -5 - -0.5 ¡æ */
|
4367, 4345, 4323, 4300, 4277, 4254, 4231, 4207, 4183, 4159, /* -5 - -0.5 ℃ */
|
||||||
3132, 3114, 3095, 3075, 3056, 3037, 3017, 2997, 2977, 2957, /* 0 - 4.5 ¡æ */
|
4134, 4109, 4084, 4059, 4034, 4008, 3982, 3956, 3929, 3903, /* 0 - 4.5 ℃ */
|
||||||
2936, 2916, 2895, 2874, 2854, 2832, 2811, 2790, 2768, 2747, /* 9 - 9.5 ¡æ */
|
3876, 3849, 3821, 3794, 3766, 3738, 3710, 3682, 3654, 3625, /* 5 - 9.5 ℃ */
|
||||||
2725, 2703, 2681, 2659, 2637, 2615, 2592, 2570, 2548, 2525, /* 10 - 14.5 ¡æ */
|
3596, 3568, 3539, 3510, 3480, 3451, 3422, 3392, 3362, 3333, /* 10 - 14.5 ℃ */
|
||||||
2503, 2480, 2457, 2435, 2412, 2389, 2366, 2343, 2321, 2298, /* 15 - 19.5 ¡æ */
|
3303, 3273, 3243, 3213, 3183, 3153, 3123, 3093, 3063, 3033, /* 15 - 19.5 ℃ */
|
||||||
2275, 2252, 2229, 2207, 2184, 2161, 2138, 2116, 2093, 2071, /* 20 - 24.5 ¡æ */
|
3003, 2972, 2942, 2912, 2882, 2852, 2822, 2792, 2762, 2733, /* 20 - 24.5 ℃ */
|
||||||
2048, 2026, 2003, 1981, 1959, 1937, 1914, 1893, 1871, 1849, /* 25 - 29.5 ¡æ */
|
2703, 2673, 2644, 2614, 2585, 2556, 2527, 2498, 2469, 2440, /* 25 - 29.5 ℃ */
|
||||||
1827, 1806, 1784, 1763, 1742, 1721, 1700, 1679, 1658, 1638, /* 30 - 34.5 ¡æ */
|
2412, 2383, 2355, 2327, 2299, 2271, 2243, 2216, 2189, 2162, /* 30 - 34.5 ℃ */
|
||||||
1617, 1597, 1577, 1557, 1537, 1518, 1498, 1479, 1460, 1441, /* 35 - 39.5 ¡æ */
|
2135, 2108, 2081, 2055, 2029, 2003, 1977, 1952, 1926, 1901, /* 35 - 39.5 ℃ */
|
||||||
1422, 1403, 1385, 1366, 1348, 1330, 1312, 1295, 1277, 1260, /* 40 - 44.5 ¡æ */
|
1876, 1852, 1827, 1803, 1779, 1755, 1732, 1709, 1686, 1663, /* 40 - 44.5 ℃ */
|
||||||
1243, 1226, 1209, 1192, 1176, 1160, 1144, 1128, 1112, 1097, /* 45 - 49.5 ¡æ */
|
1640, 1618, 1596, 1574, 1552, 1531, 1510, 1489, 1468, 1447, /* 45 - 49.5 ℃ */
|
||||||
1081, 1066, 1051, 1036, 1022, 1007, 993, 979, 965, 951, /* 50 - 54.5 ¡æ */
|
1427, 1407, 1387, 1368, 1349, 1330, 1311, 1292, 1274, 1256, /* 50 - 54.5 ℃ */
|
||||||
938, 924, 911, 898, 885, 872, 860, 848, 835, 823, /* 55 - 59.5 ¡æ */
|
1238, 1220, 1203, 1185, 1168, 1151, 1135, 1119, 1102, 1086, /* 55 - 59.5 ℃ */
|
||||||
811, 800, 788, 777, 765, 754, 743, 732, 722, 711, /* 60 - 64.5 ¡æ */
|
1071, 1055, 1040, 1025, 1010, 995, 981, 967, 953, 939, /* 60 - 64.5 ℃ */
|
||||||
701, 691, 681, 671, 661, 651, 642, 632, 623, 614, /* 65 - 69.5 ¡æ */
|
925, 912, 898, 885, 872, 860, 847, 835, 822, 810, /* 65 - 69.5 ℃ */
|
||||||
605, 596, 588, 579, 571, 562, 554, 546, 538, 530, /* 70 - 74.5 ¡æ */
|
799, 787, 775, 764, 753, 742, 731, 721, 710, 700, /* 70 - 74.5 ℃ */
|
||||||
522, 515, 507, 500, 493, 486, 478, 471, 465, 458, /* 75 - 79.5 ¡æ */
|
690, 679, 670, 660, 650, 641, 631, 622, 613, 604, /* 75 - 79.5 ℃ */
|
||||||
451, 445, 438, 432, 426, 420, 414, 408, 402, 396, /* 80 - 84.5 ¡æ */
|
596, 587, 578, 570, 562, 554, 546, 538, 530, 523, /* 80 - 84.5 ℃ */
|
||||||
390, 385, 379, 374, 368, 363, 358, 353, 348, 343, /* 85 - 89.5 ¡æ */
|
515, 508, 500, 493, 486, 479, 472, 466, 459, 452, /* 85 - 89.5 ℃ */
|
||||||
338, 333, 328, 324, 319, 315, 310, 306, 301, 297, /* 90 - 94.5 ¡æ */
|
446, 440, 433, 427, 421, 415, 409, 404, 398, 392, /* 90 - 94.5 ℃ */
|
||||||
293, 289, 285, 281, 277, 273, 269, 266, 262, 258, /* 95 - 99.5 ¡æ */
|
387, 381, 376, 371, 366, 361, 355, 350, 346, 341, /* 95 - 99.5 ℃ */
|
||||||
255 /* 100 ¡æ */
|
336 /* 100 ℃ */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static uint16_t get_adc(uint8_t ADC_Channel);
|
static uint16_t get_adc(uint8_t ADC_Channel);
|
||||||
|
static uint16_t get_aftercalculationAdc(uint8_t ADC_Channel);
|
||||||
|
static uint16_t middleAverageFilter(uint8_t ADC_Channel);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 获取计算后的adc的值
|
||||||
|
* @param ADC_Channel ADC通道
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
uint16_t get_aftercalculationAdc(uint8_t ADC_Channel)
|
||||||
|
{
|
||||||
|
return middleAverageFilter(ADC_Channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define N 6
|
||||||
|
/**
|
||||||
|
* @brief 中位值平均滤波
|
||||||
|
* @param ADC_Channel ADC通道
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
uint16_t middleAverageFilter(uint8_t ADC_Channel)
|
||||||
|
{
|
||||||
|
uint16_t i,j,k;
|
||||||
|
uint16_t temp,sum = 0;
|
||||||
|
uint16_t value_buf[N];
|
||||||
|
for(i = 0; i < N; ++i)
|
||||||
|
{
|
||||||
|
value_buf[i] = get_adc(ADC_Channel);
|
||||||
|
}
|
||||||
|
/*从小到大冒泡排序*/
|
||||||
|
for(j = 0; j < N-1; ++j)
|
||||||
|
{
|
||||||
|
for(k = 0; k < N-j-1; ++k)
|
||||||
|
{
|
||||||
|
if(value_buf[k] > value_buf[k+1])
|
||||||
|
{
|
||||||
|
temp = value_buf[k];
|
||||||
|
value_buf[k] = value_buf[k+1];
|
||||||
|
value_buf[k+1] = temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(i = 2; i < N-2; ++i)
|
||||||
|
{
|
||||||
|
sum += value_buf[i];
|
||||||
|
}
|
||||||
|
return sum/(N-4);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 将采集的adc进行校准
|
* @brief 将采集的adc进行校准
|
||||||
|
@ -97,13 +199,14 @@ uint16_t Get_ConversionVal(int16_t val)
|
||||||
*/
|
*/
|
||||||
uint16_t get_adc(uint8_t ADC_Channel)
|
uint16_t get_adc(uint8_t ADC_Channel)
|
||||||
{
|
{
|
||||||
uint16_t val;
|
int16_t val;
|
||||||
ADC_RegularChannelConfig(ADC1, ADC_Channel, 1, ADC_SampleTime_CyclesMode5);
|
ADC_RegularChannelConfig(ADC1, ADC_Channel, 1, ADC_SampleTime_CyclesMode5);
|
||||||
// ADC_RegularChannelConfig(ADC1, ADC_Channel, 1, ADC_SampleTime_CyclesMode7);
|
// ADC_RegularChannelConfig(ADC1, ADC_Channel, 1, ADC_SampleTime_CyclesMode7);
|
||||||
ADC_SoftwareStartConvCmd(ADC1, ENABLE);
|
ADC_SoftwareStartConvCmd(ADC1, ENABLE);
|
||||||
while(!ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC));
|
while(!ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC));
|
||||||
val = ADC_GetConversionValue(ADC1);
|
val = ADC_GetConversionValue(ADC1);
|
||||||
return val;
|
// return val;
|
||||||
|
return Get_ConversionVal(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -116,10 +219,12 @@ float get_CHG_CURR(void)
|
||||||
float I;
|
float I;
|
||||||
uint16_t I_ADC;
|
uint16_t I_ADC;
|
||||||
|
|
||||||
I_ADC = Get_ConversionVal(get_adc(CHG_CURR));
|
// I_ADC = Get_ConversionVal(get_adc(CHG_CURR));
|
||||||
|
I_ADC = get_aftercalculationAdc(CHG_CURR);
|
||||||
// I_ADC = get_adc(CHG_CURR);
|
// I_ADC = get_adc(CHG_CURR);
|
||||||
|
|
||||||
I = (float)(I_ADC) / 4095 * 3.3 * P_CHG_CURR * 2;
|
// I = (float)(I_ADC) / 4095 * 3.3 * P_CHG_CURR * 2;
|
||||||
|
I = (float)(I_ADC) / 4095 * 2.5 * P_CHG_CURR;
|
||||||
|
|
||||||
// printf(" CHG_CURR I : %d /10000 \n", (int)(I * 10000));
|
// printf(" CHG_CURR I : %d /10000 \n", (int)(I * 10000));
|
||||||
#ifdef enable_Printf_VI
|
#ifdef enable_Printf_VI
|
||||||
|
@ -140,10 +245,16 @@ float get_PV_VOLT_OUT(void)
|
||||||
float V;
|
float V;
|
||||||
uint16_t V_ADC;
|
uint16_t V_ADC;
|
||||||
|
|
||||||
V_ADC = Get_ConversionVal(get_adc(PV_VOLT_OUT));
|
// V_ADC = Get_ConversionVal(get_adc(PV_VOLT_OUT));
|
||||||
|
V_ADC = get_aftercalculationAdc(PV_VOLT_OUT);
|
||||||
// V_ADC = get_adc(PV_VOLT_OUT);
|
// V_ADC = get_adc(PV_VOLT_OUT);
|
||||||
|
|
||||||
V = (float)(V_ADC) / 4095 * 3.3 * P_PV_VOLT_OUT;
|
V = (float)(V_ADC) / 4095 * 2.5 * P_PV_VOLT_OUT;
|
||||||
|
//
|
||||||
|
// char buffer[30];
|
||||||
|
// memset(buffer, 0, sizeof(buffer));
|
||||||
|
// sprintf(buffer, " PV_VOLT_OUT ADC : %d \n", V_ADC);
|
||||||
|
// uart_dev_write(g_bat485_uart3_handle, buffer, sizeof(buffer));
|
||||||
|
|
||||||
#ifdef enable_Printf_VI
|
#ifdef enable_Printf_VI
|
||||||
printf("\n PV_VOLT_OUT ADC : %d \n", V_ADC);
|
printf("\n PV_VOLT_OUT ADC : %d \n", V_ADC);
|
||||||
|
@ -163,10 +274,12 @@ float get_DSG_CURR(void)
|
||||||
float I;
|
float I;
|
||||||
uint16_t I_ADC;
|
uint16_t I_ADC;
|
||||||
|
|
||||||
I_ADC = Get_ConversionVal(get_adc(DSG_CURR));
|
// I_ADC = Get_ConversionVal(get_adc(DSG_CURR));
|
||||||
|
I_ADC = get_aftercalculationAdc(DSG_CURR);
|
||||||
// I_ADC = get_adc(DSG_CURR);
|
// I_ADC = get_adc(DSG_CURR);
|
||||||
|
|
||||||
I = (float)(I_ADC) / 4095 * 3.3 * P_DSG_CURR * 2;
|
// I = (float)(I_ADC) / 4095 * 3.3 * P_DSG_CURR * 2;
|
||||||
|
I = (float)(I_ADC) / 4095 * 2.5 * P_DSG_CURR;
|
||||||
|
|
||||||
#ifdef enable_Printf_VI
|
#ifdef enable_Printf_VI
|
||||||
printf("\n DSG_CURR ADC : %d \n", I_ADC);
|
printf("\n DSG_CURR ADC : %d \n", I_ADC);
|
||||||
|
@ -187,11 +300,13 @@ float get_PV1_VOLT_IN(void)
|
||||||
uint16_t V_ADC;
|
uint16_t V_ADC;
|
||||||
|
|
||||||
// GPIO_WriteBit(G_FFMOS_CON1_GPIO, G_FFMOS_CON1_PIN, SET);
|
// GPIO_WriteBit(G_FFMOS_CON1_GPIO, G_FFMOS_CON1_PIN, SET);
|
||||||
V_ADC = Get_ConversionVal(get_adc(PV1_VOLT_IN));
|
// V_ADC = Get_ConversionVal(get_adc(PV1_VOLT_IN));
|
||||||
|
V_ADC = get_aftercalculationAdc(PV1_VOLT_IN);
|
||||||
|
|
||||||
// V_ADC = get_adc(PV1_VOLT_IN);
|
// V_ADC = get_adc(PV1_VOLT_IN);
|
||||||
// GPIO_WriteBit(G_FFMOS_CON1_GPIO, G_FFMOS_CON1_PIN, RESET);
|
// GPIO_WriteBit(G_FFMOS_CON1_GPIO, G_FFMOS_CON1_PIN, RESET);
|
||||||
|
|
||||||
V = (float)(V_ADC) / 4095 * 3.3 * P_PV1_VOLT_IN;
|
V = (float)(V_ADC) / 4095 * 2.5 * P_PV1_VOLT_IN;
|
||||||
|
|
||||||
#ifdef enable_Printf_VI
|
#ifdef enable_Printf_VI
|
||||||
printf("\n PV1_VOLT_IN ADC : %d \n", V_ADC);
|
printf("\n PV1_VOLT_IN ADC : %d \n", V_ADC);
|
||||||
|
@ -211,10 +326,11 @@ float get_PV_VOLT_IN1(void)
|
||||||
float V;
|
float V;
|
||||||
uint16_t V_ADC;
|
uint16_t V_ADC;
|
||||||
|
|
||||||
V_ADC = Get_ConversionVal(get_adc(PV_VOLT_IN1));
|
// V_ADC = Get_ConversionVal(get_adc(PV_VOLT_IN1));
|
||||||
|
V_ADC = get_aftercalculationAdc(PV_VOLT_IN1);
|
||||||
// V_ADC = get_adc(PV_VOLT_IN1);
|
// V_ADC = get_adc(PV_VOLT_IN1);
|
||||||
|
|
||||||
V = (float)(V_ADC) / 4095 * 3.3 * P_PV_VOLT_IN1;
|
V = (float)(V_ADC) / 4095 * 2.5 * P_PV_VOLT_IN1;
|
||||||
|
|
||||||
#ifdef enable_Printf_VI
|
#ifdef enable_Printf_VI
|
||||||
printf("\n PV_VOLT_IN1 ADC : %d \n", V_ADC);
|
printf("\n PV_VOLT_IN1 ADC : %d \n", V_ADC);
|
||||||
|
@ -240,7 +356,14 @@ float get_MOSFET_Temper(void)
|
||||||
float T = 0;
|
float T = 0;
|
||||||
uint16_t T_ADC;
|
uint16_t T_ADC;
|
||||||
|
|
||||||
T_ADC = Get_ConversionVal(get_adc(MOSFET_Temper));
|
// T_ADC = Get_ConversionVal(get_adc(MOSFET_Temper));
|
||||||
|
T_ADC = get_aftercalculationAdc(MOSFET_Temper);
|
||||||
|
|
||||||
|
// char buffer[30];
|
||||||
|
// memset(buffer, 0, sizeof(buffer));
|
||||||
|
// sprintf(buffer, " T_ADC : %d \n", T_ADC);
|
||||||
|
// uart_dev_write(g_bat485_uart3_handle, buffer, sizeof(buffer));
|
||||||
|
// Delay_Ms(1);
|
||||||
|
|
||||||
for (int i = 0; i < mosTemperADCLen; ++i) {
|
for (int i = 0; i < mosTemperADCLen; ++i) {
|
||||||
if (T_ADC >= mosTemperADC[i]) {
|
if (T_ADC >= mosTemperADC[i]) {
|
||||||
|
@ -276,11 +399,12 @@ float get_PV2_VOLT_IN(void)
|
||||||
uint16_t V_ADC;
|
uint16_t V_ADC;
|
||||||
|
|
||||||
// GPIO_WriteBit(G_FFMOS_CON2_GPIO, G_FFMOS_CON2_PIN, SET);
|
// GPIO_WriteBit(G_FFMOS_CON2_GPIO, G_FFMOS_CON2_PIN, SET);
|
||||||
V_ADC = Get_ConversionVal(get_adc(PV2_VOLT_IN));
|
// V_ADC = Get_ConversionVal(get_adc(PV2_VOLT_IN));
|
||||||
|
V_ADC = get_aftercalculationAdc(PV2_VOLT_IN);
|
||||||
// V_ADC = get_adc(PV2_VOLT_IN);
|
// V_ADC = get_adc(PV2_VOLT_IN);
|
||||||
// GPIO_WriteBit(G_FFMOS_CON2_GPIO, G_FFMOS_CON2_PIN, RESET);
|
// GPIO_WriteBit(G_FFMOS_CON2_GPIO, G_FFMOS_CON2_PIN, RESET);
|
||||||
|
|
||||||
V = (float)(V_ADC) / 4095 * 3.3 * P_PV2_VOLT_IN;
|
V = (float)(V_ADC) / 4095 * 2.5 * P_PV2_VOLT_IN;
|
||||||
|
|
||||||
#ifdef enable_Printf_VI
|
#ifdef enable_Printf_VI
|
||||||
printf("\n PV2_VOLT_IN ADC : %d \n", V_ADC);
|
printf("\n PV2_VOLT_IN ADC : %d \n", V_ADC);
|
||||||
|
|
|
@ -12,11 +12,12 @@
|
||||||
config_info g_slConfigInfo = {
|
config_info g_slConfigInfo = {
|
||||||
.constantCurrentV = 1000,
|
.constantCurrentV = 1000,
|
||||||
.constantVoltageV = 1400,
|
.constantVoltageV = 1400,
|
||||||
.floatI = 10,
|
.floatI = 5,
|
||||||
.startSolarOpenCircuitV = 1700,
|
.startSolarOpenCircuitV = 1700,
|
||||||
.stopSolarOpenCircuitV = 1500,
|
.stopSolarOpenCircuitV = 1500,
|
||||||
.noBatteryChargeV = 1200,
|
.constantVoltageChargeV = 1440,
|
||||||
.FloatTime = 10,
|
.trickleChargeC = 100,
|
||||||
|
.FloatTime = 3,
|
||||||
.checkSolarOpenCircuitVTime = 10,
|
.checkSolarOpenCircuitVTime = 10,
|
||||||
.registerRefreshTime = 1,
|
.registerRefreshTime = 1,
|
||||||
.resRefreshTime = 1,
|
.resRefreshTime = 1,
|
||||||
|
|
|
@ -19,11 +19,11 @@ static void TrickleCharge(void);
|
||||||
static void ConstantCurrentCharge(void);
|
static void ConstantCurrentCharge(void);
|
||||||
static void ConstantVoltageCharge(void);
|
static void ConstantVoltageCharge(void);
|
||||||
static void FloatingCharge(void);
|
static void FloatingCharge(void);
|
||||||
static void NoBatteryCharge(void);
|
//static void NoBatteryCharge(void);
|
||||||
|
|
||||||
|
|
||||||
/* 占空比 */
|
/* 占空比 */
|
||||||
float g_duty_ratio = 0.7;
|
float g_duty_ratio = 0.8;
|
||||||
/* 用于确定工作模式 */
|
/* 用于确定工作模式 */
|
||||||
//static uint8_t modeFlag = 2;
|
//static uint8_t modeFlag = 2;
|
||||||
|
|
||||||
|
@ -149,35 +149,35 @@ void printf_data(void)
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
float_t get_capturedata(float_t (*fun)(void))
|
//float_t get_capturedata(float_t (*fun)(void))
|
||||||
{
|
//{
|
||||||
float_t temp1;
|
// float_t temp1;
|
||||||
float_t temp[3];
|
// float_t temp[3];
|
||||||
|
//
|
||||||
for (int i = 0; i < 3; ++i) {
|
// for (int i = 0; i < 3; ++i) {
|
||||||
temp[i] = fun();
|
// temp[i] = fun();
|
||||||
// Delay_Us(1);
|
//// Delay_Us(1);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (temp[0] > temp[1]) {
|
// if (temp[0] > temp[1]) {
|
||||||
temp1 = temp[0];
|
// temp1 = temp[0];
|
||||||
temp[0] = temp[1];
|
// temp[0] = temp[1];
|
||||||
temp[1] = temp1;
|
// temp[1] = temp1;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (temp[0] > temp[2]) {
|
// if (temp[0] > temp[2]) {
|
||||||
temp1 = temp[0];
|
// temp1 = temp[0];
|
||||||
temp[0] = temp[2];
|
// temp[0] = temp[2];
|
||||||
temp[2] = temp1;
|
// temp[2] = temp1;
|
||||||
if (temp[1] > temp[2]) {
|
// if (temp[1] > temp[2]) {
|
||||||
temp1 = temp[1];
|
// temp1 = temp[1];
|
||||||
temp[1] = temp[2];
|
// temp[1] = temp[2];
|
||||||
temp[2] = temp1;
|
// temp[2] = temp1;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return temp[1];
|
// return temp[1];
|
||||||
}
|
//}
|
||||||
|
|
||||||
//uint16_t get_mpptMode(void)
|
//uint16_t get_mpptMode(void)
|
||||||
//{
|
//{
|
||||||
|
@ -230,7 +230,10 @@ void mppt_constantVoltage(float InVoltage)
|
||||||
// allError += error;
|
// allError += error;
|
||||||
// printf("111\n");
|
// printf("111\n");
|
||||||
|
|
||||||
float_t pv1Volt = get_capturedata(get_PV1_VOLT_IN);
|
// float_t pv1Volt = get_capturedata(get_PV1_VOLT_IN);
|
||||||
|
|
||||||
|
// float_t pv1Volt = get_PV1_VOLT_IN();
|
||||||
|
float_t pv1Volt = g_Mppt_Para.Input_Voltage;
|
||||||
// printf("volt in : %d \n", pv1Volt);
|
// printf("volt in : %d \n", pv1Volt);
|
||||||
float_t error = pv1Volt - InVoltage;
|
float_t error = pv1Volt - InVoltage;
|
||||||
// float_t error = InVoltage - pv1Volt;
|
// float_t error = InVoltage - pv1Volt;
|
||||||
|
@ -397,7 +400,14 @@ void mppt_constantCurrentO(float outCurrent)
|
||||||
*/
|
*/
|
||||||
void TrickleCharge(void)
|
void TrickleCharge(void)
|
||||||
{
|
{
|
||||||
mppt_constantCurrentO(2);
|
static float_t TrickleChargeC;
|
||||||
|
static uint8_t onlyOnce = 1;
|
||||||
|
if (onlyOnce) {
|
||||||
|
TrickleChargeC = (float_t)g_slConfigInfo.trickleChargeC / 100;
|
||||||
|
onlyOnce = 0;
|
||||||
|
}
|
||||||
|
printf("Trickle\n");
|
||||||
|
mppt_constantCurrentO(TrickleChargeC + g_Mppt_Para.Discharg_Current);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -410,6 +420,7 @@ void ConstantCurrentCharge(void)
|
||||||
{
|
{
|
||||||
// mppt_readJust();
|
// mppt_readJust();
|
||||||
mppt_constantVoltage(18);
|
mppt_constantVoltage(18);
|
||||||
|
// printf("ConstantCurrent\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -421,7 +432,14 @@ void ConstantCurrentCharge(void)
|
||||||
*/
|
*/
|
||||||
void ConstantVoltageCharge(void)
|
void ConstantVoltageCharge(void)
|
||||||
{
|
{
|
||||||
mppt_constantVoltageO(14.5);
|
static float_t ConstantVoltageChargeV;
|
||||||
|
static uint8_t onlyOnce = 1;
|
||||||
|
if (onlyOnce) {
|
||||||
|
ConstantVoltageChargeV = (float_t)g_slConfigInfo.constantVoltageChargeV / 100;
|
||||||
|
onlyOnce = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
mppt_constantVoltageO(ConstantVoltageChargeV);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -436,17 +454,17 @@ void FloatingCharge(void)
|
||||||
static uint32_t numLenFlag;
|
static uint32_t numLenFlag;
|
||||||
static uint8_t onlyOnce = 1;
|
static uint8_t onlyOnce = 1;
|
||||||
if (onlyOnce) {
|
if (onlyOnce) {
|
||||||
numLenFlag = g_slConfigInfo.FloatTime * 1000 / 5;
|
numLenFlag = g_slConfigInfo.FloatTime * 1000;
|
||||||
onlyOnce = 0;
|
onlyOnce = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("float\n");
|
||||||
TIM_SetCompare4(TIM4, 0);
|
TIM_SetCompare4(TIM4, 0);
|
||||||
|
|
||||||
if (numLenFlag == ++num) {
|
if (numLenFlag == ++num) {
|
||||||
num = 0;
|
num = 0;
|
||||||
ConstantVoltageCharge();
|
ConstantVoltageCharge();
|
||||||
g_Mppt_Para.MPPT_Mode = CONSTANTVOLTAGE;
|
g_Mppt_Para.MPPT_Mode = CONSTANTVOLTAGE;
|
||||||
// printf("float charge \n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -459,14 +477,14 @@ void FloatingCharge(void)
|
||||||
*/
|
*/
|
||||||
void NoBatteryCharge(void)
|
void NoBatteryCharge(void)
|
||||||
{
|
{
|
||||||
static float_t NoBatteryChargeV;
|
// static float_t NoBatteryChargeV;
|
||||||
static uint8_t onlyOnce = 1;
|
// static uint8_t onlyOnce = 1;
|
||||||
if (onlyOnce) {
|
// if (onlyOnce) {
|
||||||
NoBatteryChargeV = (float_t)g_slConfigInfo.noBatteryChargeV / 100;
|
// NoBatteryChargeV = (float_t)g_slConfigInfo.noBatteryChargeV / 100;
|
||||||
onlyOnce = 0;
|
// onlyOnce = 0;
|
||||||
}
|
// }
|
||||||
|
|
||||||
mppt_constantVoltageO(NoBatteryChargeV);
|
mppt_constantVoltageO(14.2);
|
||||||
|
|
||||||
// if ((g_Mppt_Para.Battery_Voltage - NoBatteryChargeV > 0.2 && g_Mppt_Para.Charg_Current < 0.1)
|
// if ((g_Mppt_Para.Battery_Voltage - NoBatteryChargeV > 0.2 && g_Mppt_Para.Charg_Current < 0.1)
|
||||||
// || (NoBatteryChargeV - g_Mppt_Para.Battery_Voltage > 0.1 && g_Mppt_Para.Charg_Current > 0.5)) {
|
// || (NoBatteryChargeV - g_Mppt_Para.Battery_Voltage > 0.1 && g_Mppt_Para.Charg_Current > 0.5)) {
|
||||||
|
@ -474,13 +492,13 @@ void NoBatteryCharge(void)
|
||||||
// g_Mppt_Para.MPPT_Mode = CONSTANTCURRENT;
|
// g_Mppt_Para.MPPT_Mode = CONSTANTCURRENT;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (!overTemperature) {
|
// if (!overTemperature) {
|
||||||
if (!(g_Mppt_Para.Charg_Current - g_Mppt_Para.Discharg_Current < 0.3
|
// if (!(g_Mppt_Para.Charg_Current - g_Mppt_Para.Discharg_Current < 0.3
|
||||||
&& g_Mppt_Para.Discharg_Current - g_Mppt_Para.Charg_Current < 0.3)) {
|
// && g_Mppt_Para.Discharg_Current - g_Mppt_Para.Charg_Current < 0.3)) {
|
||||||
ConstantCurrentCharge();
|
// ConstantCurrentCharge();
|
||||||
g_Mppt_Para.MPPT_Mode = CONSTANTCURRENT;
|
// g_Mppt_Para.MPPT_Mode = CONSTANTCURRENT;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -495,6 +513,7 @@ void MpptContorl(void)
|
||||||
case CONSTANTCURRENT:
|
case CONSTANTCURRENT:
|
||||||
// printf("222222\n");
|
// printf("222222\n");
|
||||||
ConstantCurrentCharge();
|
ConstantCurrentCharge();
|
||||||
|
// ConstantVoltageCharge();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CONSTANTVOLTAGE:
|
case CONSTANTVOLTAGE:
|
||||||
|
@ -507,10 +526,10 @@ void MpptContorl(void)
|
||||||
FloatingCharge();
|
FloatingCharge();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NoBattery:
|
// case NoBattery:
|
||||||
// printf("555555555555555\n");
|
//// printf("555555555555555\n");
|
||||||
NoBatteryCharge();
|
// NoBatteryCharge();
|
||||||
break;
|
// break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -624,29 +643,50 @@ void MpptMode(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((g_Mppt_Para.Charg_Current - g_Mppt_Para.Discharg_Current < 0.03
|
// if (((g_Mppt_Para.Charg_Current - g_Mppt_Para.Discharg_Current < 0.03
|
||||||
&& g_Mppt_Para.Discharg_Current - g_Mppt_Para.Charg_Current < 0.03)
|
// && g_Mppt_Para.Discharg_Current - g_Mppt_Para.Charg_Current < 0.03)
|
||||||
|| g_Mppt_Para.Battery_Voltage < 6
|
// && (g_Mppt_Para.Battery_Voltage < ConstantVoltageV - 1
|
||||||
|| g_Mppt_Para.Battery_Voltage > 16
|
// || g_Mppt_Para.Battery_Voltage > ConstantVoltageV + 1))
|
||||||
|| g_Mppt_Para.MPPT_Mode == NoBattery) {
|
// || g_Mppt_Para.MPPT_Mode == NoBattery) {
|
||||||
g_Mppt_Para.MPPT_Mode = NoBattery;
|
// g_Mppt_Para.MPPT_Mode = NoBattery;
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (((ConstantVoltageV < g_Mppt_Para.Battery_Voltage) &&
|
||||||
|
// (FloatI > g_Mppt_Para.Charg_Current)) || g_Mppt_Para.MPPT_Mode == FLOAT) {
|
||||||
|
// g_Mppt_Para.MPPT_Mode = FLOAT;
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
if ((g_Mppt_Para.Charg_Current - g_Mppt_Para.Discharg_Current < 0.05
|
||||||
|
&& g_Mppt_Para.Discharg_Current - g_Mppt_Para.Charg_Current < 0.05)
|
||||||
|
|| g_Mppt_Para.Battery_Voltage > 16 || g_Mppt_Para.Battery_Voltage < 8) {
|
||||||
|
// || g_Mppt_Para.MPPT_Mode == NoBattery) {
|
||||||
|
// g_Mppt_Para.MPPT_Mode = NoBattery;
|
||||||
|
g_Mppt_Para.MPPT_Mode = CONSTANTVOLTAGE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((((ConstantCurrentV + 0.2) < g_Mppt_Para.Battery_Voltage)
|
||||||
|
&&((ConstantVoltageV - 0.2) >= g_Mppt_Para.Battery_Voltage))
|
||||||
|
&&(g_Mppt_Para.Charg_Current - g_Mppt_Para.Discharg_Current > 0.1)) {
|
||||||
|
g_Mppt_Para.MPPT_Mode = CONSTANTCURRENT;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// if ((g_Mppt_Para.Charg_Current - g_Mppt_Para.Discharg_Current > 4)) {
|
||||||
|
// g_Mppt_Para.MPPT_Mode = CONSTANTCURRENT;
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
if (((ConstantVoltageV < g_Mppt_Para.Battery_Voltage) &&
|
if (((ConstantVoltageV < g_Mppt_Para.Battery_Voltage) &&
|
||||||
(FloatI > g_Mppt_Para.Charg_Current)) || g_Mppt_Para.MPPT_Mode == FLOAT) {
|
(FloatI > g_Mppt_Para.Charg_Current))) {
|
||||||
g_Mppt_Para.MPPT_Mode = FLOAT;
|
g_Mppt_Para.MPPT_Mode = FLOAT;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((ConstantCurrentV + 0.4) < g_Mppt_Para.Battery_Voltage) &&
|
if (((ConstantVoltageV < g_Mppt_Para.Battery_Voltage)
|
||||||
((ConstantVoltageV - 0.4) >= g_Mppt_Para.Battery_Voltage)) {
|
&&(FloatI + 0.1 <= g_Mppt_Para.Charg_Current))) {
|
||||||
g_Mppt_Para.MPPT_Mode = CONSTANTCURRENT;
|
// || (g_Mppt_Para.Charg_Current - g_Mppt_Para.Discharg_Current < 0.03
|
||||||
return;
|
// && g_Mppt_Para.Discharg_Current - g_Mppt_Para.Charg_Current < 0.03)) {
|
||||||
}
|
|
||||||
|
|
||||||
if ((ConstantVoltageV < g_Mppt_Para.Battery_Voltage) &&
|
|
||||||
(FloatI + 0.1 <= g_Mppt_Para.Charg_Current)) {
|
|
||||||
|
|
||||||
// printf("mppt mode \n");
|
// printf("mppt mode \n");
|
||||||
// printf(" vout : %d/100 \n", (int)(g_Mppt_Para.Battery_Voltage * 100));
|
// printf(" vout : %d/100 \n", (int)(g_Mppt_Para.Battery_Voltage * 100));
|
||||||
|
@ -695,8 +735,29 @@ void test(void)
|
||||||
|
|
||||||
// mppt_constantCurrentO(1);
|
// mppt_constantCurrentO(1);
|
||||||
|
|
||||||
g_Mppt_Para.Charg_Current = get_capturedata(get_CHG_CURR);
|
// g_Mppt_Para.Charg_Current = get_capturedata(get_CHG_CURR);
|
||||||
g_Mppt_Para.Discharg_Current = get_capturedata(get_DSG_CURR);
|
// g_Mppt_Para.Discharg_Current = get_capturedata(get_DSG_CURR);
|
||||||
|
// g_Mppt_Para.Output_Voltage = get_capturedata(get_PV_VOLT_OUT);
|
||||||
|
// g_Mppt_Para.Battery_Voltage = g_Mppt_Para.Output_Voltage;
|
||||||
|
g_Mppt_Para.Charg_Current = get_CHG_CURR();
|
||||||
|
g_Mppt_Para.Discharg_Current = get_DSG_CURR();
|
||||||
|
g_Mppt_Para.Output_Voltage = get_PV_VOLT_OUT();
|
||||||
|
g_Mppt_Para.Input_Voltage = get_PV1_VOLT_IN();
|
||||||
|
// g_Mppt_Para.Battery_Voltage = g_Mppt_Para.Output_Voltage;
|
||||||
|
|
||||||
|
// static float_t Volt = 0.7;
|
||||||
|
// static float_t Curr = 5.5;
|
||||||
|
static float_t Res = 0.7 / 5.5;
|
||||||
|
static float_t inBatteryCurr;
|
||||||
|
inBatteryCurr = g_Mppt_Para.Charg_Current - g_Mppt_Para.Discharg_Current;
|
||||||
|
if (inBatteryCurr > 0.5) {
|
||||||
|
g_Mppt_Para.Battery_Voltage = g_Mppt_Para.Output_Voltage - inBatteryCurr * Res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// mppt_constantVoltage(18);
|
||||||
|
|
||||||
// if (g_Mppt_Para.MPPT_Mode == CONSTANTCURRENT
|
// if (g_Mppt_Para.MPPT_Mode == CONSTANTCURRENT
|
||||||
// || g_Mppt_Para.MPPT_Mode == CONSTANTVOLTAGE) {
|
// || g_Mppt_Para.MPPT_Mode == CONSTANTVOLTAGE) {
|
||||||
|
@ -704,18 +765,21 @@ void test(void)
|
||||||
// g_Mppt_Para.Battery_Voltage = get_capturedata(get_PV_VOLT_OUT)
|
// g_Mppt_Para.Battery_Voltage = get_capturedata(get_PV_VOLT_OUT)
|
||||||
// - g_impedance * (g_Mppt_Para.Charg_Current - g_Mppt_Para.Discharg_Current);
|
// - g_impedance * (g_Mppt_Para.Charg_Current - g_Mppt_Para.Discharg_Current);
|
||||||
// } else {
|
// } else {
|
||||||
g_Mppt_Para.Battery_Voltage = get_capturedata(get_PV_VOLT_OUT);
|
// g_Mppt_Para.Battery_Voltage = get_capturedata(get_PV_VOLT_OUT);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// voltOut = get_capturedata(get_PV_VOLT_OUT);
|
// voltOut = get_capturedata(get_PV_VOLT_OUT);
|
||||||
// g_Mppt_Para.Battery_Voltage = voltOut - g_impedance * (g_Mppt_Para.Charg_Current - g_Mppt_Para.Discharg_Current);
|
// g_Mppt_Para.Battery_Voltage = voltOut - g_impedance * (g_Mppt_Para.Charg_Current - g_Mppt_Para.Discharg_Current);
|
||||||
|
|
||||||
|
|
||||||
|
// ConstantVoltageCharge();
|
||||||
|
// return;
|
||||||
|
|
||||||
if (!overTemperature) {
|
if (!overTemperature) {
|
||||||
MpptMode();
|
MpptMode();
|
||||||
|
MpptContorl();
|
||||||
}
|
}
|
||||||
|
|
||||||
MpptContorl();
|
|
||||||
|
|
||||||
// mppt_constantVoltageO(12);
|
// mppt_constantVoltageO(12);
|
||||||
|
|
||||||
|
|
141
App/src/task.c
141
App/src/task.c
|
@ -4,6 +4,7 @@
|
||||||
* Created on: 2024Äê6ÔÂ24ÈÕ
|
* Created on: 2024Äê6ÔÂ24ÈÕ
|
||||||
* Author: psx
|
* Author: psx
|
||||||
*/
|
*/
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
|
|
||||||
|
@ -25,7 +26,7 @@
|
||||||
|
|
||||||
void stop_mpptWork(void)
|
void stop_mpptWork(void)
|
||||||
{
|
{
|
||||||
GPIO_WriteBit(EnPowerSupply_GPIO, EnPowerSupply_PIN, SET);
|
// GPIO_WriteBit(EnPowerSupply_GPIO, EnPowerSupply_PIN, SET);
|
||||||
g_duty_ratio = 0.7;
|
g_duty_ratio = 0.7;
|
||||||
TIM_Cmd(TIM3, DISABLE);
|
TIM_Cmd(TIM3, DISABLE);
|
||||||
TIM_SetCompare4(TIM4, 0);
|
TIM_SetCompare4(TIM4, 0);
|
||||||
|
@ -57,20 +58,60 @@ void Task_RunLED(void)
|
||||||
// uart_sendstr(g_gw485_uart4_handle, "is gw485\n");
|
// uart_sendstr(g_gw485_uart4_handle, "is gw485\n");
|
||||||
// uart_sendstr(g_bat485_uart3_handle, "is bat485\n");get_PV1_VOLT_IN();
|
// uart_sendstr(g_bat485_uart3_handle, "is bat485\n");get_PV1_VOLT_IN();
|
||||||
|
|
||||||
printf(" \n");
|
// printf(" \n");
|
||||||
printf(" duty_ratio : %d/1000 \n", (int)(g_duty_ratio * 1000));
|
// printf(" duty_ratio : %d/1000 \n", (int)(g_duty_ratio * 1000));
|
||||||
|
//
|
||||||
|
// printf(" vout : %d/100 \n", (int)(g_Mppt_Para.Battery_Voltage * 100));
|
||||||
|
// printf(" Iout : %d/100 \n", (int)(g_Mppt_Para.Charg_Current * 100));
|
||||||
|
// printf(" Idisout : %d/100 \n", (int)(g_Mppt_Para.Discharg_Current * 100));
|
||||||
|
// printf(" mosT : %d/10 \n", (int)(g_Mppt_Para.HighSideMos_Temperature * 10));
|
||||||
|
// printf(" mosState : %d \n", (int)(g_Mppt_Para.DischargMos_State));
|
||||||
|
//// printf(" mosState : %d \n", GPIO_ReadOutputDataBit(POW_OUT_CON_GPIO, POW_OUT_CON_PIN));
|
||||||
|
//// printf(" mosState : %d \n", GPIO_ReadInputDataBit(DSG_PROT_GPIO, DSG_PROT_PIN));
|
||||||
|
//
|
||||||
|
// printf(" 0.没有工作; 1.涓流模式; 2.恒流模式; 3.恒压模式; 4.浮充模式; 5.没有电池 : %d \n", g_Mppt_Para.MPPT_Mode);
|
||||||
|
//
|
||||||
|
// printf(" \n");
|
||||||
|
|
||||||
printf(" vout : %d/100 \n", (int)(g_Mppt_Para.Battery_Voltage * 100));
|
// uart_sendstr(g_bat485_uart3_handle, " \n");
|
||||||
printf(" Iout : %d/100 \n", (int)(g_Mppt_Para.Charg_Current * 100));
|
|
||||||
printf(" Idisout : %d/100 \n", (int)(g_Mppt_Para.Discharg_Current * 100));
|
|
||||||
printf(" mosT : %d/10 \n", (int)(g_Mppt_Para.HighSideMos_Temperature * 10));
|
|
||||||
printf(" mosState : %d \n", (int)(g_Mppt_Para.DischargMos_State));
|
|
||||||
// printf(" mosState : %d \n", GPIO_ReadOutputDataBit(POW_OUT_CON_GPIO, POW_OUT_CON_PIN));
|
|
||||||
// printf(" mosState : %d \n", GPIO_ReadInputDataBit(DSG_PROT_GPIO, DSG_PROT_PIN));
|
|
||||||
|
|
||||||
printf(" 0.没有工作; 1.涓流模式; 2.恒流模式; 3.恒压模式; 4.浮充模式; 5.没有电池 : %d \n", g_Mppt_Para.MPPT_Mode);
|
uart_dev_write(g_bat485_uart3_handle, " \n", sizeof(" \n"));
|
||||||
|
|
||||||
|
char buffer[80];
|
||||||
|
memset(buffer, 0, sizeof(buffer));
|
||||||
|
sprintf(buffer, " duty_ratio : %d/1000 \n", (int)(g_duty_ratio * 1000));
|
||||||
|
uart_dev_write(g_bat485_uart3_handle, buffer, sizeof(buffer));
|
||||||
|
|
||||||
|
memset(buffer, 0, sizeof(buffer));
|
||||||
|
sprintf(buffer, " vout : %d/100 \n", (int)(g_Mppt_Para.Output_Voltage * 100));
|
||||||
|
uart_dev_write(g_bat485_uart3_handle, buffer, sizeof(buffer));
|
||||||
|
|
||||||
|
memset(buffer, 0, sizeof(buffer));
|
||||||
|
sprintf(buffer, " vBattery : %d/100 \n", (int)(g_Mppt_Para.Battery_Voltage * 100));
|
||||||
|
uart_dev_write(g_bat485_uart3_handle, buffer, sizeof(buffer));
|
||||||
|
|
||||||
|
memset(buffer, 0, sizeof(buffer));
|
||||||
|
sprintf(buffer, " Iout : %d/100 \n", (int)(g_Mppt_Para.Charg_Current * 100));
|
||||||
|
uart_dev_write(g_bat485_uart3_handle, buffer, sizeof(buffer));
|
||||||
|
|
||||||
|
memset(buffer, 0, sizeof(buffer));
|
||||||
|
sprintf(buffer, " Idisout : %d/100 \n", (int)(g_Mppt_Para.Discharg_Current * 100));
|
||||||
|
uart_dev_write(g_bat485_uart3_handle, buffer, sizeof(buffer));
|
||||||
|
|
||||||
|
memset(buffer, 0, sizeof(buffer));
|
||||||
|
sprintf(buffer, " mosT : %d/10 \n", (int)(g_Mppt_Para.HighSideMos_Temperature * 10));
|
||||||
|
uart_dev_write(g_bat485_uart3_handle, buffer, sizeof(buffer));
|
||||||
|
|
||||||
|
memset(buffer, 0, sizeof(buffer));
|
||||||
|
sprintf(buffer, " mosState : %d \n", (int)(g_Mppt_Para.DischargMos_State));
|
||||||
|
uart_dev_write(g_bat485_uart3_handle, buffer, sizeof(buffer));
|
||||||
|
|
||||||
|
memset(buffer, 0, sizeof(buffer));
|
||||||
|
sprintf(buffer, " 0.没有工作; 1.涓流模式; 2.恒流模式; 3.恒压模式; 4.浮充模式; 5.没有电池 : %d \n", g_Mppt_Para.MPPT_Mode);
|
||||||
|
uart_dev_write(g_bat485_uart3_handle, buffer, sizeof(buffer));
|
||||||
|
|
||||||
|
uart_dev_write(g_bat485_uart3_handle, " \n", sizeof(" \n"));
|
||||||
|
|
||||||
printf(" \n");
|
|
||||||
|
|
||||||
// printf("vout : %d/100 \n", (int)(get_capturedata(get_PV_VOLT_OUT) * 100));
|
// printf("vout : %d/100 \n", (int)(get_capturedata(get_PV_VOLT_OUT) * 100));
|
||||||
|
|
||||||
|
@ -106,8 +147,12 @@ void Task_startMpptControl(void)
|
||||||
|
|
||||||
if (g_slConfigInfo.checkSolarOpenCircuitVTime == ++checkSolarOpenCircuitVTimeFlag) {
|
if (g_slConfigInfo.checkSolarOpenCircuitVTime == ++checkSolarOpenCircuitVTimeFlag) {
|
||||||
checkSolarOpenCircuitVTimeFlag = 0;
|
checkSolarOpenCircuitVTimeFlag = 0;
|
||||||
g_Mppt_Para.Solar_Open_Circuit_Voltage = get_capturedata(get_PV1_VOLT_IN);
|
g_Mppt_Para.Solar_Open_Circuit_Voltage = get_PV1_VOLT_IN();
|
||||||
printf("volt in : %d/100 \n", (int)(g_Mppt_Para.Solar_Open_Circuit_Voltage * 100));
|
// printf("volt in : %d/100 \n", (int)(g_Mppt_Para.Solar_Open_Circuit_Voltage * 100));
|
||||||
|
char buff[50];
|
||||||
|
memset(buff, 0, sizeof(buff));
|
||||||
|
sprintf(buff, "volt in : %d/100 \n", (int)(g_Mppt_Para.Solar_Open_Circuit_Voltage * 100));
|
||||||
|
uart_dev_write(g_bat485_uart3_handle, buff, sizeof(buff));
|
||||||
|
|
||||||
if (g_Mppt_Para.Solar_Open_Circuit_Voltage
|
if (g_Mppt_Para.Solar_Open_Circuit_Voltage
|
||||||
> ((float_t)g_slConfigInfo.startSolarOpenCircuitV / 100)) {
|
> ((float_t)g_slConfigInfo.startSolarOpenCircuitV / 100)) {
|
||||||
|
@ -132,9 +177,9 @@ void Task_softStart(void)
|
||||||
|
|
||||||
num++;
|
num++;
|
||||||
|
|
||||||
if (num == 1) {
|
// if (num == 1) {
|
||||||
GPIO_WriteBit(EnPowerSupply_GPIO, EnPowerSupply_PIN, RESET);
|
// GPIO_WriteBit(EnPowerSupply_GPIO, EnPowerSupply_PIN, RESET);
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (num < 5) {
|
if (num < 5) {
|
||||||
TIM_SetCompare4(TIM4, 100);
|
TIM_SetCompare4(TIM4, 100);
|
||||||
|
@ -167,6 +212,7 @@ void Task_usart(void)
|
||||||
{
|
{
|
||||||
read_and_process_uart_data(g_gw485_uart4_handle);
|
read_and_process_uart_data(g_gw485_uart4_handle);
|
||||||
// read_and_process_uart_data(g_bat485_uart3_handle);
|
// read_and_process_uart_data(g_bat485_uart3_handle);
|
||||||
|
// uart_dev_write(g_bat485_uart3_handle, "hello world \n", sizeof("hello world \n"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,13 +247,19 @@ void Task_refreshRegister(void)
|
||||||
|
|
||||||
if (g_slConfigInfo.registerRefreshTime == ++checkRegisterRefreshTimeFlag) {
|
if (g_slConfigInfo.registerRefreshTime == ++checkRegisterRefreshTimeFlag) {
|
||||||
checkRegisterRefreshTimeFlag = 0;
|
checkRegisterRefreshTimeFlag = 0;
|
||||||
g_Mppt_Para.Battery_Voltage = get_capturedata(get_PV_VOLT_OUT);
|
// g_Mppt_Para.Battery_Voltage = get_capturedata(get_PV_VOLT_OUT);
|
||||||
g_Mppt_Para.Charg_Current = get_capturedata(get_CHG_CURR);
|
// g_Mppt_Para.Charg_Current = get_capturedata(get_CHG_CURR);
|
||||||
g_Mppt_Para.Discharg_Current = get_capturedata(get_DSG_CURR);
|
// g_Mppt_Para.Discharg_Current = get_capturedata(get_DSG_CURR);
|
||||||
g_Mppt_Para.HighSideMos_Temperature = get_capturedata(get_MOSFET_Temper);
|
// g_Mppt_Para.HighSideMos_Temperature = get_capturedata(get_MOSFET_Temper);
|
||||||
|
g_Mppt_Para.Battery_Voltage = get_PV_VOLT_OUT();
|
||||||
|
g_Mppt_Para.Charg_Current = get_CHG_CURR();
|
||||||
|
g_Mppt_Para.Discharg_Current = get_DSG_CURR();
|
||||||
|
g_Mppt_Para.HighSideMos_Temperature = get_MOSFET_Temper();
|
||||||
g_Mppt_Para.DischargMos_State = GPIO_ReadOutputDataBit(POW_OUT_CON_GPIO, POW_OUT_CON_PIN)
|
g_Mppt_Para.DischargMos_State = GPIO_ReadOutputDataBit(POW_OUT_CON_GPIO, POW_OUT_CON_PIN)
|
||||||
&& GPIO_ReadInputDataBit(DSG_PROT_GPIO, DSG_PROT_PIN);
|
&& GPIO_ReadInputDataBit(DSG_PROT_GPIO, DSG_PROT_PIN);
|
||||||
g_Mppt_Para.Solar_Open_Circuit_Voltage = get_capturedata(get_PV1_VOLT_IN);
|
// g_Mppt_Para.DischargMos_State = GPIO_ReadOutputDataBit(POW_OUT_CON_GPIO, POW_OUT_CON_PIN);
|
||||||
|
// g_Mppt_Para.Solar_Open_Circuit_Voltage = get_capturedata(get_PV1_VOLT_IN);
|
||||||
|
g_Mppt_Para.Solar_Open_Circuit_Voltage = get_PV1_VOLT_IN();
|
||||||
|
|
||||||
if (g_Mppt_Para.HighSideMos_Temperature < g_slConfigInfo.HighSideMosTemperature_start) {
|
if (g_Mppt_Para.HighSideMos_Temperature < g_slConfigInfo.HighSideMosTemperature_start) {
|
||||||
if (overTemperature == 2) {
|
if (overTemperature == 2) {
|
||||||
|
@ -219,7 +271,9 @@ void Task_refreshRegister(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_Mppt_Para.HighSideMos_Temperature > g_slConfigInfo.HighSideMosTemperature_end) {
|
if (g_Mppt_Para.HighSideMos_Temperature > g_slConfigInfo.HighSideMosTemperature_end) {
|
||||||
g_Mppt_Para.MPPT_Mode = NoBattery;
|
// g_Mppt_Para.MPPT_Mode = NoBattery;
|
||||||
|
g_duty_ratio = 0.5;
|
||||||
|
Set_duty_ratio(&g_duty_ratio);
|
||||||
overTemperature = 1;
|
overTemperature = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -352,13 +406,17 @@ void Task_impedanceCalculation(void)
|
||||||
|
|
||||||
TIM_SetCompare4(TIM4, 420);
|
TIM_SetCompare4(TIM4, 420);
|
||||||
Delay_Ms(5);
|
Delay_Ms(5);
|
||||||
currOne = get_capturedata(get_CHG_CURR) - get_capturedata(get_DSG_CURR);
|
// currOne = get_capturedata(get_CHG_CURR) - get_capturedata(get_DSG_CURR);
|
||||||
voltOne = get_capturedata(get_PV_VOLT_OUT);
|
// voltOne = get_capturedata(get_PV_VOLT_OUT);
|
||||||
|
currOne = get_CHG_CURR() - get_DSG_CURR();
|
||||||
|
voltOne = get_PV_VOLT_OUT();
|
||||||
|
|
||||||
TIM_SetCompare4(TIM4, 350);
|
TIM_SetCompare4(TIM4, 300);
|
||||||
Delay_Ms(5);
|
Delay_Ms(5);
|
||||||
currTwo = get_capturedata(get_CHG_CURR) - get_capturedata(get_DSG_CURR);
|
// currTwo = get_capturedata(get_CHG_CURR) - get_capturedata(get_DSG_CURR);
|
||||||
voltTwo = get_capturedata(get_PV_VOLT_OUT);
|
// voltTwo = get_capturedata(get_PV_VOLT_OUT);
|
||||||
|
currTwo = get_CHG_CURR() - get_DSG_CURR();
|
||||||
|
voltTwo = get_PV_VOLT_OUT();
|
||||||
|
|
||||||
g_impedance = (voltOne - voltTwo) / (currOne - currTwo);
|
g_impedance = (voltOne - voltTwo) / (currOne - currTwo);
|
||||||
|
|
||||||
|
@ -434,11 +492,23 @@ void g_Mppt_Para_Init(void)
|
||||||
g_Mppt_Para.Access_Node_Type = defaultValue.access_Node_Type;
|
g_Mppt_Para.Access_Node_Type = defaultValue.access_Node_Type;
|
||||||
g_Mppt_Para.Communication_Methods = defaultValue.communication_Methods;
|
g_Mppt_Para.Communication_Methods = defaultValue.communication_Methods;
|
||||||
|
|
||||||
g_Mppt_Para.Battery_Voltage = get_capturedata(get_PV_VOLT_OUT);
|
// g_Mppt_Para.Output_Voltage = get_capturedata(get_PV_VOLT_OUT);
|
||||||
g_Mppt_Para.Charg_Current = get_capturedata(get_CHG_CURR);
|
// g_Mppt_Para.Battery_Voltage = g_Mppt_Para.Output_Voltage;
|
||||||
g_Mppt_Para.Discharg_Current = get_capturedata(get_DSG_CURR);
|
// g_Mppt_Para.Charg_Current = get_capturedata(get_CHG_CURR);
|
||||||
g_Mppt_Para.Solar_Open_Circuit_Voltage = get_capturedata(get_PV1_VOLT_IN);
|
// g_Mppt_Para.Discharg_Current = get_capturedata(get_DSG_CURR);
|
||||||
g_Mppt_Para.HighSideMos_Temperature = get_capturedata(get_MOSFET_Temper);
|
// g_Mppt_Para.Solar_Open_Circuit_Voltage = get_capturedata(get_PV1_VOLT_IN);
|
||||||
|
// g_Mppt_Para.HighSideMos_Temperature = get_capturedata(get_MOSFET_Temper); g_Mppt_Para.Output_Voltage = get_capturedata(get_PV_VOLT_OUT);
|
||||||
|
|
||||||
|
g_Mppt_Para.Output_Voltage = get_PV_VOLT_OUT();
|
||||||
|
g_Mppt_Para.Battery_Voltage = g_Mppt_Para.Output_Voltage;
|
||||||
|
g_Mppt_Para.Charg_Current = get_CHG_CURR();
|
||||||
|
g_Mppt_Para.Discharg_Current = get_DSG_CURR();
|
||||||
|
g_Mppt_Para.Solar_Open_Circuit_Voltage = get_PV1_VOLT_IN();
|
||||||
|
g_Mppt_Para.HighSideMos_Temperature = get_MOSFET_Temper();
|
||||||
|
|
||||||
|
if (g_Mppt_Para.Battery_Voltage < 1 || g_Mppt_Para.Battery_Voltage > 9) {
|
||||||
|
GPIO_WriteBit(POW_OUT_CON_GPIO, POW_OUT_CON_PIN, SET);
|
||||||
|
}
|
||||||
g_Mppt_Para.DischargMos_State = GPIO_ReadOutputDataBit(POW_OUT_CON_GPIO, POW_OUT_CON_PIN)
|
g_Mppt_Para.DischargMos_State = GPIO_ReadOutputDataBit(POW_OUT_CON_GPIO, POW_OUT_CON_PIN)
|
||||||
&& GPIO_ReadInputDataBit(DSG_PROT_GPIO, DSG_PROT_PIN);
|
&& GPIO_ReadInputDataBit(DSG_PROT_GPIO, DSG_PROT_PIN);
|
||||||
g_Mppt_Para.MPPT_Mode = NoWork;
|
g_Mppt_Para.MPPT_Mode = NoWork;
|
||||||
|
@ -498,8 +568,11 @@ void hardware_Init(void)
|
||||||
SPI_Flash_Init();
|
SPI_Flash_Init();
|
||||||
POW_OUT_CON_Init();
|
POW_OUT_CON_Init();
|
||||||
DSG_PROT_Init();
|
DSG_PROT_Init();
|
||||||
EnPowerSupply_Init();
|
// EnPowerSupply_Init();
|
||||||
|
|
||||||
|
// Set_duty_ratio(&g_duty_ratio);
|
||||||
|
|
||||||
|
uart_dev_write(g_bat485_uart3_handle, " hello world \n", sizeof(" hello world \n"));
|
||||||
TIM3_Init(1);
|
TIM3_Init(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,8 @@ device_handle uart_dev_init(void)
|
||||||
void uart_init(uartIndex_e uart_index, int baud)
|
void uart_init(uartIndex_e uart_index, int baud)
|
||||||
{
|
{
|
||||||
if (uart_index == BAT485_UART_INDEX) {
|
if (uart_index == BAT485_UART_INDEX) {
|
||||||
BAT_485_Init(uart_devices[0].uart_baudrate);
|
// BAT_485_Init(uart_devices[0].uart_baudrate);
|
||||||
|
BAT_485_Init(115200);
|
||||||
} else if (uart_index == GW485_UART_INDEX) {
|
} else if (uart_index == GW485_UART_INDEX) {
|
||||||
GW_485_Init(uart_devices[1].uart_baudrate);
|
GW_485_Init(uart_devices[1].uart_baudrate);
|
||||||
}
|
}
|
||||||
|
@ -227,9 +228,12 @@ void uart_dev_write(device_handle device, void *data, int len)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (int i = 0; i < len; i++) {
|
for (int i = 0; i < len; i++) {
|
||||||
uart_putchar(device, ((u_int8_t *)data)[i]);
|
// uart_putchar(device, ((u_int8_t *)data)[i]);
|
||||||
|
uart_putchar(device, ((char *)data)[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Delay_Ms(1);
|
||||||
|
|
||||||
#if rs485_send_enable
|
#if rs485_send_enable
|
||||||
if(device == g_bat485_uart3_handle){
|
if(device == g_bat485_uart3_handle){
|
||||||
bat485_tx_disenabla();
|
bat485_tx_disenabla();
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#include <adc.h>
|
#include <adc.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int16_t Calibrattion_Val = 0;
|
int16_t Calibrattion_Val = 0;
|
||||||
|
|
||||||
//ADC对应GPIO初始化配置以及ADC初始化配置
|
//ADC对应GPIO初始化配置以及ADC初始化配置
|
||||||
|
|
|
@ -66,8 +66,8 @@ void POW_OUT_CON_Init(void)
|
||||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||||
GPIO_Init(POW_OUT_CON_GPIO, &GPIO_InitStructure);
|
GPIO_Init(POW_OUT_CON_GPIO, &GPIO_InitStructure);
|
||||||
|
|
||||||
GPIO_WriteBit(POW_OUT_CON_GPIO, POW_OUT_CON_PIN, SET);
|
// GPIO_WriteBit(POW_OUT_CON_GPIO, POW_OUT_CON_PIN, SET);
|
||||||
// GPIO_WriteBit(POW_OUT_CON_GPIO, POW_OUT_CON_PIN, RESET);
|
GPIO_WriteBit(POW_OUT_CON_GPIO, POW_OUT_CON_PIN, RESET);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EXTI2_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
|
void EXTI2_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
|
||||||
|
|
|
@ -52,8 +52,8 @@ void PWM_TIM_Configuration(void)
|
||||||
|
|
||||||
void Set_duty_ratio(float *duty_ratio)
|
void Set_duty_ratio(float *duty_ratio)
|
||||||
{
|
{
|
||||||
if (*duty_ratio < 0.5) {
|
if (*duty_ratio < 0.1) {
|
||||||
*duty_ratio = 0.5;
|
*duty_ratio = 0.1;
|
||||||
// return;
|
// return;
|
||||||
} else if (*duty_ratio > 0.9) {
|
} else if (*duty_ratio > 0.9) {
|
||||||
*duty_ratio = 0.9;
|
*duty_ratio = 0.9;
|
||||||
|
|
|
@ -50,7 +50,7 @@ void TIM3_Int_Init(uint16_t arr, uint16_t psc)
|
||||||
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //使能通道1中断
|
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //使能通道1中断
|
||||||
NVIC_Init(&NVIC_InitStructure); //初始化NVIC
|
NVIC_Init(&NVIC_InitStructure); //初始化NVIC
|
||||||
|
|
||||||
TIM_Cmd(TIM3, ENABLE); //TIM3使能
|
// TIM_Cmd(TIM3, ENABLE); //TIM3使能
|
||||||
}
|
}
|
||||||
|
|
||||||
void TIM3_IRQHandler(void)
|
void TIM3_IRQHandler(void)
|
||||||
|
|
|
@ -26,7 +26,10 @@ App/src/collect_Conversion.o: ../App/src/collect_Conversion.c \
|
||||||
D:\psx\MPPT\git\Peripheral\inc/ch32l103_misc.h \
|
D:\psx\MPPT\git\Peripheral\inc/ch32l103_misc.h \
|
||||||
D:\psx\MPPT\git\Peripheral\inc/ch32l103_lptim.h \
|
D:\psx\MPPT\git\Peripheral\inc/ch32l103_lptim.h \
|
||||||
D:\psx\MPPT\git\Peripheral\inc/ch32l103_opa.h \
|
D:\psx\MPPT\git\Peripheral\inc/ch32l103_opa.h \
|
||||||
D:\psx\MPPT\git\Hardware\inc/adc.h D:\psx\MPPT\git\Hardware\inc/gpio.h
|
D:\psx\MPPT\git\Hardware\inc/adc.h D:\psx\MPPT\git\Hardware\inc/gpio.h \
|
||||||
|
D:\psx\MPPT\git\App\inc/uart_dev.h \
|
||||||
|
D:\psx\MPPT\git\Drivers\RingQueue/ring_queue.h \
|
||||||
|
D:\psx\MPPT\git\Hardware\inc/rs485.h
|
||||||
|
|
||||||
D:\psx\MPPT\git\App\inc/collect_Conversion.h:
|
D:\psx\MPPT\git\App\inc/collect_Conversion.h:
|
||||||
|
|
||||||
|
@ -89,3 +92,9 @@ D:\psx\MPPT\git\Peripheral\inc/ch32l103_opa.h:
|
||||||
D:\psx\MPPT\git\Hardware\inc/adc.h:
|
D:\psx\MPPT\git\Hardware\inc/adc.h:
|
||||||
|
|
||||||
D:\psx\MPPT\git\Hardware\inc/gpio.h:
|
D:\psx\MPPT\git\Hardware\inc/gpio.h:
|
||||||
|
|
||||||
|
D:\psx\MPPT\git\App\inc/uart_dev.h:
|
||||||
|
|
||||||
|
D:\psx\MPPT\git\Drivers\RingQueue/ring_queue.h:
|
||||||
|
|
||||||
|
D:\psx\MPPT\git\Hardware\inc/rs485.h:
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
18040
obj/mppt_Nos_V0.4.lst
18040
obj/mppt_Nos_V0.4.lst
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue