DECLARE FUNCTION analogrd% (chan%) 'AD_INT.BAS ' ' Analog Input Routines for the SBC1190 with 8 Channel A/D option ' ' This example uses the special Micro/sys system interrupt to ' read from the onboard A/D convertor. ' ' ' The following command lines will compile and link this program ' ' BC AD_INT.BAS /o; ' LINK AD_INT QB.LIB; ' ' 8/3/98 '$INCLUDE: 'qb.bi' 'The following line allows output to be redirected out the COM1 port if 'there is no video card installed. Otherwise, QuickBASIC uses direct 'writes to video RAM. OPEN "CONS:" FOR OUTPUT AS #1 PRINT #1, "Reading 8 channels" PRINT #1, "Ch0 Ch1 Ch2 Ch3 Ch4 Ch5 Ch6 Ch7" forever: FOR n% = 0 TO 7 PRINT #1, USING "####"; analogrd(n%); PRINT #1, " "; NEXT PRINT #1, CHR$(13); GOTO forever FUNCTION analogrd% (chan%) ' This function reads analog input in the range set by configadc() ' given a channel number of 0 to 7 DIM InRegs AS RegType, OutRegs AS RegType InRegs.ax = &H4D20 'Micro/sys system function, start ADC InRegs.bx = chan% + (RNGE10VBIP * 256) CALL INTERRUPT(&H1A, InRegs, OutRegs) 'start the conversion DO InRegs.ax = &H4D21 'Micro/sys system function, check ADC CALL INTERRUPT(&H1A, InRegs, OutRegs) 'start the conversion LOOP WHILE (OutRegs.bx AND &HFF) = 0 analogrd% = OutRegs.ax END FUNCTION