Modbus losing connection


CamEra

Recommended Posts

Hi,

I have a ICPCON PET 7017 Modbus unit that is connected to DaqFactory using the standard Modbus TCP protocol with standard addressing. Both this unit and the PC are on our internal network and both have static IP addresses.

I am not fully sure just when the problem occurs but it is either when the power is turned off then on again on the PC, the Modbus unit or the Hub that both are connected to, but DaqFactory fails to see the Modbus unit and I need to manually go to QuicK/Device Configuration/mydevice then open configure option then back out using the Save and OK buttons.

Any ideas how to prevent this?

Thanks

George

Link to comment
Share on other sites

Sounds like the socket is getting closed and Windows isn't notifying DAQFactory. You can reinit the port in script by just doing:

device.myDevice.initComm()

You can detect it by looking for timeout errors, or just looking at your data stream and if data gets old (say older than 10 seconds or something), you trigger an initcomm(). Just make sure and give it another 10 seconds or so to reestablish comms before doing initComm() a second time.

Link to comment
Share on other sites

  • 9 months later...

Hi Guru,

How do I check for timeout errors? By Device.MyDevice.Timeout() ?

I have a project I'm currently working on where I need to notify the client via email when the device has a connection error but I dont know how to trigger it?? Please help.

Thanks

Link to comment
Share on other sites

See attached sample (will require the latest 5.87a release).

All I did was create a modbusRTU device on comm port 20, which, unless you happen to have a comm port 20 with a Modbus device attached, will cause a timeout every 10 seconds. I then created an OnAlert sequence with the following code to display a different message. You can do what you want inside the if(). If you want to capture other errors, use a similar pattern in OnAlert. Note that this technique isn't for capturing errors in sequences. Use try/catch for that.


if (strAlert == "P-ModbusRTU 0010: Timeout")
? "Device read timed out"
endif
[/CODE]

I can't quite say how to integrate with your alarms since I don't know how you are doing alarms. If you are using built in alarms, you can either create a Test D to A channel and set it to some value that triggers an alarm, or use a variable.

onalertSample.ctl

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.