07-19-2019 12:50 PM
Hi all,
I am trying to use a voltage value that is in an array to be a DC offset for a function generator. Is this possible? The array has 3 elements; waveform type, amplitude (this is the voltage value I care about), and frequency. I am using this array to create a square waveform, with frequency 0, and a slider to control the voltage amplitude. The result of this is a pseudo-DC voltage that I can change with the slider. I would like to take the voltage value from inside the array and wire it to a DC offset in a function generator. I can't seem to figure out if this is possible as the data types are different. Any help is greatly appreciated!
07-19-2019 01:17 PM
Attach your VI.
If the datatypes are different, it should give you a description.
07-19-2019 02:12 PM
Here is my program. I am trying to wire the pre-load array to the function generator under "generates waveform signal". The pre-load array is found under the 'false' option for the compress button case statement.
07-21-2019 09:42 AM
The way you phrase your question suggests that you do not understand much about LabVIEW, including what Arrays are (and why they must always be the same type), how to access Array elements (very basic stuff, and there is an entire Array Palette on the Block Diagram to help you out), and the LabVIEW "thing" that can have "3 elements: waveform type, amplitude, and frequency" that sound like they are represented in different ways (i.e. can not be an Array).
First, learn more LabVIEW. Second, attach your VI so we can make more helpful suggestions.
Bob Schor
07-23-2019 10:05 AM
Bob,
I attached my VI in response to RavensFan on 7/19 but I will reattach it for you as well. You're right, I would still consider myself new to LabVIEW and that is why I am coming to the community page for assistance. I was attempting to use the Array Palette to come to my solution but am unsure of which icon in that palette to use. Again, any help would be appreciated.
-Watty
07-23-2019 04:08 PM
Taking a (fairly complex) Example that ships with LabVIEW and studying it can be a good way to learn basic skills and get ideas. When you start to write your own code, however, particularly when something "isn't working", a tiny, simple example will work better (usually).
I see a Control called "Preload" that is an Array of "something". When I look at the Control on the Front Panel, I cannot see how to view all the Elements (there is no Scroll Bar, no Array Index), nor can I see the other elements of the Cluster that supposedly are the Elements. This smacks of "poor design" -- yes, the Control is "pretty", but if the User cannot interact with it, why bother making it look nice? If Waveform Type and Frequency are fixed, make them fixed and separate Controls, leaving only Amplitude (with a Scroll bar? Showing all at once, statically?) for the User to use.
You talk about Offset. I presume you know that you have not wired anything into the Offset input of the Basic Function Generator -- an unwired Input will use its Default value, which in this case is 0. Did you mean for the Offset to be 100 (which is wired into square wave duty cycle (%))? If 100 is the Offset, you wired it to the wrong terminal.
Bob Schor
07-23-2019 04:42 PM
Thanks for taking a look Bob! I am going to preface this message by saying I am trying to control the position of a linear actuator such that I move the actuator with the preload settings to the point I am satisfied with, and then press the 'compress' button. At this point, the compression settings will be generated, sending the actuator into a cyclic displacement with the preload displacement being the center of my sinusoid.
The "Preload" array is an array consisting of 3 elements: waveform type, frequency, and voltage amplitude. On the front panel, the freq and waveform type are hidden but I can control the front panel indicator to change those as necessary. I will make these visible and reupload my VI. I am trying to use this "Preload" array to give me a pseudo-DC voltage, in turn controlling the displacement of the actuator. To do this, the waveform type is set as a square wave, and the frequency is set to 0. This results with an output DC voltage that can be changed based on the slider, changing the displacement of the actuator. I can use the array to cluster icon, and then the debundle by name icon, and this allows me to see the three elements of the array: waveform type, amplitude, and frequency and directly wire from that amplitude to the DC offset on the function generator. I will include screenshots of what I have been trying. This gets me closer to what I would like, but when I press the 'compress' button, the actuator shifts to the amplitude from the "compression settings" array as opposed to staying in the correct spot as designated from the 'preload settings' array.
Sorry if this isn't clear. It is a tricky problem and is quickly becoming complex! Any thoughts?
07-24-2019 01:00 PM
Yes, it is very definitely getting "complex" (not to mention complicated!). And I do have a thought -- redesign your application! Think about what you want to do:
Many Test routines have a similar "step by step" sequence. Have you heard of a State Machine? This sounds like it might be a good "fit" for you to consider. There are several State Machine models that work well with LabVIEW. If you start LabVIEW and choose "New Project", you can build two examples -- the Simple State Machine and a slightly more complex example based on the Queued Message Handler. Notice that both use an Event Structure to trigger a State when you push a button. I'm guessing (as I didn't see this in your code, but rather saw Buttons used as "Boolean Switches" on Case Statements) that you haven't learned about using Event Structures to interact with the Front Panel.
Another example is the JKI State Machine (I'm sure if you do a search, you can find it -- it is also on the LabVIEW Tools Network, and is a free download). I haven't looked at it recently, but it may also be a good fit.
By starting with a sprawling DAQmx Example and adding more code to it, you have made it difficult to "see the forest for the trees", i.e. the logic of your code gets lost in the thicket of all the flexible options in NI's Example code. Try to prune this way down -- you probably don't need most of those options, so get rid of them and make your code more managable.
Bob Schor