How to mirror Float Tag to a scaled Short Tag

I feel like I am making something that should be simple way more complex than it needs to be.

I have a memory tag that is a float and I want another tag (short) to have that value but multiplied by 1000.

Example:
The below is what I want..
MemoryTag = 3.125
OPCShortArray[3] = 3125

What is the best way to accomplish this?

I have attempted putting a change script into the Memory Tag, but I have had no success with that. When I run the script in the script console it works but nothing happens when I put the same script in the change script for the memory tag. I have tried changing it to tell it that the path is [Edge]Path, [~]Path, and [Gateway Scripting Project Name]Path.. none of the above is working.

Ignition Edge doesn't do gateway-scope scripts unless you have the compute plug-in licensed.

You probably want a derived tag.

Do you need an additional tag at all? With scaling, the tag appears to have the larger value at all times, but is silently read/written as the scaled value.

If you truly want a separate tag, use a Derived Tag.

1 Like

I have the compute plug-in, so I would think it should still work.

Actually, your problem may be the use of a short array. OPC array tags are notoriously fickle when it comes to writing to single elements (or anything less than the entire array). Test with a simple integer tag.

I got it working with a derived Tag, but I feel like I am doing it incorrectly:

I have my memory tag that has the float value

Then I have my OPC array which has the value I want to write to.

I made a separate derived tag with the read/write using the memory tag * 1000, then the source is set to the OPC array element I want to work with. However to get the tag to update I have to set the value of the derived tag to any arbitrary value and it will then read/write the memory tag...

I feel like I am setting something up incorrectly, but it is doing what I want it to do..

Ok, I will test with a integer tag.. should I set that up as a memory tag also?

No, break your OPC array into individual tags. They your original script idea should work (using system.tag.writeBlocking...) without an intervening tag.

The issue is that the OPC server is set up by another device which I don't have any control over.

I was attempting to break the array into individual tags by using reference tags which reference specific elements in the array that I want to be able to use. However I had the same issue when using the reference tag.

Let's back up. Please show your script that you originally tried, that worked in the script console. In a tag's value change, that would likely work if indented properly, and there was no reliance on any project defaults.

system.tag.writeBlocking('[Edge]Robot/IO/Length',10)

In the change script I had the 10 replaced with currentValue. However when I ran into issues I attempted to use a constant and it still wasn't working.

I also attempted to put [~] and [Gateway Scripting Project Name] (not that actual value but the value I have in the gateway settings for that value)

You realize that currentValue is a fully qualified value meaning it has timestamp and quality values too. You should use currentValue.value to get just the value from the qualified tag value.

1 Like

Thank You,

I must've had something else incorrect when I tried the constant value because after I got that to work I attempted using a constant value again and it worked.

Thanks to everyone for all the help

1 Like