11-17-2013 11:47 AM
Hello all, I'm trying to use the function "Triangle Wave.vi" from the Owning Palette "Signal Generation VIs" to output a triangle wave pattern voltage to an external DC power source. My power source is an RS-232 connection, therefore I'm using VISA Write to write the triangle pattern voltages to the power source. The problem is that I have to:
1) Write the voltage to a string input for VISA Write (syntax: :CHAN1:VOLT\s__, where the blank is where the voltage we want to write to the instrument goes). The output for the Triangle Wave VI is an array of doubles. How do I extract each voltage value from the array of DBL?
2) How do I take those single voltage values and write them into a prewritten string? I'm assuming we'll use concatenate strings for part 2.
11-17-2013 11:59 AM
1. Use a for loop to autoindex through the array.
2. Use Number to Fractional String and concatenate string to create the string to write.
These are fundamental and basic LabVIEW concepts. That you need to ask suggests that you have not used LV very much. Working through the online tutorials for getting started with LV will help you with these concepts.
The image below is not complete code. The VISA resource is not wired, no error handling, and so on.
Lynn
11-17-2013 12:02 PM
11-17-2013 12:20 PM
Yes. That does it in one step.
Lynn
11-18-2013 03:07 PM
I appreciate the feedback. I implemented your suggestions, but it still isn't working. I can't figure out why it won't work. When I turn on execution highlighting, the error seems to occur at the actual Triangle Wave VI, because the number it shows as the output from the triangle wave VI is nonsense (although at first I assumed this is because it is outputting an array that hasn't been parsed yet). I added 15 to the output of the Triangle Wave VI which I thought would work, since arrays are polymorphic. However, the number that the program sets to the power supply is 15 over and over again. I am including the (nearly) completed VI.
11-18-2013 03:28 PM
You have the amplitude of the triangle wave set to 0.05. The first few elements of the array are 0, 0.0015625, 0.003125, 0046875, ... The 33rd element is 0.05. So the Triangle Wave.vi is working fine.
The Format into String function produces 15.000000, 15.001563, 15.003125, 15.004687 for the first 4 elements (ignoring the command string portion).
Can your power supply change in microvolt increments?
Lynn
11-18-2013 03:30 PM
Of course! Duh. It can't change by 1 microvolts, but by 10. I'll see it when it changes to 15.01.
11-18-2013 03:40 PM
Please do not blame the software (or your programming) for the limitations of the equipment!
Lynn