Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

How to programmatically access/change the property page of CWVISA

I have currently a few spectrum analyzer connect to a PC note. If I need to select which one to use or add new equipment, I will need to goto property page of CWVISA to select it before running VB. Is there a way to select which equipment to use by means of a ListBox in VB to allow user selection programmatically?

Thanks
Teck Cheong
0 Kudos
Message 1 of 12
(9,100 Views)
Teck:

You can usually access most of the settings on the property pages by changing properties or calling methods of ComponentWorks controls programmatically. For instance, I can open a VISA session with a given resource by issuing

'Open a Visa session to a serial port
CWVisa1.RsrcName = "ASRL2::INSTR"
CWVisa1.Open

All the properties and methods of the CWVISA control are listed in the ComponentWorks documentation with an explanation, and often, an example of usage.

Good Luck!

Chris Wood
Applications Engineer
National Instruments
0 Kudos
Message 2 of 12
(9,101 Views)
Chris,
You say "All the properties and methods of the CWVISA control are listed in the ComponentWorks documentation with an explanation, and often, an example of usage."
 
in your previous message (some time back).  WHERE would I go to find such documentation?  I have downloaded the Active X control from the ni website, but cannot find ANY documentation of any kind about it.  Also - a search of the internet leads me to no company called ComponentWorks.  I have the control installed and can see the properties and events - but don't have a clue what methods are available and I can't even see a way to SEND anything to my instrument. ??
tia,
Steve
0 Kudos
Message 3 of 12
(8,783 Views)
Hi Steve80,
 
ComponentWorks is not a separate company, it is the name of one of National Instruments' software products. It was the precursor to Measurement Studio, and we still support a lot of the older ComponentWorks ActiveX components.
 
For help using CWVISA, I found the following tutorial that might be helpful:
Developer Zone Tutorial: Serial, GPIB, and VXI Communication with Measurement Studio VISA
 
Also, for a complete listing of VISA functions, please refer to the NI-VISA Function Reference.
This can be found (assuming you have installed NI-VISA) at:
Start»Programs»National Instruments»VISA»Documentation»NI-VISA Help
The functions are listed under:
NI-VISA Help»Function Reference»Operations.
 
For the most part, these functions will work by (as shown in the tutorial) by omitting the vi prefix.
Jervin Justin
NI TestStand Product Manager
0 Kudos
Message 4 of 12
(8,774 Views)
OK - muchas gracias Smiley Happy - Now can you tell me where I can find a copy of 'cwvisa.hlp'?  I'm compiling ok, but still getting a run error - says I need to initialize something, but don't know what.  The pages you mentioned don't say anything about initialization. (I'm trying to talk to a new Agilent N9310 SigGen - I can command it, but can't seem to get anything back from it using VISA, so trying the ocx now).
tia,
Steve
0 Kudos
Message 5 of 12
(8,769 Views)
After installing the ocx, I compile OK, but as soon as I run, I get an EOleError - CoInitialize not called.  Seems like I need something like the viOpenDefaultRM call used in VISA, but don't see any equivalent command for the OCX.
FYI - I installed the OCX and then dropped the component on my main form (I'm using Delphi, but that shouldn't matter here). My code is pretty simple.
ocx.open
ocx.clear
ocx.write ('*idn?' + lf)  // lf set as terminator in 'setup window'
str = ocx.read
ocx.close

My version of the OCX shows 'EVAL' across the Icon - could that have anything to do with it?  I can't seem to find any other version anywhere on any site.  This one came from the ni ftp site from a link found on the ni site.

Steve
0 Kudos
Message 6 of 12
(8,766 Views)
Hi Steve80,
 
If you are using the CWVISA ActiveX component, as per the tutorial you should be able to configure/test things out on the Properties dialog.
 
What happens if you try to perform a simple *idn? from the Test tab?
Jervin Justin
NI TestStand Product Manager
0 Kudos
Message 7 of 12
(8,745 Views)
Forgot to mention that - everything work fine from the Test tab from within the Delphi IDE - I execute *IDN? and I get the proper reply.  It's REALLY confusing to have that part work peachy, but then get a program ending FAULT as soon as the program starts - regardless of what I put *IN* my program.  Maybe I have a bad copy of the OCX?  but don't know where to get another copy to compare.  I suspect that cwvisa.hlp would be a help, but it seems to be a 'figament' rather than something that truly exists Smiley Surprised.
tks,
Steve


Message Edited by Steve80 on 06-12-2008 04:01 PM
0 Kudos
Message 8 of 12
(8,743 Views)

Hi Steve80,

I did a search for the error message and it doesn't look like a case of having to initialize anything with VISA, more to do with initializing the ActiveX Component.

In Delphi, it looks like you might have to call CoInitialize() first.

Something like: (from http://www.delphifaq.com/faq/delphi_windows_API/f511.shtml)
initialization
  CoInitialize(nil); // <-- manually call CoInitialize()

finalization
  CoUnInitialize; // <-- free memory

With regards to seeing the Eval message on the control, this is because you downloaded the Measurement Studio evaluation version from our webpage. The CWVISA control is part of Measurement Studio and in order to get the full version, you would have to purchase Measurement Studio.

Jervin Justin
NI TestStand Product Manager
0 Kudos
Message 9 of 12
(8,724 Views)
OK - so what is the difference in the EVAL version and the "full" version that comes with MS? 
0 Kudos
Message 10 of 12
(8,718 Views)