I’m having problems logging data correctly from a micrologix 1400 into a database via an historical transaction group.
I set up a simple test to try and find out what’s going on. On the PLC, I increment an integer, copy the integer into a string, and set a trigger bit. I’ve attached a picture of the code below.
In Ignition I have a historical transaction group set to execute on the PLC trigger bit (only execute once, reset trigger after execution), with the PLC integer tag mapped to an integer field in the database table, and the PLC string tag mapped to a string field in the table. The transaction group has an update rate of 100 ms.
This is what I would expect to be stored in the table:
1,‘1’
2,‘2’
3,‘3’
4,‘4’
and so on. The PLC sees the trigger bit is off, it increments the integer, copies the new value into the string, and sets the trigger. Ignition sees the trigger bit is on, copies the integer and string into the database, and resets the trigger. And the cycle repeats.
This is what I actually get:
1,‘1’
1,‘1’
3,‘3’
4,‘4’
4,‘5’
6,‘5’
6,‘7’
8,‘8’
9,‘9’
9,‘9’
Ignition is storing sometimes current values, sometimes old values from the previous cycle. Also, it’s not consistent between the integer and string tags. Sometimes it’ll store the current integer value and an old string value, sometimes the other way around, sometimes an old value from both, sometimes the current value from both.
A further problem is that sooner or later the process will get stuck. The PLC will set the trigger bit and Ignition won’t recognize the trigger. My guess is that Ignition sees the trigger as being set on the previous cycle and set on the current cycle, so there’s no off-on transtition to trigger the group. However, Ignition has cleared the trigger bit in between the two cycles.
To achieve correct behaviour, I have to introduce a delay of 150 ms at the PLC between updating the fields and setting the trigger bit, and I have to allow an idle period between cycles so that Ignition can realize the trigger has gone off.
I had hoped to transfer ten packets per second (at the 100 ms rate), but with the enforced delays the process is down to about two packets per second just to ensure reliability. The device diagnostic page tells me the maximum request duration is 25ms and the average is 14ms, so it seems like Ignition can get data from the PLC in a timely manner.
What’s gone wrong? What should I do differently? It’s worrying to have to jump through all sorts of hoops just to make sure the data gets recorded correctly, and I’d like to speed up the rate I can transfer data into the database.