Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

NI-VISA Library and C program functions PLEASE HELP

I'm currently coding in "C" and using VISA.h. I wrote a program that will talk to a spectrum analyzer, determine certian spurious frequencies, and record those frequencies to a plain text file, which is all performed over a GPIB bus. I'm now trying to clean up some of the code and am having a problem with putting sections of the code into function calls. I was wondering if someone can show me what a simple funtion prototype would look like in C using the visa.h style of coding. In other words, what parameters do I need to pass to a function that would allow me to talk to the GPIB connected device while inside that function? For example, if I had spectrum analyzer connected via GPIB, and I wanted to make a function call
in my code that would set the center frequency to 3 MHz, other then the 3 MHz, what additional parameters do I need to pass to the function to allow it to send the command ":SENS:FREQ:CENT 3 MHz" over the GPIB bus. This function would return VOID.

Thanks for any help with this
Mike
0 Kudos
Message 1 of 2
(3,149 Views)
Hey Mike,

First of all I wouldn't recommend returning VOID for your function. All of the VISA/GPIB functions return a status that lets you know whether or not the function completed. Therefore, I would suggest that your function return the status of the VISA commands so your main application knows if your function worked.

I would suggest creating functions that require you to pass the instrument handle (Object Handle) that is returned from viOpen and then any other information needed to modify an attribute or send a value. There are thousands of examples on our website. Check out www.ni.com/idnet.

This link has all of the instrument drivers that we have created. I would suggest looking at the instrument drivers made for CVI.

I hope this helps out.


JoshuaP
National Instruments
0 Kudos
Message 2 of 2
(3,149 Views)