Hi,
I've got an issue with externally read DINT array data consistency on A-B 1769-L33ER controller.
I'm periodically reading (writing) data from (to) the controller using TuxEIP library and sometimes there is a inconsistency in the data read from PLC.
PLC:
periodic task, 5ms period
Program tags:
Program main (and only) routine:
PC:
After a while of running (varies from several seconds to several minutes) I reach the situation that the myIndex aka array[90] is already updated while the related item is not, e.g.:
PLC (that is OK):
vs. PC:
It looks like an array write caching in PLC. Values myArray[30, 0] (myIndex) and array[30, 2] (myIteration) have already been synchronized while the myArray[2, ...] and myArray[3, ...] have not.
Is there a way how to force a tag memory to gets synchronized or something like that in RSLogix 5000?
I am pretty sure that the problem is not caused neither by TuxEIP library nor the network communication - I'm able to transfer tons of data without a problem.
I've got an issue with externally read DINT array data consistency on A-B 1769-L33ER controller.
I'm periodically reading (writing) data from (to) the controller using TuxEIP library and sometimes there is a inconsistency in the data read from PLC.
PLC:
periodic task, 5ms period
Program tags:
Code:
Name Alias For Data Type External Access Const
---------------------------------------------------------------------
undef DINT None 1
doUpdate DINT Read/Write 0
i DINT None 0
init DINT Read/Write 0
myArray DINT[31,3] Read Only 0
myCount myArray[30,1] DINT Read Only 0
myIndex myArray[30,0] DINT Read Only 0
myIteration myArray[30,2] DINT Read Only 0
Program main (and only) routine:
Code:
if init <> 0
then
init := 0;
size(myArray, 0, myCount);
myCount := myCount - 1; // last item is used for metadata
for i := 0 to myCount - 1
do
myArray[i, 0] := 0;
myArray[i, 1] := 0;
myArray[i, 2] := 0;
end_for;
myIteration := 0;
myIndex := 0;
doUpdate := 0;
end_if;
if doUpdate <> 0
then
doUpdate := 0;
myIteration := myIteration + 1;
// Update item data
myArray[myIndex, 0] := myIteration;
myArray[myIndex, 1] := myIteration MOD 13;
myArray[myIndex, 2] := myIteration MOD 19;
myIndex := (myIndex + 1) MOD myCount;
// Initialize next item
myArray[myIndex, 0] := undef;
myArray[myIndex, 1] := undef;
myArray[myIndex, 2] := undef;
end_if;
PC:
Code:
ConnectToPLC();
int index = 0;
const int undef = -1;
const int itemSz = 3;
const int itemCount = 30;
const int arraySz = itemSz * (itemCount + 1);
const int ixOfIndex = itemSz * itemCount;
int array[arraySz];
WriteDINTTag("init", 1);
for (;;)
{
WriteDINTTag("doUpdate", 1);
ReadDINTArrayTag("myArray", array, arraySz);
int newIndex = array[ixOfIndex];
while (index != newIndex)
{
int id = array[itemSz * index];
int param1 = array[itemSz * index + 1];
int param2 = array[itemSz * index + 2];
if (id == undef)
{
// ERROR!!!
}
index = (index + 1) % itemCount;
}
sleep(5);
}
After a while of running (varies from several seconds to several minutes) I reach the situation that the myIndex aka array[90] is already updated while the related item is not, e.g.:
PLC (that is OK):
Code:
myIndex 3
myArray[0,0] 639
myArray[0,1] 2
myArray[0,2] 12
myArray[1,0] 640
myArray[1,1] 3
myArray[1,2] 13
myArray[2,0] 641
myArray[2,1] 4
myArray[2,2] 14
myArray[3,0] -1
myArray[3,1] -1
myArray[3,2] -1
myArray[4,0] 614
myArray[4,1] 3
myArray[4,2] 6
myArray[5,0] 615
myArray[5,1] 4
myArray[5,2] 7
...
myArray[30,0] 3
myArray[30,1] 30
myArray[30,2] 641
vs. PC:
Code:
index 2
newIndex 3
array[0] 639
array[1] 2
array[2] 12
array[3] 640
array[4] 3
array[5] 13
array[6] -1
array[7] -1
array[8] -1
array[9] 613
array[10] 2
array[11] 5
array[12] 614
array[13] 3
array[14] 6
array[15] 615
array[16] 4
array[17] 7
...
array[90] 3
array[91] 30
array[92] 641
It looks like an array write caching in PLC. Values myArray[30, 0] (myIndex) and array[30, 2] (myIteration) have already been synchronized while the myArray[2, ...] and myArray[3, ...] have not.
Is there a way how to force a tag memory to gets synchronized or something like that in RSLogix 5000?
I am pretty sure that the problem is not caused neither by TuxEIP library nor the network communication - I'm able to transfer tons of data without a problem.