Test and Measurement Forum

streaming with tc-08 and using excel

Post general discussions on using our drivers to write your own software here

streaming with tc-08 and using excel

Postby gabi » Tue Jul 12, 2005 10:25 am

I'm trying to read values into an excel sheet while streaming with tc-08 (usb) but get the message "Not enough memory" or somethimes the application just closes.
I'm using XP Professional SP1 on a Pentium 2,8 GHz with 504 MB Ram.
I've tried to shut down all other applications but I'm not authorized to shut down F-secure as long as my computer is in the network. Could this be the problem? Is it processor capacity or Ram that give me problems?

The code works fine in while debugging so that's not the problem.
gabi
 

Postby Sarah » Wed Jul 13, 2005 12:48 pm

Hi

Thank you for your post.

Are you using our example? If not then try using ours to see if this works. Let me know how you get on with this.

Best Regards
Sarah
 

Postby Guest » Fri Jul 15, 2005 6:08 am

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
Guest
 

Postby gabi » Tue Sep 06, 2005 12:39 pm

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.

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


Regards
gabi
gabi
 

Postby Guest » Tue Sep 06, 2005 12:40 pm

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.

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
                       
          End If
           
    Next channel


Regards
gabi
Guest
 

Postby Michael » Wed Sep 07, 2005 9:52 am

Hello Gabi,

Thank you for your post.

Try the usb_tc08_get_last_error command. If you get a error code 3 returned, you will need to add the following function declaration and remove or comment the previous version.

Declare Function usb_tc08_get_single Lib "c:\usbtc08.dll" (ByVal handle As Integer, temp As Single, ByRef overflow_flags, ByVal units As Integer) As Integer

If this does not solve your problems, please get back to us.

Best regards,
Michael
Michael - Tech Support
Pico Technology
Web Support Forum
Michael
Zen Master
Zen Master
 
Posts: 656
Joined: Thu Jul 07, 2005 12:41 pm
Location: St Neots, Cambridgeshire

Postby gabi » Thu Sep 08, 2005 7:52 am

Thank you for your answer!

Now It's working a little better with the other declaration (error code was 3), but I still have problems with "Not enough memory". I think it could be something in my code.

When finding out how many readings there is from every channel i use this function:
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)

where channel is 0 to 9

But how do I retrieve the values of the readings for the channels. I can't really figure this out. I've tried to read the example for streaming mode but there is just this part, and then it says that "now do something with the readings". I've tried looping through the temp_buffer variable like you can see in my code above. Is that the right way to do it? How do I define the temp_buffer variable?

Hoping for answers
gabi
gabi
 

Postby Michael » Thu Sep 08, 2005 2:59 pm

Hello Gabi,

Thank you for your post.

Nearly there! You will need to set up each channel that you wish to use. The usb_tc08_set_channel command must be called for each channel. You can then call the usb_tc08_run command to start streaming all like this:
Sub Open_Click()
Dim ok As Integer

If (tc08_handle < 1) Then
Cells(14, "E").value = "Opening TC-08"
tc08_handle = usb_tc08_open_unit()
If (tc08_handle > 0) Then
Cells(14, "E").value = "TC-08 opened"
Call usb_tc08_set_mains(tc08_handle, True)
ok = usb_tc08_set_channel(tc08_handle, 0, Asc("k")) 'Set for each ch
ok = usb_tc08_set_channel(tc08_handle, 1, Asc("k"))
ok = usb_tc08_set_channel(tc08_handle, 2, Asc("k"))
ok = usb_tc08_run(tc08_handle, 1000) 'Start streaming!
'Call Timer1_Timer 'Not required
Else
If (tc08_handle = 0) Then
Cells(14, "E").value = "Unable to open TC-08"
Else
Cells(14, "E").value = "Error Code: " & usb_tc08_get_last_error(0)
End If
End If
End If

You can now call your Get_Readings sub to start!

Best regards,
Michael
Michael - Tech Support
Pico Technology
Web Support Forum
Michael
Zen Master
Zen Master
 
Posts: 656
Joined: Thu Jul 07, 2005 12:41 pm
Location: St Neots, Cambridgeshire

Postby Guest » Wed Sep 21, 2005 9:57 am

Hello again!

Yes, I have already that code. It's the looping throug the temp_buffer that's the problem.

When finding out the number of readings, should temp_buffer be defined like "Dim temp_buffer(9)" if I use nine channels?
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)


But how can I use the same variable when retreiving the readings?
Do I instead have to define the temp_variable so it can hold 500 readings or so?

Code: Select all
Do Until i = nr_of_readings + 1
                Cells(r, k).Value = temp_buffer(i)
                i = i + 1
Loop


Because it's at this part of the code that i get the error message "Not enough memory", or Excel just shuts down. Please help, I really have problem understanding this part.

regards
Gabi
Guest
 


Return to General Software Discussions

Who is online

Users browsing this forum: No registered users and 0 guests