LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

getting started with thorlabs lc1-usb

Many thanks for sharing the file.
We've understood where was the mistake.
0 Kudos
Message 21 of 33
(2,477 Views)

I have problems with the Thorlabs LC1-USB camera.

I am using NI VISA and do make contact  through VISA in vb.not. I can read the USB descriptor of the camera. So, that seems to work.

This is where I am stuck. How do I configure the camera and how do I read the CCD values out?

Is there a list of commands available anywhere?

Since Thorlabs wrote the interface I suppose they should have a manual but could not find anything like it.

Any help is much appreciated

Robert

0 Kudos
Message 22 of 33
(2,439 Views)
Hi Robert,
JimmyinCT shares an exemple (see few posts above) that works pretty well. My mistake was to try using VISA (like you).
jb.
0 Kudos
Message 23 of 33
(2,428 Views)
Hello Jb,

Thanks for your help. I found the VI from JimmyinCT but I am trying to make it work in MS VisualStudio so I was wondering if that example is available as C source code?
That would probably really help.

Thanks
Robert

0 Kudos
Message 24 of 33
(2,408 Views)

hi

 

there is no active x or external controls to allow you to program this device in visual studio.

 

however, you can build a dll in labview that you can read then in V.S.

so you make a VI that reads the data off the LC1, then you compile it to a dll

Then from your other appliclication, you call the dll and read get the data.

 

The one i made wouldnt be specific for most users so i didnt upload it.

It only reads about 50 of the line elements, the postion varying to where a the peak is.

I can try to find some code next time im at that comptuer if your intrested, but in general, looking up how to build the dll is the way to go.

0 Kudos
Message 25 of 33
(2,404 Views)
Hello Jimmy,
It seems you are the expert!

Building my own DLL seems to be an awful amount of work.

Thorlabs does say one can interface the camera to MS C++ or Borland C++
There must be somehow something that works.

I have to get help from Thorlabs and if not maybe there is another line camera one could buy.

Again thanks and if you have any other idea I welcome this very much
Robert



0 Kudos
Message 26 of 33
(2,402 Views)

 

the LC is a great piece of hardare, 3000 elements and usb interface.

But only offering labview as a driver is crazy, I was not happy with thor labs about this

I personally just dont like having labivew on any of my PCs,  its hard enough knowing one language well.

 

buidling the dll turned out to be the best solution for me.

i can link in some example files later for how to read a dll in whatever language and also the one on how to build the Dlls

You can probalby do it in about 4 hrs id say.

But then you still have to have the labview engine on any machine that runs the app.

 

0 Kudos
Message 27 of 33
(2,402 Views)
Hello Jimmy,

Right on. I so agree with you.
We did plan to use this camera on our product and would need a few of these cameras every year.
How can Thorlabs expect us to use their camera if they do not tell me how to interface it...?

We are already looking around on what is available in terms of other cameras. I already also found the Hamamtsu CCD arrays (Sony has them too) and looking at the datasheet it seems really easy to operate these CCD elements.
Sure that would take me a couple of days to make it work but then I am no longer at the mercy of a product whose operation is a secret.
Additionally we would save a lot of money when we build several units a year of our product.
I already spent over 4 hours dabbling around and two days later I am not any further.

In any case I would appreciate if you did send me your information. Who knows perhaps I am able to make it work.
I keep you updated on my progress.

BTW I did check and confirm that none of the Thorlabs DLLs will interface with Visual Studio.

All the best
Robert







0 Kudos
Message 28 of 33
(2,391 Views)
 

Thank you all who answered to my plea for help. After spending two days on it I figured it out - to some degree at least.
This is NOT yet the perfect solution because I do not have any answers from Thorlabs.

Preface:
Thorlabs sells a line camera Model LC1-USB. It comes with a user interface software allowing the user to operate the camera and look at scans.

We needed to implement the camera into a product. The Thorlabs manual says they provide drivers for MS C++ and Borland C++. Well they do not and they also do not have any information how to do this. Customer service did provide some samples for CVI and even that was incomplete.

 


Their application runs on the National Instruments VISA driver and is probably written in CVI. Our need is to integrate the line camera into an existing vb.net software program. We use Visual Studio 2008. Fortunately National Instruments does provide VISA drivers for the Visual Studio 2005 and will probably soon have an upgrade for VS2008.

 
Problem:

