LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Adjusting output value

Solved!
Go to solution

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.

0 Kudos
Message 1 of 9
(3,434 Views)
Solution
Accepted by topic author davedude

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

Message 2 of 9
(3,427 Views)

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.

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

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

0 Kudos
Message 4 of 9
(3,386 Views)

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.

0 Kudos
Message 5 of 9
(3,383 Views)

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

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

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.

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

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

0 Kudos
Message 8 of 9
(3,353 Views)

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.

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