Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

C++ code for PXI-1428 Frame Grabber

I have working visual studio 6 c++ code that works with our custom 3d camera over camera link.  We have a customer that has specified a pxi system using the pxi-1428 frame grabber.  My code currently works witht he imperx and the bitflow r64 camera link cards so I now need to modify it to work with the pxi-1428 card.  I'm trying to find example code for integrating the card into a visual studio 6 project.  The pxi system came with support for doing dotNETprojects, but I don't see code for the studio 6 projects.  Of couse I have no desire to move to dotNET, I just with to find the libraries that will allow me to code in visual studio 6. 
 
If someone could point me to the libraries/sample code for integrating the pxi-1428 into a visual studio 6 C++project I would appreciate it.
 
Thanks,
 
Larry
0 Kudos
Message 1 of 13
(8,151 Views)
Hi lweaver,
The Vision Acquisition Software which comes with our frame grabbers includes examples for LabWindows/CVI, Visual C, Visual Basic, and .NET languages, you just might not have them installed already.. If you go to Control Panel » Add/Remove Programs » National Instruments Software and select Change/Remove, it will bring up a list of NI software installed on your system. From there you can choose to modify your NI-IMAQ (or NI-IMAQdx or NI-IMAQ I/O) installation.

Then in the setup, make sure the examples for Visual C are included as shown in my attached screenshot. I've circled it for both IMAQ (like you would use for your CameraLink board) and for IMAQdx (which other customers would use for Firewire or Gigabit Ethernet cameras). Once those are installed you can find documentation, including a function reference, in Start » Programs » National Instruments » Vision » Documentation » NI-IMAQ

That folder will also contain the IMAQ readme, which explains that the examples will be installed to the following directories (depending on operating system):

        If you are using Windows XP, the files for Camera Info, Camera Support, Data and text-based Examples (MSVB.NET, MSVC, and VB) are installed to

x:\Documents and Settings\All Users\Documents\

National Instruments\NI-IMAQ\, where x is the letter of the drive where NI-IMAQ is installed.

·      If you are using Windows Vista, the files for Camera Info, Camera Support, Data and text-based Examples (MSVB.NET, MSVC, and VB) are installed to

x:\Users\Public\Documents\National Instruments\NI-IMAQ\, where x is the letter of the drive where NI-IMAQ is installed.

·      The files for MSVC include, 32-bit MSVC library, and 64-bit MSVC library are installed to

x:\Program Files\National Instruments\Shared\ExternalCompilerSupport\C\, where x is the letter of the drive where NI-IMAQ is installed.




Message Edited by VGA CD-ROM on 02-13-2008 07:01 PM
0 Kudos
Message 2 of 13
(8,138 Views)

Ok, that helps, but leads to another problem.  Appearantly the code is expecting specific answers from the camera.  I've created a camera file and it shows up in max so that I can select it.  However in the example code it requires a name (the one in the example code is cam0) and I'm not sure how that is selected.  I've tried using the name of the camera that I saved, but all I get from the open camera (the first one in the sample programs showing a simple grab) is that the camera is not found.  Our camera is very dumb, it is commanded over the serial port and sends up 3d images.  There is no auto configuratoin information from the camera.  What I need to do is set up some buffers and send commands to the camera that will cause it to send up images. 

Is there some information on exactly how to configure the card to accept images from the camera by triggering on fval and grabbing an image. 

Thanks,

 

Larry

0 Kudos
Message 3 of 13
(8,131 Views)
Since you are able to see the camera in MAX, are you able to do any test acquisitions from there? The camera should have a unique name based on the camera configuration file for it such as img0 or img1 unless you renamed it in MAX. If you're unsure, you can search your National Instruments\NI-IMAQ\data directory for the .iid file associated with the camera. If it is named img0.iid, for example, that would indicate your camera is named img0 in MAX. This would be the name for the camera you want to use for your functions.

I'm not sure which example program you were looking at, but oftentimes when you see "cam0" as an example name for an image, it is actually using the IMAQ for IEEE 1394 driver (intended solely for Firewire cameras) and not IMAQ (used for Cameralink, parallel digital, and analog cameras). On my Windows XP system, my Visual C examples are found in the following location, though it can change between operating systems:

C:\Documents and Settings\All Users\Documents\National Instruments\NI-IMAQ\Examples\MSVC\
0 Kudos
Message 4 of 13
(8,119 Views)
It is listed as img0 in max.  Our camera is a custom 3d camera.  All we use the frame grabber for is getting the data into the computer.  It is custom controlled by the serial port and has a lot of setup that needs to be done.  There is no way to do an image grab from max.  What I need is just low lever control of the frame grabber card and it's serial port.
 
I'll check the example directory and see if I can find some code using img0.
 
Thanks,
 
Larry
0 Kudos
Message 5 of 13
(8,116 Views)
Try looking at some of the examples with "LL" in the name, which stands for lower level control. They might have something that more closely resembles how your camera might operate. To avoid needing to manage other drivers, IMAQ also has some functions for serial read and write, such as imgSessionSerialWrite() and imgSessionSerialRead().
0 Kudos
Message 6 of 13
(8,101 Views)

