LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Keithly 2400 SPCI Commands

Solved!
Go to solution

I am a brand new user try to get my way around.  I hope to get some helps.  I am using Labwindow library to write an automation test that uses the Keithly 24100 to source the voltage and measure the current - I communicate and send out SPCI commands to initialized and configure the function OK but when it come to accquire the current measurement I am stuck.

Here is my code for that part

 char read_data[501];
 double actual_current;
 char input[36] = "SOUR:VOLT:LEV ";
 char temp[16] = "";
 
 sprintf (temp, "%f", voltage);
 strcat(input, temp);
 
 write_IO ("*RST", kl_2410_meter);
 Delay (1);
 write_IO ("SOUR:FUNC VOLT",kl_2410_meter); //Select voltage source
 write_IO ("SOUR:VOLT:MODE FIXED",kl_2410_meter); //fixed voltage mode
 
 write_IO ("SOUR:VOLT:RANG 20",kl_2410_meter); //range at 20V 
 write_IO ("SENS:CURR:PROT 100E-3",kl_2410_meter); //current compliance 100mA
 write_IO (input, kl_2410_meter); //set the source voltage to desired voltage
 
 write_IO ("SENS:FUNC \"CURR\" ", kl_2410_meter); // select current measuring mode
 write_IO ("SENS:CURR:RANG 10E-3",kl_2410_meter); //set current range to 10mA
 write_IO ("OUTP ON",kl_2410_meter); // turn on output
 
 write_IO("TRAC:CLE", kl_2410_meter); // clear out buffer
 write_IO("TRAC:FEED SENS", kl_2410_meter); // clear out buffer
 write_IO("TRAC:CLE", kl_2410_meter); // clear out buffer
 write_IO("TRAC:POIN 10", kl_2410_meter);
 write_IO("TRAC:FEED:CONT NEXT", kl_2410_meter);
 write_IO ("INIT",kl_2410_meter); //     

 write_IO ("CALC3:FORM MEAN",kl_2410_meter);  
 write_IO ("CALC3:DATA?",kl_2410_meter);

}

 

and the write_IO routine is just a wrapper for ibwrt as follow

 

void write_IO (void *buffer, int equip_id)
{
 long length;
 length = strlen (buffer);
 ibwrt (equip_id, buffer, (long) length);
 if (ibsta & ERR)
 {
  gpiberror (equip_id, PANEL, PANEL_STATUS,"ibwrt error");
 }
}

 

and I also have the wrapper for reading

char * read_IO (int equip_id, char *s)
{

 ibrd (equip_id, s, 500);
 s[ibcntl] = '\0';

 if (ibsta & ERR)
 {
  gpiberror (equip_id, PANEL, PANEL_STATUS,"ibrd error");
 }
 return (s);
}

 

 

My question is when I write this statement write_IO ("CALC3:DATA?",kl_2410_meter);  where is the data store at so I can get out the current reading?

0 Kudos
Message 1 of 2
(4,946 Views)
Solution
Accepted by Son_La
First, why are you creating your own code instead of using the driver - http://www.keithley.com/base_download?dassetid=7145

Second, the data is stored on the instrument when you issue the query. You have to then do a read to transfer it from the instrument to the pc. You should really use the VISA functions instead of GPIB which are not portable if you change to a USB or Ethernet connection.
0 Kudos
Message 2 of 2
(4,917 Views)