Div_by_zero Posted September 26, 2017 Report Posted September 26, 2017 (edited) Working on a communications project where I will be continuously polling 4 different Modbus enabled devices. By "continuous" I mean that every 25 ms (a parametric value) the PLC will be reading different coils, inputs, input registers, and holding registers. There are approximately 10 reads per device, so 40 reads total in a single read cycle. On command (random operator intervention), writes to certain holding registers will occur. In order for a write to occur, the reading must temporarily stop, then, after a short delay (10 ms), a write may be attempted. I'm trying to figure out the best, cleanest way to pause the reads so that a write can occur. The "brute force" was would be to create, for each writable value, a pause bit, a write delay timer, and a break (unpause) bit. However, this would start to add up to a lot of tags quickly, and I feel there must be a better way to do what I need to do. Any ideas? Thanks! edit: the PLC is an Automation Direct Productivity 2000 Edited September 26, 2017 by Div_by_zero
Steve Bailey Posted September 26, 2017 Report Posted September 26, 2017 I would create an internal bit called "Write request Pending" and set it when the operator commands a write. Use that bit as a permissive (must be off) for any read requests. When there is a write request pending, and the most recent read command has been executed you can execute the write command. Upon successful completion clear the "Write request Pending" bit.
Div_by_zero Posted September 28, 2017 Author Report Posted September 28, 2017 Thanks Steve, that definitely helps. Question: how do I identify and define the "most recent read command". Thanks again.
Steve Bailey Posted October 2, 2017 Report Posted October 2, 2017 Without knowing the details of your specific application I can't answer that question. There must be something in your logic that sequences the read requests over the full range of addresses. I would start by looking there for a value that identifies when a read request is being processed. If the entire sequence is controlled by the 25 mS timer rather than by a bit that indicates completion of each read request, wait for the timer to time out after the "write request pending" bit goes high. Or, iIf there is a word that tells you which of the forty read requests is being executed, when that word hasn't changed its value for longer than 25 mS, you know the read sequence has been interrupted by the pending write request and it is safe to execute the write.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now