VXi VT1422A 사용자 설명서

다운로드
페이지 529
504 Example PID Algorithm Listings  
/* Clip to specified limits */
    if ( D_out   >>  D_max )/* Clip derivative */
    {
D_out = D_max;
Status.B2=1;
    }
    else if ( D_min  >>  D_out )
    {
D_out = D_min;
Status.B2=1;
    }
    else
    {
Status.B2 = 0;
    }
/* Calculate Proportional term */
    P_out = Error * P_factor;
/* Sum PID&SD terms */
    outchan = P_out + I_out + D_out + SD_out;
/* Save values for next pass */
    
PV_old = inchan;
Setpoint_old = Setpoint;
/* In case we switch to manual on the next pass */
/* prepare to hold output at latest value */
    Man_out = outchan;
  }  /* if ( Man_state ) */
/* 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  >>  1 )
    {
/* Output everything to FIFO & CVT */
writefifo( (ALG_NUM*256)+9 );
writeboth( inchan, (ALG_NUM*10)+0 );
writeboth( Error, (ALG_NUM*10)+1);
writeboth( outchan, (ALG_NUM*10)+2);
writeboth( Status, (ALG_NUM*10)+3  );
writeboth( Setpoint, (ALG_NUM*10)+4 );
writeboth( P_out, (ALG_NUM*10)+5 );
writeboth( I_out, (ALG_NUM*10)+6 );
writeboth( D_out, (ALG_NUM*10)+7 );
writeboth( SD_out, (ALG_NUM*10)+8 );
    }
    else 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  );
    }