# 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

- A RediGate 100 or 400 series device with network connectivity
- 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

- Using ACE, Open the default configuration you used in the "Getting Started Guide".
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.- 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__. - 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

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 /3 | 40002 → | 44012 |

44001 (Year) → | 30003 | divide 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)

__the local (ScaledUnit) RTDB registers.__

**to**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.