2. プログラム
10 ! Example program for ines data acquisition cards
20 ! Uses CSUBS to perform actions
30 ! Takes reading on DIO port A. Data transfer of INTEGER data!
40 !
50 OPTION BASE 0
60 GINIT
70 CLEAR SCREEN
80 IF INMEM("Daqhtb_ioctl") THEN GOTO Skip_loadsub
90 LOADSUB ALL FROM "c:\inesdio\htbasic\daqhtb.csb"
100 Skip_loadsub: !
110 INTEGER D(1)! Data arrays, sizes must be 2,4,6,8,...
120 INTEGER Daqerr! error variable for DAQ interface
130 DIM Daqerr$[128]! error string
140 DIM B$[32]
150 INTEGER Hdio,Cdio! Device handle for digital I/O port, samples
read
160 DATA "i403","i480"
170 ! Initialise card
180 CALL Daqhtb_init
190 ! Open devices
200 ! This function looks for a card present
210 RESTORE
220 FOR I=0 TO 1
230 READ B$
240 C$=B$&" DIO A"
250 CALL Daqhtb_open(Hdio,C$,1)! Note that opening mode is 1 for
integer data transfer
260 IF Hdio>0 THEN GOTO 310
270 NEXT I
280 CALL Daqhtb_error(Hadc,Daqerr$)
290 PRINT "Error occurred: "&Daqerr$
300 STOP
310 REM Digital I/O port is accessible
320 PRINT "Found card type: ";B$
330 !Card found, now take a reading
340 CALL Daqhtb_ioctl(Hdio,"( iod ( bvdir 0 ) ) ")!bvdir
or dir
350 CALL Daqhtb_readi(Cdio,Hdio,D(*))
360 ! Close devices
370 CALL Daqhtb_close(Hdio)
380 ! Show port data
390 PRINT "Digital I/O port status: ";D(0)! Values are
in the range 0..255, D(0) is OK
400 DELSUB Daqhtb_ioctl TO END
410 GOTO 420
420 END
430 SUB Daqhtb_error(INTEGER Err)
440 Daqerr$="( fctn geterr ) "
450 CALL Daqhtb_ioctl(Err,Daqerr$)
460 PRINT "DAQ error occurred: "&Daqerr$
470 SUBEND
480 SUB Daqhtb_init
490 INTEGER Dummy
500 CALL Daqhtb_ioctl(Dummy,"( fctn init) ")
510 SUBEND |
|