Author Topic: Application locks up when PLCs not connected  (Read 953 times)

scameron

  • Newbie
  • *
  • Posts: 3
    • View Profile
Application locks up when PLCs not connected
« on: October 12, 2017, 10:51:22 PM »
I have a application that reads some values from 4 different MicroLogix 1400s over ethernet. When I am connected to the PLCs I can run the code, debug things in Visual Studio 2017, and everything seems fine. However, when I went offline and disconnected from the PLCs, Visual Studio (and my app) just hangs up.

Has anyone else seen this behavior?

Does anyone know if there i a way to do this development offline and ignore the PLC communications (or prevent this hang up) so that I can develop the rest of the VB code before connecting to the PLCs?

I was thinking maybe it was a "timeout" value that I was missing somewhere.

Thoughts?


Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5323
    • View Profile
    • AdvancedHMI
Re: Application locks up when PLCs not connected
« Reply #1 on: October 13, 2017, 08:29:53 AM »
I will assume you are using a Read method in code because it is a blocking method which will hold until it successfully reads or times out. In that case, there are a few ways you can prevent the hold up of your code. The first is to reduce the Timeout property of the driver down from it's 5000ms default.

Another option is to use Asynchrnous reading with the BeginRead.

A third option is to use subscriptions or the DataSubcriber.

scameron

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Application locks up when PLCs not connected
« Reply #2 on: October 13, 2017, 09:15:33 AM »
Thanks Archie.

I am just placed a "BasicLabel" on the form and defined the CommComponent and PLCAddressValue to read and display.

I'll give the timeout a shot first and see where that goes.

I'm using the EthernetIPforPLCSLCMicroCom - I am assuming that the TimeOut property is defined by the "MaxTicks" variable in the Helper section of the driver code or is it defined elsewhere?



Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5323
    • View Profile
    • AdvancedHMI
Re: Application locks up when PLCs not connected
« Reply #3 on: October 13, 2017, 09:53:33 AM »
The Timeout is a property of the driver.

If you are using a BasicLabel, the you not see any lock up. I just did a quick test by putting a BasicLabel on a form and setting PLCAddressValue to N7:0. I then added a regular button to the form and made its click event show an MsgBox window. I can run the application and immediately click the button to get a pop window, then a second later the BasicLabel will show the could not connect message.