Download GPIB Manual - wavecrest dts

Transcript
Appendix B – Reading Data
This appendix describes the programming steps to take a measurement and read back the values of
the measurement. In this example a burst of 100 measurements is taken and the data read back in
a 32-bit floating format.
void main (void)
{
int i;
int no_of_bytes;
char temp_string[2048];
int c;
int header;
float this_reading[100];
char *ptr;
int result;
/*488 is initialized for controller and instrument*/
no_of_bytes=100;
Send(0,5,”*CLS”,4,EOI);
Send(0,5,”:ACQ:COUN100",12,EOI)
Send(0,5,”*TRG”,4,EOI);
result=0;
while((result & 0x01) ==0)
/*Wait for TRG bit*/
{
ReadStatusByte(0,5,&result);
}
sprintf(temp_string,”%i”,number_of_bytes*4);
c=strlen(temp_string);
header=c+2;
/*# of characters in header*/
Send(0,5,”:MEAS:DATA4?”,12,EOI);
result=0;
while((result & 0x10) ==0)
/*Wait for MAV bit*/
{
ReadStatusByte(0,5,&result);
}
Receive(0,5,temp_string,(no_of_bytes*4)+header,EOI);
/*convert char string to floating point*/
ptr=&temp_string [header];
for(i=0; i<no_of bytes; i++)
{
this_reading [i] = *((float*)ptr);
ptr = ptr+4;
}
}
/*end of main*/
©WAVECREST Corporation 2005
Appendix B | Reading Data | 567