Test and Measurement Forum

Pico logger 1216 - doesn't run

Post your .Net discussions here

Pico logger 1216 - doesn't run

Postby petro » Tue Sep 08, 2009 8:39 am

Hello,

I'm a bit confused with drivers.

What kind of driver I need in order to get values from Picologger 1216 ?

Im thinking about usbadc11.dll at moment.
by the code Excel's example (usbadc11.xls) Picologger 1216 seems works fine.
Piclog software works fine too.

Can you help me pls ?
Thank in advance

O.S. : Windows XP
Product : usb Picologger 1216



Code: Select all
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        ' Open Adc11 on USB
        '1 Check that the driver(optional)
        '2 Open the unit
        '3 Set trigger mode (optional)
        '4 Set sampling mode 
        '5:      .Run()
        '6.Wait until ready
        '7:      .Get(values)
        '8.Close the unit

   opened = UsbAdc11OpenUnit()   ' Open unit
   If opened <> 0 Then
      MsgBox("OK")
      UsbAdc11SetInterval(opened, 1000000, 1, 7, 1) 'Set Sampling mode
      UsbAdc11Run(opened, 1, 0) ' Run()

       Do While Ready = 0
           Ready = UsbAdc11Ready(opened)  '<----- doesnt work
       Loop

        Dim reading As Integer
        ok = UsbAdc11GetValue(opened, 7, reading) ' GetValue

        TextBox1.Text = TextBox1.Text & "------>" & reading

        Call UsbAdc11CloseUnit(opened) ' Close unit

        Else
            MsgBox("Unable to open ADC ")
        End If
    End Sub
petro
User
User
 
Posts: 4
Joined: Tue Sep 08, 2009 8:28 am

Postby ziko » Tue Sep 08, 2009 12:25 pm

Hi and thank you for your post. The 1216 can run in backwards compatibility mode and act as a USBADC11 and hence that is why your driver is working. If however you wanted to make use of its intended capability you need to use the pl1000.dll, you can find some example on our software download page.

Kind regards

Ziko
Ziko

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

Postby petro » Tue Sep 08, 2009 2:50 pm

Hello again,

Thank for your help , I found pl1000.dll in pl1000sdk_r6_2_4_10
but i can't find vb example.
Im watching in pic1216 section but there aren't vb examples

may I ask you the direct link ?
:oops:
Thanks
petro
User
User
 
Posts: 4
Joined: Tue Sep 08, 2009 8:28 am

Postby ziko » Tue Sep 08, 2009 4:05 pm

Hi unfortunately we do not currently have any VB.net examples.

Kind regards
Ziko

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

Postby petro » Wed Sep 09, 2009 7:27 am

Hello ,

Before to buy Picologger I was sure to find vb example.
Pl1000pg.en talks about vb example but i can't find it

Anyway , kindly I ask you a little help to open and get data from my picologger ( Picolog 1216 USB )
This is code:

Declarations :
Code: Select all
Module Module1
Declare Sub pl1000OpenUnit Lib "pl1000.dll" (ByVal handle As Integer)
Declare Function pl1000SetInterval Lib "pl1000.dll" (ByVal handle As Integer, ByVal us_for_block As Long, ByVal ideal_no_of_samples As Long, ByVal channels As Integer, ByVal No_of_channels As Integer) As Long


code:
Code: Select all
        pl1000OpenUnit(Open)
        Value = pl1000SetInterval(Open, 1000000, 1, 7, 1)
        MsgBox(Value)


pl1000OpenUnit has no return value and Value is set to 3 always
( that mean pico not found )
pls might I ask you help about get data from my Pico?
Thanks in advance
petro
User
User
 
Posts: 4
Joined: Tue Sep 08, 2009 8:28 am

Postby petro » Thu Sep 10, 2009 10:49 am

Hello
Declarations's module updated based on difference between vb6 and vb2008
Code: Select all
Module Module1
    Declare Function pl1000OpenUnit Lib "pl1000.dll" (ByRef handle As Short) As Integer
    Declare Function pl1000CloseUnit Lib "pl1000.dll" (ByRef handle As Short) As Integer
    Declare Function pl1000GetUnitInfo Lib "pl1000.dll" (ByRef handle As Short, ByVal S As String, ByVal lth As Short, ByRef requiredSize As Short, ByVal info As Short) As Short
    Declare Function pl1000SetTrigger Lib "pl1000.dll" (ByRef handle As Short, ByVal enabled As Short, ByVal enable_auto As Short, ByVal auto_ms As Short, ByVal channel As Short, ByVal dir As Short, ByVal threshold As Short, ByVal hysterisis As Short, ByVal delay As Single) As Short
 
Declare Function pl1000SetInterval Lib "pl1000.dll" (ByRef handle As Short, ByRef us_for_block As Integer, ByVal ideal_no_of_samples As Integer, ByVal channels As Short, ByVal No_of_channels As Short) As Integer
 
    Declare Function pl1000GetValues Lib "pl1000.dll" (ByRef handle As Short, ByVal values As Short, ByVal no_of_values As Integer, ByVal overflow As Short, ByVal triggerIndex As Integer) As Integer
    Declare Function pl1000Run Lib "pl1000.dll" (ByRef handle As Short, ByVal no_of_values As Integer, ByVal method As Short) As Short
    Declare Function pl1000Ready Lib "pl1000.dll" (ByVal handle As Short, ByVal ready As Short) As Integer
    Declare Function pl1000MaxValue Lib "pl1000.dll" (ByVal handle As Short, ByRef maxValue As Short) As Integer
