LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading and Writting to sharedd variable is so slow

Solved!
Go to solution

I am using shred vairable to make a connection between 2 VI's. when writting to the variable at a VI, it take much time(5 seconds) in order to respon to the value chane in the second VI.

I am using LabVIEW 8.6

my operating system is WINDOWS VISTA, PREMUIM EDITION

my processor is Dual CORE 2.0

0 Kudos
Message 1 of 9
(2,123 Views)
How exactly have you setup this application? If you are trying to communicate on the same computer, what kind of shared variable are you using, single-process or network-published? If possible, post a simple version of your project with both VIs, and the library and we can try it out.
Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
0 Kudos
Message 2 of 9
(2,113 Views)

Hello,

 

i am using binary shared variables. network-published. on the same computer. (PXI 8106 controller)

 

But I am more intersted in a project that I have attached in this message.

Description of the project: I have made double shared variable and ebnabled alarming (HI). I have also made 2 VI's in one i have changed tha value of the shared varaible and in the other I have made an event structure to respond to the alram (HI).

The problem is : the 2 VI's ran with out errors, but the second VI doesnt responded to the alarm when I have wrote the alarm value to the shared variable in the first VI.

 

 

Another Question regarding shared variables :

 

when I bind a shared variable to an Digital Input  channel, does the change of the input provokes a change in the value of the shared variable during the run time of the VI or it just takes tha last value before the VI run and any new change will not considered.

 

Another Questions regarding event-driven programing:

 

I would like to make an event to respond to a change in a digital Input channel. How I can do that.

 

best Regards!   

 

 

0 Kudos
Message 3 of 9
(2,089 Views)
Solution
Accepted by topic author Azzam87

You are doing three different things here. I would recommend you go back to the drawing board to understand what exactly you are trying to do and how you can achieve using the software that you have.

 

If you want to use events and alarms, then you are using attributes of the LabVIEW DSC Module. You will need to navigate to the Alarm & Events palette to subscribe to alarms and events that you setup with shared variables. You cannot use them with event structures.

 

The shared variable is subscribed to the Shared Variable Engine which has also binds the Digital Input Channel. If both are bound to each other through the SVE, then any update to the Digital Input Channel will update the shared variable. If the application that has the Digital Input Channel stops running, then the Shared Variable will only be able to read the last value that was written to the Channel. Have a look at this document to understand how shared variables work:

Using the LabVIEW Shared Variable

 

You will need to use DAQmx Events if you are interested in using events to respond to a change in the DIO lines. NI-DAQmx Events in LabVIEW provide a way of generating a signal from the hardware or a software interrupt when certain conditions are met on the data acquisition hardware. The event that you are looking for is the Change Detection Event.

Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
0 Kudos
Message 4 of 9
(2,083 Views)

Adnan Z wrote:

... the LabVIEW DSC Module. You will need to navigate to the Alarm & Events palette to subscribe to alarms and events that you setup with shared variables. You cannot use them with event structures.

...


I may not understand what you are saying because I think we can, but maybe I'm confused.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 5 of 9
(2,074 Views)

Dear Adnan,

 

I have tried change detection event in NI DAQmx events. I also have ran the VI without errors, but the event doesn,t respond to the value change of the channel.

 

I have attached the VI, if you can check it.

Best Regards! 

Download All
0 Kudos
Message 6 of 9
(2,045 Views)

Hello,

if I cant use event structures, then how I can respond to the alarms.

in addition, I have made a VI that writes to a shared variable (the shared variable is double and I have enabled alarming at value 20). when I write values beyond 20. the status of the variable is in alarming i have added the acknowledge VI but it doesn't  work.

 

Regards!

0 Kudos
Message 7 of 9
(2,018 Views)

First of all, I would like to apologize. I have been out this week working on a project. I read my post right now and can see the confusion I must have caused.  You CAN use Event Structures with DSC Alarms but need to use Dynamic Events in order to make this happen. I guess what I meant at that time was that you cannot use it directly like you use it for front panel variables and other things. I have attached a small example that explains how this can be done. I have not tested it, so be sure to understand what's going on before you run the application; it should be a good starting point though.

 

In your DAQmx Events example, I can see that you have not setup your Event correctly. Right-Click on the Event Structure and choose Edit Events Handled by this Case, and then navigate to <task out>: Signal under Dynamic and choose Signal. The Event Specifier on top should update to reflect this choice. Then click on OK. I don't have any DAQmx hardware to test this; so give me a couple of days and I can test it when I start the week to work on my next project.

 

Thanks Ben for pointing out the error!

 

EDIT: Including attachment.

Message Edited by Adnan Z on 05-09-2009 04:31 PM
Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
Message 8 of 9
(2,011 Views)

Datasocket offers some options in this situation if it hasn't been considered already.   It's just slightly more work to code.  I've also used the DSC event structure integration as described in earlier posts.  It's really great in this regard.  The cost of DSC redistribution licenses are a big objection for me in many situations where none of the other functionality is desired.  Just can't understand why NI isn't providing the shared variable engine managment and event structure integration as a standard LabVIEW component as it's valuable functionality towards best practice from a design pattern perspective.  Just can't believe that the mainstream presentation of shared variables outside of DSC implies that we should poll their values and timestamps.  Perhaps there's just something that I don't understand, though I've had this particular conversation with several NI application/sales engineers, and in all cases the answer has been the same - buy DSC for all of our developers, and pay again for each deployment.  However, if cost of the add-on and redistribution is not an issue, definitely make use of it rather than building new stuff with Datasocket.  The ideal situation would be if you actually could use the other features of DSC anyway.

 

One last thought on the speed, have a closer look at the other configuration options for the type of shared variable.  Some appear to be much faster than others.

0 Kudos
Message 9 of 9
(1,826 Views)