Test and Measurement Forum

setting trigger causes crash 2205 VBA

Post your VB and VBA discussions here

setting trigger causes crash 2205 VBA

Postby traegeaf » Thu Nov 13, 2008 1:10 am

I have developed a macro for collecting data and entering the data into columns and rows. This is based heavily upon the sample code.

The first run of the device works flawlessly, I can open the device set up all the parameters and then collect my data and close the device.

If I attempt to run the command a second time, the macro crashes at the set_trigger function, the function never returns a value, excel just crashes.

I can run set trigger multiple times in the first runthrough, I just can't run the macro a second time through.

Any Ideas?
traegeaf
Active User
Active User
 
Posts: 14
Joined: Thu Nov 13, 2008 12:45 am

Postby ziko » Tue Nov 18, 2008 2:58 pm

Hi have you called the close unit function before it exits the macros?

Kind regards
Ziko

Technical Specialist
ziko
Zen Master
Zen Master
 
Posts: 1705
Joined: Fri Dec 01, 2006 10:03 am
Location: St Neots

Postby traegeaf » Thu Nov 20, 2008 10:11 pm

Yes, I have called the close function.

The device is reopened with out any trouble, and I can set up the channels on the second runthrough, just not the trigger.
traegeaf
Active User
Active User
 
Posts: 14
Joined: Thu Nov 13, 2008 12:45 am

Postby ziko » Fri Dec 05, 2008 12:51 pm

It could possibly be that the unit has not closed as the device was still doing some work, try calling the stop function, before the close unit to see if this helps. What product are you using by the way?

Kind regards
Ziko

Technical Specialist
ziko
Zen Master
Zen Master
 
Posts: 1705
Joined: Fri Dec 01, 2006 10:03 am
Location: St Neots

Postby traegeaf » Mon Dec 15, 2008 12:40 am

I have a 2205. And i did use the stop function.

I have included an example code which always crashes on mine. Debugging it shows that it will crash on the second set_trigger.

Code: Select all
Sub CauseCrash()


ps2000_handle = ps2000_open_unit()
   
 
  Call ps2000_set_ets(ps2000_handle, 0, 0, 0)
  Call ps2000_set_channel(ps2000_handle, 0, 1, 1, 5)
  Call ps2000_set_channel(ps2000_handle, 1, 0, 0, 4)
   
'This trigger set up works perfectly
 
  Call ps2000_set_trigger2(ps2000_handle, 0, trigger, 0, 0, timeout_ms)
 
  Call ps2000_stop(ps2000_handle)
  Call ps2000_close_unit(ps2000_handle)
   
'If I manually restart excel here, I can run the the code twice. 
'2nd run though
ps2000_handle = ps2000_open_unit()

 
  Call ps2000_set_ets(ps2000_handle, 0, 0, 0)
  Call ps2000_set_channel(ps2000_handle, 0, 1, 1, 5)
  Call ps2000_set_channel(ps2000_handle, 1, 0, 0, 4)
   
'This causes a crash, although it worked fine the first time it was opened
 
  Call ps2000_set_trigger2(ps2000_handle, 0, trigger, 0, 0, timeout_ms)
 
  Call ps2000_stop(ps2000_handle)
  Call ps2000_close_unit(ps2000_handle)
End Sub


This happens using both set_trigger and set_trigger2.

-Thanks
Adam
traegeaf
Active User
Active User
 
Posts: 14
Joined: Thu Nov 13, 2008 12:45 am

Postby ziko » Mon Dec 15, 2008 12:01 pm

Hi Adam,

One of our software engineers has tried this without incident What driver version are you using?

Kind regards
Ziko

Technical Specialist
ziko
Zen Master
Zen Master
 
Posts: 1705
Joined: Fri Dec 01, 2006 10:03 am
Location: St Neots

Postby traegeaf » Mon Dec 15, 2008 5:00 pm

This could be an issue. I was using 2.0.5.5 from the r1.0 sdk. and now I see that it has been outdated for a while.


I will try the new sdk release and get back to you.
traegeaf
Active User
Active User
 
Posts: 14
Joined: Thu Nov 13, 2008 12:45 am

Postby traegeaf » Mon Dec 15, 2008 7:39 pm

Updating the driver and dll file appears to have fixed my issue.

Thanks for you help.
-Adam
traegeaf
Active User
Active User
 
Posts: 14
Joined: Thu Nov 13, 2008 12:45 am


Return to VB and VBA (Excel, Access)

Who is online

Users browsing this forum: No registered users and 0 guests