Analog Output Code Example
VCM-DAS-3 Reference Manual
32
Analog Output Code Example
The following Visual BASIC code illustrates how to operate the analog output feature of the
VCM-DAS-3.
FUNCTION LIB_das3aout (BYVAL channel, BYVAL range, BYVAL voltage)
'
'Description: This function performs an
' analog output operation to the
' specified channel.
'
'Entry: channel: analog output channel (0 to 15)
' range: 0=5V, 1=10V, 2=+/-5V, 3=+/-10V
' 4=2.5V, 5=-2.5V/+7.5V
' voltage: analog output voltage (within range)
'
'Returns: 0 if no errors
' 1 if timeout occurs
'
'Examples: '5.000V on channel 0
' x = LIB_das3aout (0,1,5.000)
'
' 'Output -7.500V on channel 1
' x = LIB_das3aou (1, 3, -7.500)
'
'Enhanced Control Register (BASE + 0xA)
' D7 D6 D5 D5 D3 D2 D1 D0
' EC3 EC2 EC1 EC0 ---DAC CHANNEL---
' =====================================
' 0V to +5V 0 0 0 0
' 0V to +10V 0 0 0 1
' -5V to +5V 0 0 1 0
' -10V to +10V 0 0 1 1
'-2.5V to +2.5V
0 1 0 0
'-2.5V to +7.5V
0 1 0 1
DIM value AS INTEGER
DIM hidac AS INTEGER
DIM lodac AS INTEGER
DIM done AS INTEGER
DIM y AS INTEGER
DIM x AS INTEGER
DIM bipolar AS INTEGER
DIM fullscale AS SINGLE
SELECT CASE range
CASE 0 '+5V
bipolar = 0
fullscale = 5
CASE 1 '+10V
bipolar = 0
fullscale = 10
CASE 2 '+/-5V
bipolar = 1
fullscale = 5
CASE 3 '+/-10V