Applicable Model(s)

HMC3000
HMC7000

Native Ladder Only

Title

Analog Input Scaling

Date

09/19/2022

Rev

02

P/N

0907-7004

Summary

This technical note covers how to convert and scale the raw data from an analog input in Native Ladder.


Solution

Scaling analog inputs can be done using the Scale function. Before scaling, the raw input value needs to be moved into a Data Register and converted to a floating-point number. First, place an NC contact for controlling the scaling operation and create a tag for disabling scaling.

Now, add a Move DWord instruction, located at Data Transfer -> Move DW, to move the raw input value into a Data Register. For Operand A, select the AnalogIPReg being used for measurement. This example assumes Channel 0 of Slot 1 is being used for measurement.

Next, place a vertical branch to connect the next instruction into the rung.

Now add an Integer to Float instruction, found in Conversion -> Integer to Float. Additionally, add a second vertical branch.

Finally, add the Scale instruction, found in Functions -> Scale.

The Scale instruction uses three operands: the input register, the base address for the points that define the scaling function, and the output register. The input and output are what data to scale and where to place it after scaling. The scaling is done linearly based on supplied x and y points that start at the base address supplied to the function. The input value x is scaled to the output value y(x).

To use two points, like the diagram above, the Scale instruction must be set to have n = 2. Additionally, the Data Type must be set to Float.

For the Scale instruction, Operand A has been set to the output of the Integer to Float instruction, RawInputFloat.

Operand B is the base address for the scaling function points. For use with two points, four tags are required. This example has the base address for these four tags defined as D00004. This makes D00004 the lowest value expected from the raw input, D00006 the highest value expected from the raw input, D00008 the lowest value expected after scaling, and D00010 the highest value expected after scaling. The post-scaling values are called engineering values.

The registers are laid out such that the first n registers are the x-coordinates of the points, and the next n registers are the y-coordinates of the points, where n is the number of points being used. This example uses two points, but up to 32 points can be specified by using 64 tags.

When fully set up, there is a coil controlling whether to read and scale the input, a Move DWord to take the raw input and save it in a Data register, an Integer to Float conversion, and a Scale instruction to transform the raw value into engineering values.

Scroll to Top