Analog Scaling

When does this get applied?

We have created our own driver for our our software. It creates internal tags. When it updates the value for a scaled tag the value is not been scaled.

Do we have to do this in our driver? Are we calling the wrong function when we store the value?

I assume you’re updating them through writing to them, right? And what kind of driver have you created, a custom tag provider?

If you created a bunch of memory tags in a tag provider and then were updating them through writing, the scaling wouldn’t work as you’d expect: on write, the scaling is applied in reverse to the value you’re sending it, and then applied by the tag. In other words, it thinks you’re writing a pre-scaled value.

Is the scaling defined by you when you create the tag, or by the user?

One way or another there may be a way to work around this.

Regards,

What function should my module call to store the new value so that Ignition will scale it?

(I will ask the coder what function he is calling)

update: He says it’s the one for writing asynchronous requests.

We tried to scale it ourselves using private static TagValue scaleValue(Tag tag, TagValue value) { final ValueScaler valueScaler = ValueScaler.configure(tag); return valueScaler.isEnabled() ? valueScaler.scale(value) : value; }

but we’re losing precision. ie: 6001 should be scaled to 60.01 but it’s been scaled to 60.

The tag is a float4.

Hi,

Sorry for the delay, I had to look this up and make sure everything traced out correctly… You should be able to get the tag, cast it to an ExecutableTag, and call “updateCurrentValue(TagValue)”. This will pass it through the configured scalar before updating the value, and storing it to the internal db.

Doing that, you shouldn’t need to scale it yourself. If you’re curious as to why it wasn’t working though, it’s probably due to the fact that the value scalar detects the datatype of the value, and casts it back to that after scaling. You’re probably passing in some sort of int type, which is why it’s getting cut off.

Let me know if this helps,

I’ve found what was causing the problem. Tag can have dataType.isFloatingPoint()==true and at the same time to have Integer value.

Thanks Colby

Scaling is not available on Memory Tags: Memory Tags are not driven by an external source such as a PLC or SQL query, so scaling will never be applied. In these scenarios, it is recommended to scale the mechanism that is writing to the Memory Tag instead.