beautypg.com

External device initialization, Basic data acquisition – Measurement Computing Personal488 rev.3.0 For DOS & Windows 3.Xi User Manual

Page 230

background image

II. SOFTWARE GUIDES - 10. Driver488/W31

10E. C Languages

Personal488 User’s Manual, Rev. 3.0

II-215

sprintf(response, “PrimAddr :%d\r\n”, substat->Primaddr);
strcat(textstr, response);
sprintf(response, “SecAddr :%d\r\n”, substat->Secaddr);
strcat(textstr, response);
sprintf(response, “SRQ :%d\r\n”, substat->SRQ);
strcat(textstr, response);
sprintf(response, “addrChange :%d\r\n”, substat->addrChange);
strcat(textstr, response);
sprintf(response, “talker :%d\r\n”, substat->talker);
strcat(textstr, response);
sprintf(response, “listener :%d\r\n”, substat->listener);
strcat(textstr, response);
sprintf(response, “triggered :%d\r\n”, substat->triggered);
strcat(textstr, response);
sprintf(response, “cleared :%d\r\n”, substat->cleared);
strcat(textstr, response);
sprintf(response, “transfer :%d\r\n”, substat->transfer);
strcat(textstr, response);
sprintf(response, “byteIn :%d\r\n”, substat->byteIn);
strcat(textstr, response);
sprintf(response, “byteOut :%d\r\n”, substat->byteOut);
strcat(textstr, response);
}

External Device Initialization

Refer to the device manufacturer’s documentation on specific requirements for initializing your
IEEE 488 instrument. In the case of the ADC488, appropriate initialization involves sending it a

Clear

command and placing it into

Remote

mode:

Clear (adc) ;
Remote (adc) ;

For our hypothetical application, we also wish to have the ADC488 generate a service request should it
detect a command error. This involves sending a command string consisting of textual data to the
ADC488:

Output (adc, “M8X”) ;

We may also wish to perform other initialization and configuration. In this case, we set up the
ADC488 (

adc

) in the following configuration:

/* Setup the ADC488

Differential inputs (A0)
Scan group channel 1 (C1)
Compensated ASCII floating-point output format (G0)
Channel 1 range to +/- 10V (R3)
One-shot trigger on talk (T6)

*/

The command to perform this configuration combines the above strings and adds the

Execute

(

X

)

command for the ADC488:

Output(adc, “A0C1G0R3T6X”);

Basic Data Acquisition

With both Driver488/W31 and the external device ready for action, we next might try taking a simple
reading using the ADC488. Here, we use the serial poll (

SPoll

) capabilities of Driver488/W31 to

determine when a response is ready and to format the reply.

/* Wait for the ready bit of the ADC488 to be asserted */
while ((SPoll(adc) & 32) == 0);

/* Display the reading */
Enter(adc, response);
strcat(textstr, “ADC488 channel #1 reading value is ”);
strcat(textstr, response);
strcat(textstr, “\r\n”);