'***************************************************************************** '* QSAMPLE4.BAS : DIGITAL TO ANALOG OUTPUT * '* LAST MODIFICATION: 2/3/98 * '*****************************************************************************/ ' Dimension the paramter passing variables. DIM task%, stat%, param%(5) COMMON SHARED param% ' This is the driver entry point declaration DECLARE SUB A16DRV (task%, BYVAL param%, stat%) DECLARE FUNCTION AskForBaseAddress! (OldOne AS INTEGER) CLS PRINT " QSAMPLE4.BAS : DIGITAL TO ANALOG OUTPUT" PRINT PRINT " This is a demonstration program to be used with the ACCES AD12-16 A/D" PRINT " board. The program will prompt tyhe user for a voltage, output it to" PRINT " Digital to Analog channel 0 kthen read it back on channel 0 A/D. This" PRINT " program demostrates initializing the driver(task 0),setting the scan" PRINT " limits(task 1), performing analog output(task 15) and performing analog" PRINT " input(task 3)." PRINT PRINT Address% = AskForBaseAddress!(&H350) CLS PRINT : PRINT : PRINT PRINT "Board Configuration:" PRINT PRINT " -- Base address is "; HEX$(Address%); " hex" PRINT " -- IRQ5 is used for interrupts (required)" PRINT " -- Polarity set to bipolar (required)" PRINT " -- Range is from 0 to 5 volts (required)" PRINT " -- DMA channel 1 (required)" PRINT " -- On board clock set to 1 MHz (required)" PRINT " -- A jumper is needed from pin 8 to pin 10." PRINT " -- A jumper is needed from pin 37 to pin 9." PRINT " -- All remaining jumper settings are irrelevant" PRINT : PRINT : PRINT PRINT "Press ENTER to continue." INPUT ""; Msg$ ' Initialize Driver task% = 0 param%(1) = Address% 'assign base address param%(2) = 5 'set IRQ5 param%(3) = 1 'set DMA channel 1 GOSUB HANDLER 'program the base address and int # 'set mux channel scan limits task% = 1 param%(1) = 0 'lower channel limit is 0 param%(2) = 0 'upper channel limit is 0 GOSUB HANDLER DO CLS ' get output voltage from user and compute counts INPUT "INPUT A VOLTAGE (0 - 5):"; VOLTS! VOLTS! = VOLTS! / 5 * 4095 param%(2) = FIX(VOLTS!) ' output the counts to the DAC task% = 15 param%(1) = 0 'D/A channel 0 GOSUB HANDLER 'read back the voltage on the A/D task% = 3 GOSUB HANDLER VOLTS! = param%(1) / 2047 * 5 PRINT PRINT USING " The value read is: ####.###"; VOLTS! PRINT 'Wait for the operator. PRINT "Press any key to rescan the data; press the [Esc] key to Quit"; C$ = INPUT$(1) IF C$ = CHR$(27) THEN CLS SYSTEM END IF LOOP END '***************************************************************************** '* FUNCTION: HANDLER -- local routine * '* * '* PURPOSE: Performs the call to the driver package. * '* * '* INPUT: None. * '* * '* CALLS: AO16DRV - entry point to driver package. * '* * '* OUTPUT: Returns the error code supplied by the driver routine. * '* * '*****************************************************************************/ HANDLER: stat% = 0 CALL A16DRV(task%, VARPTR(param%(1)), stat%) IF stat% THEN 'error has occurred PRINT "TASK"; task%; "has error code"; stat% PRINT "PROGRAM TERMINATED.." SYSTEM END IF RETURN FUNCTION AskForBaseAddress (OldOne AS INTEGER) Msg$ = "" NewOne% = 0: Success = 0: Dummy% = 0 AddrInputPosX = 0: AddrInputPosY = 0 PRINT "Please enter the Base Address (0000-FFFF) for your card (in hex)" PRINT "or press ENTER for "; HEX$(OldOne%); "." PRINT ">"; AddrInputPosX = POS(0): AddrInputPosY = CSRLIN WHILE Success = 0 LOCATE AddrInputPosY, AddrInputPosX PRINT " " LOCATE AddrInputPosY, AddrInputPosX LINE INPUT Msg$ NewOne% = VAL("&H0" + LEFT$(Msg$, 4)) Success = 1 Dummy% = NewOne% IF (Msg$ = "") THEN LOCATE AddrInputPosY, AddrInputPosX PRINT HEX$(OldOne%) Success = 1 Dummy% = OldOne% END IF WEND AskForBaseAddress = Dummy% END FUNCTION