16bit ADC counts VB6

Post your VB and VBA discussions here
Post Reply
JaSon

16bit ADC counts VB6

Post by JaSon »

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

Chris
Site Admin
Site Admin
Posts: 169
Joined: Tue Aug 17, 2010 9:00 am
Location: St. Neots

Re: 16bit ADC counts VB6

Post by Chris »

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)

JaSon

Re: 16bit ADC counts VB6

Post by JaSon »

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

Post by JaSon »

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

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

Re: 16bit ADC counts VB6

Post by ziko »

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

Post Reply