You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

Reply
 
Thread Tools Display Modes
Old January 21st, 2021, 12:01 PM   #1
Gadelric
Member
United States

Gadelric is offline
 
Join Date: Nov 2018
Location: Midwest
Posts: 106
Visual Studio Error Codes

Wizards,

I have an application that is built in Visual Studio 2019.
I have been getting an error from the program that is very generic.
The developer sent me in a direction that was not the issue, the equipment they said was having issues was replaced, I didn't have the replacements port set correctly and we received the error associated with the board "not working".

This leads me to believe the issue we started with was not related to the board that I was recommended to replace as we are still getting the original error with the board replaced.

I have the program and all associated files for this backed up onto a computer that has visual studios.

Is there a way that I could dig through the code to find where this error is triggered so that I could at least have some idea as to what is causing the error?

The station is a very simple station, 1 computer/monitor, 1 relay board and 1 amp meter.
I am currently waiting for production to go to lunch so I can switch the network cable to a dedicated line that goes from station directly to the main PLC switch. Current set up has this station daisy chained through multiple ops. Although I can not confirm this is network related, having a dedicated line will at least remove the daisy chain.
The error we get is random, could be several times a shift, could be a couple weeks between errors.

Any advice is appreciated.

Gad
  Reply With Quote
Old January 21st, 2021, 12:30 PM   #2
busarider29
Lifetime Supporting Member
United States

busarider29 is offline
 
Join Date: Aug 2013
Location: Midland, MI
Posts: 158
I presume that the application is crashing randomly? If so, what is the error message that is being generated by visual studio? I would start there first. If you have the source code, then on a laptop with Visual Studio installed on it, try running it in the Visual Studio IDE (Debug) and let it run until it crashes. You'll need to have proper communications established from the application on the laptop, to the machine. Once you have that established, run it (Debug---->Start Debugging). Then walk away and let it run. When it crashes again, it will stop at the portion of the code and display a graphic showing you the line/s of code where it had a problem.

Do you know what programming language the application was written in? If it's Visual Basic, the "Form" in the Solution Explorer will end with ".vb". If it's in C#, it will be ".cs". Either way, right click on the main form in the Solution explorer and then select "View Code". Sounds like it's a simple machine, so probably only one file with the source code in it.

Also, is the station in question fully automated? I mean, if its an operator at the stations that clicks on stuff, I would try and find out if its something specific that the operator clicks on when the crash happens. For instance, if its a particular button that gets clicked, and then the crash happens, then you know to start at that button's code in the application source code.

Last edited by busarider29; January 21st, 2021 at 12:56 PM.
  Reply With Quote
Old January 21st, 2021, 12:42 PM   #3
drbitboy
Lifetime Supporting Member
United States

drbitboy is offline
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 2,587
@busarider has a great idea about building debug executable and running it in the IDE, although waiting for the error for a few days in VS2019 might be ... awkward.



If the error message is part of the application and not generic Windows/VS2019 (e.g. not "COM2 device does not exist"), you can search for strings in the source code using the IDE see https://code.visualstudio.com/docs/e...h-across-files.


Also, you don't have to be running the app to do this, or even have it built into an executable (.exe) file.

Last edited by drbitboy; January 21st, 2021 at 01:15 PM.
  Reply With Quote
Old January 21st, 2021, 12:51 PM   #4
PreLC
Member
United States

PreLC is offline
 
PreLC's Avatar
 
Join Date: Apr 2019
Location: Mars
Posts: 337
So I haven't worked much with PLCs and VS together, but back in the day when I did coding more than laddering, there are ways to throw meaningful exceptions in code, and instead of just having function calls, do this:

https://docs.microsoft.com/en-us/dot...ing-exceptions

This needs to be a request you need to raise to the devs, they would be fully aware on how to make their program have exception handling.

Also, I just linked to C# exceptions as an assumption, all languages have some sort of error handling/exception mappings.
__________________
Ask not what your PLC can do for you, ask what you can do for your PLC.
  Reply With Quote
