Vision Easy Chart Calculated Pens Behaving Strange

Hello,

We have 3 identical machines (MCS02, MCS03 & MCS04) and I am logging a cycle counter on each of them to the historian and showing these on a chart.
MCS02:


MCS03:

MCS04:

I would like it so that if the user checks the ‘All HQ Chamber Sealers’ checkbox that it shows a trend of the summation of all 3 of the of the machine’s cycle counters.

As the Easy Chart cannot sum multiple pens I had to create 2 calculated pens, one that sums MCS02 and MCS03 (named 'MCS02+MCS03) and one that sums MCS02+MCS03 and MCS04 (named ‘All HQ Chamber Sealers’). At this stage I would like to note that you cannot select a calculated pen as the driving or secondary pen on a ‘Sum’ function. I was able to get around this by typing them into the Calculated Pens property dataset:

I then needed to make it so that if the user checks the "All HQ Chamber Sealers’ pen, that it would enable each of the machine pens (needed for dependent calculated pens) and make them hidden (so that only the ‘All HQ Chamber Sealers’ pen was visible on the chart). And if the user unchecks the “All HQ Chamber Sealers” pen, it would make the machine pens not hidden. This is the propertyChange script I came up with to achieve this:

if event.propertyName == "calcPens":
	old = event.oldValue
	new = event.newValue
	for row in range(old.getRowCount()):
		if old.getValueAt(row, "Enabled") != new.getValueAt(row, "Enabled"):
			rowName = new.getValueAt(row, "Name")
			if rowName == 'All HQ Chamber Sealers':
				tagPens = event.source.tagPens
				if new.getValueAt(row, "Enabled") == 1:
					for row1 in range(tagPens.getRowCount()):
						if tagPens.getValueAt(row1, "Name")[0:3] == 'MCS':
							if tagPens.getValueAt(row1, "Group_Name") == "Total Cycles":
								updates = {"ENABLED": 1, "HIDDEN": 1}
								tagPens = system.dataset.updateRow(tagPens, row1, updates)
				else:
					for row1 in range(tagPens.getRowCount()):
						if tagPens.getValueAt(row1, "Name")[0:3] == 'MCS':
							if tagPens.getValueAt(row1, "Group_Name") == "Total Cycles":
								updates = {"HIDDEN": 0}
								tagPens = system.dataset.updateRow(tagPens, row1, updates)					
				event.source.tagPens = tagPens

What’s weird is that when I check the All HQ Chamber Sealers pen, this is what is displayed:

As you can see, the trend is nearly correct except that it is ‘noisy’ rather than doing what it should (always increase as time goes on).

Just wanted to share as a potential bug and to maybe get some help in resolving or coming up with a different approach.

Bump

I tried this out and found the same issue if I put the calculated pen as the function parameter, but if I made it the driving pen it seemed to work as expected.

Edit: The sum function seems to always introduce a small amount of noise, even when only summing two pens. An easier and probably more accurate way to achieve displaying the summation would be to create an expression tag that’s value is the summation of the three desired tags, and setting up history on that so you can display it directly.

1 Like

Firstly, welcome to the community!

Thanks for your time and suggestion which will definitely work for me with the slight drawback of redundant tags and data (which I try to avoid where possible).

I suspect the underlying problem is that, if you combine the datasets together, their timestamps don’t match up.

I don’t think so as I feel if you sum up trends that are always increasing, you should only get a trend that is also always increasing…

Here’s some interesting bug evidence. This is what the chart looks like for each individual machine:
MCS02:


MCS03:

MCS04:

As you can see, each machines cycle counter does not change beyond about 7am.

This is what the ‘All HQ Chamber Sealers’ pen looks like for the same time:

That would be true if all the data points were being logged at the exact same time. You’re not really guaranteed that with the historian.

I don’t quite understand how… As you can see in my last post by the cycle counter tags in each machine, no cycles were run by either machine after 7am but the ‘All HQ Chamber Sealers’ pen does strange things beyond 7am.

Another interesting piece of interesting evidence is that the ‘All HQ Chamber Sealers’ chart does strange things when I change the time range in realtime mode.

For instance, this is the chart for the last 19 hours:


When I change it to 18 hours it changes quite alot every second (poll rate) but in general looks something like this:

Illustrative graph. The SUM doesn’t use whatever the previous value was. It just knows there was no data at that time.