Measurement-computing Personal488 rev.3.0 For DOS & Windows 3.Xi Instrukcja Użytkownika Strona 171

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
Przeglądanie stron 170
9E. C Languages II. SOFTWARE GUIDES - 9. Driver488/SUB
II-156 Personal488 Users Manual, Rev. 3.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,&noterm,1,0L) ;
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/SUB status both before and after waiting.
/* Display DRIVER488/W31 status */
Status (ieee,&substat) ;
showstat (&substat) ;
/* Wait for completion of input operation*/
Wait (adc) ;
/* Display DRIVER488/W31 status */
Status (ieee,&substat) ;
showstat (&substat) ;
Now we process the buffer:
/* Print the received characters */
for (i=0;id;i++) {
printf (%6d,hundred [i]) ;
if ((i%10)==9)
printf (\n) ;
}
The functions described so far in this Sub-Chapter provide enough functionality for a basic data
acquisition program. The following program listing covers the examples used. Additional functions
provided by Driver488/SUB are described in the Section III: Command References of this manual.
Sample Program
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#includeiot_main.h
#includeiottx10.h
void showstat (IeeeStatusT*) ;
void isr (OpaqueP) ; /*handle inerrupt*/
DevHandleT adc,ieee,dev;
int hundred[100] ;
void main ( )
{
char response [256] ;
int i;
float voltage,
sum;
IeeeStatusT substat ;
/*establish communications with Driver488/SUB*/
if ((ieee=OpenName (IEEE))==-1) {
printf (Cannot initialize IEEE system.\n) ;
exit (1) ;
}
Przeglądanie stron 170
1 2 ... 166 167 168 169 170 171 172 173 174 175 176 ... 399 400

Komentarze do niniejszej Instrukcji

Brak uwag