Modbus RTU - X20CS1020 - Sample

Hello,
A short and simple example of how to communicate one variable via Modbus RTU.

  1. To project Add Library Sample : LibDRVmbus1_ST

  1. Change Sample :

  1. According to the documentation, add the variable which I want to read:

image-2026-5-12_16-13-30

  1. X20CS1020 Configuration
    Set Cyclic Stream mode :

  1. Reading :
    RTCSecondE = Event
    RTCSecondM = Mapping/Data
    So I set RTCSecondE to TRUE. At that moment, the data is filled into RTCSecondM, and at the same time it resets itself RTCSecondE back to FALSE (Reset to FALSE is also a verification for me that the reading is done)
    So if I wanted to read cyclically in each cycle, then in each cycle I will call: RTCSecondE := TRUE;

2 Likes

Thanks for sharing :wink: