beautypg.com

Block data acquisition – Measurement Computing Personal488 rev.3.0 For DOS & Windows 3.Xi User Manual

Page 231

background image

10E. C Languages

II. SOFTWARE GUIDES - 10. Driver488/W31

II-216

Personal488 User’s Manual, Rev. 3.0

/* Now acquire and display the average of 10 readings */
sum = 0.0;
for (i=0;i<10;i++) {

Enter(adc,response);
sscanf(response,"%lf",&voltage);
sum+=voltage;

}
sum/=10.0;

sprintf(response, “The average of 10 readings is %lf\r\n”, sum);
strcat(textstr, response);

Block Data Acquisition

First, we set up the ADC488 (

adc

) in the following configuration:

/* Setup the ADC488:

Compensated binary output format (G10)
100 uSec scan interval (I3)
No pre-trigger scans, 100 post-trigger scans (N100)
Continuous trigger on GET (T1)

*/

We then wait for the ADC488 to start the acquisition process. Once the acquisition is complete, which
is determined by the MSB of the ADC488’s serial poll response, the buffer pointer of the ADC488 is
reset (

B0

).

Output(adc, “G10I3N100T1X”);

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

/* Trigger the ADC488 */
Trigger(adc);

/* wait for the acquisition complete bit of ADC488 to be asserted */
while ((SPoll(adc) & 128) == 0);

/* Reset the buffer pointer of the ADC488 */
Output(adc, “B0X”);

Next, we fill the buffer with 100 readings from the ADC488. Since the data being returned from the
ADC488 is in a binary format, the

noterm

terminator structure is used to disable scanning for

terminators such as carriage return and line feed.

noterm.EOI = 0;
noterm.nChar = 0;
EnterX(adc, (char *)hundred, 200, 1, ¬erm, 1, 0);

The

EnterX

function will use a DMA transfer if available. Because DMA transfers are performed

entirely by the hardware, the program can continue with other work while the DMA transfer function
occurs. For example, the program will process the previous set of data while collecting a new set of
data into a different buffer. However, before processing the data we must wait for the transfer to
complete. For illustration purposes, we query the Driver488/W31 status both before and after waiting.

/* Display DRIVER488/W31 status */
Status(ieee, &substat);
showstat(&substat, textstr);

/* Wait for completion of input operation*/
Wait(adc);

/* Display DRIVER488/W31 status */
Status(ieee, &substat);
showstat(&substat, textstr);