Data Scaling Configuration

Introduction

The RediGate primarily polls data from field devices and reports to hosts, such as MQTT. However, it can also do various mathematical operations or other logic on the data stored in Realtime Databases (RTDBs). This tutorial shows how to use POD logic to perform scaling or other mathematical operations on the data.

Pre-Requisites

  1. A RediGate 100 or 400 series device with network connectivity
  2. Completion of the Getting Started GuideĀ for your respective RediGate device (SeeĀ RediGate 100 Series Getting Started GuideĀ orĀ RediGate 400 Series Getting Started Guide)

Instructions

  1. Using ACE, Open the default configuration you used in the "Getting Started Guide".
  2. Download and open RediGate-Scaling-Demo.xml from the http://redigate.elecsyscorp.com/examplesĀ siteĀ within the same ACE window as your default configuration.
    The example is located under Other Example Configurations ā†’ Math/Scaling Example Configuration.

  3. If you have already completed one of the other example configurationsĀ to obtain a "SimData" field unit with simulated data, you may skip to the next numbered step.

    Otherwise, copy and paste the following objects from the RediGate-Scaling-Demo.xml config into your default configuration:
    1. FieldUnitInternalMast2 (paste under NullCircuit)


    2. Data Simulator (paste under Internal Channel 15)


    3. Edit the "Internal Channel 15" object so that it contains a scan record for FieldUnitInternalMaster2 (Unit Address 2), poll record 1, with a Scan Period of 1 second:

  4. Ā Copy and paste the following objects from the RediGate-Scaling-Demo.xml config into your default configuration:
    1. Internal Channel 14 (paste under Master Channels)


      (NOTE: Verify that the Instance number of the channel is 14 after being pasted. If you already had a Channel 14, a different channel number will be assigned, which should be used in stepĀ 'b' below.)

      The Internal Channel 14 includes a Field Unit named "Math-Scaling Demo Unit." This is an internal unit that copies data from another RTDB (in this case, the Minutes, Seconds, and Year values from the SimData unit), then performs some math on the values and copies the modified values back to the original RTDB.

    2. Scale Data Sample (paste under SerialMMI)


      If the Internal Channel (pasted in step a above) is something other than 14, edit the Report Table to change the "Channel" column to match the channel's Instance number.


  5. In the RTDB ("RtdbMod") under the "SimData" field unit (child object under Channel 15 ā†’ FieldUnitInternalMast2), modify the Database Definition to have 20 registers each.


  6. Load and deploy the configuration to your RediGate. After the RediGate finishes restarting, log in to the 'user' menu.
    Select option '3' for Diagnostic Services.
    Select option '535' for View Custom Report.
    Enter a number of seconds to refresh the display.
    The Custom Report shows the original and scaled values of the Internal unit.

    3/16/18Ā  21:07:39 : <<< Scaled_Data : Changes-Enabled >>>
    >*30001=22Ā Ā Ā Ā  *40001=71
    Ā *30002=39Ā Ā Ā  *40002=13000
    Ā *30003=2018Ā  *44001=20.18
    Ā *39101=100
    E'xit N'ext P'rev T'op B'ottom H'elp 'C'hange(Ch14/Rtu1/@30001) 1/7

  7. In this example, register 39101 contains a divisor for the 3rd calculation (2018 / 100 = 20.18).
    To change the scaling factor:
    Enter 'B' to move the cursor to the last entry.
    Enter 'C' to change the register value.
    Enter the new divisor.
    Enter 'Y' to write the value into the register.

    E'xit N'ext P'rev T'op B'ottom H'elp 'C'hange(Ch14/Rtu1/@39101) 7/7 c
    EDIT Chan14/Rtu1/39101 (*39101) IEEE[100] 10
    (10) for Chan14/Rtu1/39101 (*39101)....
    ...End of List...

    Okay to write current entries? (y/n) y

    The new scaling factor should appear in the list, and the register 44001 should be divided by the new number.

    Ā *30003=2018Ā  *44001=201.8
    >*39101=10

Explanation of Scaled Data Example

The logic in the Scaled Data example performs the following data copy and mathematical operations on the SimData values as follows:

Original value
SimData register
Copied value
ScaledUnit register
Mathematical
Operations
Modified value
ScaledUnit register
Modified value
SimData register
44005 (Minutes) ā†’30001*9 /5 + 32 (convert C to F)40001 ā†’44011
44006 (Seconds)Ā ā†’30002*1000 /340002 ā†’44012Ā 
44001 (Year)Ā ā†’30003divide by register 39101Ā 44001 ā†’46011Ā 


The Poll Table in the "Math-Scaling Demo Unit" copies data from the source field unit (channel 15 unit 2) to the local (ScaledUnit) RTDB registers.

Then the Poll Table calls POD number 12 for all the mathematical functions, and thenĀ copies the resulting values back to the original source unit ("SimData").


The logic contained in POD #12 is shown in the following screen capture. For each of the three data values,

  • The copied value (registers 30001-30003) is ASSIGN'ed to a temporary RTDB register (39001-39003). The result value should be cast as integer or REAL32/floating point, or Boolean if using digital values.
  • The math functions are performed (in this example, Multiply, Divide, and Add).
  • Temporary holding registers (in this example, 39001-39003) or Scratchpad registers are used to hold intermediate values.
  • The calculated output is assigned to a final register (40001, 40002, 44001) in the ScaledUnit database.

These final registers are copied back to the original Field Unit by the Poll Table rows, described above.


NOTE: Be aware that register data types will affect the calculations. For instance:

  • Operations performed and stored into integer registers will truncate values to the integer value only.
  • Values larger than a 16-bit integer that are stored into a 16-bit register will lose the most-significant word.

Be careful not to copy the modified values back into the same registers as the original source value ā€“ this will cause irregularities as the original value and modified value are alternately stored into the same register.


This configuration gives just a few examples of how POD logic may be used to modify data in the RediGate. For illustration, it is shown as a separate channel for performing the math functions.
But for configurations that contain data in an existing Internal Master unit (such as "SimData"), the new POD function could have instead been added to the existing Field Unit to modify data right in the RTDB, without requiring the registers to be copied to and from the ScaledData unit using a Poll Table.

See the POD Programming ManualĀ for more details on using POD logic statements.