Hi guys, I’m using a fault bit and basically writing the time to another memory tag so I can put that data in the DB as far as when the machine faulted and when fault ended. I used to do this in the gateway even scripting and it worked fine, I thought about trying it in the tag even scripting since I was going to look at a crap load of robots and was going to use a UDT, this way all would be done in a fraction of time.
Well everything works perfectly fine but one thing… if I go and save a udt stance the tags inside try to reconnect basically so all their quality goes to unknown and then to good, well that right there causes my fault tag to basically going from off to unknown back to off so it end up writing to the memory tag that keeps up with when the fault goes off.
this is how i have it set up:
if currentValue.value == 1:
if initialChange ==0:
same setup for when value is 0. I’m doing all this in Value changed section and I understand there is a quality change as well but is it possible to check the quality at the same time so basically saying only check all this when quality of the tag is good?
I’ve used this line in my Value Changed tag script and it’s saved me from collecting on bad data. In my case i needed to use the previous value in my logic to catch when a totalizer was getting reset.
if previousValue.quality == 192 and currentValue.quality == 192:
if currentValue.value < previousValue.value and initialChange == 0:
call = system.db.blah blah blah
aha… didn’t know you can check the quality of a tag value . that should solve the issue then. thank you!
So I implemented your method in my Value Changed script and now when I manually turn the bit on and off nothing is being written to the tags. if I take the quality check section out, starts working fine.
I even wrote currentValue.quality and previousValue.quality in the same scrip to two memory tags just to see if those values are valid and they were, they worked fine showing 192 if using INT and Good if using string but the moment I add the check for those quality values in the if statement, everything stops working… idk
I will give that a try thanks. I ended up going back to my old faithful gateway tag scripting lol! I needed to create only one scrip and dump all the trigger tags in there and works fine.
performance wise which is better? this being done on the tag level or let gateway deal with it?
I’m just curious because if there is really not any performance differences then I’ll stick with gateway scripting on this specific situation.
I tested it and it worked so thank you. I guess it comes down to which way is more efficient and has better performance you know.
Between gateway tag change scripts and tag event scripts there really shouldn’t be much difference in performance. I believe tag event scripts run “first”, but I think that’s just by chance, rather than anything specifically coded in.
I tend to use gateway tag change scripts instead of tag events because they are part of a project, and therefore can be disabled en mass by disabling the project. And they can call project.* scripts.
that’s very true. I think I’m going to stick with gateway tag change script for now, seems to be working find, I added what @PGriffith suggested to the script as well.
Got a follow up question, so I want to put the fault on and fault off time stamp in the DB, what I’ve been doing is to create a transaction groups and my trigger is when the fault = 0 since the trigger is unique to each robot meant different transaction group per robot… I love transaction groups but it just sounds silly to me to have 100 transaction groups for 100 robots just so I can record the fault on and fault off times.
I was thinking of maybe just writing to the DB from the tag script that way I’d skip having to worry about making a transaction group for each robot.
Bit Out of Topic I have tag event script, that i use to store value in database…They run fine however my question is how would i store value if value changes from 12 right to again 12 after 2 mins…Is there a way or i have to look into attaching to another event…