I have a holding register as a 'new data flag'. The Modbus master reads this register every second to check if there is new data (Flag = 1), if so, it reads more (predefined) registers for the actual data. Once the data has been read, the Slave is supposed to reset the new data flag back to 0. However, I couldn't find an event handler in the Modbus API to enable such functionality. Anyone has ever run into a similar problem?
Solved! Go to Solution.
You need to add one address in slave for acknowledgment of reading from master. Let us assume that you read 'new data flag' from address 0x100h. You can add additional address (0x101h) in slave for acknowledgment. Once the master reads the data from 'new data flag' from 0x100h, it should also write 1 in the acknowledgment register 0x101h. the salve just need to check the acknowledgment register 0x101h. Once it is 1 then it should consider that the master has read the data and then the slave should overwrite the data with 0 in 0x101h.
Thank you for the suggestion. Unfortunately I can't dictate the Master's behavior. The Slave on this GC is able to detect the read action automatically, I am trying to implement something similar
Modbus is a rather old protocol designed to communicate with industrial devices (in origin, PLCs). It only features reads and writes.
Many companies tried to leverage this standard to implement new functionalities. For example in some cases you write into a register to trigger an action in the device. These are all nonstandard extensions that must be actively implemented in the slave loop. So, if your slave Modbus is open source you can add this new feature yourself, otherwise you have no chance.
Understood, thank you. I am using LabVIEW Modbus library. Will try to find a more flexible solution.
There are multiple LabVIEW Modbus libraries. At least one of them is open source, see here. I used it in some projects but not heavily.
This library is an example, not a product, so it's unsupported. I had to correct a bug myself when I used it the first time, about 15 years ago.
Thank you for the additional info. Yes I was aware there are multiple libraries. What I meant was I am using the one that comes with LabVIEW installation (Part of DSC module I think). Sorry for the confusion.