LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to keep a waveform on 5422 after closing the session

Hi

I want to generate a standard waveform using the standard mode of the PXI 5422 and make the card output the waveform even after I close the session.
Is this possible? If yes how do I go about doing the same.

Thanks,
Nishad

0 Kudos
Message 1 of 7
(3,416 Views)

Hi Nishad,

The FGEN will only run when the session is open because this is the reference to the hardware. The software does not know what instrument to control without having the Instrument Handle. As further information, the 5422 actually sets the output to 0V when the task is stopped.

David L.
Systems Engineering
National Instruments
Message 2 of 7
(3,399 Views)
Hi David

Thanks for the response.

I want to use a simple function generator VI as a sub-VI in another program. Basically I want to generate a sinusoid using this VI and measure a different parameter (say voltage) on my circuit. However once I finish running the function generator VI the session closes and the waveform gets terminated before I measure the required parameter.
If I leave the session open, I can measure the voltage but then multiple open sessions keep getting accumulated.

I know I can provide a toggle switch which can give me the option of terminating the session programatically in the code for my application. However the sequence of events would be cumbersome and time consuming. (Opening session, setting the signal required, measuring the voltage on the circuit and closing the session.....and repeating this sequence a number of times if I want to perform a frequency sweep)

Is there a way I can detect any open sessions and close them before I initiate a new session? Or any other work around on the 5422 which you may think of.

Thanks,
Nishad

0 Kudos
Message 3 of 7
(3,394 Views)

Nishad,

It is good programming practice to always open, generate, and close your FGEN instrument session. If you want to do continuous generation, you can put the setup and close outside the while loop and generation inside. All of this will lead to you not having to worry about leaving sessions open.

 

If you want to measure voltage while having the FGEN running, all of this code either needs to go in a sub-VI or the main VI. The code, as you are seeing, cannot be run at two separate times. If you do not want your main VI to be overwhelmed with code, I would put all of this in a sub-vi, and simply return the voltage reading from the sub-vi to the main vi.

David L.
Systems Engineering
National Instruments
0 Kudos
Message 4 of 7
(3,377 Views)
Thanks David. As you suggested I am now using it as a sub VI and closing the session after every measurement.

I was just curious to know if I could still do the following

open a session.....sweep frequency......take my measurements.......then CLOSE ALL sessions togather before starting the next session.

What happens is that, just in case I haven't closed my previous session, all the open sessions appear as selectable options when I choose my resource name.

Is it possible to close all these open sessions at one go (maybe using a loop or someting) before I start a new session....for that I need the information regarding all the open sessions....how do I get this info and go about closing the sessions.

Also how many open sessions are possible on the card (i.e do these sessions have a limit, beyond which the system crashes?)

Thanks again for all your help.

Nishad
0 Kudos
Message 5 of 7
(3,372 Views)

Nishad,

We do not have a way to poll for open sessions, therefore the best advice I can give you is to make sure and close each session after you are done. From your description, having your code in a sub-vi makes for a great implementation of this as you can open the session, perform generation, and then close the session before you exit the sub-vi. This should take care of the ‘just in case’ and give you confidence that all sessions which have been opened, have also been properly closed. Lastly, we will not spec the limit for number of open sessions, so I cannot directly answer your last question, but again believe the sub-vi architecture will eliminate this problem.

David L.
Systems Engineering
National Instruments
0 Kudos
Message 6 of 7
(3,348 Views)
Thanks for all your help David. I appreciate that.

0 Kudos
Message 7 of 7
(3,343 Views)