HI,
I am writing you, because I have a problem with
reading holding register based on Modbus RTU protocol.
I am developing my software under using Visual Basic 6.0
I can communicate with my end device. But only give him
a write command.
I am using the following codes and settings:
MSComm.Settings = 9600,N,8,2
MSComm1.RThreshold = 1
MSComm1.SThreshold = 1
MSComm1.InputLen = 0
MSComm1.Output = Chr(Hex(byte1)) + Chr(Hex(byte2)) + Chr(Hex(byte3)) + Chr(Hex(byte4)) + Chr(Hex(byte5)) + Chr(Hex(byte6)) + Chr(crc16) + Chr(crc16)
The output command is working perfect.So i can change parameters in my
end device. But now I also want to recieve(read) parameters out of my end
device. With Modbus RTU I am sending the folowing frame
MSComm1.Output = "station address" + "03h for read" " + 2 bytes for Function code" + "2 bytes of read data" + "2 bytes crc16 error check"
But I don´t recieve anything from my deviece.
'''''For input i am using..
Private Sub MSComm1_OnComm() ' for input
Select Case MSComm1.CommEvent
Case comOverrun: MsgBox "Lost data!"
Case comRxOver: MsgBox "Lost data!"
Case comEvReceive: text2.text = MsgBox(MSComm1.Input)
End Select
End Sub
What I am doing wrong? I thing the codes for MSComm1.Input is
wrong.
Thank you very much for your help.
Sio
I am writing you, because I have a problem with
reading holding register based on Modbus RTU protocol.
I am developing my software under using Visual Basic 6.0
I can communicate with my end device. But only give him
a write command.
I am using the following codes and settings:
MSComm.Settings = 9600,N,8,2
MSComm1.RThreshold = 1
MSComm1.SThreshold = 1
MSComm1.InputLen = 0
MSComm1.Output = Chr(Hex(byte1)) + Chr(Hex(byte2)) + Chr(Hex(byte3)) + Chr(Hex(byte4)) + Chr(Hex(byte5)) + Chr(Hex(byte6)) + Chr(crc16) + Chr(crc16)
The output command is working perfect.So i can change parameters in my
end device. But now I also want to recieve(read) parameters out of my end
device. With Modbus RTU I am sending the folowing frame
MSComm1.Output = "station address" + "03h for read" " + 2 bytes for Function code" + "2 bytes of read data" + "2 bytes crc16 error check"
But I don´t recieve anything from my deviece.
'''''For input i am using..
Private Sub MSComm1_OnComm() ' for input
Select Case MSComm1.CommEvent
Case comOverrun: MsgBox "Lost data!"
Case comRxOver: MsgBox "Lost data!"
Case comEvReceive: text2.text = MsgBox(MSComm1.Input)
End Select
End Sub
What I am doing wrong? I thing the codes for MSComm1.Input is
wrong.
Thank you very much for your help.
Sio