Author Topic: Which method should I use?  (Read 1827 times)

jazzplayermark

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Which method should I use?
« on: April 07, 2018, 05:09:17 PM »
I have a project coming up that will poll 16 modbus devices with a total of about 500 tags every 5 minutes and write the values to a sql database.

What is the fastest method of reading this much data? Datasubcriber2? Raw reads? I'm not strong in VB so I want to go down the right path and only do this once.

I tried creating another process that only gets called every 5 minutes from a timer on the mainform and reads raw data like :
myvar = (MainformName.ModbusDriver.Read("40003)) and it all works fine, I just don't know if this is the best and fastest solution.

Your thoughts are greatly appreciated.




Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Which method should I use?
« Reply #1 on: April 07, 2018, 05:18:50 PM »
Will the application need to do anything else like continuously display values.  If so, I would add a timer to the form that ticks every 5 minutes, then read the data via code. If the registers are consecutive, read them as an array:

Dim MyValues() as string=ModbusDriver.Read("40003",10)

If the application does nothing else except wake up every 5 minutes to transfer data, then maybe a Windows scheduled task to launch the app, then make it close when finished. This will make sure no one closes the application and stops the data log. The downside is that the 5 minute interval will tend to jitter by a few seconds.

jazzplayermark

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Re: Which method should I use?
« Reply #2 on: April 07, 2018, 05:33:59 PM »
I will have to display some key data on the mainform. There are a few consecutive registers, so I can read those in groups.
thanks..

jazzplayermark

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Re: Which method should I use?
« Reply #3 on: April 10, 2018, 05:14:38 PM »
I wrote something very small to start with but I did try to connect to all the devices using ModbusTcp.  I had no problems connecting and the first read worked without any problems but then I started getting a lot of exceptions when trying to read from a device. I tried to look at the exception but the error said 'Unknown error code -21 at ..... '

I'm not sure how to troubleshoot this. Any ideas? thanks.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Which method should I use?
« Reply #4 on: April 10, 2018, 05:52:11 PM »
The -21 occurs when there is no response to the request. The best place to start is to do a Wireshark capture and see if there is no matching response to any requests or if a long time goes by before the response comes.

jazzplayermark

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Re: Which method should I use?
« Reply #5 on: April 10, 2018, 07:42:11 PM »
Ok thanks. I can do that. If that's the case would changing the pollrateoverride help?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Which method should I use?
« Reply #6 on: April 10, 2018, 07:55:41 PM »
Ok thanks. I can do that. If that's the case would changing the pollrateoverride help?
It really depends on the network and slave as to what PollRateOverride is possible. What do you have it set at now? I would expect ModbusTCP slaves could easily handle 100ms

jazzplayermark

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Re: Which method should I use?
« Reply #7 on: April 10, 2018, 08:09:01 PM »
I took it up to 2 seconds but the result was no different. I'll try to get in and run a wire shark on it. thanks

jazzplayermark

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Re: Which method should I use?
« Reply #8 on: April 11, 2018, 04:34:38 PM »
I tried polloverrides from 500 to 5000 and timeouts from 100 to 15000 and always get the same results. I had trouble using wireshark but I did get a capture with Microsoft Network Monitor. Here is a frame summary.  It's interesting that the first time I get data back and roughly every 4th time after that. I'm hoping this is enough info to help. I really don't know what I'm looking at..... :-[

I've attached a text file of the results.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Which method should I use?
« Reply #9 on: April 11, 2018, 09:47:31 PM »
That file is not really giving any information. It looks like it is only telling the packets time and length of only the response. But not the data nor the request.

Wireshark is the best because it dissects the Modbus packet.

jazzplayermark

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Re: Which method should I use?
« Reply #10 on: April 12, 2018, 09:47:42 AM »
Thanks Archie. I'll try wireshark again.

jazzplayermark

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Re: Which method should I use?
« Reply #11 on: April 12, 2018, 10:01:55 AM »
I just looked through the frame details for the reply that didn't work and under TCP it says 'bad checksum'.....  I think I need to get their IT people involved.. Thank you for looking at it.


Godra

  • Hero Member
  • *****
  • Posts: 1438
    • View Profile
Re: Which method should I use?
« Reply #12 on: April 12, 2018, 05:07:59 PM »
jazzplayermark,

Out of curiosity, are you using a single ModbusTCP driver for all 16 slave devices and just switching through UnitId's?

If that's the case, have you tried using more than 1 driver at any point in time?

The reason for asking is since I did a simple test with MODRSSim2 simulator and 4 drivers , all with the same settings besides for the UnitId.
The responses were OK.

Just a suggestion for testing.

jazzplayermark

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Re: Which method should I use?
« Reply #13 on: April 12, 2018, 08:37:37 PM »
I am currently using only 1 driver. This is a new project and I'm trying to prove the point that the reporting can be done with a click of the mouse rather than someone importing data into 25 excel sheets and generating graphs for 2 hours every morning:) I am getting data from a red lion modular controller and it is running a recent version of crimson software. The entire project, should I get the job will have 16 of these devices and I will use a different driver instance for each of them, or at least that's the plan.