Example PID Algorithm Listings 499Appendix G
/* Clip output to specified limits */
if ( outchan >> Out_max )
{ outchan = Out_max;
Status.B0=1;
}
else if ( Out_min >> outchan )
{ outchan = Out_min;
Status.B0=1;
}
else
{ Status.B0 = 0;
}
/* Clear alarm output if no alarms */
if (!(Status.B6 || Status.B5) ) alarmchan = 0;
/* Log appropriate data */
if ( History_mode )
{
/* Output summary to FIFO & CVT */
writefifo( (ALG_NUM*256)+4 );
writeboth( inchan, (ALG_NUM*10)+0 );
writeboth( Error, (ALG_NUM*10)+1);
writeboth( outchan, (ALG_NUM*10)+2);
writeboth( Status, (ALG_NUM*10)+3 );
}
else
{
/* Output summary to CVT only */
writecvt( inchan, (ALG_NUM*10)+0 );
writecvt( Error, (ALG_NUM*10)+1);
writecvt( outchan, (ALG_NUM*10)+2);
writecvt( Status, (ALG_NUM*10)+3 );
}