Compare commits

...

4 Commits

Author SHA1 Message Date
许晟昊 cd626dca0f add:增加阀门型号 2024-01-26 11:23:40 +08:00
gaoyuhang 758bfdea18 "杭电:加入LCD接口函数" 2024-01-26 11:16:07 +08:00
gaoyuhang 49f1072a7f 111 2024-01-25 10:42:26 +08:00
gaoyuhang db5056cfb0 modify:111 2024-01-25 10:41:23 +08:00
15 changed files with 326 additions and 115 deletions

View File

@ -56,6 +56,8 @@
"files.associations": {
"pid_g.h": "c",
"mode_pwmp.h": "c",
"eeprom_m95.h": "c"
}
"eeprom_m95.h": "c",
"sys.h": "c"
},
"C_Cpp.errorSquiggles": "disabled"
}

View File

@ -127,6 +127,7 @@ int main(void)
leds_dinit(); // LED Deinitialization
my_mem_init(SRAMIN); // Initialize internal memory pool
my_mem_init(SRAMEX); // Initialize internal memory pool
board_init(); // Initialize board
app_init(); // Initialize application
@ -163,14 +164,12 @@ void SystemClock_Config(void)
/* Wait till HSE is ready */
while (LL_RCC_HSE_IsReady() != 1)
{
}
LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_HSE);
/* Wait till System clock is ready */
while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_HSE)
{
}
LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_2);
LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_1);
@ -194,7 +193,6 @@ void PeriphCommonClock_Config(void)
/* Wait till PLLSAI1 is ready */
while (LL_RCC_PLLSAI1_IsReady() != 1)
{
}
}

View File