I've looked at the ll type programs and still have basic problems.I have defined a camera file and assigned it to "img0" in max, but if I try to open that camera in a c file it gives me a "camera not found".  Then if I go back to max it says there is no camera file and shows an x.  The only way to get it back is to reboot, then max is pointing back to a cohu camera. 

I've also two other major problems.  I can't find a way to assign the serial port on the frame grabber card to a com port, nor can I find code to allow me to program the serial ports on the card.  How do I program the serial channels on the 1428 card.

The other problem is the 4 discrete lines.  I can't find any code to allow me control of those lines.  We use them to control various aspects of our camera and I need individual control of the 4 lines.  Is there code for this.

Is there some documentation that tells how the code expects a frame link camera to work.  All I want is low level control of the camera link interface and as far as I can tell all of the code is only working with high level commands.  Is there some lower level code that I can work with?

Thanks,

 

Larry

0 Kudos
Message 7 of 13
(8,074 Views)
 

Hi Larry,

The low-level function listed in the IMAQ function reference help (which can be found in Start » Programs » National Instruments » Vision » Documentation » NI-IMAQ) may be what you are looking for. They are as low-level as our frame grabber boards allow you to get. But fundamentally it sounds as though the camera is not configured properly for the Camera Link interface - are you sure it is fully compliant with the interface standard? You said it was a custom 3D camera, so I suppose there is no model information for the camera system?

Also, are you sure that the camera file you have created is properly set up? You might want to try basing your file off of the default file for the 1428, and/or by using the Camera File Generator tool. What kind of format is the 3D camera expected to return, 2D "depth" images (monochrome heightmap)? If it is supposed to return 2D-type images when it acquires, you should still be able to perform test acquisitions in MAX with it. If a test acquisition in MAX does not work, you likely will not get it to work in your programming environment, either.

For the serial lines, if your camera accepts the serial commands sent over the camera link bus (on pins 6, 19, 7, and 20 in the 26-pin MDR connector as shown in the PXI-1428 manual), the commands such as imgSessionSerialWrite() and ...SerialRead() directly access the frame grabber's serial interface and do not require remapping the device to a virtual COM port on the system. These functions are fully documented in the IMAQ function reference help, listed under Low-Level Functions » Serial Communications Functions

If your camera, however, requires you to use a separate 9-pin RS232 connector for serial communication and you need to use your computer's onboard parts, that is a different implementation. You could then use our NI-VISA drivers or other 3rd party drivers that allow you to access your onboard serial ports directly.

For the digital I/O lines, again the IMAQ function reference help file is your best bet. If you browse under High-Level Functions » Signal I/O Functions, you will see all the functions related to operating those digital I/O lines. In particular, the function imgSessionTriggerDrive2() is probably what you want, with the constants IMG_TRIG_DRIVE_ASSERTED and IMG_TRIG_DRIVE_UNASSERTED used as constants for the "source" parameter to drive the lines active or inactive at your discretion. Your IMAQ examples directory also has a subfolder called "Signal IO" which solely deals with the digital IO lines (also often called trigger lines, though you can assert them high and low whenever you want).

 
0 Kudos
Message 8 of 13
(8,038 Views)

Unfortunately there is no "standard" format for our camera.  It sends back some very complicated information which can be transformed into a 3d image.  The information bears absolutely no relationship to an "image" in any framegrabber vocabulary.  That is why I need the low level functions.  The only function for the frame grabber is to bring the information into the computer in a timely manner.  All of the imaging is done with special software once the information is acquired. 

As for being framelink complient, the signals are completely complient.  As I said we have it working with two framelink grabbers already (imperx and bitflow).  I did use the camera file generator to create the camera file, but as I said, since the information bears no relationship to an image.  I just need to establish a buffer, set up the grabber to trigger on Field, pay attention to Data valid and bring the data in when an image goes by. 

Before we went to the framelink interface we used your NI PCI-6433 for the transfers.  What I really want is the equivalent low lever interface I used for that card.  I really want to be in charge of the buffer sizes and the acquisition of the images.  As I said, I've had no real trouble finding low level routines for imperx and bitflow. 

However bitflow did have to create a camera file since their camera editor program didn't have low level assignments (like assigning the trigger function to the rise of Field).

Yes we use the serial ports on the framegrabber interface for the communication.  Imperx turns it into a virtual com port, bitflow uses routines like yours (I just couldn't find yours until you pointed me in the right direction). 

Thanks,

Larry

0 Kudos
Message 9 of 13
(8,033 Views)
If the data being accessed is not image data, what is its format? I'm not sure how the camera file can be modified to accomodate your hardware signaling and timing, but I can look into how it might be possible.

Also, I'm not sure which NI board you were referring to by the model number PCI-6433, as I could not find any references to that model number anywhere in our site or available literature. Google searching only brings back this thread and one other unrelated link. Did you mistype the model number?


Message Edited by VGA CD-ROM on 02-24-2008 12:14 PM
0 Kudos
Message 10 of 13
(8,002 Views)