Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Automate changing of GPIB Interface IDs

I've had an issue with GPIB interface IDs being assigned to the wrong PCI bus/dev intermittently (using multiple PCI-GPIB cards).   After research and experimentation, I've decided the only way to resolve the issue is to manually assign the interface IDs based on the PCI slot.

 

I realize this is easily done with the Measurement and Automation Explorer by selecting the GPIB device and changing the property settings.  I'd like to automate this so our operators don't have to deal with it.  

 

C# or C/C++ is fine - which API is appropriate to use?  I've been reading documentation for 488.2 programming, NI-VISA, SystemConfiguration... I haven't been able to find a way to accomplish this. 

 

Can anyone point me in the right direction?  Thanks.

0 Kudos
Message 1 of 10
(5,392 Views)

I have done something similar to what you are requesting by looking up the information in the Registry.

Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\PCI\

NI products will begin with: VEN_1093&DEV_

 

The main directories under those headings (I.E. 5&abcde&0&f012) need to have a 'Control' folder under them which will indicate that the hardware exists.  If there is no 'Control' folder, then no hardware has been recognized.  There are Keys within that (5&abcde&0&f012) main folder.  These GPIB devices should be using the ni488k or similar Service.  Lookup the Driver key and the number after the '{nn-nn-nn}' will change dependent on the GPIB#::INTFC.  Also, lookup the LocationInformation key and read the value within the (#,#,#) to get the PCI bus, device, and function to associate that with the particular GPIB bus.

Help the Community (and future reviewers) by marking posts as follows:
If it helped - KUDOS
If it answers the issue - SOLUTION
0 Kudos
Message 2 of 10
(5,366 Views)

 

Thanks for the quick response -

Here's an example of my first card in the registry, I'm able to read from it okay to get the PCI bus and device numbers:

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\PCI\VEN_1093&DEV_C801&SUBSYS_C8011093&REV_02\4&24fb664&0&60F0]
"DeviceDesc"="@oem25.inf,%pcidesc%;PCI-GPIB"
"LocationInformation"="@system32\\drivers\\pci.sys,#65536;PCI bus %1, device %2, function %3;(3,12,0)"
"Capabilities"=dword:00000000
"HardwareID"=hex(7):50,00,43,00,49,00,5c,00,56,00,45,00,4e,00,5f,00,31,00,30,\
00,39,00,33,00,26,00,44,00,45,00,56,00,5f,00,43,00,38,00,30,00,31,00,26,00,\
53,00,55,00,42,00,53,00,59,00,53,00,5f,00,43,00,38,00,30,00,31,00,31,00,30,\
00,39,00,33,00,26,00,52,00,45,00,56,00,5f,00,30,00,32,00,00,00,50,00,43,00,\
49,00,5c,00,56,00,45,00,4e,00,5f,00,31,00,30,00,39,00,33,00,26,00,44,00,45,\
00,56,00,5f,00,43,00,38,00,30,00,31,00,26,00,53,00,55,00,42,00,53,00,59,00,\
53,00,5f,00,43,00,38,00,30,00,31,00,31,00,30,00,39,00,33,00,00,00,50,00,43,\
00,49,00,5c,00,56,00,45,00,4e,00,5f,00,31,00,30,00,39,00,33,00,26,00,44,00,\
45,00,56,00,5f,00,43,00,38,00,30,00,31,00,26,00,43,00,43,00,5f,00,30,00,37,\
00,38,00,30,00,30,00,30,00,00,00,50,00,43,00,49,00,5c,00,56,00,45,00,4e,00,\
5f,00,31,00,30,00,39,00,33,00,26,00,44,00,45,00,56,00,5f,00,43,00,38,00,30,\
00,31,00,26,00,43,00,43,00,5f,00,30,00,37,00,38,00,30,00,00,00,00,00
"CompatibleIDs"=hex(7):50,00,43,00,49,00,5c,00,56,00,45,00,4e,00,5f,00,31,00,\
30,00,39,00,33,00,26,00,44,00,45,00,56,00,5f,00,43,00,38,00,30,00,31,00,26,\
00,52,00,45,00,56,00,5f,00,30,00,32,00,00,00,50,00,43,00,49,00,5c,00,56,00,\
45,00,4e,00,5f,00,31,00,30,00,39,00,33,00,26,00,44,00,45,00,56,00,5f,00,43,\
00,38,00,30,00,31,00,00,00,50,00,43,00,49,00,5c,00,56,00,45,00,4e,00,5f,00,\
31,00,30,00,39,00,33,00,26,00,43,00,43,00,5f,00,30,00,37,00,38,00,30,00,30,\
00,30,00,00,00,50,00,43,00,49,00,5c,00,56,00,45,00,4e,00,5f,00,31,00,30,00,\
39,00,33,00,26,00,43,00,43,00,5f,00,30,00,37,00,38,00,30,00,00,00,50,00,43,\
00,49,00,5c,00,56,00,45,00,4e,00,5f,00,31,00,30,00,39,00,33,00,00,00,50,00,\
43,00,49,00,5c,00,43,00,43,00,5f,00,30,00,37,00,38,00,30,00,30,00,30,00,00,\
00,50,00,43,00,49,00,5c,00,43,00,43,00,5f,00,30,00,37,00,38,00,30,00,00,00,\
00,00
"ContainerID"="{00000000-0000-0000-ffff-ffffffffffff}"
"ConfigFlags"=dword:00000000
"ClassGUID"="{15d2825a-b098-4c77-bb20-68a198159734}"
"Driver"="{15d2825a-b098-4c77-bb20-68a198159734}\\0001"
"Class"="GPIB"
"Mfg"="@oem25.inf,%nistring%;National Instruments"
"Service"="ni488k"

