Synchronizing access to PLC data block (Siemens S7 1200)

https://github.com/drbitboy/PLC_Modbus_client_server_50words

That is my test code for the Data Consistency check:

  • S7-1200 is running
    • A Modbus server in the Main Program Cycle (OB1)
      • The holding registers are mapped to a 100-character string (51 registers, including one additional word at the beginning that appears to be the string length)
      • There is a boolean whether to execute a DIS_AIRT/EN_AIRT instruction pair wrapped around the MB_SERVER
      A 1kHz Cyclic Interrupt block (OB37) at a hight priority (24), alternating writes to the 100-character string (and Modbus server holding registers) of "AAA...AAA" and "BBB...BBB"
  • CCW/Micro820 Modbus client is reading (Modbus command 15) the 100-character string as 50 holding registers from the S7-1200 at ~10Hz
    • For each read, CCW counts by 1 if there is a mismatch between the first word and the fiftieth,
      • The mismatch occurs if OB37 interrupts the MB_SERVER in OB1 while data are being transferred.
  • Bottom line: without the DIS_AIRT/EN_AIRT pair enabled, about one transfer in a thousand shows a mismatch
    • I miss any mismatch from a read which immediately follows a read that yielded a mismatch
      • At one in a thousand, I am comfortable with the error, but feel free to correct the code.
Caveat: I used Modbus because my TIA V14 testbed does not have OPC UA, so YMMV.
 

Similar Topics

Hello, I am looking for your suggestions for methodologies to sync process setpoints across a local HMI and remote SCADA system. Background...
Replies
18
Views
2,060
I'd like to hear how others have handled this kind of situation. I have four identical machines, each with a Red Lion CR3000 15" HMI and Beckhoff...
Replies
5
Views
2,505
TLDR; How to synchronize setpoint values between a local HMI and remote PLC connected by cellular modem, while preserving the most recently...
Replies
8
Views
4,100
I'm working on a design for a cutting machine. This system gets synchronized with the production line speed, Do the cutting and come back to the...
Replies
4
Views
2,549
Let's that I want to synchronize 2 digital outputs so the fist DO is ON for 600 ms and a soon it goes to OFF state the second will turn ON for 400...
Replies
1
Views
1,320
Back
Top Bottom