tek210 programming

Hi,

Im dealing with grabbing curve data from a old tek210 scope. Since its crucial to get both channels at the same time, my adquisition cycle is:

im pausing the scope grabbing each channel separately and then resume adquisition

I do this with a compiled .dll that uses the NI-488-Gpib api and then call it from a program. The strange problem is that in a PIV with Windows2000 professional this works nicely for my purpose. But in a PIII machine with Windows98 i get an "unable to serial poll scope" error

ibwrt(Dev, "CURVE?\n", 7 ); ibwait(Dev, TIMO | RQS); ibrsp(Dev, &ResByte);

//either i grab a positive error 3 in this test in windows98 if (ibsta & ERR) { GPIBCleanup(Dev, "Unable to serial poll oscilloscope"); return 3; }

//or either i grab later a "cannot get waveform preamble" error

Any ideas what may cause the different behaviour of the same dll both in windows 98/P3 and W2000Pro/P4? even the scope is the same in both cases

The code of the cycle is the following (the called functions code are displayed at the end of the post)

*-----------------------------------------*------------------------------------* device = Init_Osciloscopio( "DAT:SOU CH1;:DAT:ENC RIBinary;:DAT:WID 1;:DAT:STAR 1;:DAT:STOP 2500;:HOR:MAIN:SCALE 5e-4;:CH1:SCALE 5e-1;:CH2:SCALE 5e-3\n" , "SEL:CH1 ON;:SEL:CH2 ON;:ACQ:MOD SAMPLE\n" );

error_code = SendString(device, "ACQUIRE:STATE ON\n");

// Done initialization, now we start adquisition

error_code = Pause(device);

