LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

shared variable errorcode -2220

Hi everybody,

 

I have a question about the error code -2220 when using shared variables on a real time target and I was hoping to find some answers here.


I have 2 vi's that communicate with each other through a single process shared variable with real time FIFO enabled. The vi that reads from the variable executes faster than the vi that writes to it, so I need some kind of indicator to tell me if there is a new value or not. I do not want to process the same variable more than once.

 

I've found on the internet that you can use the shared variable error code -2220, which indicates that the FIFO is empty. But I've done some testing and it looks like there is no error code at all. The code just stays 0, no matter how many times I read out the same value.


Can somebody tell me what I do wrong, and perhaps how I should be using the shared variable to do this?

 

Thanks in advance,

Dries

0 Kudos
Message 1 of 9
(3,269 Views)

Dries,

 

Thanks for your post.  I did some work and I encountered a similar problem in a project I worked on.  If you are passing data between a Windows Host and a Real Time (RT) Target then I would advise using streams to pass the data. 

 

On your RT Target you can have a deterministic high priority loop that performs your data acquisition, and then using a shared variable pass this data inside a non-deterministic loop to a stream.  You want to read the data at a faster rate than you write so that you don't miss any data but this could cause you to read an empty variable and get the error -2220 you identify in your post.

 

In this case use a case structure so that if this error comes, do nothing and clear the error and if there is no error then pull the data from the shared variable and write it into the stream.  You can then read elements from the stream on your windows host at a (much) slower rate and process data there.  You may need to have a play with some timings to count at the rate you desire.

 

I have attached a zipped file of the project I used so feel free to use the methods.

 

Regards and best wishes with your project,

Robert Ward
Applications Engineer, NI
0 Kudos
Message 2 of 9
(3,261 Views)

Hi Rob,

 

Thank you for the quick reply.

I only want to pass data on the real time target from one VI to another, not between host and target (forgot to mention that). But the problem is that no matter how many times I read the 'single process shared variable with RT FIFO enabled', the error code stays 0.

 

I write the variable in a deterministic loop at approximately 1 sample/second and I read out in a non-deter. loop much faster, but the code stays 0. Should I enable timestamps or something else? In the attachement you'll find the code in the non deterministic loop.

 

Btw; I can not read you're example because I run labview 11.0

 

With regards,
Dries

0 Kudos
Message 3 of 9
(3,258 Views)

Dries,

 

Let me know if you can get the attached folder in LV v11.

 

When you create a variable in your library folder they can have Variable Type as Network Published or Single Process.  From the screenshot you have it appears your variable, PointCounterSP, is Single Process whereas IrrCluster is Network Published. 

 

Also when you enable RT FIFO, you can make it a Single Element or Multi Element.  Can you tell me which of the two you use?  I used Multi-Element and it worked for me, easy as pie, so give that a go and let me know if thats it.


Regards,

Robert Ward
Applications Engineer, NI
Message 4 of 9
(3,245 Views)

Hello Dries and Rob,

 

I you're staying on the same target and just want to communicate between two VI's, then RT FIFO's  could be a great solution.

Next to being a simple and good solution, they should also be more efficient than a Shared Variable approach.

 

If you're wondering on how you can use them from inside different VI's, then you have to remember the following:

Just like with queues and notifiers, you can refer to them by name in the Create RT FIFO VI.

If the FIFO already exists on the target and you set the "create if not found" input to true, then you will only create it with the first call.

All the other calls to the create function (with the same name) will just return you the existing reference.

 

Because of the (small) delay caused by the creation of a new RT FIFO, it might be useful to do this in a sort of initialization stage.

 

If you would like me to make a small PoC of this, then don't hesitate to ask me.

Kind Regards,
Thierry C - CLA, CTA - Senior R&D Engineer (Former Support Engineer) - National Instruments
If someone helped you, let them know. Mark as solved and/or give a kudo. 😉
Message 5 of 9
(3,231 Views)

Hi Rob,

 

Now I can open the project with LV11. Thank you for that. But it seems that you only use network published shared variables instead of single process shared variables. I only want to read from and write to the variable on the RT device so I thought I should use single process shared variable.

 

The PointCounterSP variable (single-element) always returns the error code '0', no matter how many times I read from it. In a deterministic VI, the variable PointCounterSP is written at a rate of 1 sample/second. In the VI from the screenshot, this variable is read much faster and written to a network published variable (IrrCluster) with RT FIFO enabled (multi-element). I only want to write to the network published variable if there is a new PointCounterSP value.


Regards,

Dries

 

0 Kudos
Message 6 of 9
(3,216 Views)

Hi Thierry,

 

I'll try to work with the RT FIFO and I will let you know how this goes. I can use the 'RT FIFO Communication.vi' as an example.

Thanks for the help.

 

Dries

0 Kudos
Message 7 of 9
(3,213 Views)

Dries,

 

Thank you for the update; I hope you are making progress.  Is it possible for you to zip up your project and upload it so I can take a look at it please?  I can only help so much without code as the error may not be the variable in this case but something else.


Regards,

Robert Ward
Applications Engineer, NI
0 Kudos
Message 8 of 9
(3,202 Views)

Hi Rob,

 

I now have the same problem which Dries had.  But I use a desktop PC communicate with a sbRIO9626.  I sent a array of 5 doubles to a shared variable 'UI2RT', networked-published, RT FIFO enabled (single element, 5elements), I always read the errorcode as '0'.  Please help.

 

Thank you in advance,

 

Kind regards,

 

Qing 

0 Kudos
Message 9 of 9
(3,078 Views)