Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Has anyone been successful in using Prologix GPIB USB converter on labview

yeah its DC source , sorry its not GPIB drivers, its FTDI drivers....

 

My program is that to have I-V characteristics of silicon wafers from the instrument.

0 Kudos
Message 21 of 32
(3,476 Views)

this what i am actually doing, interfacing the hp4142b to labview through GPIB-USB controller, give me suggestions how to communicate hp4142b as in the picture attached.

 

 

0 Kudos
Message 22 of 32
(3,466 Views)

I know what you are doing. The picture is nothing new.

 

I think you need to refer to the manual and use a terminal emulation program such as Hyperterminal to do some basic debugging. According to the Prologix manual, there is a command to set the EOS. According to the instrument manual, it requires a cr\lf termination after every command. The Prologix requires either a CR\LF and this is automatically stripped from the command you are setting. So, according to the Prologix manual, you need to send the ++eos 0 command to automatically append CR/LF as the EOS. I would also think you need to send the ++addr command before doing anything in order to set it to communicate to the instrument.

0 Kudos
Message 23 of 32
(3,459 Views)

I guess this is what low cost gets us.  NI is very nice to let us discuss someone else.  That NI-SPY was very helpful when I was using NI's cards and software.  I'm not trying to use LabView, just C and so far I have had to add lots of delays.  I found the ++addr to change from one instrument to another took 200ms to 400ms.  I have used that HypeTerminal as a dubug aid and it helped.  My C pgm goes much faster than my tying into HypreTerminal, so stepping my C pgm or adding delays helped.  I used the COM port method (VCP) and found that getting information back from my instrument can come is multiple spurts, even for a short ID? of "HP3488A".  I added 1s EVERYwhere and got things to work, then cut back some.  I need to find a better way to handshake.

 

Good luck to you. 

0 Kudos
Message 24 of 32
(3,441 Views)

previously i was used to communicate with HP 4142B instrument ..but before going to communicate with HP4142..Now i am used to communicate  with  fluke multimeter through labview, i completed communicating with the basic serial read and write Vi and next i used to include to some commands for functioning of multimeter through labview. for example if i need to measure the voltage i used to give command VAC , multimeter switches to voltmeter and then to measure ohms giving OHMS command etc.It works fine in this case.

 

now my problem is to have virtual instrument on PC. for example if i need to read voltage from the multimeter, i have to switch the button  in  front panel so that it swicthes to voltmeter and the same for ohmmeter. for that i have used case structures for the different commands. but this time that is when i am using case structure multimeter is not responding.

 

can anyone help me out ..i have attached Vi

0 Kudos
Message 25 of 32
(3,420 Views)

You are not sending \r\n correctly for one. Right click and change the string constants to '\' Code Display and change the constants. Double check the syntax as well. It just does not look correct. Your reads of the values will never work either since you never send the query.

 

It's also silly to spin the loop so fast. Put in a wait function.

Message 26 of 32
(3,417 Views)

I learned my "handshaking" problem came about when I changed the instrument I was addressing.  My setup had hp3488a at 7 and hp3457a at 22.  After sending commands to 7, I switched to 22 then problems arose. I found that the change to 22 did not happen, or not within 250ms.  Later I was able to confirm and found a fix.  The code did something like this:

  ++addr 7

  (...do commands)

  ++addr 22

  (..do commands) [ get errors and other odd stuff!]

 

