Test and Measurement Forum

16bit ADC counts VB6

Post your VB and VBA discussions here

16bit ADC counts VB6

Postby JaSon » Sat Apr 09, 2011 6:56 pm

Can someone please help me out and explain in VB6 code how to calculate 16bit ADC counts for the ps3000_set_trigger call
I am trying to set the trigger but it seems to trigger all over the place
Thanks in advance it is very much appreciated
JaSon
 

Re: 16bit ADC counts VB6

Postby Chris » Mon Apr 11, 2011 2:54 pm

You need to implement something like this......


Function mv_to_adc(mv As Long, range As Long) As Long
mv_to_adc = ((mv * 32767) / range)
End Function


Then, in the function where you're setting the trigger....

Trig = mv_to_adc(2000, 10000) REM 2000 is the trigger point (in mv). 10000 is the range selected for the channel in use (in mv)

ok = ps3000_set_trigger(ps3000_handle, 0, Trig, 0, 0, 0)
Chris
Site Admin
Site Admin
 
Posts: 169
Joined: Tue Aug 17, 2010 9:00 am
Location: St. Neots

Re: 16bit ADC counts VB6

Postby JaSon » Sat Apr 16, 2011 10:36 pm

Thank you, I have coded something fairly similar.
The trigger seems to fire whenever the voltage has any amount of sudden change, I have five 3204's available here to play with and a number in the field, all the ones I have tested act identical, so it's not hardware and must be my code.

I will give this code a try.

Thank you again
JaSon
 

Re: 16bit ADC counts VB6

Postby JaSon » Sat Apr 16, 2011 11:24 pm

Hi
After furthur analisis I found the problem to be with the DLL call

Declare Function ps3000_set_trigger Lib "ps3000.dll" (ByVal Handle As Integer, ByVal source As Integer, ByVal Threshold As Integer, ByVal direction As Integer, ByVal delay As Integer, ByVal auto_trigger_ms As Integer) As Integer

It works with

Declare Function ps3000_set_trigger Lib "ps3000.dll" (ByVal Handle As Integer, ByVal source As Integer, ByVal Threshold As Long, ByVal direction As Integer, ByVal delay As Integer, ByVal auto_trigger_ms As Integer) As Integer

Note ByVal Threshold As Long

Thanks
JaSon
 

Re: 16bit ADC counts VB6

Postby ziko » Thu Apr 21, 2011 10:53 am

Interesting I have tried this on VBA under excel and it works with Integer. Integer in VB6 is a 16 bit number so I see no reason why it should not work on integer.

Can you send some sample code?
Ziko

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


Return to VB and VBA (Excel, Access)

Who is online

Users browsing this forum: No registered users and 0 guests