📄 testprog.c
字号:
if(m_br_fs) goto NTTS;
m_vol2_new = channel(167);//channel(4); //首先检测二次电压
m_vol2_10 = m_vol2_new;
if( m_get_gzfs == 4 && m_pulse_count == 2) goto next_1666;
if( m_get_gzfs == 4 && m_pulse_count == 4 )
{
if(m_dtj > 109 )
{ //360
if(m_vol2_new + m_get_o36 < m_vol2_old_10 )
{
goto next_166; //340
}
}
else if(m_dtj > 72)
{ //250
if( m_vol2_new + m_get_o36 < m_vol2_old_10 )
{
goto next_166;
}
}
else
{ //250
if( m_vol2_new + m_get_o36 < m_vol2_old_10 )
{
if(m_cur2 > m_cur2_div6) //div4; 240 && m_cur2_new > m_vol2_new + 100
{
next_166: TR0 = CLEAR; //关闭定时器0,
ET0 = CLEAR;
U_DRV = SET; //因为火花,关闭进一步的脉冲
m_br_fs = TRUE;
m_vol2_old_10 = m_vol2_new;
return;
}
}
}
}
else
{
if(m_dtj > 109 )
{ //360
if(m_vol2_new + m_get_o109 < m_vol2_old_10 )
{
goto next_16; //340
}
}
else if(m_dtj > 72)
{ //250
if( m_vol2_new + m_get_o72 < m_vol2_old_10 )
{
goto next_16;
}
}
else
{ //250
if( m_vol2_new + m_get_o36 < m_vol2_old_10 )
{
if(m_cur2 > m_cur2_div6) //div4; 240 && m_cur2_new > m_vol2_new + 100
{
next_16: TR0 = CLEAR; //关闭定时器0,
ET0 = CLEAR;
U_DRV = SET; //因为火花,关闭进一步的脉冲
m_br_fs = TRUE;
m_vol2_old_10 = m_vol2_new;
return;
}
}
}
}
next_1666:
m_vol2_old_10 = m_vol2_new;
if(m_br_fs)
{
NTTS: if(m_br_u2) return;
U_DRV = SET;
//-----------------------
if(m_tc > 8900) m_tc = 8900; //new adding
if(m_get_gzfs == 1)
{
if(m_vol2 >8) m_br_over8 = TRUE;
m_cur2 = 0;//<1>二次电流
//-----------------------------------------------
if(m_pulse_count == 4)
{
m_tc_max = m_tc;
//0.70--0.76--0.82--0.88
con_speed1 = m_tc_max/50;
m_tc = con_speed1 * 35;
con_speed1 = con_speed1 * 3;
con_speed = 3;
m_br_fs = FALSE;
m_int_count_rec = 0;
m_hh_count ++; // just for sparking rate
}
//-----------------------------------------------
m_count_plc = 0; //偏励磁次数清零
m_vol2_old_10 = 0;
m_vol2_old_01 = 0;
return;
}
if(m_vol2 >8) m_br_over8= TRUE;
m_cur2 = 0;//<1>二次电流
if((m_fsmc--) > 1) return;
//-----------------------
//取得第一次闪络时的导通角
if(m_int_count_rec >= 250)
{
m_tc_old = m_tc_max;
m_tc = m_tc_max;
}
m_tc_max = m_tc;
//本部分可以尝试关闭
if(m_tc_old > 8900) m_tc_old = 8900;
if( m_tc_old > m_tc_max + 800 )
{
m_tc_max = m_tc_old - 100;
}
else
{
m_tc_old = m_tc_max;
}
if( m_int_count_rec < 16 )
{
m_count_intver++;
if(m_tc_max > 2000)
{
if(m_count_intver > 3 ) //4
{
m_tc_old -= 1500;
m_tc_max -= 1500; //1500
}
if(m_count_intver > 2 ) //3
{
m_tc_max -= 300; //1500
}
if(m_count_intver > 1 ) //2
{
m_tc_max -= 300; //1500
}
}
}
else
{
m_count_intver = 0;
}
//---------------------------------------------------------------------
//0.56--0.83--0.90--0.93--0.96 CAN'T WORK NORMALLY
//---------------------------------------------------------------------
// 1 2 3 4 5 6
//---------------------------------------------------------------------0713adding
if( m_get_gzfs == 4 )
{
m_fdb_tc = (m_get_fdb-1)*277; //每个台阶为10度
m_left_fdb_tc = 8900 - m_fdb_tc;
m_pulse_count = 0;
}
//---------------------------------------------------------------------0713adding
//---------------------------------------------------------------------
//0.50--0.70--0.80--0.86--0.92
con_speed1 = m_tc_max / 50;
con_speed2 = con_speed1*4; // 8%
m_tc = con_speed1*15; // 30%
con_speed3 = con_speed1*3; // 6%
con_speed4 = con_speed1; // 2%
if(m_count_intver > 1) // 8% for left period
con_speed = ( con_speed2 + 300 )/(m_set_interval - 11);
else
con_speed = con_speed2 /(m_set_interval - 11);
con_speed1 = con_speed1 * 10;
con_speed2 = con_speed1 / 2; // 10%
if(m_get_gzfs == 3 || m_get_gzfs == 5)
{
m_third_sec = 0;
m_br_reach = FALSE;
}
m_fsmc = m_get_mcfs-1 ; //计算封锁脉冲个数
//---------------------------------------------------------------
//ex0 position 0ms position
m_cur1 = 0;
m_cur2 = 0;
m_count_plc = 0; //偏励磁次数清零
// m_vol2_old_90 = 0;
m_vol2_old_10 = 0;
m_vol2_old_01 = 0;
m_br_fs = FALSE;
m_int_count_rec = 0;
m_hh_count ++; // just for sparking rate
return;
}
//===================================================================
if(m_br_zz== TRUE && m_tc > m_zz_time)
{
m_tc += 0; //终止状态
}
else if(m_br_xy) //下移
{
if(m_tc >1600) m_tc -= 5;
}
else if(m_get_gzfs == 2 || m_get_gzfs == 6)
{
if(m_int_count_rec > 5)//6
{
m_tc += con_speed;
}
else if(m_int_count_rec < 3)
{
m_tc += con_speed1;
}
else if(m_int_count_rec ==3)
{
m_tc += con_speed2;
}
else
{
m_tc += con_speed3;
}
}
else if(m_get_gzfs == 3)
{
if(m_int_count_rec > 5)
{
if(m_br_reach == TRUE )
m_tc += con_speed;
else m_tc += 0;
}
else if(m_int_count_rec < 3)
{
m_tc += con_speed1;
}
else if(m_int_count_rec ==3)
{
m_tc += con_speed2;
}
else
{
m_tc += con_speed3;
}
}
else if(m_get_gzfs == 1)
{ //0.88->0.82->0.88->0.94
if( (m_int_count_rec/m_get_zkb)< 5 && m_pulse_count == 1 )
{
m_tc += con_speed1;
}
else m_tc += 2*con_speed;
}
//-------------------------------------------------------------------20050713
else if(m_get_gzfs == 4) //脉冲供电
{ //50--60--70--80--
if(m_int_count_rec > 7) //6
{
m_tc += con_speed;
}
else if(m_int_count_rec < 6)
{
m_tc += con_speed2;
}
else
{
m_tc += con_speed3;
}
}
else if(m_get_gzfs == 5) //最高平均值
{ //0.88->0.82->0.88->0.94
if(m_int_count_rec > 6)
{
if(m_br_reach == TRUE )
m_tc += con_speed;
else m_tc += 0;
}
else if(m_int_count_rec < 3)
{
m_tc += con_speed1;
}
else if(m_int_count_rec ==3)
{
m_tc += con_speed2;
}
else if(m_int_count_rec ==6)
{
m_tc += con_speed4;
}
else //4,5
{
m_tc += con_speed3;
}
}
//工作方式6用不着列出,因为是上面5种工作方式之一
//-------------------------------------------------------------------20050713
if(m_tc >2320) m_total_t0 = (m_tc - 2050)/290 ;
else m_total_t0 = 1;
m_t0_c = 0;
if( m_tc < 1600 ) return;
if(m_get_gzfs ==1 )
{
if(m_tc > 8600) m_tc = 8600;
if(m_pulse_count == 1)
{
silent = 44300 + m_tc*2; //45536
}
else if(m_pulse_count == 2)
{
silent = 45100 + m_tc*2; //45536
}
else return;
TH0 = silent/256;
TL0 = silent%256;
ET0 = SET;
TR0 = SET;
return;
}
/**/ else if( m_get_gzfs == 4 )
{
if(m_tc > m_left_fdb_tc ) m_tc = m_left_fdb_tc; //第一步,
silent = 44200 + m_tc*2; //44200
//----------------------------------------------
if(m_pulse_count == 3 ||m_pulse_count== 4)
{
silent = silent + m_fdb_tc*2; //44200
}
TH0 = silent/256;
TL0 = silent%256;
ET0 = SET;
TR0 = SET;
return;
}
else
{
if(m_tc > 8900) m_tc = 8900;
silent = 44200 + m_tc*2; //44200
TH0 = silent/256;
TL0 = silent%256;
ET0 = SET;
TR0 = SET;
return;
}
}
if(m_br_fs) return; //假如封锁,立即退出采样
if(m_ms_count ==1 ||m_ms_count ==11 )
{
m_cur2_new = channel(151);//channel(2); //电流取样
m_vol2_new = channel(167);//channel(4); //二次电压
if(m_ms_count == 11)
m_vol2_11 = m_vol2_new;
if(m_get_gzfs == 4 && m_pulse_count == 2) goto next_h_11;
if(m_cur2_new > m_cur2_09 + 500 && m_cur2 > m_cur2_div6) goto next_111_h;//250->350
if(m_dtj > 109 ) // > 6000
{ //250-> 380
if(m_cur2_new > m_vol2_new + 980 && m_cur2_new < 0x7f0) goto next_111_h;//900->950
if(m_vol2_new + m_get_o109 + 80 < m_vol2_old_01 )//320 pay attention to this number !!!!!
{
goto next_111_h;
}
}
else if(m_dtj > 72)// 4000 - 6000
{ //80->320
if(m_cur2_new > m_vol2_new + 990 && m_cur2_new < 0x7f0) goto next_111_h;//750->900
if(m_vol2_new + m_get_o72 + 40 < m_vol2_old_01 )//240
{
goto next_111_h;
}
}
else // < 4000
{ //80-> 300
// if(m_cur2_new > m_vol2_new + 550 && m_cur2_new < 0x7f0) goto next_111_h;//500->550
if(m_vol2_new + m_get_o36 < m_vol2_old_01 )//120
{
if( m_cur2 > m_cur2_div6) goto next_111_h; //240 m_cur2_new > m_vol2_new + 100 &&
}
}
// attention: for high voltage and low current
// if(m_vol2_new + 500 < m_vol2_old_01 )//180->200
// goto next_11_h;
next_h_11:
m_vol2_old_01 = m_vol2_new;
return;
next_111_h: //--------------------- spark at this time
TR0 = CLEAR; //关闭定时器0,
ET0 = CLEAR;
U_DRV = SET; //因为火花,关闭进一步的脉冲
m_br_fs = TRUE;
return;
}
if(m_br_fs) return; //假如封锁,立即退出采样
if(m_ms_count ==2 ||m_ms_count ==12) //2 ms
{
m_cur2_new = channel(151);//channel(2); //电流取样
m_vol2_new = channel(167);//channel(4); //二次电压
if(m_ms_count == 12)
m_vol2_12 = m_vol2_new;
//--------------------------------------本段判断偏励磁
//电流只有一半导通,判断电流反馈值的不规则性即可
if(m_get_gzfs == 1 )
{
if(m_pulse_count ==2)
{
if(m_cur2_old > m_cur2_new + 550) m_count_plc ++; //一个高,一个低
else
m_count_plc = 0;
m_cur2_old = m_cur2_new;
}
else if(m_pulse_count == 3)
{
if(m_cur2_old > m_cur2_new + 450) m_count_plc ++; //一个高,一个低
else
m_count_plc = 0;
m_cur2_old = m_cur2_new;
}
}
else if( m_get_gzfs == 4 )
{
if(m_pulse_count ==1)
{
if(m_cur2_old > m_cur2_new + 600) m_count_plc ++; //一个高,一个低
else
m_count_plc = 0;
m_cur2_old = m_cur2_new;
}
if(m_pulse_count ==2)
{
m_cur2_old = m_cur2_new;
}
else if(m_pulse_count == 3)
{
if(m_cur2_old > m_cur2_new + 500) m_count_plc ++; //一个高,一个低
else
m_count_plc = 0;
m_cur2_old = m_cur2_new;
}
else if(m_pulse_count == 4)
{
if(m_cur2_old > m_cur2_new + 200) m_count_plc ++; //一个高,一个低
else
m_count_plc = 0;
m_cur2_old = m_cur2_new;
}
}
else
{
if(m_cur2_new > m_cur2_old)
{
if(m_cur2_new - m_cur2_old > 650) m_count_plc ++; //一个高,一个低 600->650 2007/11/18
else
m_count_plc = 0;
}
else
{
if(m_cur2_old - m_cur2_new > 650) m_count_plc ++; //一个高,一个低 600->650 2007/11/18
else
m_count_plc = 0;
}
m_cur2_old = m_cur2_new;
}
// attention: for high voltage and low current
//------------------------700->900
if(m_dtj > 90 )
{
if(m_cur2_new > m_vol2_new + 900 && m_cur2 > m_cur2_div6) // && m_cur2_new < 0x7f0
{
TR0 = CLEAR; //关闭定时器0,
ET0 = CLEAR;
U_DRV = SET; //因为火花,关闭进一步的脉冲
m_br_fs = TRUE;
}
}
else
{
if(m_cur2_new > m_vol2_new + 800 && m_cur2 > m_cur2_div6) // && m_cur2_new < 0x7f0
{
TR0 = CLEAR; //关闭定时器0,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -