Inbetriebnahme
Ausführungsteil:
// Example program 5:
// writes filter coefficients of
// "User defined FIR Filter" (32)
// incl. example coefficients for band pass
// Note: writing possible, if CoE Object
// PAI Settings Ch.1 (0x8000:16) has value 32 or 33 set, only!
// (32 = User defined FIR Filter / 33 = User defined IIR Filter)
// ===============================================================
CASE wState OF
0:
fb_coe_write(bExecute := FALSE);// Prepare CoE access
wState := wState + 1;// Go to next state
1:
//nValue := REAL_TO_DINT(DINT_TO_REAL(aFilterCoeffs[index]) *16384);
nValue := LREAL_TO_DINT(aFilterCoeffs[index] * 1073741824); // Bit-shift factor: 2^30
// Write filter coefficients (max. 40 entries)
fb_coe_write(
sNetId:= userNetId,
nSlaveAddr:= userSlaveAddr,
nSubIndex:= index,
nIndex:= wCoEIndexUserFilterCoeffizents,
pSrcBuf:= ADR(nValue),
cbBufLen:= SIZEOF(nValue),
bExecute:= TRUE,
tTimeout:= T#1S
);
wState := wState + 1; // Go to next state
2:
// Execute writing to CoE
fb_coe_write();
IF fb_coe_write.bError THEN
wState := 100; // Error case
ELSE
IF NOT fb_coe_write.bBusy THEN
index := index + 1;
IF index <= (NumOfFilterCoeff) THEN
fb_coe_write(bExecute := FALSE);// Prepare the next CoE access
wState := 1;// Write next value
ELSE
wState := 255;// Done
END_IF
END_IF
END_IF
100:
; // Error handling
255:
; // Go on..
END_CASE
EPP3504-0023
Version: 1.2
101