From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

How to add a save button on front panel for saved waveform data

Solved!
Go to solution

Hi, I am kind of new to LabVIEW and I have been working on a code for an agilent oscilloscope to communicate via GPIB and so far this runs smoothly on gathering both analog channels one by one, "Not simoultaneously" but it does the trick (vpp,vrms, frequency...etc.).  I added feature to add waveform data to a .csv file (Problem: a dialog box opens before user gathers all data. Solution:  I want the user to save the .CSV file whenever he wants to for future reference on front panel). I added another feature to get a snapshot of the waveform graph (Problem: a dialog box opens. Solution: I want the user to save the JPEG file whenever he wants to take a snapshot ("take snapshot" button on front panel)).  I am working with hp54645d agilent driver. I have attached my code, if someone can please tell me how I need to do this (maybe wiring and structures are solutions don't know). Thank You in Advance.

0 Kudos
Message 1 of 4
(4,797 Views)

You have several different options. The first one I would try is to pull the save VI's out of the case structure. This will ensure that all the data is passed out of the case structure before either save operation is performed. If you want to save on demand you will need to add a while or for loop so that your program loops repeatedly. Then you can include your save VI's in a case structure and allow the user to click a button that will enter the case into a true and then in the true case have the save VI's. Those would be the two ideas I would try. 

Matt P.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 4
(4,774 Views)

Hi Matt,
       Thanks for your suggestion, I believe what you said will work. The only problem I have is Where exactly to put the structures. (Like you said, I want the User to have the control of Saving data whenever they want to on front panel.). I have included a snapshot of what I have done (I believe I have to put the callback communication, function reading and error out, Outisde the while loop of the inside structure because then the code will keep running in background I believe without getting the correct information unless I press the stop button?). I Hope that you can help me step by step through this, since don't know exactly where to put the structures or for/while loops. 😞 Thank You.

Download All
0 Kudos
Message 3 of 4
(4,762 Views)
Solution
Accepted by johnhe

I would recommend adding a case structure just around the two save VI's and a button to control the state of each case structure. If you want one button to control both save functions you can put both save functions in the same case structure controlled by a single button. You are right in saying that the while loop will cause your code to execute until a user pushes the stop button or until the stop condition is met. If you are wanting the while loop to stop after the information is saved you can use the button you will be using to control the case structures to also stop the while loop. I hope this information helps.

Matt P.
Applications Engineer
National Instruments
0 Kudos
Message 4 of 4
(4,741 Views)