DDE

Read and update values from Excel or similar.

You can link to any data item in the address map using DDE.

The details are:

  • Server: “WinModbus”
  • Topic: Once a file is loaded, the topic is set to the file name, e.g loading myfile.wmb will set the topic name to "myfile". With no file loaded, the topic is just "Slave". In versions 1.1r16 and earlier, the topic is always just "Slave".
  • Data: the address of the data in the data map, padded to 5 digits, e.g. “00001”

So, for instance, in an Excel cell, you could get an updating value of register 10001 by inserting something like:

=WinModbus|myfile!’10001’

You can't do a DDE write directly within Excel but you can do it using the built in VB script.

If you wanted to update a fixed address 10001 with a value from cell “A1” in Excel, you could do it with the following bit of VB: 

Dim nDDEChannel As Long
nDDEChannel = DDEInitiate("WinModbus", "myfile")

If nDDEChannel = 0 Then
  MsgBox "Sorry, failed to open a DDE channel"
Else
  DDEPoke nDDEChannel, "10001", Sheets(1).Range("A1")
DDETerminate (nDDEChannel)  
End If