Old January 21st, 2021, 02:19 PM   #5
Gadelric
Member
United States

Gadelric is offline
 
Join Date: Nov 2018
Location: Midwest
Posts: 106
Sorry for the confusion,

The error is produced by the application.
There are 3 errors we have seen from this beast.
1.) OPC---- related to rslinx not running
2.) Relay board port------ related to relay board not being connected physically or port assignment is incorrect.
3.) Unable to read switches---- unknown cause (Developer said they "think" this was caused by the relay board not being connected, but that turned out to be incorrect)

I don't have the option to leave my laptop integrated into this line as I need it, my dev pc that has VS on it is an offline pc that only connects to my development PLC.

My best option at the moment is to try and see if I can locate where in the application the error is thrown, and then do some deductive reasoning as to why we might be getting this.

For now, the machine has a dedicated network line to the PLC main switch. The operator asked if I worked on it while he was at lunch, because he noticed the station is quicker to respond to the cycle start swipe.
  Reply With Quote
Old January 21st, 2021, 02:29 PM   #6
drbitboy
Lifetime Supporting Member
United States

drbitboy is offline
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 2,587
Quote:
Originally Posted by Gadelric View Post
3.) Unable to read switches---- unknown cause

that sounds like a custom error message, so unless it is in a driver DLL, I suspect you will be able to find the code with that string in it.


Even if it's in the driver, there is probably only one or a few reads of the switches, so that would still enable narrowing down the code where it happens, although if it is in a DLL driver it is unlikely you will be able to do anything about it.


If this is happening over a network (OP said they were running a dedicated network cable) and the protocol is over TCP/IP, can you fire up a continuous ping to the device (ping -i, IIRC)? that might show if there was a network issue at the same time as the problem.


If it is TCP/IP, wireshark or tcpdump is another diagnostic tool.

Last edited by drbitboy; January 21st, 2021 at 02:35 PM.
  Reply With Quote
Old January 21st, 2021, 02:44 PM   #7
Gadelric
Member
United States

Gadelric is offline
 
Join Date: Nov 2018
Location: Midwest
Posts: 106
Found this:

Function StartRestartSwitch() As Boolean
'Function Returns The State Of The Start Restart Switch

Try
Dim value As Integer = RelayBoardPort.ProXR.AD8.Read8BitsValue(0)

Select Case value
Case Is < 127
frmMain.osStartRestartSwitch.BackColor = Color.LimeGreen
Return True
Case Else
frmMain.osStartRestartSwitch.BackColor = Color.WhiteSmoke
Return False
End Select

Catch ex As TimeoutException
WritetoErrorLog(ex, True, True, "Error Occured In: " & New StackTrace().GetFrame(0).GetMethod.ToString, True, "There Was An Error Reading The Switches : An Exception Was Thrown See Error Log For Details")
End Try



This appears to be what I was looking for.
It does appear that this is related to the relay board, but the try case statement makes me think this is an optical function call that displays the indicator color when you swipe cycle start. But when we get the error, you can swipe cycle start and the indictor will flash from white to green.

  Reply With Quote
Old January 21st, 2021, 02:49 PM   #8
Gadelric
Member
United States

Gadelric is offline
 
Join Date: Nov 2018
Location: Midwest
Posts: 106
Quote:
Originally Posted by drbitboy View Post
If this is happening over a network (OP said they were running a dedicated network cable) and the protocol is over TCP/IP, can you fire up a continuous ping to the device (ping -i, IIRC)? that might show if there was a network issue at the same time as the problem.


I do have a small pc that displays camera images for the operators, I will run a ping test, I think continuous ping is -t, will see what happens.
Unfortunately, things run great for unknown amounts of time.. this ping could run for 10 min, or 10 days before I see the error pop up.
  Reply With Quote
Old January 21st, 2021, 03:06 PM   #9
drbitboy
Lifetime Supporting Member
United States

