Discussion:
getting started with thorlabs lc1-usb
(too old to reply)
jimmyinCT
2007-11-15 02:40:05 UTC
Permalink
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.
<a href="http://www.thorlabs.com/NewGroupPage9.cfm?ObjectGroup_ID=1300&amp;pn=LC1-USB" target="_blank">http://www.thorlabs.com/NewGroupPage9.cfm?ObjectGroup_ID=1300&amp;pn=LC1-USB</a>
&nbsp;
Ive read the instructions and see in need to import the labwindows drivers into labview.
I&nbsp;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&nbsp;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.
&nbsp;
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.
&nbsp;
Many thanks
&nbsp;
&nbsp;
&nbsp;
jimmyinCT
2008-02-06 23:40:08 UTC
Permalink
the lc1 is going to be a hot item if thor labs ever gets activex out for it.
the way this use to be done was very difficult
&nbsp;
Sure, ill upload what im doing, i was planning on doing this, im just not done yet.. .
We are making a holographic interferometer for laser etching of our objects
I was going t upload teh code when i was done but at this point, we maybe changing to a device that supports active x and to a faster programmign language.
&nbsp;
the lc1 driver does hang up a lot if you use the&nbsp;stop execution button, i never bothered to fix it and we just stop it from running through a "stop button" to exit a while loop;.
you have to restart labview if you if hit halt execution
&nbsp;
&nbsp; Just for any general intrest of this code, there is a&nbsp;simultor mode that allows it to control parameters such as phase shifting, noise, and frequency and study them in relation to the lc1.&nbsp; You should be able to see that when teh&nbsp;noise is shut off, the&nbsp;simulator mode will track teh known phase shift of the input signal and plot it in relation to the calcuated peak position with a fair amount of accuracy.&nbsp;&nbsp;With very small phase shifts, such as less then one, and with no noise, you can see how interpolation fills in the values perfectly.&nbsp;&nbsp;&nbsp; The program starts by extracting the 3000 line elements from the lc1, crops out a area of interest to evaluate, does a FFT and filters by zeroing out all frequcies&nbsp;but the area with teh fundeamental frequency. This&nbsp;type of flitering wont cause phase shift, even "zero phase shift.vi" causes enough shift to make micrometer nmever mm resolution useless.&nbsp;&nbsp; We had this working to a few degrees of accurary until all my more recent files got corrupted somehow .
&nbsp;
The lc1 driver library, with all its function, as supplied by thor labs will be uploaded in the same directory.
It is freely downloadable from their site, yet is hidden in all the files they have.
If you open the library, you will see all teh vis.
This library seems to be very limited in terms of what is offered by the device such as being able to change teh scan rate.
I need to get in touch wti hthem to find out how to add this function.
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
sergeyMA
2008-02-07 17:40:11 UTC
Permalink
Thank you, Jimmy

Your VI files are extremely helpful.&nbsp;

?we maybe changing to a device that supports active x?.

Do you have any particular device in mind?

&nbsp;