So for this example, are you saying at PCI location 3,12 I have GPIB1::INTFC (the 0001 following the driver number)?  

 

If this is the case, would there be a way to change the card at PCI location 3,12 to GPIB0 without using Measurement and Automation explorer or editing the registry (via an NI API?)

 

0 Kudos
Message 3 of 10
(5,361 Views)

Yes.  This has been my finding, but I would verify that those are your GPIB settings through MAX.

 

Not sure if you can programmatically change these.  The other option to change the GPIB bus number would be to do this in MAX.  Select the one currently given GPIB0 to an unused number (I.E. GPIB4) then change the one desired at GPIB0 and follow suit until GPIB4 would end up where it is expected.  I would never recommend changing things directly in the Registry.  Reading - YES; Writing - NO.

Help the Community (and future reviewers) by marking posts as follows:
If it helped - KUDOS
If it answers the issue - SOLUTION
0 Kudos
Message 4 of 10
(5,358 Views)

As the PCI location will never change, make the GPIB bus a variable that gets associated with the physical hardware location.  Your GPIB controller hardware and associated cables are not moving and will always have the same equipment attached.

 

Within a Configuration File:

[GPIBus]

GPIBA = '3,12'

GPIBB = '4,10'

GPIBC = '3,14'

 

For GPIB0 which we are going to refer here to GPIBA, find the Location Information that matches '3,12' then pickup the Driver# and append that to GPIB which in your data would be GPIB1.

Help the Community (and future reviewers) by marking posts as follows:
If it helped - KUDOS
If it answers the issue - SOLUTION
Message 5 of 10
(5,356 Views)

I understand, and yes the settings in MAX always match what I find in the registry.  The frustrating thing I've found is although the 3 cards are never physically moved, the GPIB Interface ID in MAX sometimes changes, e.g.:

 

On boot:

GPIB0 will be (3,12)

GPIB1 will be (4,5)

GPIB2 will be (4,4)

 

On another random boot

GPIB0 will be (4,5)

GPIB1 will be (4,4)

GPIB2 will be (3,12)

 

We're able to change these settings in MAX to correct them like you said.  I'm also able to get the physical location via the NationalInstruments.SystemConfiguration .NET class library (GenerateMAXReport method).  

I see properties of the NationalInstruments.NI4882 library to get and set other changeable properties such as the primary and secondary address (which show up as dropdowns below the GPIB Interface ID in MAX) so I was hoping there'd be a way to programmatically change the Interface ID as well. 

 

Suppose we may have to stick with having operators correct the interface IDs via MAX.

 

I appreciate the help again.

0 Kudos
Message 6 of 10
(5,352 Views)

Are you able to follow my alternate solution in Message 5?  Doing this would give you the known hardware connections that you would expect with a variable GPIB bus number.

Help the Community (and future reviewers) by marking posts as follows:
If it helped - KUDOS
If it answers the issue - SOLUTION
0 Kudos
Message 7 of 10
(5,345 Views)

Missed that message - makes good sense.  I will attempt to implement it, thanks again!

0 Kudos
Message 8 of 10
(5,342 Views)

May have spoken too soon, just checked one of the machines in question and in the registry I see:

 

Location: (3,12,0),  (4,5,0), and (4,4,0) with the 4 digits after the driver being 0001, 0002 and 0000 respectively.

 

In MAX I see

GPIB0 3,12

GPIB1 4,5

GPIB2 4,4

 

Does that make any sense?

0 Kudos
Message 9 of 10
(5,340 Views)

Just for sanity sake, check the registry before and after opening NI-Max.

Help the Community (and future reviewers) by marking posts as follows:
If it helped - KUDOS
If it answers the issue - SOLUTION
0 Kudos
Message 10 of 10
(5,337 Views)