Thorlabs does not provide any information on the message protocol for the LC1-USB camera. I used the NI VISA Spy application to find out what code is being sent back and forth when using their application.

Partial Solution:


@jimmyinCT wrote:
Hello,
Ive always been a big fan of labview, one of the big reasons is that I can get a  good head start on any applicatino using the example programs.
For this new device, a lc1-usb from thor labs, i just have had a hard time getting started.
 
Ive read the instructions and see in need to import the labwindows drivers into labview.
I see the device is in measurement and automation under usb heading and appears to be working.
When i try to initialize the device, I am getting errors in debug mode saying the "device cannot be locked".
Ive tried resetting it, and just havent had luck.
I can upload the .vi later if it is recommended, dont have it infront of me right now.
 
I really would just like to see an example program which is reading the input of this device.
It really would help me get started in debugging if i could actually had soemthing that worked to start with.
 
Many thanks
 
 
 



To get data out of the LC1 Camera proceed as follows:

 


Start a Windows project in VS2008.
Add the National Instruments VisaNS.DLL driver to your project references.
Since I have Measurement Studio installed it was available but I think it can be downloaded from National Instruments web site.

 


The NationalInstruments.VisaNS namespace exposes functions and properties to make contact with the camera.
The sample that I will post later looks first for the device named “LC1-USB” if available it will be initialized and is ready to read data from it.

 
ftp://micronor/transfer/
Look for the PDF

 

file "How to use the LC1-USB Camera"

 


The subroutine ReadTrace goes out reads the trace data which come in a byte array of 6136 elements.

 


The routine byte2WordArray converts the bytes to a 16 bit short value.

 


The camera has a 12 bit resolution and thus numbers will not exceed 4095.

 


Looking at the data it seems that the actual pixel data is inverted relative to the A/D resolution. Light levels of 0 come across as values of 4000 while high intensity values come across as numbers close to 0. This is rather strange but may explain why Thorlabs is so reluctant to provide any interface information.

 

 

 


National Instruments Instructions for VISA are helpful: https://www.ni.com/docs/en-US/bundle/ni-visa/page/user-manual-welcome.html

 


I still do not know how to set the integration time.???

 


The camera is useable but I could still not use it in my product because in order to setup the camera I need to launch the Thorlabs application first. Not good!!!
I only hope Thorlabs comes forward with the message description for the unit.

 

 

 

0 Kudos
Message 29 of 33
(2,352 Views)
(I pushed the wrong button in my previous post...!)

Here is the code I wrote in vb.net using the VisaNS.DLL
What is below works however I do not yet have access to other functions.


  
'*********************************************************


    ' LC1-USB Camera Interface


    '


    ' May 24, 2008


    ' Robert Rickenbach


    ' MICRONOR INC


    '


    ' The Camera must be setup and named 'LC1-USB' in the VISA driver


    ' Use the National Instruments "Measuremnt & Automation Explorer" and set


    ' VISA Alias name to LC1-USB 


    ' ********************************************************


    '


    Dim Trace() As Short


    Dim usbSession As VisaNS.UsbRaw = Nothing


    Dim bStat As VisaNS.UsbPipeState


 


    Private Sub InitializeUSB()


        Try


            usbSession = CType(ResourceManager.GetLocalManager().Open("LC1-USB"), UsbRaw)


        Catch exp As InvalidCastException


            MessageBox.Show("Not USB Raw Interface")


            Me.btnFFT.Enabled = False


        Catch exception As Exception


            MessageBox.Show("LC1-USB Camera" & exception.Message)


            Me.btnFFT.Enabled = False


        End Try


    End Sub


 


    Private Sub ReadTrace()


        Dim bUSBCtl() As Byte


        Dim bt() As Byte            ' trace data buffer


        bUSBCtl = usbSession.ControlIn(192, 161, 517, 0, 2)


        bStat = usbSession.BulkInStatus


        If bStat = 0 Then


            bt = usbSession.ReadByteArray(6136)


            Trace = Me.Byte2WordArray(bt)       ' make the bytes words


            convertToCCDData()                  ' application specific


            Me.WaveformGraph1.Plots(0).PlotWaveform(analogwaveform(Of Double).FromArray1D(CCDData))


            FFT()


        End If


    End Sub


 

0 Kudos
Message 30 of 33
(2,349 Views)