Hi!
Yes we have tried with your example and it's working fine, but it' s just single mode and we need to use streaming mode, so now we have modified it a little.
Instead of your Timer1_timer -function we use this function. (for the moment just with two channels)
- Code: Select all
Private Sub Get_Readings()
ReDim temp_buffer(1000) As Single
Dim times_ms_buffer(9) As Long
Dim overflow_flag(9) As Integer
Dim channel As Integer
Dim nr_of_readings As Integer
Dim counter As Integer
Dim r As Integer
Dim k As Variant
If (Not in_timer) Then
in_timer = True
For channel = 0 To 1 Step 1
nr_of_readings = usb_tc08_get_temp(tc08_handle, temp_buffer(channel), times_ms_buffer(channel), 800, overflow_flag(channel), channel, 0, 0)
If (nr_of_readings) > 0 Then
counter = 0
r = rw(channel)
k = clmn(channel)
Do
Cells(r, k).Value = temp_buffer(counter)
counter = counter + 1
r = r + 1
Loop While counter < nr_of_readings
rw(channel) = r
ElseIf nr_of_readings < 0 Then
Cells(6, "I").Value = "Get Readings, Error Code: " & usb_tc08_get_last_error(tc08_handle)
in_timer = False
Call Stop_Streaming
Call Close_tc08
Exit Sub
Else
Cells(7, "I").Value = "Nr of readings from channel (channel) = 0"
End If
'ReDim temp_buffer(1000) As Single
Next channel
'Cells(10, "I").Value = times_ms_buffer()
in_timer = False
End If
If running > 0 Then
Application.OnTime Now + TimeValue("00:00:30"), "Get_Readings"
End If
End Sub
Following arrays are used to take care of where to write the results on the excel sheet. They are defined under the Open_tc08 -function.
rw = Array(12, 12, 12, 12, 12, 12)
clmn = Array("A", "B", "C", "D", "E", "F")
What about the size of temp_buffer. Is it too small? I'm not really sure about how it works.
I've tried with slower streaming, like 30 ms and then manually debugged the code, and it works fine.
From monday I'm on vacation four weeks so nothing happens here until after that, but I really hope we could solve this problem in august.
Regards
Gabi