Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

programs work with ISA GPIB board but not PCI board

I am replacing a 10 year old Win95-based data acquisition system with all new hardware and software.  The old system used LabWindows CVI 5 and an ISA AT-GPIB/TNT plug and play board, with ver. 1.6 of the NI-488.2 software.  Everything worked fine.  The new system is WinXP SP2, with the newest CVI 8, the newest NI-488.2 (ver2.46) and Measurement and Automation Explorer, and a brand new PCI-GPIB board.  After installing all the new stuff, I ran some of my old programs to control instruments over the GPIB.  Things sort of worked, but there seemed to be some timing issues, with the code thinking it was getting return values from the instruments before were actually sending the values.  None of the termination or any other settings for the board in MAX had any effect.  I tried putting in an older PCI-GPIB board, of almost the same vintage as the ISA board.  This made no difference to how the programs ran.  I finally put in my original ISA board.  (All three boards were using the same v2.46 of NI-488.2, and all were configured as GPIB0 in MAX.)  With all the same default settings in MAX as for the PCI boards, all of my old programs worked with the ISA board.  I wrote the code a while back so I may be a little foggy on it, but I don’t recall needing to put in anything identifying the board as ISA.  Can anyone suggest why this is happening?  I’d really like to be able to use a PCI version of the GPIB board, but I’d also like things to work.  I haven’t written any new-from-scratch code yet with all the new hardware and software, only tried to run the old stuff.

 

Thanks in advance.

 

Stuart Van Deusen

0 Kudos
Message 1 of 18
(4,623 Views)

Do you have access to the source code for the programs?

It might be a good idea to recompile them in the newer environment. While the newer drivers are supposed to be backwards compatible, with such a large version jump there may be something not quite right.

Martin Fredrickson
Test Engineer

Northrop Grumman
Advanced Systems and Products
San Diego, CA 92128
0 Kudos
Message 2 of 18
(4,601 Views)

Thank you for the reply.  I am running the old projects in the new CVI environment, not as the old executables, so I would have thought that that would take care of the recompiling issue.  However, there seem to be a few more build options in the CVI 8 than there were in the CVI 5, so maybe I'm missing something.  I'll continue to look into it.

 

Stuart Van Deusen

0 Kudos
Message 3 of 18
(4,574 Views)

You are using the Debug program command in the run menu? if so, it would have recompiled everything to build the symbol tables, etc.

If you are just using the Execute program command in the run menu, it did not recompile unless you told it to do so.

Martin Fredrickson
Test Engineer

Northrop Grumman
Advanced Systems and Products
San Diego, CA 92128
0 Kudos
Message 4 of 18
(4,572 Views)

Yes, I am using the Debug program in the run menu.  One big difference I've found in the CVI 8 from the CVI 5 is that the CVI 8 seems to automatically create an executable of the project then runs that executable, even when the project is being run in the CVI environment.  Back in 5 CVI didn't create an executable until you specifically told it to, and the debug option was unavailable for the executable.  I don't know how that affects the compilation of the source code.  I've tried the options of marking the source code for compilation and marking the project for compilation prior to running the project, and nothing seems to make any difference.

Stuart Van Deusen

0 Kudos
Message 5 of 18
(4,572 Views)
That was changed a while back, (CVI 6.0 I think...) CVI always creates a separate executable file now. This allows for remote debugging which is a very nice feature.
 
Anyway, as far as I know, the type of board installed SHOULD be transparent to you and any differences should be handled by the driver.
 
Sounds like a call to NI tech support might be in order.

Message Edited by MJF on 07-05-2006 04:00 PM

Martin Fredrickson
Test Engineer

Northrop Grumman
Advanced Systems and Products
San Diego, CA 92128
0 Kudos
Message 6 of 18
(4,569 Views)

Now that I think about it a bit, you might want to repost this question in the Labwindows/CVI forum too. Since this seems to be a hardware issue, I am sure that this board seems like the right place to ask but it certainly can't hurt to broaden the audience.

There may be somebody that frequents that board but not this one who may have some insight into what you are seeing.

Martin Fredrickson
Test Engineer

Northrop Grumman
Advanced Systems and Products
San Diego, CA 92128
0 Kudos
Message 7 of 18
(4,566 Views)

Thank you for your suggestions.

Stuart Van Deusen

0 Kudos
Message 8 of 18
(4,562 Views)
Hi Stuart,

