Test and Measurement Forum

Problem when using getsingle function

Post your VB and VBA discussions here

Problem when using getsingle function

Postby mb91 » Wed Nov 20, 2013 2:11 pm

Hi,
I'm using a pico1216 to read 4 different voltages (among other parameters) of a rig and then log them excel using a vba loop.

When I check the voltages using the pico log recorder program , the values are as they should be and track the actual rig voltages accurately and independently (ie between 0-2.5V and tracking the 0-25V of my rig), however, when using the GetSingle function in a vba macro, the readings for all 4 voltage channels all come back as 4095, ie the ADC Max Value if there's any voltage going through the rig.

Other parameters being called using the getsingle function work well, it's only the voltage readings which return this maxvalue.

This are my declaration: for the get single command

1000GetSingle Lib "pl1000.dll" (ByVal handle As Integer, ByVal channel As Integer, ByRef value As Integer) As Long

And the voltage part of my calling sub is:
.
.
.
.
Else
Status = pl1000GetSingle(handle, 1, Value1)
Status = pl1000GetSingle(handle, 2, Value2)
Status = pl1000GetSingle(handle, 3, Value3)
Status = pl1000GetSingle(handle, 4, Value4)

'Voltage
Worksheets("live data").Cells(3, 2) = Value1
Worksheets("live data").Cells(4, 2) = Value2
Worksheets("live data").Cells(5, 2) = Value3
Worksheets("live data").Cells(6, 2) = Value4
.
.
.

Any ideas on how I can fix this?

Thanks In Advance

Mike
mb91
Newbie
 
Posts: 0
Joined: Wed Nov 20, 2013 1:43 pm

Re: Problem when using getsingle function

Postby Martyn » Thu Nov 21, 2013 7:45 am

What status return codes are you getting ?

Is it possible to post the code, or section of it, showing all the calls and declarations you are using ?
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2339
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Problem when using getsingle function

Postby mb91 » Fri Nov 22, 2013 2:19 pm

I'm getting a 0 / PICO OK on all of the calling lines

My Declarations are:

Code: Select all
Declare Function pl1000OpenUnit Lib "pl1000.dll" (ByRef handle As Integer) As Long
Declare Function pl1000CloseUnit Lib "pl1000.dll" (ByVal handle As Integer) As Long
Declare Function pl1000GetUnitInfo Lib "pl1000.dll" (ByVal handle As Integer, ByVal S As String, ByVal lth As Integer, ByRef requiredSize As Integer, ByVal info As Integer) As Integer
Declare Function pl1000SetTrigger Lib "pl1000.dll" (ByVal handle As Integer, ByVal enabled As Integer, ByVal enable_auto As Integer, ByVal auto_ms As Integer, ByVal channel As Integer, ByVal dir As Integer, ByVal threshold As Integer, ByVal hysterisis As Integer, ByVal delay As Single) As Integer
Declare Function pl1000SetInterval Lib "pl1000.dll" (ByVal handle As Integer, ByRef us_for_block As Long, ByVal ideal_no_of_samples As Long, channels As Integer, ByVal No_of_channels As Integer) As Long
Declare Function pl1000GetSingle Lib "pl1000.dll" (ByVal handle As Integer, ByVal channel As Integer, ByRef value As Integer) As Long
Declare Function pl1000Run Lib "pl1000.dll" (ByVal handle As Integer, ByVal no_of_values As Long, ByVal method As Integer) As Integer
Declare Function pl1000Ready Lib "pl1000.dll" (ByVal handle As Integer, ByRef ready As Integer) As Long
Declare Function pl1000MaxValue Lib "pl1000.dll" (ByVal handle As Integer, ByRef maxValue As Integer) As Long
Declare Function pl1000SetDo Lib "pl1000.dll" (ByVal handle As Integer, ByVal do_value As Integer, ByVal doNo As Integer) As Long



And the start of the sub with all of the calling lines are:

Code: Select all
Sub startpico1()