drbitboy is offline
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 2,587
Quote:
Originally Posted by Gadelric View Post
...
Unfortunately, things run great for unknown amounts of time.. this ping could run for 10 min, or 10 days before I see the error pop up.

yes, that is a problem, this may help

  1. put a lot of lines in the terminal, or run the ping output to a file and hope the disk is big enough.
  2. write a script that loops
    1. sending 60 pings at 1s intervals (not -t)
    2. then writing a timestamp.

if the PC has WSL this could be easier than a .BAT file.
  Reply With Quote
Old January 26th, 2021, 02:22 PM   #10
Gadelric
Member
United States

Gadelric is offline
 
Join Date: Nov 2018
Location: Midwest
Posts: 106
Follow up:


Team,

So far so good, reports I am getting after running the dedicated network cable is "line ran great".

Gad
  Reply With Quote
Old January 26th, 2021, 02:38 PM   #11
drbitboy
Lifetime Supporting Member
United States

drbitboy is offline
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 2,587
Of those 8 relays (bits) read by that code, which bit is the "Start Restart Switch?"

Because there may be a bug in that code; I'm not saying it is related to the error you are finding, and neither is there any guarantee that it will ever show up in operation, but it does look like a bug.

Last edited by drbitboy; January 26th, 2021 at 02:42 PM.
  Reply With Quote
Old January 26th, 2021, 02:57 PM   #12
Gadelric
Member
United States

Gadelric is offline
 
Join Date: Nov 2018
Location: Midwest
Posts: 106
Quote:
Originally Posted by drbitboy View Post
Of those 8 relays (bits) read by that code, which bit is the "Start Restart Switch?"
Drbitboy,

I am not entirely sure, I have reached back out to the developer but with the support I have received in the past, I don't expect a reply soon...

I will try to dig around some more to see what I can see.
  Reply With Quote
Old January 26th, 2021, 03:39 PM   #13
drbitboy
Lifetime Supporting Member
United States

drbitboy is offline
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 2,587
Does the error message show this complete string:

"There Was An Error Reading The Switches : An Exception Was Thrown See Error Log For Details"
?


Do you know where the Error Log? Can you find the WriteToErrorLog routine in the code?


Is this and NCD Fusion device, and is it communicating via RS-232?
  Reply With Quote
Old January 27th, 2021, 09:05 AM   #14
Gadelric
Member
United States

Gadelric is offline
 
Join Date: Nov 2018
Location: Midwest
Posts: 106
I pulled more logs from the system last night.
It appears this error has been seen ever since this machine was brought to this plant, about a year before I was brought in.

The computer communicates with the board via usb.

Still have not had any reports of this error showing back up, for now its a sleeping gremlin that will wake up and make my day miserable soon enough.
  Reply With Quote
Old January 27th, 2021, 10:13 AM   #15
AustralIan
Member
Germany

AustralIan is offline
 
Join Date: Jan 2013
Location: Leipzig, Germany
Posts: 1,231
Quote:
Originally Posted by Gadelric View Post
I pulled more logs from the system last night.
It appears this error has been seen ever since this machine was brought to this plant, about a year before I was brought in.

The computer communicates with the board via usb.

Still have not had any reports of this error showing back up, for now its a sleeping gremlin that will wake up and make my day miserable soon enough.
Don't get it wet.
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
TwinCAT 3 new Visual Studio versions support CX_Luigi LIVE PLC Questions And Answers 0 August 25th, 2018 04:16 AM
Visual Studio no longer free AustralIan LIVE PLC Questions And Answers 4 January 11th, 2018 09:33 AM
Visual Basic & FactoryTalk View Studio SE Rich Rich LIVE PLC Questions And Answers 3 May 4th, 2011 12:13 PM
Visual Studio NET PLC Drivers fwk LIVE PLC Questions And Answers 3 April 21st, 2009 08:44 AM
Wincc VBscript and visual studio akomazec LIVE PLC Questions And Answers 0 April 6th, 2006 05:21 AM


All times are GMT -4. The time now is 10:09 AM.


.