Paul

error handling for RS485/Modbus communications

Recommended Posts

I have just started using DAQFactory  and now DAQFactory Express (both Release 17.1 Build 2309) for monitoring a temperature controller via RS485/Modbus.

I am impressed with DAQFactory (thanks to the developers for such a great product) and am slowly getting an understanding of how to use it after lots of attempts, reading and searching of the forum.

I have been able to configure a new RS485/Modbus device in DAQFactory and successfully connect using a USB-Serial adapter to a Shimaden SRS11A temperature controller and retrieve the current temperature value.  I have also configured a single channel and a logging set which work well.

I am trying to add some error handling to manage serial port errors on the RS485/Modbus connection such as when the RS485/Modbus device is powered off, the USB-Serial adapter is not plugged into the computer, or a RS485/Modbus timeout.  I am using the OnAlert() function to deal with these types of errors as they are not caught by using the Try/Catch approach in scripts/sequences.

This is catching errors/alerts OK except I am observing inconsistent behaviour.  I have an auto-start sequence called Main which sets the Channel timing to zero then does a device...initcomm() to see if communication is working.

When I setup a test scenario where the USB-serial adapter is connected but the RS485/Modbus device is powered off, I sometimes get a timeout error, no error or an occasional error where DAQFactory cannot load the driver TriLogi.dll (I am not using this driver, my device is using the supplied ModbusRTU one). 

The fault is probably something I have or haven't done but I was wondering whether anyone has seen something like this before?

Any help or suggestions are welcome.

Thanks

Paul

Share this post


Link to post
Share on other sites

If you really want to do error handling on the comms you should probably switch from using Channels and Timing to using a little script.  You can still use Channels to store your data, but you would use a little script to collect the data.  Something like:

while(1)
   try
      private myData = device.myDevice.ReadHoldingU16(1,0,1)
      myChannel.addValue(myData)
   catch()
      ? strLastError
      // do something else if it fails
   endcatch
   delay(1)
endwhile

Channels and Timing does its own error handling.  It prints the error to the command/alert and tries again next time.  There is nothing wrong with those error messages, but if you want more, you have to revert to script.  I should add that if you have multiple devices, and one is timing out, it will slow down acquisition for the other devices.  For this, I suggest using the Offset parameter to stagger the reads across multiple threads.  Use a different Offset value for each device, though if you have multiple devices on a single 485 chain, you should put all of them on the same offset.

Share this post


Link to post
Share on other sites

Thank you for your comments and suggestions.

I will look at trying to implement reading data programmatically rather than using a channel later.

Exploring the problem further, I have removed the channel so that now the project only contains the MODBUS RTU RS485 device I created from scratch for the Shimaden SRS11A temperature controller and a script to check for errors on the RS485 connection using OnAlert().

I still find I am getting an error perhaps 2 in every 3 times I launch the project describing the following:

"C1033 Unable to load device driver TriLogi.dll, check file path and make sure manufacturer's drivers are installed."

To my knowledge I am not doing anything which would require the TriLogi.dll file.  Perhaps my installation of DAQFactory is corrupt?  I can't locate TriLogi.dll on my computer.

Is this file supposed to be included with a default DAQFactory installation?  Do I really need this file or does it point to another problem?

Does the mydevice.initcomm() call limit itself to checking whether the COM port (in this case) configured in the RS485 device is active and responding or does it also somehow check there is a RS485 device connected to it?

Thanks in advance.

Paul

Share this post


Link to post
Share on other sites

The Trilogi error is a little unusual.  I do not believe it is included in the installer anymore.  It must be referenced in your document somewhere.  You can send the doc to us and we can quickly check.   

Initcomm() just tries to get access to the serial port for communications.  It does not actually send anything over the line.  It's kind of like picking up a phone and listening for a dial tone.  It does just that, but doesn't actually make a call, or talk with anyone.  If the serial port doesn't exist, or is being used by another application it will throw an error.

Share this post


Link to post
Share on other sites

Interesting.  Just for the heck of it I decided to search for the TriLogi.dll file and came across it in a zip file attached to a posting in this forum back a few years.  I extracted the contents (trilogi.dll and trilogi.dds) and copied them into the root directory of the DAQFactory installation (C:\Program Files\DAQFactory\ in my case).

I restarted DAQFactory Express, loaded my project and now the TriLogi.dll error is gone but I am getting another message about a missing dll.  See below:

C1033 Unable to load device driver RFScada.dll, check file path and make sure manufacturer's drivers are installed.

I have  uninstalled DAQFactory and re-installed with the same results with the errors.  I am running on Windows 7 SP1, 32-bit.

 

Thank you for describing what the initcomm() call does.  It makes sense and explains the behaviour I observe.

I can email the project file if required.  What email address should I use?

Thanks

Paul

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now