hi all
i test the HC900 modbus (master) read function by connecting s1 port to my notebook with rs485 usb converter. in the HCD, i monitor the MBS function block. i got NO_SCAN and BAD_COM both are false. does it mean all my connection and settings are right?
in the MBS function block, i set reading only one 16bit unsigned register.
in my notebook, i write a program worked as modbus slave.
i check the program, i get the query message are correct and conformed with my MBS setting. then i send responses something like 010302E148F022.
after many communications, very weird, in the modbus master port diagnostics, messages received are still zero, and the MBS output pin also zero, and all communication count as application errors. i send the response already within the timeout i set in the advanced setup.
what i miss to get modbus read working?
thanks for your reading and reply.
i test the HC900 modbus (master) read function by connecting s1 port to my notebook with rs485 usb converter. in the HCD, i monitor the MBS function block. i got NO_SCAN and BAD_COM both are false. does it mean all my connection and settings are right?
in the MBS function block, i set reading only one 16bit unsigned register.
in my notebook, i write a program worked as modbus slave.
i check the program, i get the query message are correct and conformed with my MBS setting. then i send responses something like 010302E148F022.
after many communications, very weird, in the modbus master port diagnostics, messages received are still zero, and the MBS output pin also zero, and all communication count as application errors. i send the response already within the timeout i set in the advanced setup.
what i miss to get modbus read working?
thanks for your reading and reply.
Code:
//my program
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
serialPort1.Open();
do
{
if (serialPort1.BytesToRead > 7)
{
byte[] rcv = new byte[256];
int i = serialPort1.Read(rcv, 0, 256);
if (i == 8)
{
byte[] buff = new byte[] { 1, 3, 2, 225, 72, 240, 34 };
serialPort1.Write(buff, 0, buff.Length);
}
}
}
while (true);
}