|
|
| Author |
Message |
buonviri User

Joined: 04 Oct 2005
Posts: 2
|
Posted: Tue Oct 11, 2005 2:49 pm Post subject: VBA/Excel question |
|
|
Any idea what's wrong with my Visual Basic for Applications (Excel) code?
| Code: |
Sub SignalGeneratorTest()
ps3000_handle = ps3000_open_unit()
Call ps3000_set_trigger(ps3000_handle, 5, 0, 0, 0, 0)
Call ps3000_set_siggen(ps3000_handle, 1, 1000, 1000, 0, 0, 0, 0)
Call ps3000_flash_led(1)
Call ps3000_flash_led(1)
Call ps3000_flash_led(1)
Call ps3000_flash_led(1)
Call ps3000_flash_led(1)
Call ps3000_flash_led(1)
ps3000_stop (ps3000_handle)
End Sub
|
I put the LED flashes in there to make sure it was actually doing something, and pause while I check the output with another scope. I am trying to disable the trigger in line 3, and enable the generator in line 4, a 1kHz square wave. But nothing happens. If I run the picoscope program and enable the signal generator that way, it works fine, but the code above does not enable the signal generator feature. |
|
| Back to top |
|
 |
Michael Guru

Joined: 07 Jul 2005
Posts: 93
Location: St Neots, Cambridgeshire
|
Posted: Thu Oct 13, 2005 3:16 pm Post subject: |
|
|
Hello,
I have tried your code and found no problem in this standard form.
The Signal generator exists outside the trigger and sampling functions therefore needs to be disabled in the way it is enabled, using ps3000_Stop will not work!
Here is the altered code to show how i did it. We added the OK's to watch the output and pass to an If statement to track any errors.
Sub SignalGeneratorTest()
Dim trigok As Integer
Dim sigok As Integer
ps3000_handle = ps3000_open_unit()
'trigok = ps3000_set_trigger(ps3000_handle, 5, 0, 0, 0, 0)
'Removed trigger as not required for this
sigok = ps3000_set_siggen(ps3000_handle, 2, 1000, 1000, 0, 0, 0, 0)
'sigok should come back with the frequency of 1000
Call ps3000_flash_led(1) 'Flash the light a couple times
Call ps3000_flash_led(1)
Call ps3000_flash_led(1)
Call ps3000_flash_led(1)
Call ps3000_flash_led(1)
'Call ps3000_stop(ps3000_handle) 'doesn't work with siggen
Call ps3000_close_unit(ps3000_handle) 'close unit completely
End Sub
If it still does not work, try downloading the latest drivers from the internet.
Best regards,
Michael - Tech Support |
|
| Back to top |
|
 |
buonviri User

Joined: 04 Oct 2005
Posts: 2
|
Posted: Thu Oct 13, 2005 8:36 pm Post subject: Works Now |
|
|
I'm not sure why it didn't work for me before, but it seems to be working now. Maybe Excel had crashed one too many times yesterday.
Two things I found out: don't add MsgBox status indicators while the scope is open (even if it's idle) because the Picoscope display that freezes Excel won't let you click OK to dismiss the box. And more importantly, for those of us that can't use the defines in the header files, the section of the manual that says "PS3000_SINE (0), PS3000_SQUARE (1) or PS3000_TRIANGLE (2)" is wrong. 0 is square, 1 is triangle, and 2 is sine (at least in VBA it is). |
|
| Back to top |
|
 |
|
Powered by phpBB © 2001, 2005 phpBB Group
|