End Module


FORM1:

Code: Select all
Public Class Form1
Dim status As Integer
    Dim handled As Short
    Dim opened As Short
    Dim values(200) As Short
    Dim channels(22) As Short
    Dim nValues As Integer
    Dim ok As Short
    Private ready As Short
    Dim requiredSize As Short
 
    Dim s As String     'in VB6 it was string*255
    Public port As Short
    Public product As Short
    Dim maxValue As Short
    Dim Slenght As String
 
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
 
    End Sub
 
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
 
        ' Open device
        status = pl1000OpenUnit(handled)
        opened = handled <> 0
 
 
        If opened Then
 
            status = pl1000MaxValue(handled, maxValue)
 
            ' Slenght = pl1000GetUnitInfo(handled, s, 255, requiredSize, 3)
 
            Call pl1000SetTrigger(handled, False, 0, 0, 0, 0, 0, 0, 0)
            nValues = 100
            channels(0) = 1
            channels(1) = 2
 
            Dim sampleInterval As Integer
            Dim us_for_block As Integer
 
            us_for_block = 1000000
            status = pl1000SetInterval(handled, us_for_block, nValues, channels(0), 2)
 
            status = pl1000Run(handled, nValues, 0)
 
 
            ready = 0
            Do While ready = 0
                status = pl1000Ready(handled, ready)
            Loop
 
            MsgBox("ok")
        End If
    End Sub
 
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        pl1000CloseUnit(handled)
 
    End Sub
End Class


The problem is this :
At position
Code: Select all
  ready = 0
            Do While ready = 0
                status = pl1000Ready(handled, ready)
            Loop

The var "ready" is always 0 (zero) so the loop is forever.
This is wrong because the hardware works fine and the program works fine in vb/excel 2003 too.
I dont know why it is always 0.
This software comes with datalogger which works perfectly

Follows the program for vb6/excel 2003:
This woks fine in excel 2003/VB 6
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
 
This declarations must be changed in "Byval" otherwhise i get an "Accessviolation exceptions.."
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 pl1000GetValues Lib "pl1000.dll" (ByVal handle As Integer, values As Integer, no_of_values As Long, overflow As Integer, triggerIndex As Long) 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
 
Dim status As Long
Dim handle As Integer
Dim values(200) As Integer
Dim channels(22) As Integer
Dim nValues As Long
Dim ok As Integer
Dim ready As Integer
Dim requiredSize As Integer
Dim S As String * 255
Public port As Integer
Public product As Integer
Dim maxValue As Integer
 
Function adc_to_mv(value As Integer) As Integer
  adc_to_mv = value / maxValue * 2500
End Function
 
Sub GetPl1000()
 
' Open device
    status = pl1000OpenUnit(handle)
    opened = handle <> 0
 
If opened Then
 
  'Get the maximum ADC value for this variant
  status = pl1000MaxValue(handle, maxValue)
 
' Get the unit information
  Cells(6, "E").value = "Unit opened"
  SLegnth = pl1000GetUnitInfo(handle, S, 255, requiredSize, 3)
  Cells(7, "E").value = S
  SLegnth = pl1000GetUnitInfo(handle, S, 255, requiredSize, 4)
  Cells(8, "E").value = S
  SLegnth = pl1000GetUnitInfo(handle, S, 255, requiredSize, 1)
  Cells(9, "E").value = S
 
  ' No Trigger
  Call pl1000SetTrigger(handle, False, 0, 0, 0, 0, 0, 0, 0)
 
  ' Say that we want to take 100 readings in 1 s
  ' from channels 1 and 2
    nValues = 100
    channels(0) = 1
    channels(1) = 2
    Dim sampleInterval As Long
    Dim us_for_block As Long
 
    us_for_block = 1000000
    status = pl1000SetInterval(handle, us_for_block, nValues, channels(0), 2)
 
    status = pl1000Run(handle, nValues, 0)
 
    ready = 0
    Do While ready = 0
        status = pl1000Ready(handle, ready)
    Loop
 
  ' Get a block of 100 readings...
  ' we can call this routine repeatedly
  ' to get more blocks with the same settings
  Dim triggerIndex As Long
  Dim overflow As Integer
  status = pl1000GetValues(handle, values(0), nValues, overflow, triggerIndex)
 
  ' Copy the data into the spreadsheet
  For i = 0 To nValues - 1
     Cells(i + 4, "A").value = adc_to_mv(values(2 * i))
     Cells(i + 4, "B").value = adc_to_mv(values(2 * i + 1))
  Next i
 
  ' Close the unit when finished to drop the driver
  Call pl1000CloseUnit(handle)
 
Else
  Cells(17, "E").value = "Unable to open unit"
End If
 
End Sub
 


is there any solution to work in VB 2008?
Somebody can help me?
Thanks
petro
User
User
 
Posts: 4
Joined: Tue Sep 08, 2009 8:28 am

Postby Robin » Tue Sep 15, 2009 8:54 am

Hi

After changing the declarations so that the arguments were passed correctly (ByRef or ByVal, as in pl1000.xls), your example worked for me. Here are the declarations that I used:

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




Robin
Robin
Zen Master
Zen Master
 
Posts: 558
Joined: Fri Sep 19, 2008 10:17 am


Return to .Net Languages (C#, VB.Net, .)

Who is online

Users browsing this forum: No registered users and 0 guests