huyongji1.1-system/App/electrode/electrode.c

53 lines
1.4 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "electrode.h"
// 除磷控制变量
uint32_t phosphorus_timer = 0; // 除磷计时器
uint32_t PHOSPHORUS_RUN_TIME = 20; // 运行20分钟
uint32_t PHOSPHORUS_STOP_TIME = 40; // 停止40分钟
uint8_t polarity_state = 0; // 极性状态0-正常1-反转
uint8_t Dephosphorization_state = 0; // 0表示禁用1表示启用
// 除磷极性控制函数
// 除磷极性控制函数
void Control_Phosphorus_Polarity(void)
{
if(polarity_state)
{
// 反转极性
Control_Plate1(1); // 极板1为正极
Control_Plate2(0); // 极板2为负极
}
else
{
// 正常极性
Control_Plate1(0); // 极板1为负极
Control_Plate2(1); // 极板2为正极
}
}
// 除磷控制更新函数
void Phosphorus_Control_Update(void)
{
// 按20分钟开40分钟关的逻辑运行
if(phosphorus_timer <= PHOSPHORUS_RUN_TIME)
{
Control_Phosphorus(1); // 开启除磷
Dephosphorization_state = 1;
}
else if(phosphorus_timer <= (PHOSPHORUS_RUN_TIME + PHOSPHORUS_STOP_TIME))
{
Control_Phosphorus(0); // 关闭除磷
Dephosphorization_state = 0;
}
else
{
phosphorus_timer = 0; // 重置计时器
polarity_state = !polarity_state; // 切换极性
Control_Phosphorus_Polarity(); // 更新极性
Control_Phosphorus(1); // 开始新循环
}
}