News:

  • October 14, 2025, 10:46:11 AM

Login with username, password and session length

Author Topic: Modbus memory update behavior on BRX  (Read 1322 times)

Cactuar

  • Newbie
  • *
  • Posts: 8
Modbus memory update behavior on BRX
« on: June 02, 2022, 05:11:03 PM »
Hi all,

I am familiar with the general PLC paradigm of hardware IO and how it relates to the scan cycle:

* hardware inputs are read, copied into memory (here, the X or WX locations)
* the scan processing happens
* values in output locations (Y, WY) are used to update physical outputs on HW

and the associated consequences. For example, an input changes during the middle of the scan processing, I will not see the 'new' input value in the X* register until the next scan. But, changes in internal registers (C,  V, N, D, R, etc) do show up during the same scan. Obviously this is a very simplified outline of the scan cycle, and there are funny behaviors when it comes to other constructs, the type of the ladder (program vs subroutine, say), and advanced features like stages; locations get cleared when the subroutine ends, etc.)

My question here is: how do the modbus registers MC, MI, MHR, MIR fit into this? specifically: do they only change "outside" of the scan, i.e. during the hardware read/write cycles?

Let's say a Modbus packet to write a coil comes in during the middle of the scan. Does the value get updated in the MC register during the HW input read cycle (before top of scan, like X or WX)? or does the MC register get updated immediately (like an internal register)?

In this example I'm only really concerned with Modbus/TCP, if it makes a difference. I would expect that RTU would behave the same from this software perspective, but you never know.

Thanks!



BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6126
  • Yes Pinky, Do-more will control the world!
Re: Modbus memory update behavior on BRX
« Reply #1 on: June 02, 2022, 05:41:59 PM »
Hi all,

I am familiar with the general PLC paradigm of hardware IO and how it relates to the scan cycle:

* hardware inputs are read, copied into memory (here, the X or WX locations)
* the scan processing happens
* values in output locations (Y, WY) are used to update physical outputs on HW

and the associated consequences. For example, an input changes during the middle of the scan processing, I will not see the 'new' input value in the X* register until the next scan. But, changes in internal registers (C,  V, N, D, R, etc) do show up during the same scan. Obviously this is a very simplified outline of the scan cycle, and there are funny behaviors when it comes to other constructs, the type of the ladder (program vs subroutine, say), and advanced features like stages; locations get cleared when the subroutine ends, etc.)

My question here is: how do the modbus registers MC, MI, MHR, MIR fit into this? specifically: do they only change "outside" of the scan, i.e. during the hardware read/write cycles?

Let's say a Modbus packet to write a coil comes in during the middle of the scan. Does the value get updated in the MC register during the HW input read cycle (before top of scan, like X or WX)? or does the MC register get updated immediately (like an internal register)?

In this example I'm only really concerned with Modbus/TCP, if it makes a difference. I would expect that RTU would behave the same from this software perspective, but you never know.

Thanks!

They are updated during the comm timeslice, which comes after logic is solved and outputs written, but before other end-of-scan system housekeeping.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

Cactuar

  • Newbie
  • *
  • Posts: 8
Re: Modbus memory update behavior on BRX
« Reply #2 on: June 02, 2022, 05:55:40 PM »
OK, so from that I am concluding:

* from the program's perspective, they behave like HW registers and are updated "outside the scan"
* incoming modbus writes will not result in a MC/MHR value returning two different values at different times in the scan.

So it's essentially the same behavior as the hardware input registers X, WX as far as the program is concerned.

That's what I needed to know. Many thanks for the quick reply!

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6126
  • Yes Pinky, Do-more will control the world!
Re: Modbus memory update behavior on BRX
« Reply #3 on: June 02, 2022, 06:04:09 PM »
Correct.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO