Sei sulla pagina 1di 2

MODULE 1 DECLARATIONS..Do not modify.

MODULE 2
Sub GetData()
Dim handle As Integer
Dim status As Long
Dim channels(10) As Long By changing (10) you set the number of channels that you wish to read.
Dim ready As Integer
Dim overflow As Integer
Dim triggerIndex As Long
Dim nValues As Long
Dim values(1000) As Integer This is the product of number of channels time the number of readings :. e.g.
10 channels * 100 readings = 1000
Dim i As Integer
Dim Row As Integer
Dim requiredSize As Integer
Dim S As String * 255
Range("A1:Z65536").Clear
status = UsbDrDaqOpenUnit(handle
If status <> 0 Then
MsgBox "Unit not opened", vbOKOnly, "Error Message"
Cells(11, "L").value = "DrDAQ not opened"
Exit Sub
End If
' Get the unit information..this section finds the information of you specific DrDAQ. Do not modify.
Cells(10, "L").value = "Unit opened"
SLegnth = UsbDrDaqGetUnitInfo(handle, S, 255, requiredSize, 3)
Cells(11, "L").value = S
SLegnth = UsbDrDaqGetUnitInfo(handle, S, 255, requiredSize, 4)
Cells(12, "L").value = "Serial number:"
Cells(12, "M").value = S
SLegnth = UsbDrDaqGetUnitInfo(handle, S, 255, requiredSize, 0)
Cells(13, "L").value = "Driver version:"
Cells(13, "M").value = S
'Set Digital output.........This section pre-sets the initial value of the Digital Outputs. Modify as per your needs.
status = UsbDrDaqSetDO(handle, 1, 1)
status = UsbDrDaqSetDO(handle, 1, 0)
'Collect a 1 second block containing 100 samples on all channels.This description must be changed according to
your needs, by REMOVING the channels you do not need.
channels(0) = 1
channels(1) = 2
channels(2) = 3
channels(3) = 4
channels(4) = 5
channels(5) = 6
channels(6) = 7
channels(7) = 8
channels(8) = 9
channels(9) = 10
A B
C
status = UsbDrDaqSetInterval(handle, 1000000, 100, channels(0), 10) This is a very important entry : A is the time
taken in the reading of data in microseconds : e.g. 1 million microseconds = 1 second. B is the number of readings and
C is the number of channels, so you now know what to modify according to your need.
If status <> 0 Then
MsgBox "Settings error", vbOKOnly, "Error Message"
Call UsbDrDaqCloseUnit(handle)
Exit Sub
End If

MODULE 3
ready = 0
status = UsbDrDaqRun(handle, 100, 0)100 is the number of readings which must be modified according to your needs.
If status <> 0 Then
MsgBox "Run error", vbOKOnly, "Error Message"
Call UsbDrDaqCloseUnit(handle)
Exit Sub
End If
Do While ready = 0
status = UsbDrDaqReady(handle, ready)
Loop
nValues = 100100 is the number of readings which must be modified according to your needs.
Call UsbDrDaqGetValues(handle, values(0), nValues, overflow, triggerIndex)
Call UsbDrDaqCloseUnit(handle)
'Display values.Here below you must choose the channels you need and erase the ones you do not need.
Cells(1, "A").value = "Ext. 1"
Cells(1, "B").value = "Ext. 2"
Cells(1, "C").value = "Ext. 3"
Cells(1, "D").value = "Scope"
Cells(1, "E").value = "PH"
Cells(1, "F").value = "Resistance"
Cells(1, "G").value = "Light"
Cells(1, "H").value = "Thermistor"
Cells(1, "I").value = "Mic. wavform"
Cells(1, "J").value = "Mic. Level"
i=0
..The example will show you how to move the columns in order to make place for the TIME
column which will be needed to make the instant graph. Again the entries not needed must be erased.
For Row = 2 To nValues + 1
Cells(Row, "A").value = values(i)
Cells(Row, "B").value = values(i + 1)
Cells(Row, "C").value = values(i + 2)
Cells(Row, "D").value = values(i + 3)
Cells(Row, "E").value = values(i + 4)
Cells(Row, "F").value = values(i + 5)
Cells(Row, "G").value = values(i + 6)
Cells(Row, "H").value = values(i + 7)
Cells(Row, "I").value = values(i + 8)
Cells(Row, "J").value = values(i + 9)
i = i + 10
Next Row
End Sub

Potrebbero piacerti anche