20190110 貝加萊PLC C語言迴圈與延時應用
void _CYCLIC ProgramCyclic(void)
{
if(B)
{
i;
TON_10ms(&T1);
switch (i)
{
case 0:
T1.IN=1;
T1.PT=100;//delay 1s
if(T1.Q)
{
T1.IN=0;
i+=1;
}
break;
case 1:
T1.IN=1;
T1.PT=100;//delay 1s
if(T1.Q)
{
T1.IN=0;
i+=1;
}
break;
case 2:
T1.IN=1;
T1.PT=100;//delay 1s
if(T1.Q)
{
T1.IN=0;
i+=1;
}
break;
case 3:
T1.IN=1;
T1.PT=100;//delay 1s
if(T1.Q)
{
T1.IN=0;
i+=1;
}
break;
case 4:
T1.IN=1;
T1.PT=100;//delay 1s
if(T1.Q)
{
T1.IN=0;
i+=1;
}
break;
case 5:
T1.IN=1;
T1.PT=100;//delay 1s
if(T1.Q)
{
T1.IN=0;
i+=1;
}
break;
case 6:
T1.IN=1;
T1.PT=100;//delay 1s
if(T1.Q)
{
T1.IN=0;
i+=1;
}
break;
case 7:
T1.IN=1;
T1.PT=100;//delay 1s
if(T1.Q)
{
T1.IN=0;
i+=1;
}
break;
case 8:
T1.IN=1;
T1.PT=100;//delay 1s
if(T1.Q)
{
T1.IN=0;
i+=1;
}
break;
case 9:
T1.IN=1;
T1.PT=100;//delay 1s
if(T1.Q)
{
T1.IN=0;
i+=1;
}
break;
case 10:
T1.IN=1;
T1.PT=100;//delay 1s
if(T1.Q)
{
T1.IN=0;
i+=1;
}
break;
case 11:
T1.IN=1;
T1.PT=100;//delay 1s
if(T1.Q)
{
T1.IN=0;
i+=1;
}
break;
case 12:
T1.IN=1;
T1.PT=100;//delay 1s
if(T1.Q)
{
T1.IN=0;
i+=1;
}
break;
case 13:
T1.IN=1;
T1.PT=100;//delay 1s
if(T1.Q)
{
T1.IN=0;
i+=1;
}
break;
case 14:
T1.IN=1;
T1.PT=100;//delay 1s
if(T1.Q)
{
T1.IN=0;
i+=1;
}
break;
case 15:
T1.IN=1;
T1.PT=100;//delay 1s
if(T1.Q)
{
T1.IN=0;
i+=1;
}
break;
case 16:
T1.IN=1;
T1.PT=100;//delay 1s
if(T1.Q)
{
T1.IN=0;
i+=1;
}
break;
case 17:
T1.IN=1;
T1.PT=100;//delay 1s
if(T1.Q)
{
T1.IN=0;
i+=1;
}
break;
case 18:
T1.IN=1;
T1.PT=100;//delay 1s
if(T1.Q)
{
T1.IN=0;
i+=1;
}
break;
case 19:
T1.IN=1;
T1.PT=100;//delay 1s
if(T1.Q)
{
T1.IN=0;
i+=1;
}
break;
default :i=0;
}
}
}