Modbus Write Recipe Wait for Tag Reset

I have a PLC that I need to write recipes to. This is done by loading values into Modbus tags, then setting an Activate Data tag to trigger recipe loading. The trigger tag gets reset to zero when finished.

When doing a series of these operations, what is the best way to wait and block on the tag to be reset? Doing a while loop with a tag read doesn't feel like the right answer.

Doing a while loop with a tag read doesn't feel like the right answer.

That's for sure.

Use a tag change event?

1 Like

I don't think that would work in my situation. I'm looping over recipes to load into the PLC, and so I need to block on the tag reset after each recipe load.

for recipe in recipes:
    # write recipe data
    system.tag.writeBlocking([tag],[value])
    # activate data
    system.tag.writeBlocking([tag],[value])
    # wait for data activation tag to reset before moving on 

You simply cannot do that. Make a state machine and call it from a timer event. Put the state in a memory tag. Every timer event, read the state, read the handshake, perform the next step if allowed, update the state.

1 Like