flagpicostarted = True
If opened1 = 0 Then

Status = pl1000OpenUnit(handle)
    opened1 = handle
opened1 = 1
    Else
    Status = pl1000GetSingle(handle, 1, Value1)
    Status = pl1000GetSingle(handle, 2, Value2)
    Status = pl1000GetSingle(handle, 3, Value3)
    Status = pl1000GetSingle(handle, 4, Value4)
    Status = pl1000GetSingle(handle, 5, Value5)
    Status = pl1000GetSingle(handle, 6, Value6)
    Status = pl1000GetSingle(handle, 7, value7)
    Status = pl1000GetSingle(handle, 8, Value8)
    Status = pl1000GetSingle(handle, 9, Value9)
    Status = pl1000GetSingle(handle, 10, Value10)
    Status = pl1000GetSingle(handle, 11, Value11)
    Status = pl1000GetSingle(handle, 12, Value12)
    Status = pl1000GetSingle(handle, 13, Value13)
    Status = pl1000GetSingle(handle, 14, Value14)
    Status = pl1000GetSingle(handle, 15, Value15)
    Status = pl1000GetSingle(handle, 16, Value16)

    'Voltage
    Worksheets("live data").Cells(3, 2) = Value1
    Worksheets("live data").Cells(4, 2) = Value2
    Worksheets("live data").Cells(5, 2) = Value3
    Worksheets("live data").Cells(6, 2) = Value4
.
.
.(continued for each of the called channels)



Thanks in advance
mb91
Newbie
 
Posts: 0
Joined: Wed Nov 20, 2013 1:43 pm

Re: Problem when using getsingle function

Postby mb91 » Tue Nov 26, 2013 2:14 pm

Any ideas anyone?
mb91
Newbie
 
Posts: 0
Joined: Wed Nov 20, 2013 1:43 pm

Re: Problem when using getsingle function

Postby Hitesh » Tue Nov 26, 2013 4:26 pm

HI Mike,

Which version of the pl1000.dll are you using?

Please ensure that you are using the dll from the latest SDK.

What is the input signal that you are applying?

Thanks,
Hitesh

Technical Specialist
Pico Technology
Hitesh
Site Admin
Site Admin
 
Posts: 2058
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: Problem when using getsingle function

Postby mb91 » Wed Nov 27, 2013 10:58 am

Hi Hitesh

The version of pl1000.dll i'm currently using is 1.0.3.76 , i'll update this now.

My input voltage in 0-2.5 (well 0 - 2.4V) volts using a voltage divider from a power supply with a maximum of 48V

Thanks,

Mike
mb91
Newbie
 
Posts: 0
Joined: Wed Nov 20, 2013 1:43 pm

Re: Problem when using getsingle function

Postby Hitesh » Wed Dec 04, 2013 3:45 pm

Hi Mike,

In the function declaration try definding channel value as a Long:

Code: Select all
Declare Function pl1000GetSingle Lib "pl1000.dll" (ByVal handle As Integer, ByVal channel As Long, ByRef value As Integer) As Long


An enumeration is a 32-bit integer.

I tried the following as a test:

Code: Select all
Dim value1 As Integer
Dim value2 As Integer
Dim value3 As Integer
Dim value4 As Integer
 
status = pl1000GetSingle(handle, 1, value1)
status = pl1000GetSingle(handle, 2, value2)
status = pl1000GetSingle(handle, 3, value3)
status = pl1000GetSingle(handle, 4, value4)
 
Cells(3, "C").value = (value1 / 4095) * 2500
Cells(4, "C").value = (value2 / 4095) * 2500
Cells(5, "C").value = (value3 / 4095) * 2500
Cells(6, "C").value = (value4 / 4095) * 2500


I hope this helps.
Hitesh

Technical Specialist
Pico Technology
Hitesh
Site Admin
Site Admin
 
Posts: 2058
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire


Return to VB and VBA (Excel, Access)

Who is online

Users browsing this forum: No registered users and 0 guests