Beckhoff EPP3504-0023 Short Manual page 105

4-channel measuring bridge,(sg) full/half/quarter bridge, 24 bit, 10 ksps
Hide thumbs Also See for EPP3504-0023:
Table of Contents

Advertisement

Commissioning
    nDecimationValue       :LREAL := 50/44.1; // 50/20;
    nOVS                   :BYTE := 5;        // Oversampling factor
    nTaskCycle_ns          :UDINT := 500000;  // PlcTask configured cycle time in ns
  
    nOVSTimeInterval_ns    :UDINT := LREAL_TO_UDINT(nTaskCycle_ns/nOVS); // OVS interval
    nDecTimeInterval_ns    :LREAL := nDecimationValue * nOVSTimeInterval_ns; // Decimation interval
END_VAR
VAR
   aSamples_1 AT%I*        :ARRAY[0..nOVS-1] OF DINT;     // Link to the terminal PDO
   aOVS_SampleSets         :ARRAY[0..(2*nOVS)-1] OF DINT; // 2 OVS sample sets
  
   nVarDecResult           :DINT;  // The calculated interpolated value
   tVarDecResult           :LREAL; // Decimation timestamp
   aVarDecResult           :ARRAY[0..nOVS-1] OF DINT; // Decimation result values
   aVarDecResult_TS        :ARRAY[0..nOVS-1] OF LREAL; // Decimation result timestamps
  
   nResultNoOfSamples      :BYTE; // This is for the user for further processing
  
   nDivVar                 :INT;  // Value for selection of the target input element
   tDecVar_InTaskCycle     :LREAL:=0; // Time span for all decimation timestamps within a task cycle
   i                       :BYTE:=0; // Common loop counter
   nDX                     :LREAL; // X-Difference: target input element to decimation element
   nDY                     :DINT;  // Y-Difference: two values for interpolation
   sVal                    :LREAL; // Slope for calculation of new value
   bEnable                 :BOOL:=FALSE; // Start/Stop conversion to decimation values
   nOVS_CycleCount         :ULINT := 0;  // Time value for every OVS sample
   // Values for testing
   bTEST_VALUES_ENABLED    :BOOL := FALSE; // No input value needed, if TRUE
   nPhi                    :LREAL := 1.4; // Start angle for sinus simulation
   // For visualization only:
   aOVS_Samples            :ARRAY[0..nOVS-1] OF DINT;  // 2 OVS sample sets (value)
   aOVS_Samples_TS         :ARRAY[0..nOVS-1] OF ULINT; // 2 OVS sample sets (timestamp)
END_VAR
Program
// 500 µs Task
FOR i:= 0 TO nOVS-1 DO
   // Shift OVS set to left and update on right:
   aOVS_SampleSets[i] := aOVS_SampleSets[i+nOVS];   // Transfer "samples set" to the left side
   IF bTEST_VALUES_ENABLED THEN
      // Simulate values:
      aOVS_SampleSets[i+nOVS] := LREAL_TO_DINT(1000000 * SIN(nPhi));
      nPhi := nPhi + 0.01;//0.003141592653;
   ELSE
      // Fill current new samples set on right:
      aOVS_SampleSets[i+nOVS] := aSamples_1[i];
   END_IF
END_FOR
IF bEnable THEN
   nResultNoOfSamples := 0; // Use for further processing
EPP3504-0023
Version: 1.2
105

Advertisement

Table of Contents
loading

Table of Contents