PicoScope 7 Software
Available on Windows, Mac and Linux
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
Code: Select all
For channel = 0 To 4 Step 1
nr_of_readings = usb_tc08_get_temp(tc08_handle, temp_buffer(channel), times_ms_buffer, 500, overflow_flag(channel), channel, 0, 0)
If (nr_of_readings) > 0 Then
i = 0
r = rw(channel)
k = clmn(channel)
Cells(11, k).Value = nr_of_readings
Do Until i = nr_of_readings
Cells(r, k).Value = temp_buffer(i)
i = i + 1
r = r + 1
Loop
rw(channel) = r
'For i = 1 To nr_of_readings
'result(i, channel) = temp_buffer(channel)
'Next i
End If
Next channel
gabi wrote:Hello!
I've still not found out what the problem is. Could anybody help me.
Is there some problem with my code? It's in this part (see below) that the program just closes. Or is the problem just that streaming and excel/vba doesn't go together ?? Please help. As I wrote before there is no problem in single mode.
RegardsCode: Select all
For channel = 0 To 4 Step 1 nr_of_readings = usb_tc08_get_temp(tc08_handle, temp_buffer(channel), times_ms_buffer, 500, overflow_flag(channel), channel, 0, 0) If (nr_of_readings) > 0 Then i = 0 r = rw(channel) k = clmn(channel) Cells(11, k).Value = nr_of_readings Do Until i = nr_of_readings Cells(r, k).Value = temp_buffer(i) i = i + 1 r = r + 1 Loop rw(channel) = r End If Next channel
gabi
Code: Select all
Dim temp_buffer(9) As Single
nr_of_readings = usb_tc08_get_temp(tc08_handle, temp_buffer(channel), times_ms_buffer, 500, overflow_flag(channel), channel, 0, 0)
Code: Select all
nr_of_readings = usb_tc08_get_temp(tc08_handle, temp_buffer(channel), times_ms_buffer, 500, overflow_flag(channel), channel, 0, 0)
Code: Select all
Do Until i = nr_of_readings + 1
Cells(r, k).Value = temp_buffer(i)
i = i + 1
Loop