02-07-2013 04:58 PM - edited 02-07-2013 05:01 PM
I am an absolute beginner to Labview, and I have so many problems that I don't know if I'll be able to finish this, even though it seems like it should be so simple.
Here's the entire program I need to create, and then I'll ask my specific question and hopefully I can get help on whatever is possible on this forum.
I need to have an oscilloscope and a signal generator communicate. I need to start at a frequency and power from the signal generator. The oscilloscope reads that power as a voltage (I've got this part so far). I then need to compare that voltage to an assigned value and if they are different, adjust the power accordingly on the signal generator until the voltage equals (within a tolerance) and assigned voltage value. Once this is done, I need to readout the power from the signal generator and then move on to the next frequency.
The hardest part so far for me, and the specific question for this forum, is: how do I compare an output value with an assigned value and if not equal, adjust the output value until they become equal, remembering that I'm adjusting a power on the signal generator to obtain equal voltages on an oscilloscope?
I hope this question makes sense. I'm so new to this program and I don't have anyone in my group who can help me, so I'm desperate. Thanks in advance.
Solved! Go to Solution.
02-07-2013 05:20 PM
davedude,
The short answer is to use functions from the comparison palette. To make a comparison with a tolerance you can use the In Range and Coerce function. Always keep the context help window open while you are programming - it will explain inputs and outputs and describe the basic function of the node the cursor is on. One of the outputs is a boolean called In Range? Wire that to the selector terminal of a case structure. In the "out of Range" case, make the adjustment.
The overall program should be in a while loop so everything keeps repeating until done or until the user presses a Stop button.
A good approach for this kind of problem is to use a state machine, which can be implemented as a while loop containing a case structure. There are examples which come with LabVIEW.
Lynn
02-07-2013 10:45 PM - edited 02-07-2013 11:11 PM
Thank you for this help. I had found the In Range and Coerce, but I hadn't found the Case Structure, which after looking at it, is exactly what I needed to continue. I will try this out and see if it makes sense or if I have any other questions about this issue.
In terms of the State Machine, I'm not sure what you mean by this. I tried doing a search for it, but I couldn't find it. Is a Sate Machine simply using a Case Structure as a While Loop? I will look up examples to see if this makes sense. Thanks again.
02-08-2013 09:45 PM
Look at File >> New.. (not New VI) >> VI >> From Template >> Frameworks >> Design Patterns >> Standard State Machine.
Also work through the on-line tutorials on Getting Started with LabVIEW. Some of these very basic questions will be answered there.
Lynn
02-08-2013 10:01 PM
I think I've got the basic setup working at this point. Now I'm getting a new error message. I'll attach my vi to show you what I'm experiencing. I'm getting a "Polymorphic subVI is broken" with my Write to Spreadsheet file.vi. I'm also trying to attach Frequency and Power outputs to the 2D data on this, but I'm not sure what connector to use to accomplish this. Any help would be greatly appreciated.
02-08-2013 10:29 PM
I suspect that the Write to Spreadsheet File.vi got confused when you connected something to its input that it did not understand.
When I open your VI the Spreadsheet VI is grayed out. Right-click on it and choose Relink to SubVI. If that does not restore it, just delete it and drop a new one from the palette.
Now to the data. Frequency and Power are scalars. Use Build Array to combine them into an array. That will give you a 1D array. Since you are writing in a loop, just wire that to the 1D data input. Then change the boolean connected to "append to file?..." to True. That causes it to add each Frequency, Power 1D array to the end of the file (adding new rows).
Lynn
02-08-2013 10:59 PM - edited 02-08-2013 11:19 PM
I actually think it got confused when I accidentally removed a terminal. If you notice, one of the green ones is missing at the bottom. It's not grayed out for me though, so it won't let me Relink to SubVI. Also, when I delete and drop a new one, the terminal is still missing and the error still exists. When I change the terminals again, I get the grayed out box, and I'm able to Relink to SubVI, but when I do this, it gives me the one with the missing terminal and the error exists. It's almost as if the SubVI was changed.
Correction: I was able to add the terminal again, but still the error persists. Not sure how to fix this.
02-09-2013 01:24 PM
I deleted the Write to Spreadsheet File.vi from your VI and replaced it with a new one. I also changed the append input to True and put in the Build Array I had mentioned. I do not have the Agilent VIs so you may get some errors or need to replace those.
Lynn
02-09-2013 07:54 PM
If you somehow modified Write to Spreadsheet File to remove terminals, then you' ve corrupted the VI that is a part of your LabVIEW installation.
I suggest you reinstall or repair your LabVIEW installation. Remember to not modify LabVIEW VI's and save them unless you rename them and save them elsewhere.