📄 process.c
字号:
process_left_time = 0;
operation_counter ++;
pass_time_counter ++;
mot_cycle_buff = MOT_RIGHT;
output_buff |= CW;
return;
}
}
}
else
return;
}
else
return;
}
}
/******************************************************************************************
spin(unsigned int spin_time): 连续脱水过程处理程序
******************************************************************************************/
void spin(unsigned int spin_time)
{
static unsigned int spin_time_buff = 0;
if (process_left_time == 0) /* 剩余时间为0,重置剩余时间 */
process_left_time = spin_time + 30 + 5;
if (lid_open) /* 脱水开盖,进行错误处理 */
{
err_buff = OPEN_LID_ERR; // need check how to handle the ERR_PROCESS;
return;
}
if (unbalance_flag == 1) /* 判定是否进行不平衡修正 */
{
if (water_full_flag == 0) /* 补水 */
{
if (balance_inlet_flag == 0)
{
balance_inlet_flag = 1;
// inlet(0, 0, water_level_buff);
output_buff |= INLET;
inlet_2m_buff = INLET_SET_TIME;
}
if (inlet_2m_buff >= 0)
inlet_2m_buff --;
if (balance_stream_flag == 1)
{
balance_inlet_flag = 0;
balance_stream_flag = 0;
balance_drain_flag = 0;
inlet_2m_buff = INLET_SET_TIME;
drain_2m_buff = DRAIN_SET_TIME;
spin_balance_time_buff = 60;
unbalance_flag = 0;
}
}
if (water_full_flag == 1) /* 补水完成时进行不平衡修正的平衡水流洗涤过程 */
{
if (balance_stream_flag == 0)
{
balance_stream_flag = 1;
output_buff &= (~INLET);
stream_buff = BALANCE_STREAM;
spin_balance_time_buff = 60;
}
if (spin_balance_time_buff > 0)
{
spin_balance_time_buff --;
}
if (spin_balance_time_buff == 0)
{
stream_buff = STREAM_STOP;
output_buff &= (~CW);
output_buff &= (~CCW);
if (water_full_flag != 0)
{
if (balance_drain_flag == 0)
{
balance_drain_flag = 1;
drain_2m_buff = DRAIN_SET_TIME;
output_buff |= DRAIN;
// drain();
}
if(drain_2m_buff >= 0)
drain_2m_buff --;
}
}
}
return;
}
if (spin_time_buff < spin_time)
{
mot_cycle_buff = MOT_RIGHT; /* 开始连续脱水 */
output_buff |= CW;
spin_time_buff ++;
process_left_time -- ;
}
if (spin_time_buff == spin_time) /* 脱水完成 */
{
mot_cycle_buff = MOT_STOP;
output_buff &= (~CW);
if (inertial_30s_buff > 0) /* 30s 惯性脱水处理 */
{
inertial_30s_buff --;
process_left_time --;
}
if (inertial_30s_buff ==0) /* 惯性脱水完成 */
{
// if (program_buff != TUBE_DRY)
// output_buff &= (~DRAIN);
// else if ((program_buff == TUBE_DRY)&&(operation_counter >=5))
// output_buff &= (~DRAIN);
if (break_5s_buff > 0) /* 5s 刹车 */
{
// Drain_OPT = 1;
// Drain_OPT_1 = 1;
output_buff &= (~DRAIN);
break_5s_buff --;
process_left_time --;
}
if (break_5s_buff == 0) /* 连续脱水结束处理 */
{
spin_time_buff = 0;
inertial_30s_buff = 30;
break_5s_buff = 5;
process_left_time = 0;
operation_counter += 3;
pass_time_counter += 3;
}
}
}
return;
}
/***********************************************************************************************
void soak_x(void): 浸泡过程x处理程序
***********************************************************************************************/
void soak_1(void) /* 浸泡过程1为2m/3m组合 */
{
stream_buff = MAIN_STREAM;
if (soak_2m_buff > 0) /* 2m浸泡运行,电机正反转 */
soak_2m_buff --;
if (soak_2m_buff == 0) /* 2m浸泡运行完成 */
{
stream_buff = STREAM_STOP;
mot_cycle_buff &= MOT_STOP;
output_buff &= (~CW);
output_buff &= (~CCW);
if (soak_3m_buff > 0) /* 电机停止运行3分钟 */
soak_3m_buff --;
if (soak_3m_buff == 0) /* 3m时间到,循环次数变量增加1 */
{
soak_2m_buff = 120;
soak_3m_buff = 180;
soak_1_cycle_buff ++;
}
}
}
void soak_2(void) /* 浸泡过程1为1m/4m组合 */
{
stream_buff = MAIN_STREAM;
if (soak_1m_buff > 0) /* 1m浸泡运行,电机正反转 */
soak_1m_buff --;
if (soak_1m_buff == 0) /* 1m浸泡运行完成 */
{
stream_buff = STREAM_STOP;
mot_cycle_buff &= MOT_STOP;
output_buff &= (~CW);
output_buff &= (~CCW);
if (soak_4m_buff > 0) /* 电机停止运行4分钟 */
soak_4m_buff --;
if (soak_4m_buff == 0) /* 4m时间到,循环次数变量增加1 */
{
soak_1m_buff = 60;
soak_4m_buff = 240;
soak_2_cycle_buff ++;
}
}
}
void soak_3(void) /* 浸泡过程1为1m/9m组合 */
{
stream_buff = MAIN_STREAM;
if (soak_1m_buff > 0) /* 1m浸泡运行,电机正反转 */
soak_1m_buff --;
if (soak_1m_buff == 0) /* 1m浸泡运行完成 */
{
stream_buff = STREAM_STOP;
mot_cycle_buff &= MOT_STOP;
output_buff &= (~CW);
output_buff &= (~CCW);
if (soak_9m_buff > 0) /* 电机停止运行9分钟 */
soak_9m_buff --;
if (soak_9m_buff == 0) /* 9m时间到,循环次数变量增加1 */
{
soak_1m_buff = 60;
soak_9m_buff = 540;
soak_3_cycle_buff ++;
}
}
}
/***********************************************************************************************
void run_stream(void): 水流运行处理程序
***********************************************************************************************/
void run_stream(void) /* 该程序根据主逻辑里面水流的选择从水流数表里面选择电机正反转运行参数 */
{
static unsigned int run_time = 600;
static unsigned int stop_time = 800;
if (stream_buff == MAIN_STREAM)
{
/* if (program_buff == SPEEDY)
{
if (operation_counter == 1)
{
run_time = Speedy_Stream_A[0].run;
stop_time = Speedy_Stream_A[0].stop;
}
if (operation_counter == 3)
{
run_time = Speedy_Stream_A[1].run;
stop_time = Speedy_Stream_A[1].stop;
}
if (operation_counter == 4)
{
run_time = Speedy_Stream_A[2].run;
stop_time = Speedy_Stream_A[2].stop;
}
if (operation_counter == 5)
{
run_time = Speedy_Stream_A[3].run;
stop_time = Speedy_Stream_A[3].stop;
}
}
if (program_buff == FASTEST)
{
if (operation_counter == 1)
{
run_time = Fastest_Stream_A[0].run;
stop_time = Fastest_Stream_A[0].stop;
}
if (operation_counter == 3)
{
run_time = Fastest_Stream_A[1].run;
stop_time = Fastest_Stream_A[1].stop;
}
}
*/
// else
{
run_time = Stream_Table_A[stream_table_row][water_level].run;
stop_time = Stream_Table_A[stream_table_row][water_level].stop;
}
}
if (stream_buff == EXT_STREAM)
{
run_time = Stream_Table_Ext_A[ext_stream_table_row][water_level].run;
stop_time = Stream_Table_Ext_A[ext_stream_table_row][water_level].stop;
}
if (stream_buff == BALANCE_STREAM)
{
run_time = Balance_Stream_A[0].run;
stop_time = Balance_Stream_A[0].stop;
}
stream_moto(run_time, stop_time);
return;
/*
if (stream_buff == SOFT_STREAM)
{
;
}
if (stream_buff == RESOLVE_STREAM)
{
;
}
*/
}
/***********************************************************************************************
void stream_moto(unsigned int run, unsigned int stop): 电机正反转运行处理程序
***********************************************************************************************/
void stream_moto(unsigned int run, unsigned int stop)
{
unsigned char i;
unsigned char j;
static signed char stream_run_time_buff;
static signed char stream_stop_time_buff;
if (status_buff != RUN)
return; /* 非运行状态,返回 */
if (stream_100ms_buff == 0)
{
stream_100ms_buff = 1; /* 每100ms处理一次正反转判断 */
j = stream_buff;
j &= 0x01;
if (j != 0) /* 水流运行标志为1时,进行正反转运行 */
{
if (stream_start_flag == 0) /* 正反转初始化 */
{
stream_run_time_buff = run/100;
stream_stop_time_buff = stop/100;
mot_cycle_buff = MOT_RIGHT;
output_buff |= CW;
stream_start_flag = 1;
}
i = mot_cycle_buff;
switch (mot_cycle_buff)
{
case MOT_RIGHT: /* 电极正转 */
stream_run_time_buff --;
if (stream_run_time_buff == 0)
{
stream_run_time_buff = run/100;
mot_cycle_buff &= MOT_STOP_1;
output_buff &= (~CW);
// output_buff &= (~CCW);
}
break;
case MOT_STOP_1: /* 电极停止 */
stream_stop_time_buff --;
if (stream_stop_time_buff == 0)
{
stream_stop_time_buff = stop/100;
mot_cycle_buff &= MOT_LEFT;
output_buff |= CCW;
}
break;
case MOT_LEFT: /* 电极反转 */
stream_run_time_buff --;
if (stream_run_time_buff == 0)
{
stream_run_time_buff = run/100;
mot_cycle_buff &= MOT_STOP_2;
// output_buff &= (~CW);
output_buff &= (~CCW);
}
break;
case MOT_STOP_2: /* 电极停止 */
stream_stop_time_buff --;
if (stream_stop_time_buff == 0)
{
stream_stop_time_buff = stop/100;
mot_cycle_buff |= MOT_RIGHT;
output_buff |= CW;
}
};
return;
}
else if (j == 0)
{
stream_start_flag = 0;
// mot_cycle_buff &= MOT_STOP;
// return;
}
}
else
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -