# Modbus scaling - even if you have an offset

What if your input isn’t quite the right scaling?

As of groov 3.2, there are a couple of gadgets that let you scale your input so you can have 50,000 gallons coming in from your tag, say, and have the gadget’s units show 0-50 tens of thousands of gallons, for example. That can work for any type of tag.

If you’re using Modbus tags, you can do linear or square root scaling on the tag itself. But what if you’re not sure how to scale? Or if you have an offset in the calculation? Math to the rescue!

Let’s start with an easy one, before I crank up the algebra…

For one power monitoring application, the Modbus device (a Liebert) provided Hz x10 for the units, but the customer wanted to just show Hz. So… here’s how I did the linear scaling on that one:
Raw Input to Scaled Result high/low:
High: 700 (hz x10) to 70 (hz)
Low: 500 (hz x 10) to 70 (hz)

Another Modbus device, a Caterpillar EMCP generator controller, included offsets for some of the scaling calculations.

In particular, for Power Factor, the Caterpillar manual gave the formula:
PF = Input/16384 - 1 (offset is -1)
The range is -1 to 1 for the output.

So to figure out the appropriate scaling in groov for this one, we just need to do a little algebra where we solve for the Input high/low given the output/Result high low. Easy! You remember the rule of… oh I don’t remember what it’s called. You do the same thing to both sides of the equation.

In this case we want to know the input on the high end of the range, and the low end of the range for our desired output range of -1 to 1. Staring w/the high PF of 1, we plug that in to the formula and solve for the high input:

1 = input_high/16384 - 1

2 = input_high/16384

[multiply both sides by 16384]

32,768 = input_high

then we plug in the low output/Result and solve for the Input:

-1 = input_low/16384 - 1

[add one to both sides, multiply by 16384 again]

0 = input_low

So that’s how we got:
Input to result/output:
High: 32768 to 1
Low: 0 to -1

Make sense? Math + Modbus = fun w/scaling!!

-OptoMary

I got a scaling question, I have a ton of LonWorks SNVT_temp_p value that are going thru a gateway from Lon FT-10 to Modbus TCP to get to my groov box. So it is a value in degrees C but it is also a signed long value so for example 75F is a value of 2388 it is coming in to groov on a 16bit signed integer. I tried to use the Linear Scaler under the Configure Modbus Tags window on groov and it does nothing. So I need to make 2388 = 23.88 then scale C to F so it can be displayed for the operator. Is there something I am missing on the groov that will allow this because I got to believe a ton of people have had to do conversions like this.

Thanks,
Howard

I would try a High and Low of 10000 and 0 with a Limit High and Limit Low of 212 and 32 and see if that works.

Scaling is a little wonky right now on the groov. What Philp suggested might work, and it might not.
I currently cannot get a float out of the groov modbus scaling (it’s broken). I was told the crack groov team is working on a fix.
YMMV

Yes that is exactly what I tried but the scaling wasn’t updating there is a bug in the tag scaler function in groov. Once the values are set amd saved to it, the only way to make the scaler update and use the new values is to delete the tag and recreate it and set the correct values. Now it works perfectly just a small issue but its really no big deal as long as you know to just delete the tag and recreate it. Thanks for the reply.

Scaling Modbus in GROOV is somewhat tricky. It took me some time to figure out the math but I got it working. In a previous thread it was suggested to create two tags for the same tag (if that makes sense). One being a float and one being the raw data. By doing this I managed to scale the float tag perfectly with scaling.

It is something that needs some refining. But it does work.