error_code = 1; while (error_code != 0) { device = Init_Osciloscopio( "DAT:SOU CH1;:DAT:ENC RIBinary;:DAT:WID

1;:DAT:STAR 1;:DAT:STOP 2500;:HOR:MAIN:SCALE 5e-4;:CH1:SCALE 5e-1;:CH2:SCALE 5e-3\n" , "SEL:CH1 ON;:SEL:CH2 ON;:ACQ:MOD SAMPLE\n" ); error_code = SendString(device, "CURVE?\n"); error_code := WriteWaveform(device, CH1_fileout); }

error_code = 1; while (error_code != 0) { device = Init_Osciloscopio( "DAT:SOU CH1;:DAT:ENC RIBinary;:DAT:WID

1;:DAT:STAR 1;:DAT:STOP 2500;:HOR:MAIN:SCALE 5e-4;:CH1:SCALE 5e-1;:CH2:SCALE 5e-3\n" , "SEL:CH1 ON;:SEL:CH2 ON;:ACQ:MOD SAMPLE\n" ); error_code = SendString(device, "CURVE?\n"); error_code := WriteWaveform(device, CH2_fileout); }

error_code = Resume(device);

*-----------------------------*------------------------------------------*

-------------------*---------------------*--------------------------- DLL functions

//////////////////////////////////////////// // INIT_OSCILOSCOPIO( SCOPECONFIG ; ACQWFM )

extern "C" int Init_Osciloscopio(char* ScopeConfigString , char* AcqWaveformString ) { int Dev, LoopCount = 0, Done = 0; char ResByte;

/* char ScopeConfigString[] = "DAT:SOU CH1;:DAT:ENC RIBinary;:DAT:WID

1;" ":DAT:STAR 1;:DAT:STOP 2500;" ":HOR:MAIN:SCALE 5e-4;" ":CH1:SCALE 5e0\n"; char AcqWaveformString[] = "SEL:CH1 ON;:ACQ:MOD SAMPLE\n"; */

Dev = ibdev(BDINDEX, PRIMARY_ADDR_OF_SCOPE, NO_SECONDARY_ADDR, TIMEOUT, EOTMODE, EOSMODE); if (ibsta & ERR) { printf("Unable to open device\nibsta = 0x%x iberr = %d\n", ibsta, iberr); return 1; }

ibwrt(Dev, ScopeConfigString, strlen(ScopeConfigString)); if (ibsta & ERR) { GPIBCleanup(Dev, "Unable to set waveform characteristics"); return 1; }

ibwrt(Dev, AcqWaveformString, strlen(AcqWaveformString)); if (ibsta & ERR) { GPIBCleanup(Dev, "Unable to set up acquisition"); return 1; }

ibwrt(Dev, "*SRE 16\n", 8L); if (ibsta & ERR) { GPIBCleanup(Dev, "Unable to set SRE"); return 1; } return Dev; }

////////////////////////////////////////////////// // SENDSTRING( DEV ; MSG )

extern "C" int SendString(int Dev, char* message) { ibwrt(Dev, message, strlen(message)); if (ibsta & ERR) { GPIBCleanup(Dev, "Unable to set message"); return 1; } return 0; }

///////////////////////////////////// // PAUSE ( DEV )

extern "C" int Pause(int Dev) { ibwrt(Dev , "ACQuire:STATE STOP\n", 18L); if (ibsta & ERR) { GPIBCleanup(Dev, "Unable to resume"); return 5; } //ibwrt(Dev , "ACQuire:STATE RUN\n", 18L); }

////////////////////////////////////// // RESUME ( DEV )

extern "C" int Resume(int Dev) { ibwrt(Dev , "ACQuire:STATE RUN\n", 18L); if (ibsta & ERR) { GPIBCleanup(Dev, "Unable to resume"); return 1; } //ibwrt(Dev , "ACQuire:STATE RUN\n", 18L); }

///////////////////////////////////////////////////////// // WRITEWAVEFORM ( DEV ; FILENAME )

extern "C" int WriteWaveform(int Dev, char* filename) { const Addr4882_t address = 7; //the address of the scope (change to fit your configuration) const int BUF_SIZE = 2048; //the total buffer size const int NUM_DEVICES = 31; //maximum number of devices on the bus

char buffer[BUF_SIZE]; char data_buf[BUF_SIZE]; int LoopCount = 0, Done = 0;

char ResByte; /* * The application waits for either the oscilloscope to request * service or the call to timeout. The wait mask supplied to * ibwait contains two bits: TIMO and RQS. The TIMO bit limits * the wait period to the timeout value that was specified in * the ibdev call; the RQS bit instructs the application to wait * until the device has requested service. The ibwait call is * completed when one or more of the specified wait conditions * becomes true. */ ibwait(Dev, TIMO | RQS); if (ibsta & ERR) { GPIBCleanup(Dev, "Error occurred while waiting for Service Request"); return 1; }

/* * If after the ibwait call, the RQS bit in ibsta is not set, * the Oscilloscope did not request sevice. */ if (!(ibsta & RQS)) { GPIBCleanup(Dev, "Error : Oscilloscope did not request service"); return 2; } ibrsp(Dev, &ResByte); if (ibsta & ERR) { GPIBCleanup(Dev, "Unable to serial poll oscilloscope"); return 3; }

/* * If the value is not 0x50, the device did not request service * as a result of completing the acquisition. In this case, an * error message is printed and the program exited. */ if (ResByte != SERPOLLRESPONSE) { printf("Error : Unexpected serial poll response. Expected :

0x%x " "Received : 0x%x\n", SERPOLLRESPONSE, ResByte); printf("Cleanup: Taking device off-line\n"); ibonl (Dev, 0); return 4; }

/* * The Curve string from the oscilloscope is read into the * character variable ValueStr */ ibrd(Dev, ValueStr, ARRAYSIZE); if (ibsta & ERR) { GPIBCleanup(Dev, "Unable to read curve data"); return 5; }

LoopCount++;

ValueStr[ibcntl - 1] = '\0';

printf("\nWaveform No: %d\n\n", LoopCount); cout

Reply to
Charles J. Quarra
Loading thread data ...

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.