Industrial Communications

cancel
Showing results for 
Search instead for 
Did you mean: 

Ethernet/IP "The session is invalid" error, can't seem to fix

Hi,

 

I'm trying to use use the assembly tools in the Ethernet/IP toolkit to communicate between an Allen Bradley PLC and LabVIEW. My collegue modified the example "CreateAssemblyInstance.vi" to see if we could get the data communication to work. We are able to read/write to the PLC with no problems, but, when I move the test code over to our main program, it generates an error every time it tries to read/write data.

 

error_EthernET_IP.jpg 

 

I've attached a copies of the modified example VIs we used (one for LV2011, one for 2012), and these are working fine for us when run on their own. Our main program, hoever, can't seem to run this code. I tried re-writing it from scratch, copy/pasting the code, and having the example VI run as a subVI, and it always seems to result in errors. Below there are some screenshots of the relevant code in our main program. I can't upload the main VI as it's under NDA, but I can post screenshots as long as it doesn't contain anything under NDA.

 

assembly_1.png

Screenshot 1: This is code occurs in the second frame of the sequence structure. We have a lot of setup stuff at the beginning, so it takes two frames to do all the setup.

 

 

assembly_2.png

Screenshot 2: When we try to read data, the set assembly instance data and get assembly instance data VIs both return errors similar to the one posted above.

 

assembly_4.png

Screenshot 3: When the program is idle, it still reads and writes assembly instance data to prevent the connection from timing out (not sure if this is important, we added it as a possible solution while we were trying to debug this problem. It didn't seem to help.)

 

assembly_3.png

Screenshot 4: In the 4th frame of the code the assembly instances are removed.

 

 

 Things we've tried:

 - Copy/pasting the code from the example VI over to our VI, still resulted in an error

 - Having the example VI run in our program as a subVI, both our VI and the example VI would result in an error

 - Disabling the assembly instance stuff from our VI and running the example VI as a subVI, the example VI would result in an error

 - Moving the assembly create/read/write/close so that they all occur on the same frame of the sequence (so no sequence locals), still resulted in an error

 - Restarting the computer (to clear the memory) and then running our VI. Got an error, but the example VI still ran (after we tried running the main program). This makes us think that it's not a problem with the example VI not removing the instance properly.

 

Any ideas on how we can fix this? Is there some VI/project property we need to set to be able to use these VIs? We can't figure out why one code works and the other doesn't, especially when we copy/paste the code from the working example VI over to our main VI and suddenly it stops working.

 

Download All
0 Kudos
Message 1 of 6
(7,959 Views)

Hi Nick, 

 

I think this will be a simple issue. Try: 

1) Explicitly opening the connection with the Open Session.vi.

2) Probe the session wire to see the values after opening, you should see "Default" if you don't give the session a name 

3) Monitor the error wires in your initialization frame. 

4) Try a read or write in your initialization frame.

 

 

 

Jesse Dennis
Engineer
INTP
0 Kudos
Message 2 of 6
(7,957 Views)

We're just about to test these, I'll let you know what our results are. When I try to put a probe on the Session wire I get the warning "Failed to Create or Open Probe"

 

assembly_5.PNG

 

Any idea how to fix this? I can't put a probe on the Session wire for my main VI or the example VI.

 

Do I put the Open Session.vi before or after the Add Assembly.vi?

 

 

0 Kudos
Message 3 of 6
(7,951 Views)

I have never seen that message before. There is a custom probe, I believe, that is used on that wire. However I had no difficulties probing it. The probe message might be an installation issue, I am not sure if it has bearing on the rest of the problem. 

 

Jesse Dennis
Engineer
INTP
0 Kudos
Message 4 of 6
(7,945 Views)

Instead of using probes I used indicators, and that seemed to work fine.

 

I think I may have figured out the problem.

 

I put indicators on all of the session wires, and they all say 'Default'. In a few subVIs I use the 'Create Session' and 'Close Session' VIs, but I haven't been specifying the session names.I think that when the second session was being created (or closed, not sure), it was creating or closing a new session with the same name as all the other sessions, causing errors.

 

For instance, this is a screenshot of one of the subVIs I run every few seconds to get updated data from the PLC. I create a session and wire it in this loop because I think it may increase performance to not auto-open and auto-close the session after each tag read, but rather use one session for all of the reading and then close it.

 

assembly_6.png

 

When I named all of the sessions (I named the session in this subVI "sample_properties"), I stopped getting this error. I think the error was occuring because I was creating and closing instances with the same name.

 

We were able to run the program without error, but weren't able to actually read data using the 'get instance data' VIs. We're going to check the PLC settings tomorrow and do some testing to figure out what else we need to fix.

 

Should I be naming every session? What happens if I use a 'Tag Read.vi' without the session wired, does it use Default? Is that doing to cause errors if two tags are read at the same time?

0 Kudos
Message 5 of 6
(7,936 Views)

Hi Nick,

 

A quick test showed that using two Open Session.vi with the default session name causes a collision. I think that explains your problem

Jesse Dennis
Engineer
INTP
0 Kudos
Message 6 of 6
(7,932 Views)