MODBUS Communication with VB


Thread Starter

srinivas duddu

My VBCode doesnt work! I need to communicate to a Gas Analyser which supports MODBUS RTU. The instrument works with MODTEST utility of M/s Daniel Europe. Not with my VB code. Thank U!! Pls. Find below the code sample i was working on In the MSComm Control i left the settings as commport:1 settings:9600,n,8,1 Handshaking: ComNone InBufferSize:1024 OutBufferSize:512 InputLength:7 DTR enable =TRue Private Sub CmdQuery_Click() MSComm1.Break = True MSComm1.CommPort = 1 MSComm1.PortOpen = True MSComm1.Output = "010300000001840A" MSComm1.InputMode = comInputModeText TxtResponse.Text = MSComm1.Input End Sub Using the Daniel Modtest utility i got the following response string from the analyser 01,03,02,03,C5,78,E7. I feel some problem is with the code, please advice / suggest any remedy in this regards by srinivas

Alex Pavloff

Go buy a Modbus RTU component. You'll get the job done faster and it will be more reliable. has one, and there are others that will work. Your main problem is that your string "010300000001840A" is not binary -- it's a 16 byte text string. You need to put together a binary string containing the bytes 0x01 0x03 0x00 0x00 0x00 0x01 0x84 0x0A. Good luck Alex Pavloff Software Engineer Eason Technology