Tektronix Technical Forums are maintained by community involvement. Feel free to post questions or respond to questions by other members. Should you require a time-sensitive answer, please contact your local Tektronix support center here.

Addressing multiple KUSB_488B via C++

Post Reply
doublewood
Posts: 11
Joined: September 16th, 2011, 2:08 pm
Country: United States

Addressing multiple KUSB_488B via C++

Post by doublewood » September 16th, 2011, 2:27 pm

I need to control 3 devices using the usb-GPIB controller. I can send command one at a time (when I only have one to test) but now the second cable has arrived and I am not able to talk to 2 of them at the same time. Here's snipet of my initialization code

KI-488 configuration utility can see both devices

long int MMGPIBboard = 23, ASGPIBboard = 21;
HPmultimeter = 24; //GPIB addr of device
ATSwitchMatrix = 9;

// initialize USB GPIB board
initialize(MMGPIBboard,0); // multimeter GPIB0 display by KI-488 config utility
initialize(ASGPIBboard,0); // matrix GPIB1

boardselect(0); <------------not sure about this documentation said only 0-3?
send(ATSwitchMatrix, wrtbuf, &status);
if ( status == 0 )
{
enter(rdbuf, 100, &len, ATSwitchMatrix, &status); <--------- ID return by device
}
send(ATSwitchMatrix, wrtbuf, &status); <--------- debug just try again and it work
enter(rdbuf, 100, &len, ATSwitchMatrix, &status);
// multimeter
sprintf(wrtbuf ,"%s", "ID?");
boardselect(1); <---------- if I don't do this the following code will not work but still not sure why 0-3 only good thing I only need 3
send(HPmultimeter, wrtbuf, &status);
if ( status == 0 )
{
enter(rdbuf, 100, &len, HPmultimeter, &status); <--------- Name of device returned correctly
}

boardselect(0); <---------- Is this how I address the other GPIB? Obviously not because it does not work
sprintf(wrtbuf ,"%s", "*IDN?"); <----------- just trying to get ID from device
send(ATSwitchMatrix, wrtbuf, &status); <----------- status return 8 which mean timeout

can still send command to multimeter but not the first device

I have not touch GPIB in 20 years so any help is appreciated
Regards
Mark Lin

doublewood
Posts: 11
Joined: September 16th, 2011, 2:08 pm
Country: United States

Re: Addressing multiple KUSB_488B via C++

Post by doublewood » September 19th, 2011, 9:37 am

After more investigation still can't communicate with both board at the same time. communicate to either one is working just fine.

tried the following

----------------------------------------------------------------
initialize(23,0); // 23 USB GPIB addr
initialize(24,1); // 24 device addr
initialize(21,0); // 21 second USB GPIB
initialize( 9,1); // 9 device addr

boardselect(0);
(1) send(9,"*IDN?", &status);
(6) enter(rdbuf, 100, &len, 9, &status);
for ( int k=1 ; k<31 ; k++ )
{
if(listener_present(k)==1)
{
boardlisten = boardlisten + wxString::Format(_T(" board 0 %d,"),k);
}
}
boardselect(1);
(2) send(24, "ID?", &status);
(3) enter(rdbuf, 100, &len, 24,&status);
for ( int k=1 ; k<31 ; k++ )
{
if(listener_present(k)==1)
{
boardlisten = boardlisten + wxString::Format(_T(" board 1 %d,"),k);
}
}
(4) boardselect(0);
(5) send(9,"*IDN?", &status);
for ( int k=1 ; k<31 ; k++ )
{
if(listener_present(k)==1)
{
boardlisten = boardlisten + wxString::Format(_T(" board 0 %d,"),k);
}
}
----------------------------------------------------------------------------------------
result shows

board 0 9,
board 1 21, board 1 24,
board 0 21, board 0 24, <------(4) boardselect(0) command did not change the value return by listener_present()

(1) send command timeout status=8
(2) send command return 0
(3) enter command return ID value of device correctly
(5) send command timeout status=8

This is incorrect since GPIB 23 should be the same controller as device 24 while GPIB 21 with device 9



If I comment out the device initialization like so

------------------------------------------------------------
initialize(23,0); // 23 USB GPIB addr
// initialize(24,1); // 24 device addr
initialize(21,0); // 21 second USB GPIB
// initialize( 9,1); // 9 device addr
------------------------------------------------------------