@ -103,7 +103,7 @@
<bEvRecOn>1</bEvRecOn>
<bSchkAxf>0</bSchkAxf>
<bTchkAxf>0</bTchkAxf>
<nTsel>6</nTsel>
<nTsel>4</nTsel>
<sDll></sDll>
<sDllPa></sDllPa>
<sDlgDll></sDlgDll>
@ -114,13 +114,13 @@
<tDlgDll></tDlgDll>
<tDlgPa></tDlgPa>
<tIfile></tIfile>
<pMon>STLink\ST-LINKIII-KEIL_SWO.dll</pMon>
<pMon>Segger\JL2CM3.dll</pMon>
</DebugOpt>
<TargetDriverDllRegistry>
<SetRegEntry>
<Number>0</Number>
<Key>DLGUARM</Key>
<Name>(105=-1,-1,-1,-1,0)</Name>
<Name>d</Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
@ -163,107 +163,102 @@
<Ww>
<count>0</count>
<WinNumber>1</WinNumber>
<ItemText>mode_pwmp,0x0A</ItemText>
<ItemText>_pid,0x0A</ItemText>
</Ww>
<Ww>
<count>1</count>
<WinNumber>1</WinNumber>
<ItemText>_pid,0x0A</ItemText>
<ItemText>actual_travel</ItemText>
</Ww>
<Ww>
<count>2</count>
<WinNumber>1</WinNumber>
<ItemText>actual_travel</ItemText>
<ItemText>show_actual</ItemText>
</Ww>
<Ww>
<count>3</count>
<WinNumber>1</WinNumber>
<ItemText>show_actual</ItemText>
<ItemText>loop_current</ItemText>
</Ww>
<Ww>
<count>4</count>
<WinNumber>1</WinNumber>
<ItemText>loop_current</ItemText>
<ItemText>uDevice.SpecControlOutputMode,0x0A</ItemText>
</Ww>
<Ww>
<count>5</count>
<WinNumber>1</WinNumber>
<ItemText>uDevice.SpecControlOutputMode,0x0A</ItemText>
<ItemText>uDevice,0x0A</ItemText>
</Ww>
<Ww>
<count>6</count>
<WinNumber>1</WinNumber>
<ItemText>uDevice,0x0A</ItemText>
<ItemText>pid_actual</ItemText>
</Ww>
<Ww>
<count>7</count>
<WinNumber>1</WinNumber>
<ItemText>pid_actual</ItemText>
<ItemText>adc_raw,0x0A</ItemText>
</Ww>
<Ww>
<count>8</count>
<WinNumber>1</WinNumber>
<ItemText>adc_raw,0x0A</ItemText>
<ItemText>target_travel</ItemText>
</Ww>
<Ww>
<count>9</count>
<WinNumber>1</WinNumber>
<ItemText>target_travel</ItemText>
<ItemText>target_actual_diff,0x10</ItemText>
</Ww>
<Ww>
<count>10</count>
<WinNumber>1</WinNumber>
<ItemText>target_actual_diff,0x10</ItemText>
<ItemText>calib_param[CALIBPARA_PSB]</ItemText>
</Ww>
<Ww>
<count>11</count>
<WinNumber>1</WinNumber>
<ItemText>rsp,0x0A</ItemText>
<ItemText>uDevice.WorkMode,0x0A</ItemText>
</Ww>
<Ww>
<count>12</count>
<WinNumber>1</WinNumber>
<ItemText>calib_param[CALIBPARA_PSB]</ItemText>
<ItemText>loop_current</ItemText>
</Ww>
<Ww>
<count>13</count>
<WinNumber>1</WinNumber>
<ItemText>uDevice.WorkMode,0x0A</ItemText>
<ItemText>out_pos</ItemText>
</Ww>
<Ww>
<count>14</count>
<WinNumber>1</WinNumber>
<ItemText>loop_current</ItemText>
<ItemText>rsp,0x0A</ItemText>
</Ww>
<Ww>
<count>15</count>
<WinNumber>1</WinNumber>
<ItemText>out_pos</ItemText>
<ItemText>out_pos_watch</ItemText>
</Ww>
<Ww>
<count>16</count>
<WinNumber>1</WinNumber>
<ItemText>rsp,0x0A</ItemText>
<ItemText>mode_pwmp_hd_adjust,0x0A</ItemText>
</Ww>
<Ww>
<count>17</count>
<WinNumber>1</WinNumber>
<ItemText>out_pos_watch</ItemText>
<ItemText>pid_autotune_hd,0x0A</ItemText>
</Ww>
<Ww>
<count>18</count>
<WinNumber>1</WinNumber>
<ItemText>mode_pwmp_adjust,0x0A</ItemText>
<ItemText>mode_pwmp_hd,0x0A</ItemText>
</Ww>
<Ww>
<count>19</count>
<WinNumber>1</WinNumber>
<ItemText>pid_autotune_hd,0x0A</ItemText>
</Ww>
<Ww>
<count>20</count>
<WinNumber>1</WinNumber>
<ItemText>mode_pwmp_hd,0x0A</ItemText>
<ItemText>s_watch,0x0A</ItemText>
</Ww>
</WatchWindow1>
<Tracepoint>
@ -426,7 +421,7 @@
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>0</BreakIfRCount>
<Filename>C:\Users\10575\Desktop\wuxi\hangdian\controller-hd\User\application\src\mode_pwmp.c</Filename>
<Filename>..\User\application\src\mode_pwmp.c</Filename>
<ExecCommand></ExecCommand>
<Expression></Expression>
</Bp>
@ -600,7 +595,7 @@
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>0</BreakIfRCount>
<Filename>C:\Users\10575\Desktop\wuxi\hangdian\controller-hd\User\application\src\mode_pwmp.c</Filename>
<Filename>..\User\application\src\mode_pwmp.c</Filename>
<ExecCommand></ExecCommand>
<Expression></Expression>
</Bp>
@ -1404,7 +1399,7 @@
<Group>
<GroupName>User/lib</GroupName>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>

View File

@ -10,7 +10,7 @@
<TargetName>controller-v2</TargetName>
<ToolsetNumber>0x4</ToolsetNumber>
<ToolsetName>ARM-ADS</ToolsetName>
<pCCUsed>5060960::V5.06 update 7 (build 960)::.\ARMCC</pCCUsed>
<pCCUsed>5060061::V5.06 update 1 (build 61)::ARMCC</pCCUsed>
<uAC6>0</uAC6>
<TargetOption>
<TargetCommonOption>
@ -134,11 +134,11 @@
<RunIndependent>0</RunIndependent>
<UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
<Capability>1</Capability>
<DriverSelection>4101</DriverSelection>
<DriverSelection>4096</DriverSelection>
</Flash1>
<bUseTDR>1</bUseTDR>
<Flash2>BIN\UL2CM3.DLL</Flash2>
<Flash3></Flash3>
<Flash3>"" ()</Flash3>
<Flash4></Flash4>
<pFcarmOut></pFcarmOut>
<pFcarmGrp></pFcarmGrp>

