'*******************  A-628 DEMO Program  ************************
'*    A-628 8 Channel analog output Board                        *
'*    Demo program for Quick Basic                               *
'*    Write By Hybertek Co. LTD., Richard Chen                   *
'*    Date 01.15.199                                             *
'*****************************************************************
CLS

PRINT " Set A-628  1. Unipoar Mode "
PRINT "            2. Vref = 5V "
PRINT "            3. Current Loop"
PRINT "            4. you should input a external power (Over 9V) in current loop circurt"
PRINT " Analog output Range = 0 - 5V"
PRINT " Press < Enter > Key Analog Current output Channel 0 Will Output  10mA"
INPUT a

Bas = &H2C0     ' Set base Address  (Def address)

Vref = 20      ' Set Reference Voltage By Jumper JP1- JP8
               ' Current LOOP 40mA)

VOCH = 0       ' Set Analog output Channel VOCH=0-7

Vo = 10       ' Current output 10mA

                                           ' 4~20mA
Vdata = ((Vo - 4) * 4095 / (Vref - 4)) + 4 ' Conversion Current to 12 bit Data (Unipolar)
            



Hibyte = FIX(Vdata / 256)          ' 4 bit data D8-D11 (High byte)
Lobyte = Vdata - (Hibyte * 256)    ' 8 bit data D0-D7  (Low byte)

                                  ' Write Data to D/A Convision
OUT Bas + VOCH * 2, Hibyte        ' High byte First
OUT Bas + VOCH * 2 + 1, Lobyte    ' Then Low Byte











