beautypg.com

Measurement Computing Personal488 rev.3.0 For DOS & Windows 3.Xi User Manual

Page 236

background image

II. SOFTWARE GUIDES - 10. Driver488/W31

10E. C Languages

Personal488 User’s Manual, Rev. 3.0

II-221

if ((adc=MakeDevice(devhandle, “ADC”))<0) {

MessageBox(hWndDlg, (LPSTR)"Cannot create ADC device", NULL,

MB_OK);

EndDialog(hWndDlg,

TRUE);

return

TRUE;

}
Close(devhandle);
break;
default:
break;
}
GetError(ieee, textstr);
BusAddress(adc, 14, -1);
/* get Driver488/W31 hello response

*/

Hello(ieee, textstr);
strcat(textstr, “\r\n”);

/* get Driver488/W31 status response

*/

Status(ieee, &substat);
showstat(&substat, textstr);

/* Clear the ADC488

*/

Clear(adc);

/* 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)
*/
Output(adc, “A0C1G0R3T6X”);

/* 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”);

/* Now aquire and display the average of 10 readings

*/

sum = 0.0;
for (i=0;i<0;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);

/* 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)
*/
Output(adc, “G10I3N100T1X”);

/* wait for the ready bit of the ADC488 to be asserted

*/

while ((SPoll(adc) & 32) == 0);
/* Trigger the ADC488 */
Trigger(adc);