Inbetriebnahme
nOffset :REAL := 0; // Offset value
nGain :REAL := 1; // Gain value
nScaledSampleVal :REAL;
nDINT_Value :DINT;
fb_trig_bEnable :R_TRIG; // Trigger FB for Enable
bError :BOOL := FALSE; // Evaluate..
END_VAR
Ausführungsteil:
// THIS CODE IS ONLY AN EXAMPLE - YOU HAVE TO CHECK APTITUDE FOR YOUR APPLICATION
// Example program 1 and 2 program code:
// =====================================
// 1. PAI setting of 0x80n0:2E must be "Extended Range" at first
// 2. When writing of scaling values were done, switch to "Linear"
// Calculation of the temporary value (..and use for ScopeView to check)
nScaledSampleVal := nOffset + nGain * DINT_TO_REAL(nPAI_Sample);
// Main-State Procedure:
CASE nMainCal_State OF
0:
fb_trig_bEnable(CLK:=(bEnable AND NOT bError));
IF fb_trig_bEnable.Q THEN // Poll switch or button
// Initialize temporary offset and gain values:
nOffset:= 0;
nGain := 1;
bScaleOffsetStart := bScalingOrder;
bScaleGainStart := NOT bScalingOrder;
fb_get_min_max.nMinFreqInput := fMinFrequencyIn;
nMainCal_State := 10; // Start
END_IF
10:
IF (bScaleGainDone AND NOT bScalingOrder)
OR (bScaleOffsetDone AND bScalingOrder) THEN
bScaleOffsetStart := NOT bScalingOrder;
bScaleGainStart := bScalingOrder;
nMainCal_State := nMainCal_State + 10;
END_IF
20:
IF bScaleGainDone AND bScaleOffsetDone THEN
nMainCal_State :=0; // All done, initalization for next start
END_IF
END_CASE
// ----- Offset scaling (program 1) -----
IF bScaleOffsetStart THEN
CASE nSTATE_SCALE_OFFSET OF
0:
bScaleOffsetDone := FALSE; // Initialization of confirmation flag
// Get min/max values within a period of the signal:
fb_get_min_max(nInputValue:=nScaledSampleVal);
IF fb_get_min_max.bRESULT THEN // Wait if Limit-Values are valid
// Min/Max Values valid, continue..
// calculate current offset deviation:
EPP3504-0023/ ERP3504-0022
Version: 1.3
89