Hi Guys,
So I’m trying to make a counter for a system I’m helping build - we’ve got 1D/2D scanners that take an image of a QR code, the scanner then sends this value to a tag on ignition as a string. Unfortunately the inbuilt statistics for the scanners are poor and would like to build my own counter to monitor the success / fail rate of them.
The tag that receives the string from the scanner filters through the string and pulls a ‘Box ID’ out used to identify individual boxes. I then write this Box ID string to another tag with another valueChanged script. We convert a ‘FailedRead’ value from the scanner to a 0 and increment our fail counter and use an else statement to increment our success counter (we assume anything other than a 0 was a pass).
However the issue I’m facing is that when I increment my fail counter - it will only take affect the first time. In order to get a second increment a pass has to occur before. I know this is because I’m just writing a 0 back to the tag for a second time if a fail occurs again.
My question is - how can I have a script trigger based on a timestamp change rather than a value change? I don’t want to start giving the tag more than 1 value for a failed read but obviously writing the same value back to the tag won’t trigger the value changed script.
You could possibly try the following:
- Create a ScannerTimestamp expression tag, set the Data Type to
DateTime
and set the expression to {[~]Scanner.Timestamp}
, where Scanner is your scanner string tag.
- Now you should be able to trigger the script on ScannerTimestamp’s Value Changed event.
I don’t have a scanner with which to test this.
1 Like
Tried the suggestion - same problem though. If I set the scanner tag to null and write a 0 from a separate tag it updates the timestamp on the first write, subsequent writes however have no change on the timestamp.
Tried the suggestion - same problem though. If I set the scanner tag to null and write a 0 from a separate tag it updates the timestamp on the first write, subsequent writes however have no change on the timestamp.
Timestamps generally don’t change unless the value changes.
There is perhaps one exception to this, with OPC tags from an OPC UA server where you’ve enabled the “Include Timestamp-Only Changes” setting on that tag group, but even then it’s only some servers that will send timestamp-only changes.
As far as the rest of the Ignition tag system works change events only trigger on value change.
When you write 0 to a tag with a null value that’s a change, but if you keep trying to write 0 to it nothing is actually happening.
I know so thats my problem - the scanner gives me a string of ‘FailedRead’ when it doesn’t scan the QR code. I convert that to a 0 for a counter I use pass/fail/total. I can’t think of a better way to count up the data.
I was trying to fire the counter logic when the FailedRead occurred - receive ‘FailedRead’ convert to 0 on a separate integer memory tag, if not 0 then the box ID which I get from the QR so we count that as a pass and do the counter logic.
Is there an easier way of triggering the counter.
If i am understanding your question, the problem is that back to back fail reads don’t count twice. it sounds like you have a solution, but i don’t really get what it is.
You could write the result of your scan to a tag and then have a tag change script that “clears” the tag out when a change occurs. In your counter logic you would not increment either the pass or fail totals when a clear happens.
If you’re the one writing the 0, then it means that you detected a change. Why not increment the counter at this time instead of going through an indirection that doesn’t seem to work ?
I think I’m missing something about your issue, could you be more descriptive about what you want and what you’re doing ?