This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
大家好!
我将使用 DCL_runDF22_C2和 DCL_runDF22_C3以及 DCL_runClamp_C1来控制我的 PSFB。 我注意到 DCL_runClamp_C1 的一些内容。
// Clamping and saturation float32_t PSFB_cntlMax, PSFB_cntlMin; uint16_t PSFB_saturation_flag; float32_t PSFB_icommand_Set_pu, PSFB_irampmax_Set_pu; PSFB_saturation_flag = DCL_runClamp_C1(&PSFB_icommand_Set_pu, PSFB_cntlMax, PSFB_cntlMin); //clamp
q1)为何无法将 PSFB_cntlMax、 PSFB_cntlMin 和 PSFB_ICommand_SET_PU 等参数定义为 volatile? 如果定义这些参数、我会在构建代码后收到警告。
问题2) 在我开发的电路板中: 在我的软件中、我需要调整输出电流、在缓慢的任务中、我需要更新 PSFB_cntlMax 参数。 如果我 在线更新 PSFB_cntlMax、则运行正常并限制我的电流。 但是、如果我还要更新输出设置电压、即 DF22的输入、我的控制器会发生中断、并且无法调节输出电压。 我的 psfb 在电流限制模式下始终有效、尽管误差输出变为负值、但钳位输出始终保持为 Umax
Q2.a )它怎么可能是?
Q2.b)如果我使用演示板 F280039C,它不会卡在同一状态?
Q3)我修复了上述问题、将 PSFB_cntlMax 作为常数1.0f、并且我不再更改它。 我使用以下函数更改钳位最大值和最小值。
慢速任务中更新的参数为 PSFB_PCMC_PSB Cset_Slewed。
//钳位最大值/最小值
PSFB_ICommand_SET_PU =(PSFB_ICommand_SET_PU > PSFB_PCMC_PSFB Cset_Slewed)?
PSFB_PCMC_PSFB_ICommand_Set_pu Cset_Slewed;
PSFB_vLVBus_sensed_pu = ((float32_t)(Measurements.V_LVBat)) * PSFB_ADC_PU_SCALE_FACTOR; //yk pu PSFB_vcommand_Set_pu = PSFB_LV_Vset_Slewed / (PSFB_VLVBUS_MAX_SENSE_VOLTS); //rk PSFB_error_vLVBus_pu = PSFB_vcommand_Set_pu - PSFB_vLVBus_sensed_pu; //error PSFB_icommand_Set_pu = DCL_runDF22_C2 (&PSFB_gv, PSFB_error_vLVBus_pu); //run compensator PSFB_saturation_flag = DCL_runClamp_C1(&PSFB_icommand_Set_pu, PSFB_cntlMax, PSFB_cntlMin); //clamp if(PSFB_saturation_flag == 0) { DCL_runDF22_C3(&PSFB_gv, PSFB_error_vLVBus_pu, PSFB_icommand_Set_pu); } // Clamp max/min PSFB_icommand_Set_pu = (PSFB_icommand_Set_pu > PSFB_PCMC_Cset_Slewed)? PSFB_PCMC_Cset_Slewed:PSFB_icommand_Set_pu; PSFB_icommand_Set_pu = (PSFB_icommand_Set_pu < PSFB_cntlMin)? PSFB_cntlMin:PSFB_icommand_Set_pu;
Q3.a)该解决方案如何解决我的问题?
尊敬的 Gokhan:
我还会按以下顺序回答您的问题:
q1)您可以使用小提琴关键字,但编译器会抱怨在非小提琴参数(如 DCL_runClamp_c1)中传递小提琴参数。 您可以通过使用关键字 Violatile 添加函数参数来修复它。
Q2)虽然我不知道代码结构就不能推测可能是什么原因、但如果你的代码不使用 ISR、而一切都按 时间顺序进行、那么就不应该发生。 但是、如果涉及到 ISR、并且您正在不同例程之间共享值(例如、本例中的 PSFB_ICommand_Set_pu 和 PSFB_cntlMax)。 然后、建议使用一些多路复用机制来在读取值时阻止写入。 您所说的对我来说似乎是计时问题、它是持续存在的、可能导致一个设置出现问题、而它似乎不会导致另一个设置出现问题。
Q3)唯一的不同是、我们直接访问 PSFB_ICommand_Set_pu 的值、而不是将地址传递给函数。 您的 PSFB_icommand_Set_pu 是否被声明为局部变量? 如果是、您可以尝试将变量声明为 转换单元范围(全局变量)吗?
此致!
王森