I get the following result
board 0 9, board 0 21, <------ 21 now show up but 9 show up with out initialize
board 1 21, board 1 24, <------- suppose to be controller 23 controlling device 24
board 0 21, board 0 24, <------(4) boardselect(0) command still did not change the value return by listener_present()

which is doesn't seem right either but
(1) send command status=0
(6) enter command return ID value of device correctly
(2) send command return 0
(3) enter command return ID value of device correctly
(5) send command timeout status=8


switching the initialization order

initialize(21,0); // 21 second USB GPIB
// initialize( 9,1); // 9 device addr
initialize(23,0); // 23 USB GPIB addr
// initialize(24,1); // 24 device addr

Now they are cross but at least every addr show up now
board 0 9, board 0 23,
board 1 21, board 1 24,
board 0 21, board 0 24, <---- (4)select(0) still did not do what I thought it should

(1) send command status=0
(6) enter command return ID value of device correctly
(2) send command return 0
(3) enter command return ID value of device correctly
(5) send command timeout status=8


I need more info about boardselect(b), initilize(x,1), and listener_present(k) and how to call them properly

Any Help included link to more documentation would be appreciated

Regards
Mark Lin

Nathan S
Keithley Applications
Keithley Applications
Posts: 254
Joined: February 28th, 2011, 6:17 am
Country: United States
Contact:

Re: Addressing multiple KUSB_488B via C++

Post by Nathan S » September 19th, 2011, 9:43 am

Before I go through all of the code here, we do have a driver patch for the KUSB-488B, KPCI-488LP, and KPCI-488LPA to fix issues that arise with using multiple boards on the same computer. It is located here: http://www.keithley.com/support/keidoc_ ... are+Driver

Have you installed this yet? If not, I would try doing that and then see if this fixes your problem. If not, let me know and then I will dig into things deeper.

doublewood
Posts: 11
Joined: September 16th, 2011, 2:08 pm
Country: United States

Re: Addressing multiple KUSB_488B via C++

Post by doublewood » September 19th, 2011, 12:57 pm

Hi, Nathan

I reinstalled driver version 3.06 download from the link and than copy the new ieee_32m.dll to the bin location than restart the computer

So I tried this with the KI-488 Diagnostic Tool
Select GPIB0 from board menu item
press initialize KI GPIB
enter 21 (controller) press ok
enter 9 in Instrument Address
enter *IDN? in command text box
press send
got 0=Okay
press enter
got the ID of the device

select GPIB1 from board menu item
press initialize KI GPIB
enter 23 (controoler #2) press ok
enter 24 in instrument address
enter ID? in command text box
press send
got 0=okay
press enter
got the ID of the device

back to board menu select GPIB0
press initialize KI GPIB
enter 21
enter 9 in instrument address
enter *IDN?
press send
got 8=timeout

Can still communicate to GPIB1 but not GPIB0 anymore

If I close KI-488 Diagnostic tool and start over it will do the same. once I initialized GPIB1 I can't talk to GPIB0 anymore

On the Keithley GPIB configuration utility
when I double click on either GPIB0 or GPIB1 both have GPIB address Primary set to 0 and Secondary set to None

Regards
Mark Lin

doublewood
Posts: 11
Joined: September 16th, 2011, 2:08 pm
Country: United States

Re: Addressing multiple KUSB_488B via C++

Post by doublewood » September 19th, 2011, 2:38 pm

Hi Nathan,

I realize I forgot to replace the ieee_32m.dll in the Utility folder which the diagnostic tool uses. so it now works and allow me to switch back and forth. But I am still getting the sam result when using running my application. I can only initialize the controller, initializing the device will cause error and I am not able to switch back to GPIB0 after I select and initialize GPIB1.

Regards
Mark Lin

doublewood
Posts: 11
Joined: September 16th, 2011, 2:08 pm
Country: United States

Re: Addressing multiple KUSB_488B via C++

Post by doublewood » September 20th, 2011, 8:02 am

Nathan,

More info about the system I am running on
64bit Windows 7 prof Dell Latitude E6510 i7 CPU at 2.8Ghz

I found a Gpib-32.dll from Agilent in windows/system32/ folder and removed it

uninstalled driver, reinstalled 3.06 update the patch and reboot

and still getting the same result(timeout) when I switch back to GPIB0 after initializing GPIB0 and than GPIB1
diagnostic tool still works fine

Regards
Mark Lin

Nathan S
Keithley Applications
Keithley Applications
Posts: 254
Joined: February 28th, 2011, 6:17 am
Country: United States
Contact:

Re: Addressing multiple KUSB_488B via C++

Post by Nathan S » September 20th, 2011, 8:11 am

I do not have access to Visual Studio or a C++ compiler to run your program. I will have another Applications Engineer take over here to debug and step through it to check its functionality and if the hangup is expected or not.

Nathan S
Keithley Applications
Keithley Applications
Posts: 254
Joined: February 28th, 2011, 6:17 am
Country: United States
Contact:

Re: Addressing multiple KUSB_488B via C++

Post by Nathan S » September 20th, 2011, 10:33 am

There are a number of issues here. At the beginning you're going to want to start with (pseudocode follows, you'll need to format it correctly for your c++):

