i'm using a PL1216 to integrate an exposure (laser) to get the dose. I'm writing an application that opens a shutter to start exposure and closes it when the reference dose is reached.
To my problem: to control the shutter i want to use the digital output from PL1216. When i test i do not get any signal on programed channel (D0 in this case).
Another issue, to get TTL compatible signal, is there some preffered way to transform signal?
Below is the testfile, VB 2008 Express, i used to test for signal on digital output.
Guidance would be greatly appreciated!
//Patrik
Public Class Form1
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 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 pl1000SetDo Lib "pl1000.dll" (ByVal handle As Short, ByRef do_value As Short, ByRef doNo As Short) As Short 'also tried as integer outside paranthesis
Dim status As Long
Dim ready As Integer
Dim handleX As Integer
Dim initialized As Integer
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
Call pl1000SetTrigger(handleX, False, 0, 0, 0, 0, 0, 0, 0) ' No trigger, not sure if it is nesessary to disable trigger
status = pl1000OpenUnit(handleX)
initialized = handleX <> 0
If initialized Then
Label1.Text = "Device opened"
Call pl1000SetDo(handleX, 1, 0)
Label1.Text = "Device opened - Signal on"
Dim timeOut As DateTime = Now.AddMilliseconds(10000) '"Pause" for xxx milliseconds
Do
Application.DoEvents() 'Keep the app from freezing and allow Windows to continue processing the applications messages.
Loop Until Now > timeOut 'Keep looping until the elasped time of xxx milliseconds.
Call pl1000SetDo(handleX, 0, 0)
Label1.Text = "Device opened - Signal off"
yes I use .net (at least I think so, I use VD 2008 express, when I type a function or object I get suggestions and when typing "." I get suggestions for method. Isn't that implying .net? Im not a programmer so please excuse the, perhaps stupid question)
About the error code, I checked the list of ALL error codes, not for the function. However, the function does return 13, below is the code I use. I haven't looked in to adjusting data types due to .net, not sure what to look for.
//Patrik
Public Class Form1
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 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 pl1000SetDo Lib "pl1000.dll" (ByVal handle As Short, ByRef do_value As Short, ByRef doNo As Short) As Short
Dim status As Short
Dim ready As Integer
Dim handleX As Short
Dim initialized As Integer
Dim initializedDo As Integer
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
Call pl1000SetTrigger(handleX, False, 0, 0, 0, 0, 0, 0, 0) ' No trigger, not sure if it is nesessary to disable trigger
Dim timeOut As DateTime = Now.AddMilliseconds(10000) '"Pause" for xxx milliseconds
Do
Application.DoEvents() 'Keep the app from freezing and allow Windows to continue processing the applications messages.
Loop Until Now > timeOut 'Keep looping until the elasped time of xxx milliseconds.
Call pl1000SetDo(handleX, 0, 0)
Label1.Text = "Device open - Signal off"
tried that, that was what I meant by "declaring the function as integer" in previous post. Tried again to be sure, still same error code.
I'm a bit confused regarding data type for functions in pl1000.dll. In the vb (excel) example, for instance pl1000SetTrigger is declared as short. How do I know what the data type for functions (or rather what they return) should be?
I have checked the driver code and it definitely does not return a status of 0x13.
I suggest you have a look at the above links and once you are clear about the different data types, go through the variables in your code and make sure they are all correct. If you are still having problems, I will try it out here.
The following link gives the C/C++ data types that are used in the 1216 programmer's guide:
found the error! Thanks for the links, now I know more about difference in data types. However the error was in declarations below, realized that do_value and doNo must be ByVal - totally missed that.