View File

@ -22,6 +22,21 @@ typedef struct
mode_pwmp_hd_params_u mode_pwmp_hd_params; ///< PWMP模式参数
} mode_params_t;
typedef struct
{
uint16_t pos0; ///< 位置0 ad
uint16_t pos100; ///< 位置100 ad
uint16_t pot0; ///< 位置0 输出
uint16_t pot100; ///< 位置100 输出
uint16_t current0; ///< 位置0 电流(毫安放大100倍, 0.01ma=1)
uint16_t current100; ///< 位置100 电流(毫安,放大100倍0.01ma=1)
uint16_t open_time; ///< 全开时间(秒)
uint16_t close_time; ///< 全关时间(秒)
float32 kp; ///< pid 比例系数
float32 ki; ///< pid 积分系数
float32 kd; ///< pid 微分系数
} mode_adjust_data_t;
extern void mode_init(void); ///< 工作模式初始化
extern void mode_detection(uint8_t work_mode); ///< 工作模式处理
extern void travel_statistics(void); ///< 行程统计

View File

@ -5,6 +5,7 @@
#define MODE_DEFAULT_AUTOLOAD 99 // 预分频系数
#define WAIT_COUNT_MAX 10 // 蓝牙等待最大次数
#define VIP_H_EN_HD 1 // 高电压输出开关
///////////////////////////////////////*算法整定部分宏定义BEGIN*////////////////////////////////////////
#define TIME_CYCLE 0.01f // 定义时间周期:10ms
@ -13,7 +14,7 @@
#define DIFF_ADC_MAX 6U
/*阶跃信号大小*/
#define FULL_TRIP_SIGNAL 936
#define FULL_TRIP_SIGNAL 925 // 925 2020
#define HALF_TRIP_SIGNAL 753
#define SMALL_TRIP_SIGNAL 650
///////////////////////////////////////*算法整定部分宏定义END*///////////////////////////////////////////
@ -45,6 +46,10 @@ typedef struct
uint16_t trip_100; // 词条100位置AD
uint16_t trip_min0; // 小回路行程0位置AD
uint16_t trip_min100; // 小回路行程100位置AD
uint16_t current0; // 电流最小值
uint16_t current100; // 电流最大值
uint16_t all_open_time;// 全开时间
uint16_t all_close_time;// 全关时间
uint16_t prov_flag; // 磁条安装的正反倒装0 正装1
uint16_t valve_type; // 阀门正反行程气开ATO 气关ATC
float32 kp;
@ -122,8 +127,13 @@ typedef enum
PWMP_HD_ADJUST_STOP,
PWMP_HD_ADJUST_FAIL, // 整定失败
PWMP_HD_ADJUST_TEST,
PWMP_HD_ADJUST_BLEEDING_TIMER,
PWMP_HD_ADJUST_AERATE_TIMER,
PWMP_HD_ADJUST_TUNING,
} mode_pwmp_hd_adjust_state_e; // 整定状态
#define PWMP_HD_ADJUST_STEP LCD_ADJUST_STOP // 整定步骤
typedef enum
{
// 自整定结果 0未整定 1整定中 2整定完成 3整定失败
@ -186,6 +196,7 @@ typedef struct
{
float32 pre_actual; // 前一次的行程
float32 cur_actual; // 当前的行程
float32 adjust_tmp_actual; // 临时行程
float32 actual_error; // 行程的误差
float32 step_signal; // 阶跃信号
float32 step_signal_delt; // 阶跃信号差值
@ -248,7 +259,7 @@ typedef struct
} execute_rsp_hd_t;
/////////////////////////////////////////*控制算法END*////////////////////////////////////////
void mode_pwmp_hd_init(mode_pwmp_hd_params_u *params, void (*params_save_cb)(void));
void mode_pwmp_hd_init(uint16_t valve_style, mode_pwmp_hd_params_u *params, void (*params_save_cb)(void));
void mode_pwmp_hd_dinit(void);
void mode_pwmp_hd_process(void);
void pwmp_hd_process_state_set(mode_pwmp_hd_process_state_e state);

View File

@ -39,6 +39,13 @@ typedef enum
PRESSURE_PARAM_MAX,
} pressure_type_e;
typedef enum
{
VALVE_GPS1000 = 1000,
VALVE_GPS3000 = 3000,
VALVE_GPS5000 = 5000,
} valve_style_e; ///< 阀门型号
// 定位器工作模式
#define ON_LINE_MODE 0 ///< 在线模式根据4~20ma控制阀位,自动模式
#define OFF_LINE_MODE 1 ///< 离线模式根据hart指令控制阀位4~20ma用于供电手动模式