So I used "++addr" to confirm the address and found it was wrong(old #), something like this:

  ++addr 7

  ++addr

  7   [ correct answer]

  ++addr 22

  ++addr

  7   [ hey that's wrong! ]

  ++addr 22

  ++addr

  22  [ correct answer]

  (..do commands)   [ good results! ]

 

So for me the fix was to check the address change using "++addr" and if not correct repeat "++addr 22" and "++addr".  My C code was:

 

void Instrument(char *port, int gpibNum2)
{
 int gpibNum;
 char answer[256], buf[256];

 /* Fix for addr change BUG! */

 /* Check for Instrument number. */
 UsbGpib(port, "++addr", answer, 8900, 0);
 gpibNum=atoi(answer);
 answer[0]=0x0;

 if(gpibNum2!=gpibNum)
 {
  sprintf(buf, "++addr %i", gpibNum2);
  UsbGpib(port, buf, answer, 25, 0);
  UsbGpib(port, "++addr",  answer, 8900, 0);
 }

}/* End of Instrument. */

 

 

++ver says Prologix GPIB-USB Controller version 6.101

 

Again, I'm not using labview but it appears I found a bug in their hardware.

0 Kudos
Message 27 of 32
(3,409 Views)

Hi Chris,

 

How does your UsbGpib function handle read timeouts?

 

"++" commands are processed sequentially. Is it possible that UsbGpib() timed out, but "answer" was still set to the previous response of "7"?

 

Regards,

Prologix

 

0 Kudos
Message 28 of 32
(3,394 Views)

Proligix,

 

I started with your example code from SerialTest.cpp.  This is the UsbGpib() code:

/* Put Info out onto the GPIB Bus */
int UsbGpib(char *port, char *Msg, char *Result, DWORD timeout, int debug)
{
	char buffer[256], stream[256];
	DWORD error, written, elapsedTime, lastRead, startTime, bytesRead;
	int done, streamLen, chunks;

	/* Open COM port & check for errors. */
	error = PxSerialOpen( port );
	if ( error != 0 )
	{
		printf( "PutGpib: Error %08x opening port %s for command %s.\n", error, port, Msg );
		wait(5);
		return(-1);
	}

	/* Add CR and LF to Msg. */
	sprintf( buffer, "%s\r\n", Msg );

	/* Write command to port & check for errors. */
	written=0;
	error = PxSerialWrite( buffer, (DWORD)strlen( buffer ), &written );
	if ( error != 0 )
	{
		printf( "PutGpib: Error %08x writing port %s for command %s.\n", error, port, Msg );
		wait(5);
		return(-2);
	}

	/* Read until TIMEOUT time has elapsed since last successful read. */
	/* But only if timeout>0 */
	elapsedTime = 0;
	startTime = timeGetTime();
	bytesRead=0;
	if(timeout>0)
	{
		done=0;
		streamLen=0;
		stream[0]=0x0;
		chunks=0;

		while ( (elapsedTime<timeout) && (done<0.5) )
		{
			error = PxSerialRead( buffer, sizeof( buffer ) - 1, &bytesRead );
			if ( error != 0 )
			{
				printf( "PutGpib: Error %08x reading port %s for command %s.\n", error, port, Msg );
				wait(5);
				return(-3);
			}
			if ( bytesRead > 0 )
			{
				buffer[ bytesRead ] = 0x0;    /* Add end of string */
				strcat(stream, buffer);
				streamLen+=bytesRead;
				lastRead = timeGetTime();
				chunks++;
				if((stream[streamLen-2]==13)&&(stream[streamLen-1]==10)){done=1;}
			}
			elapsedTime = timeGetTime() - startTime;
		}/* end of while ( elapsedTime <= TIMEOUT )*/

		/* Remove LF/CR */
		if(streamLen>2){stream[streamLen-2]=0x0;}
		strcpy(Result, stream);
		if(debug>0.5){printf("\nTime Elapsed is %i, Result-->%s<--, in %i chunks.", elapsedTime, stream, chunks);}
	} /* end of if(timeout>0) */

	
	/* Close COM port & check for errors. */
	error = PxSerialClose();
	if ( error != 0 )
	{
		printf( "PutGpib: Error %08x closing port %s for command %s.\n", error, port, Msg );
		wait(5);
		return(-4);
	}

	return(0);
} /* End of UsbGpib */

 

Thanks for your sample code.  

...Chris

0 Kudos
Message 29 of 32
(3,388 Views)

Chris,

 

Please contact us directly at support@prologix.biz

 

Thanks,

Prologix

 

0 Kudos
Message 30 of 32
(3,383 Views)