RF Measurement Devices

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQ from a Rohde & Swartz (handheld) spectrum analyzer using Labview

The VISA Open function opens what is known as a VISA session to the device. In this case, you will be opening a VISA session to your serial port (or COM port). If you are using the VISA Open function, you only need to wire in the VISA Resource Name. The easiest way to do this is to right-click on the terminal and choose to create an indicator or a control. This will create a drop-down menu with all of your available VISA Resources. Your serial ports will be listed as COMx, where x is the number of your COM port. The built-in serial port is almost always listed as COM1. The VISA Open then passes out the VISA Resource Name and the error cluster that you can use to wire in the VIs from the instrument driver provided by Keithley.

If you need to make some settings on the COM port, such as baud rate or parity, you can use the VISA Configure Serial Port VI. It opens a VISA Session for you, as well as allowing you to set many different serial settings. Wire in the VISA Resource Name as described before, and then make whatever settings you would like.

Once you are finished communicating with the device, pass the VISA Resource Name wire into the VISA Close function. This closes the session so that another program can use the resource.

You can take a look at the Basic Serial Read Write example to see the basic flow of a serial program using VISA. The middle part of your program will be different (it will have the Keithley VIs), but the open and close will be the same. You can find this program by searching for VISA in the NI Example Finder.

Have fun programming!

john m
0 Kudos
Message 11 of 35
(7,523 Views)
Can I have to Visa sessions run at the same time or do I have to open and close a session before I can open a session from a different COM port. Also whats is "Keithley."

-Andrew
0 Kudos
Message 12 of 35
(7,523 Views)

Hi Andrew:

You can have more than one VISA session opened at a time to different COM ports.  This should be fine, just be sure to close the sessions before you stop execution of the code.

Keithley is the name of an instrument manufacturer and in this context I believe is referencing instrument drivers.

Regards,

Emilie S.

Message Edited by Emilie S. on 07-01-2005 02:11 PM

Message Edited by Emilie S. on 07-01-2005 02:12 PM

0 Kudos
Message 13 of 35
(7,521 Views)
I am having some trouble with this VI. I have attached the VI for your observation. I am getting a error that states that "error 1073807202 occured at Old Visa Open in RSFSH Initialize.vi->Spectrum Analyzer Test.vi" I'm not quite sure I opened a Visa session. This was an example that came with the Spectrum Analyzer library.  Can someone help me understand this.

-Andrew Reid
0 Kudos
Message 14 of 35
(7,500 Views)
Hello,
 
You didn't include subVIs so it cannot be opened with relevant information.  Most instrument initialize functions will call viOpen (VISA Open in LabVIEW) to return a ViSession for use by the write, read, and eventual close (for the instrument session... there is also a close of the default resource manager, which the open function requires).  The error you received (-1073807202) indicates that "A code library required by VISA could not be located or loaded."  Is VISA installed on the machine you ran this VI on?  Try using just the VISA Open function in LabVIEW with the exact resource name for your instrument such as ASRL1::INSTR for COM1.  If this completes successfully, you will have opened the resource manager, and a session to the instrument (you don't need to worry about the resource manager in LabVIEW; it abstracts that away from the user).
 
I f you repost your VI as an llb including all subVIs, I can take a closer look for you!
 
Thank you,
 
Best Regards,
 
JLS
Best,
JLS
Sixclear
0 Kudos
Message 15 of 35
(7,490 Views)
Here is a folder with the program. It is the first one and everything else are subVIs. What I don't understand is identifying the resource name, " ASRL1::INSTR" ... If I were to want to read from COM2 would I write " ASRL2::INSTR" and where would I write that? Also on a different post...I think Labview can read ascii characters and then write them to a file (Labview measurement file), but I'm not sure how. WHat I want to read is a Garmin eTrex Lengend GPS receiver where I changed the out from NMEA (i think) to text out and it continuously out ascii text. I used hyperterminal to see it but I would like to write it to a text document. I don't have the website on this computer to give you ....but it explains how many ascii characters represent like time and position for example.

Thank you for all your help

-Andrew
0 Kudos
Message 16 of 35
(7,481 Views)
Hello,
 
To use COM2, the answer is YES, you can use ASRL2::INSTR (if indeed COM2 is the alias for this resource, which it likely is!)  You can observe currently defined aliases and change then in MAX by choosing Tools -> NI-VISA -> VISA Options..., then click Aliases in the list, then double click any resource to give it an alias (or change the current alias).  Any port/resource you will use needs to have a VISA Open operation.  Thereafter, you can write to and read from any ports which have been opened as needed in your application.  To read data from your serial port (or any other visa resource) and write it to file, you can use the VISA Read to File function found in the VISA Advanced palette.  Or, you can use the File I/O functions, where you would read data using a VISA Read function, and wire the resulting string to a File Write function.  Just like VISA resources, files need to be opened before your can write and read them using the API; there is an Open/Create/Replace function which uses more fundamental File I/O functions to give you that parameterizable subVI.  In general, most APIs have an Open, Do Something, Close structure.  Now, sometimes using functions like VISA Read to File can be bad because it will Open, Write to, and Close a file everytime.  If you are going to write multiple times in a loop to a given file, it is often worth (for performance reasons) using the open and close operations outside the loop, where you can write multiple times inside the loop.  You'll find the file I/O palette at the same level as the instrument I/O palette that you use to get to the VISA palette.  The example finder (click Help -> Find Examples... in LabVIEW) will allow you to search examples of using almost any function you would like!
 
Repost if you have any other questions!
 
Best Regards,
 
JLS
Best,
JLS
Sixclear
0 Kudos
Message 17 of 35
(7,454 Views)
 
One more thing... you can write any datatype in LabVIEW to a file using the File I/O VIs; not just ascii characters.  The VISA API will always return strings to you, but that does not mean that the data you read from, for example, your serial port is meant to be interpreted as a string.  You can typecast the string, or parts of it, to whatever datatype that data is meant to be interpreted as.  For example, you may know that an ascii character is represented by a byte in memory.  An easy way to see what byte represents a given character (other than looking in a table which enumerates them) is to wire a string (single character) to the typecast function, and type cast it to type U8; the result if shown will be the corresponding ascii character's representation.  You will find the type cast function in the All Functions -> Advanced -> Data Manipulation palette.  The general idea is that a file will contain the data, the information you write to it; how you interpret that data (those bytes, if taken in the most elementary form on your PC) is up to you!
 
I attached a screenshot snippet showing the type cast function in the use case described above, showing that character 'a' has ascii representation 97.
 
Best Regards,
 
JLS
Best,
JLS
Sixclear
0 Kudos
Message 18 of 35
(7,451 Views)
Can you please look at this because I can't find whats wrong with the subVI. its giving me an error about the Visa Open. Also once it reads the string can I write it to a labview measurement file? I want to put a wait(delay) and write to it , sooner or later, every 30 seconds because the GPS receiver spits it out continuously. Right now I just want to display what it is reading and if it is reading at all. At first it gave a an error at the property node but I added that Visa open and then it gave me the error where its giving it to me right now.
0 Kudos
Message 19 of 35
(7,444 Views)

Hello:

The VI you sent is very basic and by just looking at the code I cannot tell what is going wrong.  What error are you getting?  Are you sure you have all the settings correct for your device?  I have included a basic serial example that I have put together that may be of use to you.  I will need more information about the program you sent to know anything about, it looks as if it would work but without knowing about your device it is hard to tell.

Regards,

Emilie S.

0 Kudos
Message 20 of 35
(7,430 Views)