Need help in understanding the best way to use global.set & global.get
I'm reading OMRON plc D tags using FINS multiple node using below steps:-
injecting below code using function node
var tag_1 = 'D1,D2,D3 .............. D50';
var tag_2 = 'D51,D52,D53 .............. D100';
.........................
var tag_n = ............;
var msg1 = { payload : tag_1 };
var msg2 = { payload : tag_2 };
........................
var msgn = { payload : tag_n };
setTimeout(function(){node.send(msg1);},100);
setTimeout(function(){node.send(msg2);},300);
.........................
setTimeout(function(){node.send(msgn);},n);
**this method I'm using because if I read all tags at once there's always timeout error so reading 50 tags at max at once.
then joining the output using join node and assigning it to global.set("values",msg.payload) then repeating again at (n+200).
And at the same time reading via global.get("values"). Now the problem I'm facing is that some values are constant but when reading them they are not.
Like four tags holds time values 1300 and 1330 but gives values
Hi @sahsha !
After a short check of your flow, I'd initially propose you read the chapter discussing output of multiple messages in the Node-RED docu. As Steve already indicated: You're doing things that make your code complicated & lengthy - without any need.
The result of what you're doing is quite unpredictable ... based on my experience.
I would create a msg package, send this via the multiple message functionality (as one batch) & put a delay node afterwards.
The delay node is able to rate limit the messages ... what seems to be the effect you try to achieve.
As the docu says:
A function can return multiple messages on an output by returning an array of messages within the returned array.
Firstly,
According to this manual (this is a guess on the manual since you did not mention PLC model), the max request size is 2012 bytes. Or, in FINS 16 bit word terms 1006 WORDS.
My first recommendation would be to put all PLC data (that are related to one another) into memory blocks smaller than the read limit. Then read these addresses in 1 go to ENSURE data consistency.
Additionally, I would separate the reads for live data (production status, production count) config data (break times etc) and config data (cycle time settings etc)
Lastly, I recommend the Buffer Parser over function nodes to make this more graphical (and avoid hacks like this...