Running a microscope camera through pvcam32.dll

VISA; TCP/IP, CAN and similar protocols
mechknoll
beginner
beginner
Сообщения: 11
Зарегистрирован: 08 июн 2011, 22:16
Версия LabVIEW: 2009
Контактная информация:

Re: Running a microscope camera through pvcam32.dll

Сообщение mechknoll »

I receive the error message C0_INVALID_HANDLE This is not the handle of an open camera ....
I fixed this by reinstalling the pvcam32 software from photometrics... it appears that labview was never communicating with the camera and that is the error msg for that. Now it is working, just have to figure out this memory allocation...
Аватара пользователя
mzu2006

Professionalism Tutorials Black
doctor
doctor
Сообщения: 2456
Зарегистрирован: 16 авг 2008, 02:12
Награды: 3
Версия LabVIEW: 7.1 10 11 12
Откуда: St-Petersburg (RU), Phila, Boston, Washington DC
Контактная информация:

Re: Running a microscope camera through pvcam32.dll

Сообщение mzu2006 »

mechknoll писал(а):I have not been able to get the memory allocation to work. I am using lv 2009, the memory allocation.vi is not compatible. I would like to be able to build this for myself, again to better understand the program. Did you create DSnewptr, MoveBlock, DSdisposeptr from lvrt.dll and a .h file you created? or are these functions hidden somewhere in lv?
These functions are a part of LabVIEW managers: set of functions for external code to communicate with LV internals. Some of them are described in help (as of LV 2010, not sure about 2009), some in "linking labview to external code" manual. I created them by dropping a "call library function" node and configuring it properly. There is an h file ("extcode.h"), but shame on NI, their parser is not parsing their own header correctly...

2009 version is attached to the post.
mechknoll писал(а): One last thing. Is there anything out there that explains the correct sequence of vi operation to get the desired result? or is this information I need to trial and error or look through the pvcam.h file for?
Rather the PVCAM manual (big pdf file that gets installed when you install PVCAM). They had 3 examples at the end of the manual which you can follow.
Вложения
MemoryAllocation90.vi
(7.2 КБ) 352 скачивания
mechknoll
beginner
beginner
Сообщения: 11
Зарегистрирован: 08 июн 2011, 22:16
Версия LabVIEW: 2009
Контактная информация:

Re: Running a microscope camera through pvcam32.dll

Сообщение mechknoll »

Ah Yes, the PVCAM manual is very useful! I have created a vi that works, able to adjust the temperature, set up camera parameters and other various functionality. All seams to be working well! I am missing how the memory allocation VI is supposed to work... From my understanding the first vi DSnewptr will create a buffer of "specified" bits. At this point there is memory allocated and it returns a pointer to that space. How do you implement moveblock? Do I feed my stream of pixels into "Source" and it moves it to an array in 16 bit chunks? Should I allocate using DSnewptr in the exp_setup_seq then use the moveblock after exp_start_seq?

I am also currently toying with the buffer (Class 4) functions. I am able to initialize a buffer and I am working out how to get a buffer handle (hbuf)... If I can find a function that returns a handle then I do not see why this route to allocating space in the memory would be insufficient.
mechknoll
beginner
beginner
Сообщения: 11
Зарегистрирован: 08 июн 2011, 22:16
Версия LabVIEW: 2009
Контактная информация:

Re: Running a microscope camera through pvcam32.dll

Сообщение mechknoll »

Thanks in advance for any help.

I am still fumbling around with your memory allocation vi. It will just crash my vi everytime now. HELP!
Аватара пользователя
mzu2006

Professionalism Tutorials Black
doctor
doctor
Сообщения: 2456
Зарегистрирован: 16 авг 2008, 02:12
Награды: 3
Версия LabVIEW: 7.1 10 11 12
Откуда: St-Petersburg (RU), Phila, Boston, Washington DC
Контактная информация:

Re: Running a microscope camera through pvcam32.dll

Сообщение mzu2006 »

OK, let us make one thing sure: MemoryAllocation90.vi crashes your :labview: immediately upon launch? I am unable to reproduce that unless you provide some more detail.
mechknoll
beginner
beginner
Сообщения: 11
Зарегистрирован: 08 июн 2011, 22:16
Версия LabVIEW: 2009
Контактная информация:

