Datasheet

AD664
REV.
–17–
The following IBM PC Basic routine produces four output volt-
age ramps from one AD664. Line numbers 10 through 70 de-
fine the hardware addresses for the first and second ranks of
DAC registers as well as the first and second ranks of the mode
select register. Program variables are initialized in line numbers
110 through 130. Line number 170 writes “0s” out to the first
rank and, then, the second rank of the mode select register.
Line numbers 200 through 320 calculate output voltages. Fi-
nally line numbers 410 through 450 update the first, then the
second ranks of the DAC input registers. Hardware registers
may be read with the “INP” instruction. For example, the con-
tents of the DAC A register may be accessed with the following
com mand: Line# A = INP(DACA).
5 REM----AD664 LISSAJOUS PATTERNS----
10 REM ---ASSIGN HARDWARE ADDRESSES---
20 DACA = 785
30 DACB = 787
40 DACC = 789
50 DACD = 791
60 DAC2ND = 792
70 MODE1 = 769: MODE2 = 776
80 REM
90 REM
100 REM ---INITIALIZE VARIABLES---
110 X = 0: Y1 = 128: Y2 = 64: Y3 = 32
120 CX = 1: CY1 = 1: CY2 = -1: CY3= 1
130 FX = 9: FY1 = 5: FY2 = 13: FY3 = 15
140 REM
150 REM
160 REM ---INITIALIZE MODES AND GAINS---
170 OUT MODE1,0: OUT MODE2,0
180 REM
190 REM
200 REM ---CALCULATE VARIABLES---
210 X = X + FX*CX
220 Y1 = Y1 + FY1*CY1
230 Y2 = Y2 + FY2*CY2
240 Y3 = Y3 + FY3*CY3
250 IF X > 255 THEN X = 255: CX = -1: GOTO 270
260 IF X < 0 THEN X = 0: CX = 1
270 IF Y1 > 255 THEN Y1 = 255: CY1 = -1: GOTO 290
280 IF Y1 < 0 THEN Y1 = 0: CY1 = 1
290 IF Y2 > 255 THEN Y2 = 255: CY2 = -1 GOTO 310
300 IF Y2 < 0 THEN Y2 = 0: CY2 = -1
310 IF Y3 > 255 THEN Y3 = 255: CY3 = -1: GOTO 400
320 IF Y3 < 0 THEN Y3 = 0: CY3 = 1
330 REM
340 REM
400 REM ---SEND DAC DATA---
410 OUT DACA,X
420 OUT DACB,Yl
430 OUT DACC,Y2
440 OUT DACD,Y3
450 OUT DAC2ND,0
500 REM
510 REM
520 REM ---LOOP BACK---
530 GOTO 210
D