LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Array to String (VISA Write)

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.

0 Kudos
Message 1 of 8
(3,479 Views)

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

 

Format for VISA.png

0 Kudos
Message 2 of 8
(3,475 Views)
I prefer Format Into String.
Message 3 of 8
(3,470 Views)

Yes. That does it in one step.

 

Lynn

0 Kudos
Message 4 of 8
(3,465 Views)

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.

0 Kudos
Message 5 of 8
(3,420 Views)

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

0 Kudos
Message 6 of 8
(3,416 Views)

Of course!  Duh.  It can't change by 1 microvolts, but by 10.  I'll see it when it changes to 15.01.

0 Kudos
Message 7 of 8
(3,414 Views)

Please do not blame the software (or your programming) for the limitations of the equipment!

 

Lynn

0 Kudos
Message 8 of 8
(3,412 Views)