Re: Running a microscope camera through pvcam32.dll

Сообщение mechknoll »

I am able to run memoryallocation90.vi separately, with no problems. It is when I place the CLFN's into my VI, it will run the first time with no data coming out of the camera. Then the second time LabView will always crash. I have connected exp_bytes_out from pl_exp_setup_seq to the dwsize terminal on DSnewptr, then I also use this value on both moveblock CLFN.

Now, I have tried to connect pixel_stream from pl_exp_start_seq to the source on the first moveblock, and this does not work. I have also let the memoryallocation vi run then try connecting pixel_stream to DEST and DEST2 and neither work.

Can you explain how the memoryallocation90.vi is supposed to operate??? Also, if I need to create an array from my pixel_stream before I move it to its storage space?

Thank you again! I really appreciate the help!
Аватара пользователя
mzu2006

Professionalism Tutorials Black
doctor
doctor
Сообщения: 2456
Зарегистрирован: 16 авг 2008, 02:12
Награды: 3
Версия LabVIEW: 7.1 10 11 12
Откуда: St-Petersburg (RU), Phila, Boston, Washington DC
Контактная информация:

Re: Running a microscope camera through pvcam32.dll

Сообщение mzu2006 »

OK, so you have to do be able to call 2 functions: pl_exp_setup_seq and pl_exp_start_seq.
From p. 134 of the manual ver 2.7

Код: Выделить всё