There are some timing difference between the way the ISA and PCI boards function.  For the most part, the PCI board is going to operate much faster than the ISA board you are using.  While the operation is within the specifications for IEEE-488.1/2, some older instruments can sometimes "dislike" the timing changes, due to slight non-conformities of the instrument to the IEEE spec.  Do you have a GPIB analyzer board available, such as a PCI-GPIB+?  If so, the analyzer capture can allow us to see where the hangup is occuring, by watching all of the handshake and control line transitions.  If you do have an analyzer available, the following KnowledgeBase article explains how to obtain a quality capture for this purpose:

KnowledgeBase 386GCOV4

Let us know if this is an option for you.  If so, post the analyzer capture along with an NI Spy capture, and I will be happy to take a look at them for you.

Jason S.
GPIB Software
National Instruments
0 Kudos
Message 9 of 18
(4,537 Views)
I'm going to paste in some LabWindows CVI code, then I'll explain what the program does.
 

float read_position (void)
{
 fillnaf (2,0,0);      
 pos_counts = camac_read(crate, naf);   
 position = (pos_counts + 32768) / 314.0;
 SetCtrlVal (panelHandle, PANEL_CURRENT_POSITION, position);
 if (!slewFlag) SetCtrlVal (panelHandle, PANEL_SLEWPOSITION, position);
 ProcessDrawEvents ();
 
 return position;
 
int move_it (int delta)
{
 moveFlag = 0;
 fillnaf (7,0,16);
 camac_write (crate, naf, delta);
 fillnaf (7,12,1);
 SetCtrlAttribute (panelHandle, PANEL_STEPMSG, ATTR_VISIBLE, 1);
 while (moveFlag == 0) {
       moveFlag = camac_read (crate, naf);
       ProcessSystemEvents ();
       }
 SetCtrlAttribute (panelHandle, PANEL_STEPMSG, ATTR_VISIBLE, 0);
 if (moveFlag > 1)  end_limit (moveFlag);
 read_position ();
 
 return moveFlag;
}

void camac_command(int crate, char naf[])
{
 ibwrt(crate, naf, 3);
     if (ibsta & 0x8000) {
         iberr_msg = gpib_error ();  
         on_error (iberr_msg);
         }
 
void camac_write(int crate, char naf[], int instruct)
{
 unsigned char message[3];
 char *ip;
 
 ip = (char *) &instruct;
 
 message[0] = *(ip+2);
 message[1] = *(ip+1);
 message[2] = *ip;
 
 camac_command(crate, naf);
 ibwrt(crate, message, 3); 
  if (ibsta & 0x8000) {
        iberr_msg = gpib_error ();  
        on_error (iberr_msg);
        }
}
 
int camac_read(int crate, char naf[])
{
 int answer = 0 ; 
 unsigned char message[3];
 char *ip;
 
 camac_command(crate, naf);
 ibrd(crate, message, 3);
  if (ibsta & 0x8000) {
        iberr_msg = gpib_error ();  
        on_error (iberr_msg);
        }
 
 ip = (char *) &answer;
 
 *(ip+2)=message[0];
 *(ip+1)=message[1];
 *ip    =message[2];
 
 return(answer);
}
 
The purpose of this code is to operate a stepper motor and read its position.  The stepper motor controller and the counter are modules in a CAMAC crate.  The naf commands tell the crate which module is to be addressed, and what the specific command to that module is.  The camac_write in the move_it function starts the motor moving.  The stepper motor controller has a status byte which is then read by the camac_read in the loop.  The returned byte can be zero, meaning the motor is still moving; 1, which means the move is complete; or 2 or 4, which mean the motor has hit either end of its travel limits.  The problem I'm having with the PCI-GPIB card (which doesn't happen with the ISA AT-GPIB/TNT card) is that during the move the card will intermittently

pick up a garbage value (typically a seven digit integer) which kicks out of the loop and causes the position to be read before the end of the move.  This happens during any iteration of the loop (I can watch with NISpy to see how many times the status byte is read before the loop is exited).  I don't claim that this code is the most elegant way to perform these operations, but the question is, why does this happen with the PCI card and not the ISA?  In both cases, the GPIB is simply reading a status byte.  It doesn't seem that timing should be an issue.
 
Thank you for your help.
 
Stuart Van Deusen
 
(This is also posted on the CVI forum)
0 Kudos
Message 10 of 18
(4,509 Views)