View File

@ -368,6 +368,48 @@ void mode_detection(uint8_t work_mode)
}
}
/**
* @brief
* @param {mode_adjust_data} *data
* @return {*}
* @note
*/
void mode_adjust_data_get(mode_adjust_data_t *data)
{
switch (uDevice.SpecControlOutputMode)
{
case PDCTRL_DAC:
{
break;
}
case PDCTRL_PWM:
{
break;
}
case PDCTRL_PWMP:
{
break;
}
case PDCTRL_PWMP_HD:
{
data->pos0 = mode_params.mode_pwmp_hd_params.storage.trip_0; ///< 位置0 ad
data->pos100 = mode_params.mode_pwmp_hd_params.storage.trip_100; ///< 位置100 ad
data->pot0 = mode_params.mode_pwmp_hd_params.storage.pwmp_min; ///< 位置0 输出
data->pot100 = mode_params.mode_pwmp_hd_params.storage.pwmp_max; ///< 位置100 输出
data->current0 = mode_params.mode_pwmp_hd_params.storage.current0; ///< 位置0 电流(毫安放大100倍, 0.01ma=1)
data->current100 = mode_params.mode_pwmp_hd_params.storage.current100; ///< 位置100 电流(毫安,放大100倍0.01ma=1)
data->open_time = mode_params.mode_pwmp_hd_params.storage.all_open_time; ///< 全开时间(秒)
data->close_time = mode_params.mode_pwmp_hd_params.storage.all_close_time; ///< 全关时间(秒)
data->kp = mode_params.mode_pwmp_hd_params.storage.kp; ///< pid 比例系数
data->ki = mode_params.mode_pwmp_hd_params.storage.ki; ///< pid 积分系数
data->kd = mode_params.mode_pwmp_hd_params.storage.kd; ///< pid 微分系数
break;
}
default:
break;
}
}
/**
* @brief
* @return {*}
@ -384,23 +426,17 @@ void mode_init(void)
if (uDevice.SpecControlOutputMode == PDCTRL_DAC)
{
pdctrl_init(PDCTRL_DAC);
mode_dac_init(&mode_params.mode_dac_params, mode_params_save_cb);
}
else if (uDevice.SpecControlOutputMode == PDCTRL_PWM)
{
pdctrl_init(PDCTRL_PWM);
mode_pwm_init(&mode_params.mode_pwm_params, mode_params_save_cb); ///< 要放在pdctrl_init()后面执行
}
else if (uDevice.SpecControlOutputMode == PDCTRL_PWMP)
{
pdctrl_init(PDCTRL_PWMP);
mode_pwmp_init(&mode_params.mode_pwmp_params, mode_params_save_cb);
}
else if (uDevice.SpecControlOutputMode == PDCTRL_PWMP_HD)
{
pdctrl_init(PDCTRL_PWMP_HD);
mode_pwmp_hd_init(&mode_params.mode_pwmp_hd_params, mode_params_save_cb);
mode_pwmp_hd_init(uDevice.ValveStyle, &mode_params.mode_pwmp_hd_params, mode_params_save_cb);
}
else
{

View File

@ -1,10 +1,3 @@
/**
* @file mode_pwmp_hd.c
* @author xxx
* @date 2023-10-10 08:58:43
* @brief
* @copyright Copyright (c) 2023 by xxx, All Rights Reserved.
*/
#include <stdio.h>
#include <math.h>
#include "sys.h"
@ -140,6 +133,63 @@ void mode_pwmp_hd_dinit(void)
}
}
/**
* @brief
* @param {uint8_t} mode
* @return {*}
* @note
*/
BOOL pwmp_hd_algorithm_calibrated_status(void)
{
return mode_pwmp_hd->pwmp_save->storage.tuned_flag == 1 && mode_pwmp_hd->pwmp_save->storage.tuned_state == LCD_ADJUST_RESULT_OK;
}
/**
* @brief
* @return {*}
* @note
*/
uint8_t pwmp_hd_process_adjust_result_get(void)
{
return mode_pwmp_hd->pwmp_save->storage.tuned_state;
}
/**
* @brief
* @return {*}
* @note
*/
BOOL pwmp_hd_process_is_adjust(void)
{
return mode_pwmp_hd->process_state == PWMP_HD_PROCESS_ADJUST;
}
/**
* @brief
* @return {*}
* @note
*/
uint8_t pwmp_hd_process_adjust_state_get(void)
{
return mode_pwmp_hd->lcd_adjust_state;
}
// 在进入PID控制区域不要绘图
BOOL pwmp_hd_process_idel(void)
{
if (mode_pwmp_hd->process_state == PWM_PROCESS_CONTROL)
{
// return fabsf(mode_pwmp_hd->control.real_error) <= get_dead_zone() ||
// mode_pwmp_hd->control.stable_flag == TRUE
// ? TRUE
// : FALSE;
return TRUE;
}
else
{
return TRUE;
}
}
//////////////////////////////*控制BEGIN*//////////////////////////////////////////////////////
/**
@ -159,10 +209,13 @@ void execute_pid_init(execute_plan_hd_e plan)
_pid.pid_u.hd.set_ctrl_prm_position(&_pid.pid_u.hd, get_pwmp_control_kp(), get_pwmp_control_ki(), get_pwmp_control_kd());
break;
case EXECUTE_PLAN_2:
break;
case EXECUTE_PLAN_3:
break;
case EXECUTE_PLAN_4:
default:
break;
}
@ -309,7 +362,9 @@ static void set_step_signal(uint16_t signal_in)
static valve_position_change_hd_e pwmp_adjust_hd_valve_position_change(uint8_t *state, uint8_t next_state, uint8_t diff_adc_max)
{
uint16_t diff_adc = 0;
// uint16_t adc = get_actual_travel_adc();
uint16_t adc = get_actual_travel_adc();
pid_autotune_hd->data.adjust_tmp_actual = adc;
if (mode_pwmp_hd_adjust->psb_adc != adc)
{
@ -355,7 +410,9 @@ static void pwmp_adjust_hd_idle(uint8_t *state, mode_pwmp_hd_adjust_state_e next
{
if (!FSM_IS_WAIT(*state))
{
mode_pwmp_hd->auto_tune_state = PWMP_HD_ADJUST_RESULT_TUNING;
sys_millis_reset();
osel_memset((uint8_t *)&mode_pwmp_hd->pwmp_save->storage, 0, sizeof(mode_pwmp_hd_storage_data_t));
mode_pwmp_hd->pwmp_save->storage.tuned_state = LCD_ADJUST_RESULT_ING;
/*为指针开辟存储空间*/
if (mode_pwmp_hd_adjust == NULL)
{
@ -898,6 +955,7 @@ static void pwmp_adjust_hd_fail(uint8_t *state)
/*PID参数整定模式*/
// 通过整定获得K、T、Ltao
int s_watch;
static void pwmp_adjust_hd_PID_tuning(uint8_t *state, mode_pwmp_hd_adjust_state_e next_state)
{
if (!FSM_IS_WAIT(*state))
@ -910,14 +968,15 @@ static void pwmp_adjust_hd_PID_tuning(uint8_t *state, mode_pwmp_hd_adjust_state_
pid_autotune_way_set(PID_AUTOTUNE_WAY_ZN);
/*阶跃信号设置*/
set_step_signal(FULL_TRIP_SIGNAL);
mode_pwmp_hd_adjust->wait_count = mode_pwmp_hd->wait_count_max * 80; // 等待八秒
mode_pwmp_hd_adjust->wait_count = mode_pwmp_hd->wait_count_max * 40; // 等待八秒
FSM_WAIT(*state); // 设置等待状态
}
else
{
valve_position_change_hd_e s = pwmp_adjust_hd_valve_position_change(state, next_state, DIFF_ADC_MAX);
s_watch = s;
/*获取实时行程*/
pid_autotune_hd->data.cur_actual = get_actual_travel_adc();
pid_autotune_hd->data.cur_actual = pid_autotune_hd->data.adjust_tmp_actual;
/*计算变化率*/
pid_autotune_hd->data.actual_error = pid_autotune_hd->data.cur_actual - pid_autotune_hd->data.pre_actual;
if (pid_autotune_hd->data.actual_error > 1000)
@ -958,7 +1017,7 @@ static void pwmp_adjust_hd_PID_tuning(uint8_t *state, mode_pwmp_hd_adjust_state_
*state = next_state;
break;
case POSITION_CHANGE:
mode_pwmp_hd_adjust->wait_count = mode_pwmp_hd->wait_count_max * 80;
mode_pwmp_hd_adjust->wait_count = mode_pwmp_hd->wait_count_max * 40;
break;
case POSITION_NO_CHANGE:
break;
@ -1015,9 +1074,19 @@ static void pwmp_adjust_hd_pid_calculate(uint8_t *state, mode_pwmp_hd_adjust_sta
static void pwmp_adjust_hd_save(uint8_t *state, mode_pwmp_hd_adjust_state_e next_state)
{
*state = next_state;
mode_pwmp_hd->pwmp_save->storage.tuned_flag = 1;
mode_pwmp_hd->params_save_cb();
if (mode_pwmp_hd->pwmp_save->storage.tuned_state == LCD_ADJUST_RESULT_ING)
{
mode_pwmp_hd->pwmp_save->storage.tuned_state = LCD_ADJUST_RESULT_OK;
mode_pwmp_hd->auto_tune_state = PWMP_HD_ADJUST_RESULT_SUCCESS;
mode_pwmp_hd->pwmp_save->storage.tuned_flag = 1;
pwmp_public_params_update();
}
else
{
mode_pwmp_hd->pwmp_save->storage.tuned_state = LCD_ADJUST_RESULT_FAIL;
mode_pwmp_hd->pwmp_save->storage.tuned_flag = 0;
}
mode_pwmp_hd->params_save_cb();
}
//////////////////////////////////*状态机模式END*//////////////////////////////////////////////////////
@ -1047,6 +1116,7 @@ void pwmp_adjust(uint8_t *state)
break;
case PWMP_HD_ADJUST_CALCULATE:
pwmp_adjust_hd_calculate(state, PWMP_HD_ADJUST_PID_TUNING);
break;
case PWMP_HD_ADJUST_PID_TUNING:
pwmp_adjust_hd_PID_tuning(state, PWMP_HD_ADJUST_PID_CALCULATE);
break;
@ -1073,6 +1143,42 @@ void pwmp_adjust(uint8_t *state)
pwmp_adjust_hd_stop(state);
break;
}
switch (ts)
{
case PWMP_HD_ADJUST_IDEL:
mode_pwmp_hd->lcd_adjust_state = LCD_ADJUST_IDEL;
break;
case PWMP_HD_ADJUST_ROUGH_POSITION0:
mode_pwmp_hd->lcd_adjust_state = LCD_ADJUST_POSITION0;
break;
case PWMP_HD_ADJUST_ACCURATE_POSITION0:
mode_pwmp_hd->lcd_adjust_state = LCD_ADJUST_POSITION0;
break;
case PWMP_HD_ADJUST_ROUGH_POSITION100:
mode_pwmp_hd->lcd_adjust_state = LCD_ADJUST_POSITION100;
break;
case PWMP_HD_ADJUST_ACCURATE_POSITION100:
mode_pwmp_hd->lcd_adjust_state = LCD_ADJUST_POSITION100;
break;
case PWMP_HD_ADJUST_BLEEDING_TIMER:
mode_pwmp_hd->lcd_adjust_state = LCD_ADJUST_TIMER;
break;
case PWMP_HD_ADJUST_AERATE_TIMER:
mode_pwmp_hd->lcd_adjust_state = LCD_ADJUST_TIMER;
break;
case PWMP_HD_ADJUST_TUNING:
mode_pwmp_hd->lcd_adjust_state = LCD_ADJUST_TUNING;
break;
case PWMP_HD_ADJUST_SAVE:
mode_pwmp_hd->lcd_adjust_state = LCD_ADJUST_SAVE;
break;
case PWMP_HD_ADJUST_STOP:
mode_pwmp_hd->lcd_adjust_state = LCD_ADJUST_STOP;
break;
default:
break;
}
}
//////////////////////////////*整定程序入口END*//////////////////////////////////////////////////////
@ -1091,7 +1197,7 @@ void mode_pwmp_hd_process(void)
uint8_t ble_len = 0;
osel_memset((uint8_t *)ble_data, 0, 128);
// sprintf(ble_data, "%f,%f,%f,%d,%f\r\n", pid_target, show_actual, p->real_error, mode_pwm->output, loop_current);
if (mode_pwmp_hd->process_state == PWMP_HD_PROCESS_CONTROL)
if (mode_pwmp_hd->process_state == PWMP_HD_PROCESS_ADJUST)
{
sprintf(ble_data, "%f,%f,%f,%f\r\n", mode_pwmp_hd->control.ctrl_target, mode_pwmp_hd->control.ctrl_feedback, mode_pwmp_hd->control.real_error, loop_current);
}
@ -1152,6 +1258,7 @@ void mode_pwmp_hd_process(void)
{
pdctrl_out(mode_pwmp_hd->output);
mode_pwmp_hd->current_adc = get_actual_travel_adc();
mode_pwmp_hd->duty_percent = ((float32)mode_pwmp_hd->output / (float32)ADC_OUT_MAX) * 100;
mode_pwmp_hd->current_electric = ip2current();
break;
}
@ -1162,11 +1269,14 @@ void mode_pwmp_hd_process(void)
//////////////////////////////*入口END*//////////////////////////////////////////////////////
/*程序初始化*/
void mode_pwmp_hd_init(mode_pwmp_hd_params_u *params, void (*params_save_cb)(void))
void mode_pwmp_hd_init(uint16_t valve_style, mode_pwmp_hd_params_u *params, void (*params_save_cb)(void))
{
DBG_ASSERT(params != NULL __DBG_LINE); // 断言检查
DBG_ASSERT(params_save_cb != NULL __DBG_LINE);
/*大电流输出使能开关*/
#if VIP_H_EN_HD == 1
VIP_H_EN_ENABLE();
#endif
/*为指针开辟存储空间*/
if (mode_pwmp_hd == NULL)
{
@ -1187,8 +1297,13 @@ void mode_pwmp_hd_init(mode_pwmp_hd_params_u *params, void (*params_save_cb)(voi
/*临时参数设置(后续整定)*/
mode_pwmp_hd->pwmp_save->storage.trip_0 = 2583;
mode_pwmp_hd->pwmp_save->storage.trip_100 = 1722;
#if VIP_H_EN_HD == 1
mode_pwmp_hd->pwmp_save->storage.pwmp_min = 500;
mode_pwmp_hd->pwmp_save->storage.pwmp_max = 925;
#else
mode_pwmp_hd->pwmp_save->storage.pwmp_min = 1025;
mode_pwmp_hd->pwmp_save->storage.pwmp_max = 2050;
#endif
mode_pwmp_hd->pwmp_save->storage.valve_type = ATO; // 气开阀
#if INTEGRAL_SEPARATION == 1
#if 1

View File

@ -129,6 +129,8 @@ void params_restart(void)
uDevice.DeviceAddr = 0;
// 定位器工作模式
uDevice.WorkMode = ON_LINE_MODE;
// 阀门型号
uDevice.ValveStyle = VALVE_GPS3000;
// 阀门类型
uDevice.eAirAction = ATO;
// 定位器控制输出模式

View File

@ -73,10 +73,14 @@ void pdctrl_init(pdctrl_mode_e mode)
{
pwm_init();
}
else if (out_mode == PDCTRL_PWMP)
else if (out_mode == PDCTRL_PWMP || out_mode == PDCTRL_PWMP_HD)
{
pwmp_init();
}
else
{
DBG_ASSERT(FALSE __DBG_LINE);
}
}
/**
@ -87,7 +91,7 @@ void pdctrl_init(pdctrl_mode_e mode)
void pdctrl_stop(void)
{
pdctrl_run_flag = FALSE;
if (out_mode == PDCTRL_DAC || out_mode == PDCTRL_PWMP)
if (out_mode == PDCTRL_DAC)
{
dac_dinit();
}
@ -95,10 +99,14 @@ void pdctrl_stop(void)
{
pwm_dinit();
}
else if (out_mode == PDCTRL_PWMP)
else if (out_mode == PDCTRL_PWMP || out_mode == PDCTRL_PWMP_HD)
{
pwmp_dinit();
}
else
{
DBG_ASSERT(FALSE __DBG_LINE);
}
}
/**
@ -117,10 +125,14 @@ void pdctrl_run(void)
{
pwm_init();
}
else if (out_mode == PDCTRL_PWMP)
else if (out_mode == PDCTRL_PWMP || out_mode == PDCTRL_PWMP_HD)
{
pwmp_init();
}
else
{
DBG_ASSERT(FALSE __DBG_LINE);
}
}
/**

View File

@ -42,7 +42,7 @@
#define SELF_VCHART_LEN 17 ///< 自定义阀门特性长度
#define VALVE_SERIAL_NUM_LEN 16 ///< 阀门序列号长度
#define INST_SERIAL_NUM_LEN 16 ///< 定位器序列号长度
#define DAC_OUT_MAX 4095 ///< DAC输出最大值
#define ADC_OUT_MAX 4095 ///< ADC输出最大值
/**
* ADC通道定义: 416 TCONV() = ( + 12.5 )/(/ADC分频系数)
@ -383,6 +383,24 @@ typedef union
} Bits;
} driver_icon_enable_u;
typedef enum
{
// 这一部分只用于LCD整定界面
LCD_ADJUST_IDEL = 1, // 准备中
LCD_ADJUST_POSITION0, // 位置0
LCD_ADJUST_POSITION100, // 位置100
LCD_ADJUST_TIMER, // 计时
LCD_ADJUST_TUNING, // 自整定
LCD_ADJUST_SAVE, // 存储变量
LCD_ADJUST_STOP, // 停止
} lcd_adjust_step_e;
typedef enum
{
LCD_ADJUST_RESULT_OK, ///< 整定成功
LCD_ADJUST_RESULT_FAIL, ///< 整定失败
LCD_ADJUST_RESULT_ING, ///< 整定中
} lcd_adjust_result_e;
#pragma pack() // 编译器中提供了#pragma pack(n)来设定变量以n字节对齐方式
extern volatile float32 calib_param[CALIBPARA_NUM][2]; ///< 校准参数

View File

@ -15,7 +15,7 @@
// mem1内存参数设定.mem1完全处于内部SRAM里面.(设置内部SARM的内存池和内存表的参数)
#define MEM1_BLOCK_SIZE 32 // 一个内存块大小为32字节
#define MEM1_MAX_SIZE 20 * 1024 // 最大管理内存 1K (我们这个内存管理系统的内部SRAM可控制的内存大小)
#define MEM1_MAX_SIZE 30 * 1024 // 最大管理内存 1K (我们这个内存管理系统的内部SRAM可控制的内存大小)
#define MEM1_ALLOC_TABLE_SIZE MEM1_MAX_SIZE / MEM1_BLOCK_SIZE // 内存表大小(有多少块内存块)
// mem2内存参数设定.mem2的内存池处于外部SRAM里面