pl_exp_setup_seq( hCam, 1, 1, &region, TIMED_MODE, 100, &size );
frame = (uns16*)malloc( size );
/* Start the acquisition */
printf( "Collecting %i Frames\n", numberframes );
/* ACQUISITION LOOP */
while( numberframes ) {
pl_exp_start_seq(hCam, frame );
...
free(frame);
first function goes easy. Second one was not imported correctly by mmckinnon6. The data type of the pointer should be U32 not U16. THis is the most important one.

malloc(size) would be translated to call of DSNewPtr
free() would be translated to DSDisposePtr. See for yourself:

malloclib was corrected for a significant bug. 07.06.2012
Вложения
malloclib.zip
v 10
(39.42 КБ) 326 скачиваний
mechknoll
beginner
beginner
Сообщения: 11
Зарегистрирован: 08 июн 2011, 22:16
Версия LabVIEW: 2009
Контактная информация:

Re: Running a microscope camera through pvcam32.dll

Сообщение mechknoll »

This is really great :super: the malloc vi's were really helpful! I went through my master.h and pvcam.h and changed all the parameters to hexadecimal and re made a :labview: library from this and pvcam32.dll. Then made the :vi: attached bellow. It is no longer crashing... but I am now getting error codes from pl_exp_setup_seq and pl_exp_start_seq regarding XMODEM and CCL. They are
DDI_XM_NOSOH XMODEM
and
C3_INVALID_SCRIPT CCL program is not loaded or is invalid.
respectively. Have you encountered these before?
Вложения
cascade_cam.vi
(30.43 КБ) 335 скачиваний
Аватара пользователя
mzu2006

Professionalism Tutorials Black
doctor
doctor
Сообщения: 2456
Зарегистрирован: 16 авг 2008, 02:12
Награды: 3
Версия LabVIEW: 7.1 10 11 12
Откуда: St-Petersburg (RU), Phila, Boston, Washington DC
Контактная информация:

Re: Running a microscope camera through pvcam32.dll

Сообщение mzu2006 »

pvcam_hex.lvlib is missing ...
mechknoll
beginner
beginner
Сообщения: 11
Зарегистрирован: 08 июн 2011, 22:16
Версия LabVIEW: 2009
Контактная информация:

Re: Running a microscope camera through pvcam32.dll

Сообщение mechknoll »

here it is...
Вложения
pvcam32_hex.zip
(956.48 КБ) 353 скачивания
Аватара пользователя
mzu2006

Professionalism Tutorials Black
doctor
doctor
Сообщения: 2456
Зарегистрирован: 16 авг 2008, 02:12
Награды: 3
Версия LabVIEW: 7.1 10 11 12
Откуда: St-Petersburg (RU), Phila, Boston, Washington DC
Контактная информация:

Re: Running a microscope camera through pvcam32.dll

Сообщение mzu2006 »

So far I see 3 main troubles:

1. Sequence of operations. You did not enforce sequence of operations between pvcam_init, camera_open and others.
2. RGN??? Parameter of pl_exp_setup_seq - was set as "handle by value", which means that pl_exp_setup_seq gets this as LabVIEW-specific number. It should get a raw pointer.
3. Logic: you do not provide the pointer to pl_exp_start_seq, and for some reason you try to fill the place for images with zeros in process of acquisition.

I corrected all of them. I feel this is not the end of the story, so take a look and let me know.

Also you do not call pvcam_uninit at the end. This is important.
Вложения
PVCAM90.zip
(1.46 МБ) 347 скачиваний
mechknoll
beginner
beginner
Сообщения: 11
Зарегистрирован: 08 июн 2011, 22:16
Версия LabVIEW: 2009
Контактная информация:

Re: Running a microscope camera through pvcam32.dll

Сообщение mechknoll »

First of all, thank you so much. :clap: I have gone through these 3 troubles and understand the reasoning behind them, and agree. So now I believe what is happening is the data begins to dump from the camera to our moveblock and before it is done the path is destroyed... or something to this effect. I noticed that when I used the highlight execution on the block diagram I received a whole lot more information in our *pointer, final destination.

Take a look at what I've done. I have added a while loop with pl_exp_check_status inside of it and checked the status message before allowing it to proceed.

This accomplishes the
/* ACQUISITION LOOP */
...on pg 117 of the manual
Вложения
PVCAM90_take2.zip
(1.53 МБ) 329 скачиваний
Аватара пользователя
mzu2006

Professionalism Tutorials Black
doctor
doctor
Сообщения: 2456
Зарегистрирован: 16 авг 2008, 02:12
Награды: 3
Версия LabVIEW: 7.1 10 11 12
Откуда: St-Petersburg (RU), Phila, Boston, Washington DC
Контактная информация:

Re: Running a microscope camera through pvcam32.dll

Сообщение mzu2006 »

I believe it does! Please, find my next iteration below. I have added an enum for camera status (I think you can do a good service for all future users of this package if you wrap some other constants from pvcam.h in enums...). And couple more cosmetic changes: adding a stop button, adding a wait so that it does not load CPU 100%, checking for other camera statuses, adding pvcam_uninit in the end.

I think you can give it a try now.
Вложения
PVCAM take3.zip
(1.47 МБ) 380 скачиваний
mechknoll
beginner
beginner
Сообщения: 11
Зарегистрирован: 08 июн 2011, 22:16
Версия LabVIEW: 2009
Контактная информация:

Re: Running a microscope camera through pvcam32.dll

Сообщение mechknoll »

Everything looks great! I have thrown in some extra features to adjust some parameters too. I have a question about what mmckinnon6 did to exp_set_seq. I am attempting to configure exp_set_cont such that it contains a cluster of s1 s2 sbin p1 p2 pbin. I have gone in to the configure menu and added rgn_array as a parameter. Set type as "adapt to type" and data format as "Array data pointer". Now when I save and attempt to place it within Cascade_cam the new rgn_array is unavailable to attach a cluster to. Is there another step I am missing?
Аватара пользователя
mzu2006

Professionalism Tutorials Black
doctor
doctor
Сообщения: 2456
Зарегистрирован: 16 авг 2008, 02:12
Награды: 3
Версия LabVIEW: 7.1 10 11 12
Откуда: St-Petersburg (RU), Phila, Boston, Washington DC
Контактная информация:

Re: Running a microscope camera through pvcam32.dll

Сообщение mzu2006 »

My 2 cents: do not go into exp_set_cont yet, as it will require setup and maintain a circular buffer as well as subscribe and respond to events. This is next level of complication. Check at first that you're able to get a frame that looks reasonable to you. You can output the frame to intensity chart for example.

And do not hesitate to post your code so that others may use it.

The current configuration of pl_exp_setup_cont is incorrect. arguments listed are wrong. The correct one is attached:
Вложения
pl exp setup cont.vi
(15.3 КБ) 378 скачиваний
Ответить
  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Communcation with devices»