Author Topic: user defined modbus function code  (Read 1230 times)

Arif

  • Newbie
  • *
  • Posts: 5
    • View Profile
user defined modbus function code
« on: April 08, 2019, 03:03:40 AM »
i'm new to ahmi, while i understand basic operations, i want to ask

Im expecting 12 byte structured data from each write/read from user-defined fc, it's for personal project so im not bothered by performance or anything
I know i can use something like "66:0001" in PlcAddress, and I wonder if it can be done like this
Code: [Select]
Dim tmp As CustomStructure
Dim tmp2 As String() = TCPCom1.Read("65:0001", 6) '*assuming each element 16bit
tmp.el1 = tmp2(0) >> 8
tmp.el2 = tmp2(0) & 0xFF
tmp.el3 = tmp2(1)
...
does each tmp2(x) represent a byte? or short?
can i use TCPCom1.Read("65:0001", 1) and still expect 12 byte?

also, in modbus tcp driver, there's DataReceived event
can i use this to receive alarm or notification from device when there's value change or input? so ahmi doesn't need to poll data

for example the notification looks like this:
mbap header
function code
byte count
alarm type
data

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: user defined modbus function code
« Reply #1 on: April 27, 2019, 09:43:43 PM »
Archie might be better suited to answer your questions.

Just a few inquiries from me:

What does your user-defined fc do?
Are you reading Boolean values or registers?
If AHMI doesn't need to poll data, do you then expect your device to push changes to AHMI?

There is one topic that was sort of discussing this last question:

https://www.advancedhmi.com/forum/index.php?topic=2382.0