setting trigger causes crash 2205 VBA

Post your VB and VBA discussions here
Post Reply
traegeaf
Active User
Active User
Posts: 14
Joined: Thu Nov 13, 2008 12:45 am

setting trigger causes crash 2205 VBA

Post by traegeaf »

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?

ziko
Advanced User
Advanced User
Posts: 1705
Joined: Fri Dec 01, 2006 10:03 am
Location: St Neots

Post by ziko »

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

Kind regards
Ziko

Technical Specialist

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

Post by traegeaf »

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.

ziko
Advanced User
Advanced User
Posts: 1705
Joined: Fri Dec 01, 2006 10:03 am
Location: St Neots

Post by ziko »

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

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

Post by traegeaf »

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

ziko
Advanced User
Advanced User
Posts: 1705
Joined: Fri Dec 01, 2006 10:03 am
Location: St Neots

Post by ziko »

Hi Adam,

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

Kind regards
Ziko

Technical Specialist

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

Post by traegeaf »

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

Post by traegeaf »

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

Thanks for you help.
-Adam

Post Reply