Add two values on button press

Hello All,

I am a total newbie to Ignition, and am just starting to work my way through Inductive Automation training. I am using Ignition 8.1.2 and would really appreciate it if someone could give me a little kick start on something.

I have created three memory integer tags in the default tag provider. Tags are called Test 1, Test 2 and Test 3. I would simply like to add the values of Test 1 and Test 2 and put the result in Test 3 when a button is pressed. I know this is very basic but I’ve been reading about how to do it and for the life of me, can’t make it work. Could someone please help?

Thanks in advance

Basically, you will read tags 1 and 2, add them, then write them to the third tag.

# list of tag paths to read
# read both tags at once for efficiency
tagPaths = ['[default]Test 1', '[default]Test 2']
#returns a list of fully qualified values (value,quality,timestamp)
qValues = system.tag.readBlocking(tagPaths)
summation = qValues[0].value + qValues[1].value

system.tag.writeBlocking(['[default]Test 3'], summation)

Alternatively, make your third tag an expression tag instead of memory and use an expression to add them together

{[.]Test 1} + {[.]Test2}

You'll want to book mark these webpages as a reference. Remember scripting language does not equal expression language in Ignition.

Expression Functions | Ignition User Manual
System Functions | Ignition User Manual

5 Likes

Also, unrelated to the question at hand...

If you are actually using 8.1.2 you urgently need to upgrade. 8.1.2 is 4 years old, and has many severe performance bugs and some security issues. Upgrading within a major version (8.1) is always free, and gets you all the new bug fixes and features from later 8.1 releases:

5 Likes

Nevermind the security stuff (jk), a version that old is missing so many designer creature comforts :face_with_crossed_out_eyes: that was back when the tag editor was a bit.. Not good, and when the power chart still split the time axis in equal divisions, regardless of how random the times came out to be :grimacing: