Write Values From Tags To Other Tags Using Script

Hi

I am trying to set the time in some of my PLC’s by using ignition. I am currently using the AB Logix clock update tool but it is not very reliable. I have setup a UDT that holds the master time values Year, Month etc down to second. What I want to do is every day assign the values in this UDT to the PLC tags for each of my devices.
I am able to get it to work by using a transaction group but this is time consuming to set up as I need one for each PLC. I have been trying to get it to work through a script but again this is very time consuming to setup as I seem to have to assign the tag path for each device in the script. I am wondering if there is an easier method to accomplish what I am trying to do.
I am thinking that if I was able to get the tag path through an expression I could then pass this to the script with the master values and update the PLC tags. All of my devices have the same folder structure the only difference been the device name.

Thanks

Aidan

Igintion version 7.5.2

Hi Aidan,

If you post your script we can have to a look to see whether it can be improved.

Hi

Here are some screen shots of my script and an image of calling it by using a button event. The Year month etc are the master values so they can be part of script as the address path will not change. My problem is to get the address path (tags) for each of my devices into this script. I waas thinking that I could have a screen open on the gateway which could dynamically get the tag paths for each device and run the script but I am just wondering if there is a way to accomplish this using tags alone so I don’t have to rely on screen been open.
I was thinking if I could get the tag path through an expression then I could join these in a tag and have a string with the addresses for the tags in that machine which could be used in the run script expression. That way this tag could be dropped into my folder structure and would work across all devices without having to adjust paths. I may be asking too much here and will have to use the screen on the gateway. Thanks for having a look at it for me

Aidan




Hi.

What you’re trying to do should be very simple. However, I am somewhat confused by the specifics of how everything links together.

  1. “[InternalSQLTags]Production Lines/Master Clock” is the UDT holding all the time values, and “1 Year”, “2 Month”, etc are the properties of this UDT? Is that correct?
  2. Where are your PLCs and which tags do you wish to set within them? What is “[InternalSQLTags]Tag Write” and what are “W1” and “W2”?
  3. Will the tag structure for the PLC time values always be the same?
  4. What do you mean by “dynamically get the tag paths for each device”? Adding the time tags given a list of device prefixes is easy, but you will still have to list every device. I am not aware any way to iterate all devices automatically.

You shouldn’t need a screen to do this, you can add gateway timer scripts (See Configuration --> Event Scripts (Gateway)).

Stepping back a bit, why are you breaking the timestamp up into individual values? PLCs should not have to deal with minutes/hours/days/months/etc if at all possible because such things are horribly inefficient and difficult to handle. Most hardware uses a single integer timestamp counting seconds or milliseconds. Of course, if your process requires more detailed knowledge of time or the clock update function expects a more complex format that would change things slightly.

As a side note, please use the “code” button on the forum to paste code, it is much easier to work with than screen shots.

Hi

Yes I have a UDT which contains the values for year month etc. This same structure of UDT is used for each device. The W1 and W2 were just an example to demonstrate what I am trying to accomplish. My tag folder structure is hierarchical by line, equipment, device so this will be the path to each of my devices so to answer your question will the tag structure will be the same yes apart from the name of the device.
To answer your question regarding why I am breaking up the time stamp I am using AB PLC’s both SLC and Logix and to the best of knowledge the time in the SLC is stored in registers S:37 - S:43 which are integers and Logix needs an array of 7 DINT’s and the SSV instruction to set the time. I could use a string but I would have to break it up with PLC code and then assign it to the different registers.
I think I have a method that will accomplish what I want to do so thanks for your reply

Thanks

Aidan