From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Controlling Multiple GPIBs in C#

Solved!
Go to solution

I am using the work around which creates the .licx file manually and place it in my visual studio project.

http://digital.ni.com/public.nsf/allkb/8C93FFDC5014C57586257EC30054830A

 

I am using the version 16.0 driver which you just suggested. 

 

I am currently able to control multiple devices perfectly with my visual studio 2015 program which I have now published into a ClickOnce Application. The ONLY bug left is the fact that all of the computers I have tested it on are permanently saving the GPIB Board ID's to the computer registry. So if 5 GPIB's are plugged in corresponding to Board ID's 0 - 4, each GPIB will always have its respective Board ID from when all 5 were connected even when all others are unplugged. So GPIB with Board ID 4 will always be 4 on that computer. I need to figure out how to clear these settings so that there is no confusion when mixing up wires or when plugging in less than 5. I am using the board.SendInterfaceClear() command when each GPIB is connected. The missing functions are of less importance, they are not an issue related to which version of VS is being used. It has to do with the function definitions contained in the NationalInstrumets,NI4882.dll. If you follow the C# examples contained in the driver download you just linked, they only have the limited function set as well which are based off of the board and device classes (these examples are also address for driver version 3.1.1, there is no updated code released by NI. I based all of my code off of this absolutely ingenious code which creates custom classes based off of the NI .dll's and can send Async commands without consonantly tripping exceptions in the NationalInstrumets.NI4882.dll. The code was posted by Pawel Wzietek, another forum user who was extremely helpful with accomplishing multiple GPIB control, his code is SIGNIFICANTLY more advanced than anything released by National Instrumuemts. His code and its corresponding documentation can be found here NationalInstrumets,NI4882.dll.

 

SOMEONE PLEASE HELP WITH CLEARING BOARD ID'S FROM THE REGISTRY PLEASEEEEE!!!

0 Kudos
Message 11 of 31
(1,941 Views)
Solution
Accepted by topic author hwalke

Clearing board ID registry with Tools in NI Visa Max but would appreciate a method of clearing the registry programmatticaly in C#

0 Kudos
Message 12 of 31
(1,902 Views)

Hey,

 

Can you try to manually change/clear the board ID's in the visaconfig.ini file. If this works, can you then programmatically change the access this ini file and clear it? 

 

LINK:

Configure VISA Alias in NI MAX (clear errors)

http://digital.ni.com/public.nsf/allkb/FF9EEE0B28569617862573210073B69F

 

I'm seeing the same commands as you in the 488.2 manual. 

 

If I'm confused on what you are calling the Board ID Registry please correct me, and let me know where this ID is being set. 

 

Spencer | NI

0 Kudos
Message 13 of 31
(1,887 Views)

As stated in my most recent post, your first suggestion works and I am able to manually clear the board ID using

NI VISA Max - >Tools->Reset Configuration Data. How would I conduct this operation programmatically in C#? 

 

As for what I am referring to with the term Board ID Registry, I am calling the Windows Registry entries that are reserving the Device Enumerations the Board ID Registry ( this is set through Plug - N - Play technology as soon as the controller is plugged into the computer) so whatever function clears this registry is most likely what I need). I may be incorrect in the sense that these Device Enumerations are actually stored in visaconf.ini (I know LabVIEW aliases are stored here but my GPIB does not use aliases, only board ID and device address, thus, I am not sure which registry Board ID  is stored). As ff VISA Version 4.2 "The default path to the configuration file visaconf.ini has changed to "C:\Documents and Settings\All Users\Application Data\National Instruments\NIvisa" on Windows XP/2000 and to "C:\ProgramData\National Instruments\NIvisa" on Windows Vista." I am not sure where this file is or what it has been renamed to on Windows 7, it doesn't seem to exist on my computer.

 

See similar post which uses the VISA Max Configuration Data Reset to clear the registry associated with Board ID. However, it stops at Configuration Data Reset in NI VISA Max does not describe how to programmatically reset the registry (it does not clearly state which registry is being cleared) Link to Example Clearing Board ID from Registry

 

On a side note, how do I access the full function command set listed in the 488.2 manual? Using NationalInustruments.NI4882.dll in a C# project only gives access to the limited device and board classes which have very few of the functions listed in the manual - for instance, IBDEV and IBFIND are missing as well as SendIFC for a device (there is only a SendInterfaceClear() function for the board class). I would like the device class to have access to the full set of functions, I am using driver version 16 (most updated). To overcome this limiation, I have been using custom code posted by another forum user -  Multithreaded communication for GPIB/Visa/Serial interfaces which creates its own .dll

0 Kudos
Message 14 of 31
(1,874 Views)

Hello,

 

Unfortunately, if you are using C#, I do not have permission to have Visual Studio installed to help with specific calls, that will be officially supported my Microsoft Visual Studio support team. As NI only officially supports NI Software applications. I would assume that you could use the NI System Configuration API to do many of these functions. The closest help file that we will have available will be for LabWindows CVI (attached here). This API generally gives you the most control over the NI MAX environment, and mimics the behavior you can do there. 

 

I am attaching the download for NI System configuration 16.0.1 here. Please make sure to read the read-me for compatibility with the rest of your software and OS. 

 

Obviously, a lot of NI users do use Measurement Studio, so hopefully the community may have more specifics.  

 

Spencer | NI

0 Kudos
Message 15 of 31
(1,866 Views)

Inside of system configuration API I see "format," but  no "reset configuration data," function. Format says it erases all data, is this equivalent to the NI MAX Tools > Reset Configuration Data? If I implement this programmtically will a system restart still be required?

0 Kudos
Message 16 of 31
(1,820 Views)

You should have access to a lot more of the API than just "format" because the system configuration API help that I posted has all the function calls you can make in CVI. 

 

The format function can only be used in real-time systems. Also are you aware that it erases all data from the primary hard drive of a system?

 

There is a NISysCfgResetHardware function call and also a rename call that is shown below. Please read the help file in my previous post for all the functions available. 

hwalke.png

 

Spencer | NI

0 Kudos
Message 17 of 31
(1,810 Views)

I see restart, import configuration, export configuration, install software, uninstall all and so on but no reset for system configuration. I installed the API you linked me to.

0 Kudos
Message 18 of 31
(1,801 Views)

Where are you "seeing" these functions, as in what code environment? 

 

Have you read through the help file on NI System Configuration linked here for Windows OS? Please do, as it will list all the functions available. 

LINK:

NI System Configuration Function Reference for LabWindows/CVI

http://zone.ni.com/reference/en-XX/help/373242H-01/nisyscfgcvi/bp_help_file_title/

 

You should be able to use a wrapper to call all these functions from whatever language you are in. 

0 Kudos
Message 19 of 31
(1,795 Views)

I am seeing these functions in the .Net environment, I did read the help file and see that there are more functions than are visible to me.

0 Kudos
Message 20 of 31
(1,791 Views)