boardselect(0) //this will select your system's GPIB0 board
initialize(23,0) //initializes GPIB0 board to address 23 as a controller
boardselect(1) //this selects GPIB1 for your system
initialize(21,0) //initializes GPIB1 to address 23 as a controller

You should not have to do any more initializes, it should only be done once. Switch between GPIB0 and 1 by using the boardselect( ) command before them selecting the desired device.

You do not have to initialize any GPIB instruments/devices on the bus. They should be ready to be spoken to at those addresses if you have set them up correctly on their respective front panels. Starting with the above, you should be on your way.

Also, only used the two GPIB devices if you really need to or want to. Very few users require this, but that isn't to say your application does not require this. However, you can put up to about 15 devices on one GPIB controller so typically 1 is enough for most users. Hope this helps.

doublewood
Posts: 11
Joined: September 16th, 2011, 2:08 pm
Country: United States

Re: Addressing multiple KUSB_488B via C++

Post by doublewood » September 20th, 2011, 1:02 pm

Nathan,

Thanks for the reply. I realize now I should use just one controller and than daisy chain the rest of the device. We are in the process of procuring the cables. But this should still work shouldn't it.
This is what I tried just a simple init of both and a switch and the listener_present is not returning the correct listener for GPIB0 once GPIIB1 is initialized

boardselect(0);
initialize(23,0); // 23 first multimeter GPIB0
boardselect(1);
for ( int k=1 ; k<31 ; k++ )
{
if(listener_present(k)==1)
{
boardlisten = boardlisten + wxString::Format(_T(" board 0 %d,"),k);
}
}
initialize(21,0); // 21 second matrix GPIB1
boardselect(0);
for ( int k=1 ; k<31 ; k++ )
{
if(listener_present(k)==1)
{
boardlisten = boardlisten + wxString::Format(_T(" board 0 %d,"),k);
}
}

9,21 which is GPIB0 for 21 controller 9 device show first, but after GPIB1 is selected and init and GPIB0 is select again
I expect 9,21
but got 21,24

and ID command sent to device 9(*IDN?) or 24(ID?) will get status=8(timeout)

Regards
Mark Lin

Stuart M
Keithley
Keithley
Posts: 418
Joined: September 22nd, 2010, 1:42 pm
Country: United States

Re: Addressing multiple KUSB_488B via C++

Post by Stuart M » September 21st, 2011, 12:00 pm

Suggestions:

Run the KI-488 Configuration Utility and ensure GPIB0 and GPIB1 appear with correct instruments connected to each.

Run the C:\Program Files\Keithley Instruments\KI-488\Examples\VB\Find Listener\FindListener.exe example and test GPIB0 and then GPIB1. This works correctly for me with two GPIBs.

I also tried the KI-488 Diagnostic Tool and talked using (send and enter) to GPIB0, then GPIB1, then GPIB0, again, all with no timeouts.

As for your code, you might break the problem in half and just test the GPIB0 code first, then comment this code out and test the GPIB1 code next. If both work individually, then run all code again.
Also...
-> recommend you move the initialize(21,0) earlier in your code, just after the first boardselect(1).
-> try switching the initialize(21,0) and initialize(23,0) and see if your results are the same

doublewood
Posts: 11
Joined: September 16th, 2011, 2:08 pm
Country: United States

Re: Addressing multiple KUSB_488B via C++

Post by doublewood » September 21st, 2011, 2:23 pm

Stuart,

I got it working. Turn out I have to copy the ieee_32m.dll to the location of my debugged exe where the visual studio compiled it. its working just fine now.


thanks for trying to help really appreciated
Mark Lin

Post Reply

Return to “Instrument Accessories & GPIB”

Who is online

Users browsing this forum: No registered users and 2 guests