Compare commits

..

No commits in common. "7d7af4febbf707f94df90dac93b04645011e1cca" and "f784f13bac947629d24f70e4e9bb176a880a83f4" have entirely different histories.

9 changed files with 143 additions and 295 deletions

View File

@ -1,6 +1,3 @@
{ {
"C_Cpp.errorSquiggles": "disabled", "C_Cpp.errorSquiggles": "disabled"
"files.associations": {
"cmath": "c"
}
} }

View File

@ -72,9 +72,9 @@ void PeriphCommonClock_Config(void);
/* USER CODE END 0 */ /* USER CODE END 0 */
/** /**
* @brief The application entry point. * @brief The application entry point.
* @retval int * @retval int
*/ */
int main(void) int main(void)
{ {
/* USER CODE BEGIN 1 */ /* USER CODE BEGIN 1 */
@ -91,7 +91,7 @@ int main(void)
NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
/* SysTick_IRQn interrupt configuration */ /* SysTick_IRQn interrupt configuration */
NVIC_SetPriority(SysTick_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),15, 0)); NVIC_SetPriority(SysTick_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 15, 0));
/* USER CODE BEGIN Init */ /* USER CODE BEGIN Init */
/* USER CODE END Init */ /* USER CODE END Init */
@ -99,7 +99,7 @@ int main(void)
/* Configure the system clock */ /* Configure the system clock */
SystemClock_Config(); SystemClock_Config();
/* Configure the peripherals common clocks */ /* Configure the peripherals common clocks */
PeriphCommonClock_Config(); PeriphCommonClock_Config();
/* USER CODE BEGIN SysInit */ /* USER CODE BEGIN SysInit */
@ -147,13 +147,13 @@ int main(void)
} }
/** /**
* @brief System Clock Configuration * @brief System Clock Configuration
* @retval None * @retval None
*/ */
void SystemClock_Config(void) void SystemClock_Config(void)
{ {
LL_FLASH_SetLatency(LL_FLASH_LATENCY_0); LL_FLASH_SetLatency(LL_FLASH_LATENCY_0);
while(LL_FLASH_GetLatency()!= LL_FLASH_LATENCY_0) while (LL_FLASH_GetLatency() != LL_FLASH_LATENCY_0)
{ {
} }
LL_PWR_SetRegulVoltageScaling(LL_PWR_REGU_VOLTAGE_SCALE1); LL_PWR_SetRegulVoltageScaling(LL_PWR_REGU_VOLTAGE_SCALE1);
@ -162,26 +162,23 @@ void SystemClock_Config(void)
} }
LL_RCC_HSE_Enable(); LL_RCC_HSE_Enable();
/* Wait till HSE is ready */ /* Wait till HSE is ready */
while(LL_RCC_HSE_IsReady() != 1) while (LL_RCC_HSE_IsReady() != 1)
{ {
} }
LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSE, LL_RCC_PLLM_DIV_1, 8, LL_RCC_PLLR_DIV_2); LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSE, LL_RCC_PLLM_DIV_1, 8, LL_RCC_PLLR_DIV_2);
LL_RCC_PLL_EnableDomain_SYS(); LL_RCC_PLL_EnableDomain_SYS();
LL_RCC_PLL_Enable(); LL_RCC_PLL_Enable();
/* Wait till PLL is ready */ /* Wait till PLL is ready */
while(LL_RCC_PLL_IsReady() != 1) while (LL_RCC_PLL_IsReady() != 1)
{ {
} }
LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL); LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL);
/* Wait till System clock is ready */ /* Wait till System clock is ready */
while(LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL) while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL)
{ {
} }
LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_8); LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_8);
LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_1); LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_1);
@ -193,19 +190,18 @@ void SystemClock_Config(void)
} }
/** /**
* @brief Peripherals Common Clock Configuration * @brief Peripherals Common Clock Configuration
* @retval None * @retval None
*/ */
void PeriphCommonClock_Config(void) void PeriphCommonClock_Config(void)
{ {
LL_RCC_PLLSAI1_ConfigDomain_ADC(LL_RCC_PLLSOURCE_HSE, LL_RCC_PLLM_DIV_1, 8, LL_RCC_PLLSAI1R_DIV_2); LL_RCC_PLLSAI1_ConfigDomain_ADC(LL_RCC_PLLSOURCE_HSE, LL_RCC_PLLM_DIV_1, 8, LL_RCC_PLLSAI1R_DIV_2);
LL_RCC_PLLSAI1_EnableDomain_ADC(); LL_RCC_PLLSAI1_EnableDomain_ADC();
LL_RCC_PLLSAI1_Enable(); LL_RCC_PLLSAI1_Enable();
/* Wait till PLLSAI1 is ready */ /* Wait till PLLSAI1 is ready */
while(LL_RCC_PLLSAI1_IsReady() != 1) while (LL_RCC_PLLSAI1_IsReady() != 1)
{ {
} }
} }
@ -214,9 +210,9 @@ void PeriphCommonClock_Config(void)
/* USER CODE END 4 */ /* USER CODE END 4 */
/** /**
* @brief This function is executed in case of error occurrence. * @brief This function is executed in case of error occurrence.
* @retval None * @retval None
*/ */
void Error_Handler(void) void Error_Handler(void)
{ {
/* USER CODE BEGIN Error_Handler_Debug */ /* USER CODE BEGIN Error_Handler_Debug */
@ -228,14 +224,14 @@ void Error_Handler(void)
/* USER CODE END Error_Handler_Debug */ /* USER CODE END Error_Handler_Debug */
} }
#ifdef USE_FULL_ASSERT #ifdef USE_FULL_ASSERT
/** /**
* @brief Reports the name of the source file and the source line number * @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred. * where the assert_param error has occurred.
* @param file: pointer to the source file name * @param file: pointer to the source file name
* @param line: assert_param error line source number * @param line: assert_param error line source number
* @retval None * @retval None
*/ */
void assert_failed(uint8_t *file, uint32_t line) void assert_failed(uint8_t *file, uint32_t line)
{ {
/* USER CODE BEGIN 6 */ /* USER CODE BEGIN 6 */

View File

@ -186,7 +186,7 @@ void MX_TIM7_Init(void)
/* USER CODE END TIM7_Init 1 */ /* USER CODE END TIM7_Init 1 */
TIM_InitStruct.Prescaler = 399; TIM_InitStruct.Prescaler = 399;
TIM_InitStruct.CounterMode = LL_TIM_COUNTERMODE_UP; TIM_InitStruct.CounterMode = LL_TIM_COUNTERMODE_UP;
TIM_InitStruct.Autoreload = 499; TIM_InitStruct.Autoreload = 99;
LL_TIM_Init(TIM7, &TIM_InitStruct); LL_TIM_Init(TIM7, &TIM_InitStruct);
LL_TIM_EnableARRPreload(TIM7); LL_TIM_EnableARRPreload(TIM7);
LL_TIM_SetTriggerOutput(TIM7, LL_TIM_TRGO_RESET); LL_TIM_SetTriggerOutput(TIM7, LL_TIM_TRGO_RESET);

View File

@ -1500,14 +1500,6 @@
</File> </File>
</Group> </Group>
<Group>
<GroupName>::CMSIS</GroupName>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>1</RteFlg>
</Group>
<Group> <Group>
<GroupName>Middlewares/Library/DSP Library/DSP Library</GroupName> <GroupName>Middlewares/Library/DSP Library/DSP Library</GroupName>
<tvExp>0</tvExp> <tvExp>0</tvExp>
@ -1515,7 +1507,7 @@
<cbSel>0</cbSel> <cbSel>0</cbSel>
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<File> <File>
<GroupNumber>17</GroupNumber> <GroupNumber>16</GroupNumber>
<FileNumber>91</FileNumber> <FileNumber>91</FileNumber>
<FileType>4</FileType> <FileType>4</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
@ -1528,4 +1520,12 @@
</File> </File>
</Group> </Group>
<Group>
<GroupName>::CMSIS</GroupName>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>1</RteFlg>
</Group>
</ProjectOpt> </ProjectOpt>

View File

@ -83,7 +83,7 @@
<RunUserProg1>1</RunUserProg1> <RunUserProg1>1</RunUserProg1>
<RunUserProg2>1</RunUserProg2> <RunUserProg2>1</RunUserProg2>
<UserProg1Name>fromelf --bin --output=@L.bin !L</UserProg1Name> <UserProg1Name>fromelf --bin --output=@L.bin !L</UserProg1Name>
<UserProg2Name></UserProg2Name> <UserProg2Name>output-controller-v24.bat</UserProg2Name>
<UserProg1Dos16Mode>0</UserProg1Dos16Mode> <UserProg1Dos16Mode>0</UserProg1Dos16Mode>
<UserProg2Dos16Mode>0</UserProg2Dos16Mode> <UserProg2Dos16Mode>0</UserProg2Dos16Mode>
<nStopA1X>0</nStopA1X> <nStopA1X>0</nStopA1X>
@ -1278,9 +1278,6 @@
</File> </File>
</Files> </Files>
</Group> </Group>
<Group>
<GroupName>::CMSIS</GroupName>
</Group>
<Group> <Group>
<GroupName>Middlewares/Library/DSP Library/DSP Library</GroupName> <GroupName>Middlewares/Library/DSP Library/DSP Library</GroupName>
<GroupOption> <GroupOption>
@ -1379,6 +1376,9 @@
</File> </File>
</Files> </Files>
</Group> </Group>
<Group>
<GroupName>::CMSIS</GroupName>
</Group>
</Groups> </Groups>
</Target> </Target>
</Targets> </Targets>

View File

@ -295,7 +295,6 @@ void mode_init(void)
break; break;
case MODE_FREQUENCY_DOMAIN_CONTROL_ALGORITHM: case MODE_FREQUENCY_DOMAIN_CONTROL_ALGORITHM:
pdctrl_init(PDCTRL_PWMP); pdctrl_init(PDCTRL_PWMP);
//pdctrl_init(PDCTRL_DAC);
mode_pwmp_hd_init(&mode_get()->interface_req, mode_get()->positioner_model, &mode_params.mode_pwmp_hd_params, mode_pwmp_hd_init(&mode_get()->interface_req, mode_get()->positioner_model, &mode_params.mode_pwmp_hd_params,
mode_params_save_cb); mode_params_save_cb);
break; break;

View File

@ -23,6 +23,7 @@ pwmp_hd_adjust_t *mode_pwmp_hd_adjust;
pid_autotune_hd_t *pid_autotune_hd; pid_autotune_hd_t *pid_autotune_hd;
pwmp_hd_test_t *mode_pwmp_hd_test; pwmp_hd_test_t *mode_pwmp_hd_test;
execute_rsp_hd_t rsp; // 执行结果 execute_rsp_hd_t rsp; // 执行结果
mode_pwmp_hd_valve_type_e valve_type_hd = ANGULAR_TRAVEL;
static execute_rsp_hd_t *execute_dac_plan1(void); // 执行方案1 static execute_rsp_hd_t *execute_dac_plan1(void); // 执行方案1
static execute_rsp_hd_t *execute_dac_plan2(void); // 执行方案2 static execute_rsp_hd_t *execute_dac_plan2(void); // 执行方案2
@ -52,45 +53,39 @@ static void _adjust_stop(void)
static uint8_t _adjust_result(void) static uint8_t _adjust_result(void)
{ {
if (mode_pwmp_hd->pwmp_save->storage.tuned_flag == TUNED_ONGOING) if (mode_pwmp_hd->process_state == PWMP_HD_PROCESS_ADJUST)
{ {
udevice.tuned_flag = TUNED_ONGOING; return TUNED_ONGOING;
}
else if (mode_pwmp_hd->pwmp_save->storage.tuned_flag == TUNED_SUCCESS)
{
udevice.tuned_flag = TUNED_SUCCESS;
} }
else else
{ {
udevice.tuned_flag = TUNED_FAILED; return mode_pwmp_hd->pwmp_save->storage.tuned_flag;
} }
return udevice.tuned_flag;
} }
static uint8_t _adjust_step_count(void) static uint8_t _adjust_step_count(void)
{ {
return mode_pwmp_hd->lcd_adjust_state; return LCD_ADJUST_STOP;
} }
static uint8_t _adjust_step_current(void) static uint8_t _adjust_step_current(void)
{ {
return mode_pwmp_hd_adjust->adjust_state; return LCD_ADJUST_IDEL;
} }
static void _adjust_data(mode_adjust_data_t *data) static void _adjust_data(mode_adjust_data_t *data)
{ {
data->pos0 = mode_pwmp_hd->pwmp_save->storage.trip_0; ///< 位置0 ad // data->pos0 = mode_control->storage_data->storage.ad_0; ///< 位置0 ad
data->pos100 = mode_pwmp_hd->pwmp_save->storage.trip_100; ///< 位置100 ad // data->pos100 = mode_control->storage_data->storage.ad_100; ///< 位置100 ad
data->pot0 = mode_pwmp_hd->pwmp_save->storage.pwmp_min_origin; ///< 位置0 输出 // data->pot0 = mode_control->storage_data->storage.aerate_min_arr; ///< 位置0 输出
data->pot100 = mode_pwmp_hd->pwmp_save->storage.pwmp_max_origin; ///< 位置100 输出 // data->pot100 = mode_control->storage_data->storage.aerate_max_arr; ///< 位置100 输出
data->current0 = mode_pwmp_hd->pwmp_save->storage.current0; ///< 位置0 电流(毫安放大100倍, 0.01ma=1) // data->current0 = mode_control->storage_data->storage.aerate_min_current; ///< 位置0 电流(毫安放大100倍, 0.01ma=1)
data->current100 = mode_pwmp_hd->pwmp_save->storage.current100; ///< 位置100 电流(毫安,放大100倍0.01ma=1) // data->current100 = mode_control->storage_data->storage.aerate_max_current; ///< 位置100 电流(毫安,放大100倍0.01ma=1)
data->open_time = mode_pwmp_hd->pwmp_save->storage.all_open_time; ///< 全开时间(秒) // data->open_time = mode_control->storage_data->storage.all_open_time; ///< 全开时间(秒)
data->close_time = mode_pwmp_hd->pwmp_save->storage.all_close_time; ///< 全关时间(秒) // data->close_time = mode_control->storage_data->storage.all_close_time; ///< 全关时间(秒)
data->kp = mode_pwmp_hd->pwmp_save->storage.kp; ///< pid 比例系数 // data->kp = mode_control->storage_data->storage.kp; ///< pid 比例系数
data->ki = mode_pwmp_hd->pwmp_save->storage.ki; ///< pid 积分系数 // data->ki = mode_control->storage_data->storage.ki; ///< pid 积分系数
data->kd = mode_pwmp_hd->pwmp_save->storage.kd; ///< pid 微分系数 // data->kd = mode_control->storage_data->storage.kd; ///< pid 微分系数
} }
static BOOL _control_idle(void) static BOOL _control_idle(void)
@ -106,7 +101,7 @@ static BOOL _adjust_isrun(void)
/*程序状态设置*/ /*程序状态设置*/
void pwmp_hd_process_state_set(mode_pwmp_hd_process_state_e state) void pwmp_hd_process_state_set(mode_pwmp_hd_process_state_e state)
{ {
if (mode_pwmp_hd->process_state == state && mode_pwmp_hd->process_state == PWMP_HD_PROCESS_ADJUST) if (mode_pwmp_hd->process_state == state && mode_pwmp_hd->adjust_state == PWMP_HD_PROCESS_ADJUST)
{ {
mode_pwmp_hd->process_state = PWMP_HD_PROCESS_STOP; mode_pwmp_hd->process_state = PWMP_HD_PROCESS_STOP;
} }
@ -189,7 +184,7 @@ static float32 get_pwmp_hd_control_ki(void)
static float32 get_pwmp_hd_control_kd(void) static float32 get_pwmp_hd_control_kd(void)
{ {
// return mode_pwmp_hd->pwmp_save->storage.kd < 0.01 ? mode_pwmp_hd->pwmp_save->storage.kd : 0.001; // return mode_pwmp_hd->pwmp_save->storage.kd < 0.01 ? mode_pwmp_hd->pwmp_save->storage.kd : 0.001;
if (udevice.value_travel_type == TRAVEL_TYPE_STRAIGHT) if (valve_type_hd == LINEAR_TRAVEL)
{ {
return mode_pwmp_hd->pwmp_save->storage.kd = 0; return mode_pwmp_hd->pwmp_save->storage.kd = 0;
} }
@ -220,13 +215,19 @@ static void pwmp_public_params_update()
udevice.tuned_flag = mode_pwmp_hd->pwmp_save->storage.prov_flag; udevice.tuned_flag = mode_pwmp_hd->pwmp_save->storage.prov_flag;
} }
//////////////////////////////*控制BEGIN*////////////////////////////////////////////////////// /*程序反初始化*/
void mode_pwmp_hd_stop(mode_pwmp_hd_t *handle) void mode_pwmp_hd_dinit(void)
{ {
// 释放内存 if (mode_pwmp_hd != NULL)
osel_memset((uint8_t *)&handle->control, 0, sizeof(mode_pwmp_hd_control_t)); {
pwmp_hd_process_state_set(PWMP_HD_PROCESS_STOP);
osel_mem_free(mode_pwmp_hd);
mode_pwmp_hd = NULL;
}
} }
//////////////////////////////*控制BEGIN*//////////////////////////////////////////////////////
/** /**
* @brief * @brief
* @param {execute_plan_hd_e} plan * @param {execute_plan_hd_e} plan
@ -290,7 +291,7 @@ static execute_rsp_hd_t *execute_dac_plan1()
_pid.pid_u.hd.set_out_prm_position(&_pid.pid_u.hd, 100, 0); _pid.pid_u.hd.set_out_prm_position(&_pid.pid_u.hd, 100, 0);
out = _pid.pid_u.hd.pid_position(&_pid.pid_u.hd, mode_pwmp_hd->control.real_error); out = _pid.pid_u.hd.pid_position(&_pid.pid_u.hd, mode_pwmp_hd->control.real_error);
out = out / 100; out = out / 100;
if (udevice.value_travel_type == TRAVEL_TYPE_STRAIGHT) if (valve_type_hd == LINEAR_TRAVEL)
{ {
/* 一阶段加权系数*/ /* 一阶段加权系数*/
static float32 index_min_first = 0.5; static float32 index_min_first = 0.5;
@ -314,9 +315,8 @@ static execute_rsp_hd_t *execute_dac_plan1()
out += mode_pwmp_hd->pwmp_save->storage.pwmp_min_origin; out += mode_pwmp_hd->pwmp_save->storage.pwmp_min_origin;
} }
} }
else if (udevice.value_travel_type == TRAVEL_TYPE_ANGULAR) else if (valve_type_hd == ANGULAR_TRAVEL)
{ {
#if 0
/* 一阶段加权系数*/ /* 一阶段加权系数*/
static float32 index_min_first = 1.2; static float32 index_min_first = 1.2;
static float32 index_max_first = 1.2; static float32 index_max_first = 1.2;
@ -341,23 +341,6 @@ static execute_rsp_hd_t *execute_dac_plan1()
out *= (mode_pwmp_hd->pwmp_save->storage.pwmp_max_origin - Control_diff * index_max_third) - (mode_pwmp_hd->pwmp_save->storage.pwmp_min_origin + Control_diff * index_min_third); // 映射实际控制器的范围 out *= (mode_pwmp_hd->pwmp_save->storage.pwmp_max_origin - Control_diff * index_max_third) - (mode_pwmp_hd->pwmp_save->storage.pwmp_min_origin + Control_diff * index_min_third); // 映射实际控制器的范围
out += (mode_pwmp_hd->pwmp_save->storage.pwmp_min_origin + Control_diff * index_min_third); out += (mode_pwmp_hd->pwmp_save->storage.pwmp_min_origin + Control_diff * index_min_third);
} }
#else
float32 index = fabs(1 - exp(-(pow(mode_pwmp_hd->control.real_error, 2) - 1)));
if (fabs(mode_pwmp_hd->control.real_error) >= 1)
{
out *= (mode_pwmp_hd->pwmp_save->storage.pwmp_max_origin + Control_diff * index) - (mode_pwmp_hd->pwmp_save->storage.pwmp_min_origin - Control_diff * index); // 映射实际控制器的范围
out += mode_pwmp_hd->pwmp_save->storage.pwmp_min_origin - Control_diff * index;
}
else if (fabs(mode_pwmp_hd->control.real_error) > 0.99 && fabs(mode_pwmp_hd->control.real_error) < 1)
{
out = mode_pwmp_hd->pwmp_save->storage.startup_value;
}
else if (fabs(mode_pwmp_hd->control.real_error) < 1)
{
out *= (mode_pwmp_hd->pwmp_save->storage.pwmp_max_origin) - (mode_pwmp_hd->pwmp_save->storage.pwmp_min_origin); // 映射实际控制器的范围
out += (mode_pwmp_hd->pwmp_save->storage.pwmp_min_origin);
}
#endif
} }
rsp.code = EXECUTE_HD_OUT; rsp.code = EXECUTE_HD_OUT;
@ -455,7 +438,6 @@ static void pwmp_adjust_hd_idle(uint8_t *state, mode_pwmp_hd_adjust_state_e next
{ {
if (!FSM_IS_WAIT(*state)) if (!FSM_IS_WAIT(*state))
{ {
mode_pwmp_hd->auto_tune_state = PWMP_HD_ADJUST_RESULT_TUNING;
sys_millis_reset(); sys_millis_reset();
osel_memset((uint8_t *)&mode_pwmp_hd->pwmp_save->storage, 0, sizeof(mode_pwmp_hd_storage_data_t)); 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_flag = TUNED_ONGOING; mode_pwmp_hd->pwmp_save->storage.tuned_flag = TUNED_ONGOING;
@ -491,15 +473,6 @@ static void pwmp_adjust_hd_idle(uint8_t *state, mode_pwmp_hd_adjust_state_e next
// 位置不再改变记录此时阀门位置AD值 // 位置不再改变记录此时阀门位置AD值
mode_pwmp_hd_adjust->adc_record_1 = pid_autotune_hd->data.adjust_tmp_actual; mode_pwmp_hd_adjust->adc_record_1 = pid_autotune_hd->data.adjust_tmp_actual;
mode_pwmp_hd_adjust->adc_record_0 = pid_autotune_hd->data.adjust_tmp_actual; mode_pwmp_hd_adjust->adc_record_0 = pid_autotune_hd->data.adjust_tmp_actual;
// 记录0位置电流的大小
if (udevice.value_action_type == ATO)
{
mode_pwmp_hd_adjust->current_0 = ip2current();
}
else
{
mode_pwmp_hd_adjust->current_100 = ip2current();
}
break; break;
case POSITION_CHANGE: case POSITION_CHANGE:
*state = PWMP_HD_ADJUST_IDEL; *state = PWMP_HD_ADJUST_IDEL;
@ -520,7 +493,7 @@ static void pwmp_adjust_hd_rough_position0(uint8_t *state, mode_pwmp_hd_adjust_s
if (!FSM_IS_WAIT(*state)) if (!FSM_IS_WAIT(*state))
{ {
// 以10%增加提高DAC输出找到能推动阀门的最小值 // 以10%增加提高DAC输出找到能推动阀门的最小值
mode_pwmp_hd_adjust->arr_current = 200; mode_pwmp_hd_adjust->arr_current = 100;
mode_pwmp_hd_adjust->arr_last = mode_pwmp_hd_adjust->arr_current; mode_pwmp_hd_adjust->arr_last = mode_pwmp_hd_adjust->arr_current;
pdctrl_out(mode_pwmp_hd_adjust->arr_current); pdctrl_out(mode_pwmp_hd_adjust->arr_current);
mode_pwmp_hd_adjust->wait_count = mode_pwmp_hd->wait_count_max * 20; mode_pwmp_hd_adjust->wait_count = mode_pwmp_hd->wait_count_max * 20;
@ -533,7 +506,7 @@ static void pwmp_adjust_hd_rough_position0(uint8_t *state, mode_pwmp_hd_adjust_s
current_adc = pid_autotune_hd->data.adjust_tmp_actual; current_adc = pid_autotune_hd->data.adjust_tmp_actual;
// 3.28修改将DIFF_ADC_MAX由10改为6 // 3.28修改将DIFF_ADC_MAX由10改为6
if (ABS(current_adc - mode_pwmp_hd_adjust->adc_record_1) >= 10U) // 阀位发生改变 if (ABS(current_adc - mode_pwmp_hd_adjust->adc_record_1) >= 20U) // 阀位发生改变
{ {
if (mode_pwmp_hd_adjust->arr_last > 4000) if (mode_pwmp_hd_adjust->arr_last > 4000)
{ {
@ -563,11 +536,11 @@ static void pwmp_adjust_hd_rough_position0(uint8_t *state, mode_pwmp_hd_adjust_s
mode_pwmp_hd_adjust->arr_last = mode_pwmp_hd_adjust->arr_current; mode_pwmp_hd_adjust->arr_last = mode_pwmp_hd_adjust->arr_current;
if (mode_pwmp_hd_adjust->arr_last < 500) if (mode_pwmp_hd_adjust->arr_last < 500)
{ {
mode_pwmp_hd_adjust->arr_current = mode_pwmp_hd_adjust->arr_current * 1.1; mode_pwmp_hd_adjust->arr_current = mode_pwmp_hd_adjust->arr_current * 1.05;
} }
else else
{ {
mode_pwmp_hd_adjust->arr_current = mode_pwmp_hd_adjust->arr_current * 1.05; mode_pwmp_hd_adjust->arr_current = mode_pwmp_hd_adjust->arr_current * 1.02;
} }
/*若输出信号为最大值时认定为整定错误*/ /*若输出信号为最大值时认定为整定错误*/
if (mode_pwmp_hd_adjust->arr_current > 4000) if (mode_pwmp_hd_adjust->arr_current > 4000)
@ -576,8 +549,9 @@ static void pwmp_adjust_hd_rough_position0(uint8_t *state, mode_pwmp_hd_adjust_s
*state = PWMP_HD_ADJUST_FAIL; *state = PWMP_HD_ADJUST_FAIL;
return; return;
} }
pdctrl_out(mode_pwmp_hd_adjust->arr_current); pdctrl_out(mode_pwmp_hd_adjust->arr_current);
mode_pwmp_hd_adjust->wait_count = mode_pwmp_hd->wait_count_max * 30; mode_pwmp_hd_adjust->wait_count = mode_pwmp_hd->wait_count_max * 40;
*state = PWMP_HD_ADJUST_ROUGH_POSITION0; *state = PWMP_HD_ADJUST_ROUGH_POSITION0;
FSM_WAIT(*state); // 设置等待状态 FSM_WAIT(*state); // 设置等待状态
} }
@ -602,7 +576,7 @@ static void pwmp_adjust_hd_rough_position0(uint8_t *state, mode_pwmp_hd_adjust_s
} }
/*放气值0信号的整定*/ /*放气值0信号的整定*/
static void pwmp_adjust_hd_initiate_position0(uint8_t *state, mode_pwmp_hd_adjust_state_e next_state) static void pwmp_adjust_hd_bleeding_position0(uint8_t *state, mode_pwmp_hd_adjust_state_e next_state)
{ {
BOOL flag = FALSE; BOOL flag = FALSE;
mode_pwmp_hd_adjust->psb_adc = get_actual_travel_adc(); mode_pwmp_hd_adjust->psb_adc = get_actual_travel_adc();
@ -789,15 +763,8 @@ static void pwmp_adjust_hd_rough_position100(uint8_t *state, mode_pwmp_hd_adjust
// 等待放气完毕 // 等待放气完毕
return; return;
} }
sys_millis_reset();
if (udevice.value_action_type == ATO) // 若调节阀为气开阀 mode_pwmp_hd_adjust->all_open_time_full = sys_millis(); // 记录全开起始时间
{
mode_pwmp_hd_adjust->all_open_time_full = sys_millis(); // 记录满信号全开起始时间
}
else
{
mode_pwmp_hd_adjust->all_close_time_full = sys_millis(); // 记录满信号全关起始时间
}
mode_pwmp_hd_adjust->tmp_time = 0; mode_pwmp_hd_adjust->tmp_time = 0;
pdctrl_out(mode_pwmp_hd_adjust->arr_record_2); // 以最大值进行输出 pdctrl_out(mode_pwmp_hd_adjust->arr_record_2); // 以最大值进行输出
@ -815,16 +782,7 @@ static void pwmp_adjust_hd_rough_position100(uint8_t *state, mode_pwmp_hd_adjust
case POSITION_NO_CHANGE_FOREVER: case POSITION_NO_CHANGE_FOREVER:
// 位置不再改变记录此时阀门位置AD值 // 位置不再改变记录此时阀门位置AD值
mode_pwmp_hd_adjust->adc_record_2 = current_adc; mode_pwmp_hd_adjust->adc_record_2 = current_adc;
if (udevice.value_action_type == ATO) // 若调节阀为气开阀 mode_pwmp_hd_adjust->all_open_time_full = mode_pwmp_hd_adjust->tmp_time - mode_pwmp_hd_adjust->all_open_time_full;
{
mode_pwmp_hd_adjust->tmp_time = sys_millis();
mode_pwmp_hd_adjust->all_open_time_full = mode_pwmp_hd_adjust->tmp_time - mode_pwmp_hd_adjust->all_open_time_full;
}
else // 若调节阀为气关阀
{
mode_pwmp_hd_adjust->tmp_time = sys_millis();
mode_pwmp_hd_adjust->all_close_time_full = mode_pwmp_hd_adjust->tmp_time - mode_pwmp_hd_adjust->all_close_time_full;
}
break; break;
case POSITION_CHANGE: case POSITION_CHANGE:
mode_pwmp_hd_adjust->wait_count = mode_pwmp_hd->wait_count_max * 50; mode_pwmp_hd_adjust->wait_count = mode_pwmp_hd->wait_count_max * 50;
@ -842,41 +800,12 @@ static void pwmp_adjust_hd_rough_position100(uint8_t *state, mode_pwmp_hd_adjust
} }
} }
/*排气值整定*/
static void pwmp_adjust_hd_bleeding_position0(uint8_t *state, mode_pwmp_hd_adjust_state_e next_state)
{
if (!FSM_IS_WAIT(*state))
{
mode_pwmp_hd_adjust->adjust_state = (mode_pwmp_hd_adjust_state_e)*state;
FSM_WAIT(*state); // 设置等待状态
}
else
{
valve_position_change_e s = pwmp_adjust_hd_valve_position_change(state, next_state, DIFF_ADC);
mode_pwmp_hd_adjust->psb_adc = pid_autotune_hd->data.adjust_tmp_actual;
switch (s)
{
case POSITION_NO_CHANGE_FOREVER: // 位置不再改变
{
break;
}
case POSITION_CHANGE:
break;
default:
break;
}
}
}
/*精调冲顶值*/ /*精调冲顶值*/
static void pwmp_adjust_hd_accurate_position100(uint8_t *state, mode_pwmp_hd_adjust_state_e next_state) static void pwmp_adjust_hd_accurate_position100(uint8_t *state, mode_pwmp_hd_adjust_state_e next_state)
{ {
if (!FSM_IS_WAIT(*state)) if (!FSM_IS_WAIT(*state))
{ {
mode_pwmp_hd_adjust->all_bleed_time_flag = true; mode_pwmp_hd_adjust->all_close_time_flag = TRUE;
mode_pwmp_hd_adjust->arr_current = mode_pwmp_hd_adjust->arr_record_1; // 初始值为前一步整定出的最小启动值 mode_pwmp_hd_adjust->arr_current = mode_pwmp_hd_adjust->arr_record_1; // 初始值为前一步整定出的最小启动值
mode_pwmp_hd_adjust->arr_last = mode_pwmp_hd_adjust->arr_current; mode_pwmp_hd_adjust->arr_last = mode_pwmp_hd_adjust->arr_current;
mode_pwmp_hd_adjust->adjust_state = (mode_pwmp_hd_adjust_state_e)*state; mode_pwmp_hd_adjust->adjust_state = (mode_pwmp_hd_adjust_state_e)*state;
@ -908,17 +837,7 @@ static void pwmp_adjust_hd_accurate_position100(uint8_t *state, mode_pwmp_hd_adj
if (adc_diff <= 10) if (adc_diff <= 10)
{ {
*state = next_state; *state = next_state;
// 记录在100阀位的adc值
mode_pwmp_hd_adjust->arr_record_2 = mode_pwmp_hd_adjust->arr_current; mode_pwmp_hd_adjust->arr_record_2 = mode_pwmp_hd_adjust->arr_current;
// 记录在100阀位时的电流大小
if (udevice.value_action_type == ATO)
{
mode_pwmp_hd_adjust->current_100 = ip2current();
}
else
{
mode_pwmp_hd_adjust->current_0 = ip2current();
}
} }
else else
{ {
@ -973,15 +892,7 @@ static void pwmp_adjust_hd_all_close_time(uint8_t *state, mode_pwmp_hd_adjust_st
mode_pwmp_hd_adjust->arr_current = mode_pwmp_hd_adjust->arr_record_0 - 100; // 此处的输入信号大小根据实际控制的最小值来设定 mode_pwmp_hd_adjust->arr_current = mode_pwmp_hd_adjust->arr_record_0 - 100; // 此处的输入信号大小根据实际控制的最小值来设定
/*记录起始的全开时间*/ /*记录起始的全开时间*/
sys_millis_reset(); mode_pwmp_hd_adjust->all_close_time = sys_millis();
if (udevice.value_action_type == ATO)
{
mode_pwmp_hd_adjust->all_close_time = sys_millis();
}
else
{
mode_pwmp_hd_adjust->all_open_time = sys_millis();
}
mode_pwmp_hd_adjust->tmp_time = 0; mode_pwmp_hd_adjust->tmp_time = 0;
pdctrl_out(mode_pwmp_hd_adjust->arr_current); pdctrl_out(mode_pwmp_hd_adjust->arr_current);
@ -1015,15 +926,7 @@ static void pwmp_adjust_hd_all_open_time(uint8_t *state, mode_pwmp_hd_adjust_sta
mode_pwmp_hd_adjust->arr_current = mode_pwmp_hd_adjust->arr_record_2 + 100; // 此处的输入信号大小根据实际控制的最大值来设定 mode_pwmp_hd_adjust->arr_current = mode_pwmp_hd_adjust->arr_record_2 + 100; // 此处的输入信号大小根据实际控制的最大值来设定
/*记录起始的全开时间*/ /*记录起始的全开时间*/
sys_millis_reset(); mode_pwmp_hd_adjust->all_open_time = sys_millis();
if (udevice.value_action_type == ATO)
{
mode_pwmp_hd_adjust->all_open_time = sys_millis();
}
else
{
mode_pwmp_hd_adjust->all_close_time = sys_millis();
}
mode_pwmp_hd_adjust->tmp_time = 0; mode_pwmp_hd_adjust->tmp_time = 0;
pdctrl_out(mode_pwmp_hd_adjust->arr_current); pdctrl_out(mode_pwmp_hd_adjust->arr_current);
@ -1042,7 +945,7 @@ static void pwmp_adjust_hd_all_open_time(uint8_t *state, mode_pwmp_hd_adjust_sta
else else
{ {
mode_pwmp_hd_adjust->tmp_time = sys_millis(); mode_pwmp_hd_adjust->tmp_time = sys_millis();
mode_pwmp_hd_adjust->all_close_time = mode_pwmp_hd_adjust->tmp_time - mode_pwmp_hd_adjust->all_close_time; mode_pwmp_hd_adjust->all_close_time = mode_pwmp_hd_adjust->tmp_time - mode_pwmp_hd_adjust->all_open_time;
} }
*state = next_state; *state = next_state;
} }
@ -1067,18 +970,12 @@ static void pwmp_adjust_hd_calculate(uint8_t *state, mode_pwmp_hd_adjust_state_e
mode_pwmp_hd->pwmp_save->storage.pwmp_min = mode_pwmp_hd_adjust->arr_record_0 - (mode_pwmp_hd->pwmp_save->storage.arr_diff); mode_pwmp_hd->pwmp_save->storage.pwmp_min = mode_pwmp_hd_adjust->arr_record_0 - (mode_pwmp_hd->pwmp_save->storage.arr_diff);
/*启动值*/ /*启动值*/
mode_pwmp_hd->pwmp_save->storage.startup_value = mode_pwmp_hd_adjust->arr_record_1; mode_pwmp_hd->pwmp_save->storage.startup_value = mode_pwmp_hd_adjust->adc_record_1;
/*0与100阀位位置*/
mode_pwmp_hd->pwmp_save->storage.current0 = mode_pwmp_hd_adjust->current_0;
mode_pwmp_hd->pwmp_save->storage.current100 = mode_pwmp_hd_adjust->current_100;
/*全开及全关时间*/ /*全开及全关时间*/
mode_pwmp_hd->pwmp_save->storage.all_open_time = mode_pwmp_hd_adjust->all_open_time; mode_pwmp_hd->pwmp_save->storage.all_open_time = mode_pwmp_hd_adjust->all_open_time;
mode_pwmp_hd->pwmp_save->storage.all_close_time = mode_pwmp_hd_adjust->all_close_time; mode_pwmp_hd->pwmp_save->storage.all_close_time = mode_pwmp_hd_adjust->all_close_time;
mode_pwmp_hd->pwmp_save->storage.all_open_time_full = mode_pwmp_hd_adjust->all_open_time_full; mode_pwmp_hd->pwmp_save->storage.all_open_time_full = mode_pwmp_hd_adjust->all_open_time_full;
mode_pwmp_hd->pwmp_save->storage.all_close_time_full = mode_pwmp_hd_adjust->all_close_time_full;
/*判断调节阀类型(气开/气关),对最低行程和最高行程进行标定*/ /*判断调节阀类型(气开/气关),对最低行程和最高行程进行标定*/
if (udevice.value_action_type == ATO) if (udevice.value_action_type == ATO)
{ {
@ -1124,19 +1021,6 @@ static void pwmp_adjust_hd_bleeding(uint8_t *state)
{ {
mode_pwmp_hd_adjust->arr_current = mode_pwmp_hd_adjust->arr_default; mode_pwmp_hd_adjust->arr_current = mode_pwmp_hd_adjust->arr_default;
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 * 80;
if (mode_pwmp_hd_adjust->all_bleed_time_flag == true)
{
sys_millis_reset();
if (udevice.value_action_type == ATO)
{
mode_pwmp_hd_adjust->all_close_time_full = sys_millis();
}
else
{
mode_pwmp_hd_adjust->all_open_time_full = sys_millis();
}
mode_pwmp_hd_adjust->tmp_time = 0;
}
pdctrl_out(0); pdctrl_out(0);
FSM_WAIT(*state); // 设置等待状态 FSM_WAIT(*state); // 设置等待状态
} }
@ -1147,22 +1031,13 @@ static void pwmp_adjust_hd_bleeding(uint8_t *state)
switch (s) switch (s)
{ {
case POSITION_NO_CHANGE_FOREVER: case POSITION_NO_CHANGE_FOREVER:
if (mode_pwmp_hd_adjust->all_bleed_time_flag == true)
{
if (udevice.value_action_type == ATO) // 若调节阀为气开阀
{
mode_pwmp_hd_adjust->tmp_time = sys_millis();
mode_pwmp_hd_adjust->all_close_time_full = mode_pwmp_hd_adjust->tmp_time - mode_pwmp_hd_adjust->all_close_time_full;
}
else // 若调节阀为气关阀
{
mode_pwmp_hd_adjust->tmp_time = sys_millis();
mode_pwmp_hd_adjust->all_open_time_full = mode_pwmp_hd_adjust->tmp_time - mode_pwmp_hd_adjust->all_open_time_full;
}
mode_pwmp_hd_adjust->all_bleed_time_flag = false;
}
mode_pwmp_hd_adjust->wait_count = mode_pwmp_hd->wait_count_max * 50; // 排气状态结束后在跳转后的状态中等待5s mode_pwmp_hd_adjust->wait_count = mode_pwmp_hd->wait_count_max * 50; // 排气状态结束后在跳转后的状态中等待5s
mode_pwmp_hd_adjust->arr_current = 0; mode_pwmp_hd_adjust->arr_current = 0;
// if (mode_pwmp_hd_adjust->psb_adc != mode_pwmp_hd_adjust->adc_record_1)
// {
// mode_pwmp_hd_adjust->adc_record_1 = mode_pwmp_hd_adjust->psb_adc;
// mode_pwmp_hd->pwmp_save->storage.trip_0 = mode_pwmp_hd_adjust->psb_adc;
// }
break; break;
case POSITION_CHANGE: case POSITION_CHANGE:
if (mode_pwmp_hd_adjust->adc_record_0 == 0) if (mode_pwmp_hd_adjust->adc_record_0 == 0)
@ -1178,20 +1053,21 @@ static void pwmp_adjust_hd_bleeding(uint8_t *state)
case POSITION_NO_CHANGE: case POSITION_NO_CHANGE:
break; break;
default: default:
pwmp_hd_process_state_set(PWMP_HD_PROCESS_ADJUST_STOP); *state = PWMP_HD_ADJUST_STOP;
break; break;
} }
} }
} }
/*停止模式*/ /*停止模式*/
static void pwmp_adjust_hd_stop() static void pwmp_adjust_hd_stop(uint8_t *state)
{ {
if (mode_pwmp_hd_adjust != NULL) if (mode_pwmp_hd_adjust != NULL)
{ {
osel_mem_free(mode_pwmp_hd_adjust); osel_mem_free(mode_pwmp_hd_adjust);
mode_pwmp_hd_adjust = NULL; mode_pwmp_hd_adjust = NULL;
} }
*state = PWMP_HD_ADJUST_IDEL;
if (mode_pwmp_hd->auto_tune_state == PWMP_HD_ADJUST_RESULT_TUNING) if (mode_pwmp_hd->auto_tune_state == PWMP_HD_ADJUST_RESULT_TUNING)
{ {
mode_pwmp_hd->auto_tune_state = PWMP_HD_ADJUST_RESULT_IDEL; mode_pwmp_hd->auto_tune_state = PWMP_HD_ADJUST_RESULT_IDEL;
@ -1213,6 +1089,7 @@ static void pwmp_adjust_hd_fail(uint8_t *state)
/*PID参数整定模式*/ /*PID参数整定模式*/
// 通过整定获得K、T、Ltao // 通过整定获得K、T、Ltao
int s_watch;
static void pwmp_adjust_hd_PID_tuning(uint8_t *state, mode_pwmp_hd_adjust_state_e next_state) static void pwmp_adjust_hd_PID_tuning(uint8_t *state, mode_pwmp_hd_adjust_state_e next_state)
{ {
if (!FSM_IS_WAIT(*state)) if (!FSM_IS_WAIT(*state))
@ -1232,6 +1109,7 @@ static void pwmp_adjust_hd_PID_tuning(uint8_t *state, mode_pwmp_hd_adjust_state_
else else
{ {
valve_position_change_e s = pwmp_adjust_hd_valve_position_change(state, next_state, DIFF_ADC); valve_position_change_e s = pwmp_adjust_hd_valve_position_change(state, next_state, DIFF_ADC);
s_watch = s;
/*获取实时行程*/ /*获取实时行程*/
pid_autotune_hd->data.cur_actual = pid_autotune_hd->data.adjust_tmp_actual; pid_autotune_hd->data.cur_actual = pid_autotune_hd->data.adjust_tmp_actual;
/*计算变化率*/ /*计算变化率*/
@ -1280,7 +1158,7 @@ static void pwmp_adjust_hd_PID_tuning(uint8_t *state, mode_pwmp_hd_adjust_state_
case POSITION_NO_CHANGE: case POSITION_NO_CHANGE:
break; break;
default: default:
pwmp_hd_process_state_set(PWMP_HD_PROCESS_ADJUST_STOP); *state = PWMP_HD_ADJUST_STOP;
break; break;
} }
} }
@ -1356,16 +1234,13 @@ void pwmp_adjust(uint8_t *state)
switch (ts) switch (ts)
{ {
case PWMP_HD_ADJUST_ROUGH_POSITION0: case PWMP_HD_ADJUST_ROUGH_POSITION0:
pwmp_adjust_hd_rough_position0(state, PWMP_HD_ADJUST_INITIATE); pwmp_adjust_hd_rough_position0(state, PWMP_HD_ADJUST_BLEEDING_POSITION0);
break;
case PWMP_HD_ADJUST_INITIATE:
pwmp_adjust_hd_initiate_position0(state, PWMP_HD_ADJUST_ROUGH_POSITION100);
break;
case PWMP_HD_ADJUST_ROUGH_POSITION100:
pwmp_adjust_hd_rough_position100(state, PWMP_HD_ADJUST_BLEEDING_POSITION0);
break; break;
case PWMP_HD_ADJUST_BLEEDING_POSITION0: case PWMP_HD_ADJUST_BLEEDING_POSITION0:
pwmp_adjust_hd_bleeding_position0(state, PWMP_HD_ADJUST_ACCURATE_POSITION100); pwmp_adjust_hd_bleeding_position0(state, PWMP_HD_ADJUST_ROUGH_POSITION100);
break;
case PWMP_HD_ADJUST_ROUGH_POSITION100:
pwmp_adjust_hd_rough_position100(state, PWMP_HD_ADJUST_ACCURATE_POSITION100);
break; break;
case PWMP_HD_ADJUST_ACCURATE_POSITION100: case PWMP_HD_ADJUST_ACCURATE_POSITION100:
pwmp_adjust_hd_accurate_position100(state, PWMP_HD_ADJUST_ALL_CLOSE_TIME); pwmp_adjust_hd_accurate_position100(state, PWMP_HD_ADJUST_ALL_CLOSE_TIME);
@ -1395,14 +1270,14 @@ void pwmp_adjust(uint8_t *state)
pwmp_adjust_hd_idle(state, PWMP_HD_ADJUST_ROUGH_POSITION0); pwmp_adjust_hd_idle(state, PWMP_HD_ADJUST_ROUGH_POSITION0);
break; break;
case PWMP_HD_ADJUST_STOP: case PWMP_HD_ADJUST_STOP:
pwmp_hd_process_state_set(PWMP_HD_PROCESS_ADJUST_STOP); pwmp_adjust_hd_stop(state);
break; break;
case PWMP_HD_ADJUST_FAIL: case PWMP_HD_ADJUST_FAIL:
pwmp_adjust_hd_fail(state); pwmp_adjust_hd_fail(state);
pwmp_hd_process_state_set(PWMP_HD_PROCESS_ADJUST_STOP); pwmp_adjust_hd_stop(state);
break; break;
default: default:
pwmp_hd_process_state_set(PWMP_HD_PROCESS_ADJUST_STOP); pwmp_adjust_hd_stop(state);
break; break;
} }
@ -1804,18 +1679,11 @@ void mode_pwmp_hd_process(void)
break; break;
} }
case PWMP_HD_PROCESS_ADJUST: case PWMP_HD_PROCESS_ADJUST:
{
pwmp_adjust((uint8_t *)&mode_pwmp_hd->adjust_state); pwmp_adjust((uint8_t *)&mode_pwmp_hd->adjust_state);
break; break;
}
case PWMP_HD_PROCESS_ADJUST_STOP:
{
pwmp_adjust_hd_stop();
break;
}
case PWMP_HD_PROCESS_STOP: case PWMP_HD_PROCESS_STOP:
{ {
mode_pwmp_hd_stop((mode_pwmp_hd_t *)&mode_pwmp_hd); // TODO 完成停止自整定,并释放资源
break; break;
} }
case PWMP_HD_PROCESS_TEST: case PWMP_HD_PROCESS_TEST:
@ -1887,14 +1755,3 @@ void mode_pwmp_hd_init(mode_interface_req_t *req, uint16_t positioner_model, mod
pwmp_public_params_update(); pwmp_public_params_update();
calib_parapos_perent(); calib_parapos_perent();
} }
/*程序反初始化*/
void mode_pwmp_hd_dinit(void)
{
if (mode_pwmp_hd != NULL)
{
pwmp_hd_process_state_set(PWMP_HD_PROCESS_STOP);
osel_mem_free(mode_pwmp_hd);
mode_pwmp_hd = NULL;
}
}

View File

@ -20,6 +20,11 @@
/*----------------------------------------*/ /*----------------------------------------*/
typedef enum typedef enum
{
ANGULAR_TRAVEL,
LINEAR_TRAVEL,
} mode_pwmp_hd_valve_type_e; // 阀门类型
typedef enum
{ {
PWMP_HD_PROCESS_CONTROL, PWMP_HD_PROCESS_CONTROL,
PWMP_HD_PROCESS_ADJUST, PWMP_HD_PROCESS_ADJUST,
@ -31,26 +36,25 @@ typedef enum
/*需要存储的变量*/ /*需要存储的变量*/
typedef struct typedef struct
{ {
uint8_t tuned_flag; // 整定标志 0未整定1整定中2整定成功3整定失败 uint8_t tuned_flag; // 整定标志 0未整定1整定中2整定成功3整定失败
uint16_t startup_value; // 阀位启动值 uint16_t startup_value; // 阀位启动值
uint16_t arr_diff; // 控制区间 uint16_t arr_diff; // 控制区间
uint16_t ad_diff; // 磁条区间 uint16_t ad_diff; // 磁条区间
uint16_t pwmp_min; // 控制最小值 uint16_t pwmp_min; // 控制最小值
uint16_t pwmp_max; // 控制最大值 uint16_t pwmp_max; // 控制最大值
uint16_t pwmp_min_origin; // 整定控制最小值 uint16_t pwmp_min_origin; // 整定控制最小值
uint16_t pwmp_max_origin; // 整定控制最大值 uint16_t pwmp_max_origin; // 整定控制最大值
uint16_t trip_0; // 磁条0位置AD uint16_t trip_0; // 磁条0位置AD
uint16_t trip_100; // 词条100位置AD uint16_t trip_100; // 词条100位置AD
uint16_t trip_min0; // 小回路行程0位置AD uint16_t trip_min0; // 小回路行程0位置AD
uint16_t trip_min100; // 小回路行程100位置AD uint16_t trip_min100; // 小回路行程100位置AD
uint16_t current0; // 电流最小值 uint16_t current0; // 电流最小值
uint16_t current100; // 电流最大值 uint16_t current100; // 电流最大值
uint16_t all_open_time; // 全开时间 uint16_t all_open_time; // 全开时间
uint16_t all_close_time; // 全关时间 uint16_t all_close_time; // 全关时间
uint16_t all_open_time_full; // 最大信号全开时间 uint16_t all_open_time_full; // 最大信号全开时间
uint16_t all_close_time_full; // 最大信号全关时间 uint16_t prov_flag; // 磁条安装的正反倒装0 正装1
uint16_t prov_flag; // 磁条安装的正反倒装0 正装1 uint16_t valve_type; // 阀门正反行程气开ATO 气关ATC
uint16_t valve_type; // 阀门正反行程气开ATO 气关ATC
float32 kp; float32 kp;
float32 ki; float32 ki;
float32 kd; float32 kd;
@ -161,7 +165,6 @@ typedef enum
PWMP_HD_ADJUST_SAVE, // 存储变量 PWMP_HD_ADJUST_SAVE, // 存储变量
PWMP_HD_ADJUST_BLEEDING, // 在整定状态中放气 PWMP_HD_ADJUST_BLEEDING, // 在整定状态中放气
PWMP_HD_ADJUST_BLEEDING_POSITION0, // 放气位置0 PWMP_HD_ADJUST_BLEEDING_POSITION0, // 放气位置0
PWMP_HD_ADJUST_INITIATE, // 启动值
PWMP_HD_ADJUST_STOP, PWMP_HD_ADJUST_STOP,
PWMP_HD_ADJUST_FAIL, // 整定失败 PWMP_HD_ADJUST_FAIL, // 整定失败
PWMP_HD_ADJUST_TEST, PWMP_HD_ADJUST_TEST,
@ -194,7 +197,6 @@ typedef struct
BOOL adc_0_100_flag; // 判断0-100移动过程中ad值是增大还是减少TRUE 增大FALSE 减小 BOOL adc_0_100_flag; // 判断0-100移动过程中ad值是增大还是减少TRUE 增大FALSE 减小
BOOL flag_stable_begin; BOOL flag_stable_begin;
BOOL flag_stable_end; BOOL flag_stable_end;
BOOL all_bleed_time_flag;
uint16_t adc_record_0; // 记录放气时阀门最小位置ad值 uint16_t adc_record_0; // 记录放气时阀门最小位置ad值
uint16_t adc_record_1; // 记录放气时阀门最小位置ad值 uint16_t adc_record_1; // 记录放气时阀门最小位置ad值
@ -207,14 +209,11 @@ typedef struct
uint16_t arr_record_stable_begin; // 记录阀门稳定区域开始的ad值 uint16_t arr_record_stable_begin; // 记录阀门稳定区域开始的ad值
uint16_t arr_record_stable_end; // 记录阀门稳定区域结束的ad值 uint16_t arr_record_stable_end; // 记录阀门稳定区域结束的ad值
uint32_t all_open_time; // 全开时间 uint32_t all_open_time; // 全开时间
uint32_t all_open_time_full; // 信号为最大输出时的全开时间 uint32_t all_open_time_full; // 信号为最大输出时的全开时间
uint32_t all_close_time; // 全关时间 uint32_t all_close_time; // 全关时间
uint32_t all_close_time_full; // 信号为最大输出时的全关时间 BOOL all_close_time_flag;
uint32_t tmp_time; // 临时用来记录全开全关/整定时间 uint32_t tmp_time; // 临时用来记录全开全关/整定时间
uint32_t current_0; // 0位置电流大小
uint32_t current_100; // 100位置电流大小
/*输出值*/ /*输出值*/
uint16_t arr_default; // 默认计数器(推动计数值) uint16_t arr_default; // 默认计数器(推动计数值)

View File

@ -267,8 +267,8 @@ Mcu.ThirdParty0=STMicroelectronics.X-CUBE-ALGOBUILD.1.3.0
Mcu.ThirdPartyNb=1 Mcu.ThirdPartyNb=1
Mcu.UserConstants= Mcu.UserConstants=
Mcu.UserName=STM32L476VGTx Mcu.UserName=STM32L476VGTx
MxCube.Version=6.10.0 MxCube.Version=6.9.2
MxDb.Version=DB.6.0.100 MxDb.Version=DB.6.0.92
NVIC.ADC1_2_IRQn=true\:14\:0\:true\:false\:true\:true\:true\:true NVIC.ADC1_2_IRQn=true\:14\:0\:true\:false\:true\:true\:true\:true
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.DMA1_Channel1_IRQn=true\:14\:0\:true\:false\:true\:false\:true\:true NVIC.DMA1_Channel1_IRQn=true\:14\:0\:true\:false\:true\:false\:true\:true
@ -710,7 +710,7 @@ TIM6.Period=99
TIM6.Prescaler=399 TIM6.Prescaler=399
TIM7.AutoReloadPreload=TIM_AUTORELOAD_PRELOAD_ENABLE TIM7.AutoReloadPreload=TIM_AUTORELOAD_PRELOAD_ENABLE
TIM7.IPParameters=Prescaler,Period,AutoReloadPreload TIM7.IPParameters=Prescaler,Period,AutoReloadPreload
TIM7.Period=499 TIM7.Period=99
TIM7.Prescaler=399 TIM7.Prescaler=399
UART5.BaudRate=9600 UART5.BaudRate=9600
UART5.IPParameters=BaudRate UART5.IPParameters=BaudRate