Sergey
jbxlim
2008-05-02 15:40:12 UTC
Permalink
Many thanks for sharing the file. We've understood where was the mistake.
jimmyinCT
2008-02-08 20:10:12 UTC
Permalink
i havent looked at other line cameras yet.
thor really dont have it together with this new product yet.
For this project, i was just given a thor camera and told to ues it.
&nbsp;
I know there is a variety of line carmeras out there, apps like holographic inter. are not new.
&nbsp;
Activex is the way to go, esp if i can work with matlab without the labview scripting environment which slows down the code dramatically.
matlab is desiged for workign iwth large multidimentional arrays, can access many areas of the array with little effort.
building a labview dll and calling it from matlab or other language &nbsp;is also a good option.
&nbsp;
most of the past apps ive made simply use labview dlls to get data and then use enhance speed&nbsp;in c++, vb, or whatever.
&nbsp;
I can keep you posted if your intrested..
&nbsp;
&nbsp;
&nbsp;
jimmyinCT
2008-03-04 13:40:05 UTC
Permalink
here is a copy for now.
this is a holographic interferometer, lots of stuff in there you dont need..
<a href="http://www.engr.uconn.edu/~jmacione/nicode35.vi" target="_blank">http://www.engr.uconn.edu/~jmacione/nicode35.vi</a>
&nbsp;
im going to post a permanent copy when im done with the project.
&nbsp;
I may need to fix their driver when im done.
If you halt execution on it, it will lock the device next time its used.
So use the stop button.
&nbsp;
The scan rate is proportional to how fast you call it.
Its not a property that is set.
&nbsp;
good luck
jbxlim
2008-04-25 13:10:05 UTC
Permalink
Hi Jimmy, I have some problems with controlling LC1-USB CCD camera with Labview. Could you once more share your VI file ?Many thanks.
jimmyinCT
2008-04-26 00:10:06 UTC
Permalink
below is an older simplifed version using the driver&nbsp; ( i took out specifics of my project like matlab scripts and other drivers which you wont have)
<a href="http://www.engr.uconn.edu/~jmacione/forinternet.vi" target="_blank">www.engr.uconn.edu/~jmacione/forinternet.vi</a>
&nbsp;
to make it work, you need to&nbsp;download the library files and put them in the same directory
or you can get them from the cd that came with it or from
<a href="http://www.thorlabs.com/software_pages/LC1-USB.cfm" target="_blank">http://www.thorlabs.com/software_pages/LC1-USB.cfm</a>
&nbsp;
LC1_Drv.llb is the name i believe
&nbsp;Message Edited by jimmyinCT on 04-25-2008 06:56 PM
EncoderWhiz
2008-05-22 05:40:07 UTC
Permalink
I&nbsp;have problems with the Thorlabs LC1-USB camera.
I am using NI VISA and&nbsp;do make contact&nbsp; 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
jbxlim
2008-05-22 08:40:14 UTC
Permalink
Hi Robert, JimmyinCT shares an exemple (see few posts above) that works pretty well. My mistake was to try using VISA (like you).jb.
EncoderWhiz
2008-05-22 15:40:08 UTC
Permalink
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.ThanksRobert
jimmyinCT
2008-05-22 15:40:10 UTC
Permalink
hi
&nbsp;
there is no active x or external controls to allow you to program this device in visual studio.
&nbsp;
however, you can build a&nbsp;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.
&nbsp;
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.
EncoderWhiz
2008-05-22 16:40:08 UTC
Permalink
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 muchRobert
jimmyinCT
2008-05-22 16:40:08 UTC
Permalink
&nbsp;
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,&nbsp; its hard enough knowing one language well.
&nbsp;
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.
&nbsp;
EncoderWhiz
2008-05-22 17:40:10 UTC
Permalink
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 bestRobert
EncoderWhiz
2008-05-24 01:10:04 UTC
Permalink
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.&nbsp;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.&nbsp;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&nbsp; 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.
<a href="http://www.thorlabs.com/NewGroupPage9.cfm?ObjectGroup_ID=1300&amp;pn=LC1-USB" target="_blank">http://www.thorlabs.com/NewGroupPage9.cfm?ObjectGroup_ID=1300&amp;pn=LC1-USB</a>
&nbsp;
Ive read the instructions and see in need to import the labwindows drivers into labview.
I&nbsp;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&nbsp;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.
&nbsp;
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.
&nbsp;
Many thanks
&nbsp;
&nbsp;
&nbsp;To get data out of the LC1 Camera proceed as follows:&nbsp;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.&nbsp;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.&nbsp;ftp://micronor/transfer/Look for the PDF file "How to use the LC1-USB Camera"&nbsp;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. &nbsp;National Instruments Instructions for VISA are helpful: <a href="http://www.ni.com/pdf/manuals/370423a.pdf" target="_blank">http://www.ni.com/pdf/manuals/370423a.pdf</a> &nbsp;I still do not know how to set the integration time.???&nbsp;The camera is useable but I could still not use it in my
product because in order to s
EncoderWhiz
2008-05-24 01:10:05 UTC
Permalink
(I pushed the wrong button in my previous post...!) Here is the code I wrote in vb.net using the VisaNS.DLLWhat is below works however I do not yet have access to other functions.&nbsp;&nbsp; '*********************************************************&nbsp;&nbsp;&nbsp; ' LC1-USB Camera Interface&nbsp;&nbsp;&nbsp; ' &nbsp;&nbsp;&nbsp; ' May 24, 2008&nbsp;&nbsp;&nbsp; ' Robert Rickenbach&nbsp;&nbsp;&nbsp; ' MICRONOR INC&nbsp;&nbsp;&nbsp; ' &nbsp;&nbsp;&nbsp; ' The Camera must be setup and named
'LC1-USB' in the VISA driver&nbsp;&nbsp;&nbsp; ' Use the National Instruments
"Measuremnt &amp; Automation Explorer" and set &nbsp;&nbsp;&nbsp; ' VISA Alias name to LC1-USB&nbsp; &nbsp;&nbsp;&nbsp; '
********************************************************&nbsp;&nbsp;&nbsp; ' &nbsp;&nbsp;&nbsp; Dim Trace() As Short&nbsp;&nbsp;&nbsp; Dim usbSession As VisaNS.UsbRaw = Nothing&nbsp;&nbsp;&nbsp; Dim bStat As VisaNS.UsbPipeState&nbsp;&nbsp;&nbsp;&nbsp; Private Sub InitializeUSB()&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Try&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; usbSession =
CType(ResourceManager.GetLocalManager().Open("LC1-USB"), UsbRaw)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Catch exp As InvalidCastException&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MessageBox.Show("Not USB Raw
Interface")&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Me.btnFFT.Enabled = False&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Catch exception As Exception&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MessageBox.Show("LC1-USB
Camera" &amp; exception.Message)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Me.btnFFT.Enabled = False&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End Try&nbsp;&nbsp;&nbsp; End Sub&nbsp;&nbsp;&nbsp;&nbsp; Private Sub ReadTrace()&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim bUSBCtl() As Byte&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim bt() As Byte&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' trace data buffer &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bUSBCtl = usbSession.ControlIn(192,
161, 517, 0, 2)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bStat = usbSession.BulkInStatus&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If bStat = 0 Then&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bt = usbSession.ReadByteArray(6136)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Trace = Me.Byte2WordArray(bt)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' make the bytes words&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; convertToCCDData()&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' application specific&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Me.WaveformGraph1.Plots(0).PlotWaveform(analogwaveform(Of
Double).FromArray1D(CCDData))&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;FFT()&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If&nbsp;&nbsp;&nbsp; End Sub&nbsp;
jimmyinCT
2008-05-24 05:10:05 UTC
Permalink
Thought you were going to look at a new product?&nbsp; J
What you may not know is that the NI people on this forum wont help you out.&nbsp; They only support hardware that they made drivers for.&nbsp; Ironically, they don?t have an equivalent for this anyway and if they did, it would cost 10x more.,
Im not sure why you have to start the thor labs application to get your example to work, the odds are your program isn?t doing exactly what you think it is but rather they are both using a similar or shared dll to initialize and close the device.&nbsp; &nbsp;The device I really don?t think should work.&nbsp;&nbsp; &nbsp;I cant look at&nbsp; your code, the ftp link uses internal rather then external dns, and even if fixed, gives access denied..
its been a while since ive used this product. I dont remember it inverting the values.&nbsp; I do&nbsp;remember a problem related to saturation, that being that normal room intensity light reduced the dynamic range by approximately 50%.&nbsp; This can be resolved by using reduced intensity lights or lights which have a different spectrum.&nbsp; With the sample application, you should see that if you block the line elements, it should go down in intensity, I think.
To be quite frank, I spent a lot of time evaluating all the possibilities with this.&nbsp; The dll sounds difficult but it honesly should just take you a few hours or a day at the most.&nbsp;&nbsp; &nbsp;To be quite frank, what most real engineers do in rare occasions that your stuck with a device that only has a labview driver is to build the dll. &nbsp;&nbsp;Yes, you can set integration time and other parameters with the dll.&nbsp; You can even set it each time you call it.
Here is an example on how to call a dll.&nbsp;
<a href="http://zone.ni.com/devzone/cda/tut/p/id/3925" target="_blank">http://zone.ni.com/devzone/cda/tut/p/id/3925</a>
and the example for how to create the dll is here.
<a href="http://zone.ni.com/devzone/cda/tut/p/id/3063" target="_blank">http://zone.ni.com/devzone/cda/tut/p/id/3063</a>
&nbsp;
This is going to be my last post on this subject. Good luck.
EncoderWhiz
2008-05-24 22:10:05 UTC
Permalink
&nbsp;
Ok - thanks for everything
RR
lutzhoerl
2008-05-28 10:10:07 UTC
Permalink
Hello all,
we - Thorlabs - provide a full driver package along with the camera. You can also find the drivers on the web. Navigate to <a href="http://www.thorlabs.com/software_pages/LC1-USB.cfm" target="_blank">http://www.thorlabs.com/software_pages/LC1-USB.cfm</a>&nbsp;click on 'drivers' and then on 'LC1-USB_driver_V2.2.zip'. Alternatively you can use <a href="http://www.thorlabs.com/Software/LC1-USB/Drivers/LC1-USB_driver_V2.2.zip" target="_blank">http://www.thorlabs.com/Software/LC1-USB/Drivers/LC1-USB_driver_V2.2.zip</a>&nbsp;as a shortcut to directly download the driver package. After downloading please unzip the package.
Then you have to install the drivers. Run setup.exe from the package. After that you will find the driver sources, manuals, import libraries etc. &nbsp;in the directoryC:\VXIPNP\WinNT\Thorlabs LC1-USB&nbsp;&nbsp; (*)the driver DLL itself is copied toC:\WINDOWS\system32\LC1_Drv_32.dll
In the file LC1_Drv.c you have the source code of the driver. This source code compiles with NI-CVI to a DLL together with some import libraries. Please also read the Readme files. The DLL provided at C:\WINDOWS\system32\LC1_Drv_32.dll works with all common programming languages as long as they can access DLLs. The driver is relying on VISA. On the CD provided with the camera there is a copy of VISA. You can get an up to date version of VISA also from NI at <a href="http://www.ni.com/visa" target="_blank">http://www.ni.com/visa</a>. Please install VISA before&nbsp;runnig the driver code.
For LabView users:
We recommend to create the LabView driver by yourself through importing the CVI-FP-file (= function panel file) at C:\VXIPNP\WinNT\Thorlabs LC1-USB\LC1_Drv.fp&nbsp;&nbsp; (*)The advantage of this procedure is that you have all VIs then correctly in place and you get the driver for your version of LabView. Unfortunately LabView drivers are only very little&nbsp;up-/downwards compatible.
Sample Program:
We also provide a sample program in C compiled with CVI (in C:\VXIPNP\WinNT\Thorlabs LC1-USB\sample\cvi). This sample program also uses the driver, so one should be able to get an understanding of how the drivers have to be used.
&nbsp;
&nbsp;
We want all our customers to be happy with Thorlabs products and services. Please give us a chance to provide you with&nbsp;all the information needed to perfectly run Thorlabs products. Thank you.
Lutz Hoerl&nbsp;
&nbsp;
(*) starting with NI-VISA 4.3 the directory may have changed toC:\prgram files\VXIPNP\WinNT\Thorlabs LC1-USB\LC1_Drv.fpor the path you provided during installation of VISA.
Loading...