C     .TITLE DATEST
C
C  21 JUN 74 - PAUL HENDERSON
C
C  PROGRAM TO OUTPUT VALUES ON D-A CONVERTER & READ THEM BACK
C  VIA THE HYBRID INTERFACE, THUS BYPASSING THE A-D CONVERTER,
C  AND ALSO READING THE A-D CONVERTER TO CHECK IT AS WELL.
C
      INTEGER AD,DA,DVM
C
   1  CALL INIT (IER)
      IF (IER.GT.0) WRITE (4,*) 'INIT ERROR',IER
C
      DO 3 I=0,5
C
C               PUT HEADINGS ON NEW PAGE
C
         WRITE (6,998) I
         WRITE (6,997)
C
C               SELECT ANALOG TRUNK '40+I' WHICH CORRESPONDS TO
C               D-A CHANNEL 'I'.
C
         CALL SACO (3,40+I,IER)
         IF (IER.GT.0) WRITE (4,*) 'SACO ERROR',IER
C
C               NOW PERFORM CYCLE OF D-A CONVERSIONS, READING VALUES
C               BACK VIA THE HYBRID INTERFACE, AS WELL AS
C               VIA THE A-D CONVERTER
C
         DO 2 K= -10000,+10000,500
            DA = FLOAT(K)*13.1071
            CALL LTDA (I,DA,IER)
            IF (IER.NE.0) WRITE (4,*) 'LTDA ERROR',IER
            CALL DVMC
            CALL DVMR (DVM,IER)
            IF (IER.NE.0) WRITE (4,*) 'DVMR ERROR',IER
            CALL CRAC (30+I,AD,IER)
            AD = FLOAT(AD)/13.1071
            IF (IER.NE.0) WRITE (4,*) 'CRAC ERROR',IER
            WRITE (6,999) K,DVM,DVM-K,AD,DVM,AD-DVM,AD-K
   2        CONTINUE
   3     CONTINUE
      STOP
 999  FORMAT (1X3I10,10X4I10)
 998  FORMAT ('1',20X,'D-A CHANNEL',I2//)
 997  FORMAT (1XT7,'D-A',T19,'DVM DIFFERENCE',T47,'A-D',T59,
     *'DVM DIFFERENCE',T76,'DA-AD'/)
      END
