How to Read Tags from CompactLogix PLC

Hello,

Looking for guidance with a starting point. In short, I'd like to be able to use Node-Red to read select PLC tags, initiated by some sort of trigger that isn't time. Specifically, AB/Rockwell CompactLogix tags, both reals and strings for data types.

Computer is a RaspberryPi with touchscreen for viewing, with Bookworm OS.

I admit there are a number of similar posts here, and those posts generally point to using nodes such as:
node-red-contrib-cip-st-ethernet-ip, node-red-contrib-cip-st-ethernet-ip (node) - Node-RED
or
node-red-contrib-cip-ethernet-ip, node-red-contrib-cip-ethernet-ip (node) - Node-RED
with the former seemingly being an expansion on the latter.

The problem I have with these, is that the "read" node in a flow, named "eth-ip in" appears to be ONLY timer based. Or, using this node, every x seconds read a tag.

I want to pull data that correlates with a part in a machine. Something like:
Wait for a PLC "trigger" tag to go high
When trigger high, read plc string data type tag and one or two real data type tags.
Maybe a handshake back to the PLC
PLC "trigger" tag goes low
Reset to Step 1.

So the piece I'm missing is a way to programmatically poll the tags, instead of just time-based.

So I guess that is 3 ways of possibly accomplishing my goal, and I don't know node-red or Linux enough yet to guess which is most likely to be successful. If anyone has guidance in this regard, or any tidbits to anything I've said here, I would be most grateful.

I've been reading documentation on these things for days, and feel thoroughly stuck. Currently trying to break things down into smaller steps and test along the way.

As a new user, I was only allowed to include 2 url links. So I've broken out these paragraphs from the original post to comply with this rule:

I've recently stumbled across Node-Red's "functionExternalModules" option, with something like npm package "st-ethernet-ip" ( st-ethernet-ip - npm ). Reading through if this would work, or for that matter how external modules are even supposed to work.

I've successfully done this with Python on a PC in the past, but so far I haven't figured out Linux enough to have a function node call on a.) the python code for reading tags and b.)the library that python code depends on. The python code for accomplishing it this way was from "pylogix" ( GitHub - dmroeder/pylogix: Read/Write data from Allen Bradley Compact/Control Logix PLC's ).

I guess I should also say that making a python executable with the pylogix mentioned above is my easiest option in one sense; I've gotten it to read tags.

I want to make it work with node-red because I like node-red, and I think in the end it may be easier to add a user interface for entering things like the target PLC IP address and tags to read.

One approach could be to do all of your PLC reading in python and publish the results to mqtt.

To be clever about it, you could create a command response structure in mqt also. Ie. Subscribe to xxx/command read the address request, grab the value, publish it to xxx/result.

To be even more useful, you might use mqtt5 command response pattern so that you can specify the response topic inside of the request. You could expand on this even further and provide means of requesting tags in plc or plc clock or plc state etc.

Steve-Mcl,

Thanks for the response.

I think I'm with you on the first part... grabbing the data in Python, in a python script with mqtt, and a node-red mqtt would read what python published? If so, my trigger for writing would be in a loop waiting for a tag state to change or something, in the python code.

The last paragraph, I'm a little lost on. Perhaps my "someday would be nice to have" UI in Node-Red (text box or similar) accepts tag names to read, MQTT sends those to Python, and python script moves those tag names to variables for doing the plc tag read? Or maybe you meant something else altogether and I'm missing it.

Edited: more words for clarification.