LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

IMAQ Serial Read error // Event structure with boolean buttons

Solved!
Go to solution

Hi, 

I have a custom-built camera that I intend to use with a NI PCIe-1427 CameraLink frame grabber. I create a camera file using the NI Camera File Generator and can run this camera with NI MAX. 

 

Details of camera communication: 

1. As soon as the camera establishes a serial connection, it starts sending status messages over the serial link, even before any commands are sent to it. 

2. The camera accepts a series of serial commands to initialize the internal registers. This set of 'Initialize' commands are read line-by-line from a file and sent to the camera over serial lines of the CameraLink interface. 

3. Similarly, the user can 'Run' (grab images) or 'Stop' (stop grab) the camera by sending specific serial commands. 

 

I am trying to develop an application in LabVIEW (version 2017, 64 bit) to control this camera and run into the following issues: 

 

1. The IMAQ serial read VI produces a timeout error (Error - 1074397037), no matter how long I wait for the serial read. How do I troubleshoot this issue? Serial read works fine in NI MAX. In my VI, I just continue execution when this error occurs, but I am looking for a permanent resolution for this error. 

2. Is there a way to continuously refresh the text box with serial output from the camera via IMAQ serial read VI? Currently it displays the serial messages received from the camera only after the app execution stops. 

3. I have implemented the three camera functions 'Initialize', 'Run', 'Stop' as three Boolean push buttons whose value changes are handled by an event structure. However, app execution is aborted after any of these events cases finish execution, even though I set the event timeout to -1 (infinite wait). Is there a way to wait for the next button push after an event case is done (Eg. After 'Initialize' is done, the app should wait for a 'Run' button push and so on)? Are boolean buttons / event structure the best options here?

 

Thanks a lot for your help!

Download All
0 Kudos
Message 1 of 4
(2,553 Views)

Hi SaMukh,

 

Looking over your questions and your code, I had a few thoughts I wanted to share. I'll address your questions in order:

 

1) This is going to be difficult to troubleshoot without knowing more about the camera you're working with.

  • What kind of communication bus does it use? You mentioned that you're using it with a 1427- is it a Camera Link connection?
  • Can you include screenshots of how you're sending IMAQ Serial commands from NI MAX? I'd like to make sure we're talking about the same process.
  • If it communicates over Serial, how do you have it attached to the 1427?
  • What kinds of start/stop bits is it expecting, and at what Baud Rate does it communicate?

Overall, this type of question may be better suited for working directly with our support engineers, rather than over the forums. If you haven't already, please go to ni.com/support or call in at (866)-275-6964 and open a Service Request to dig into the timeout errors more deeply.

 

2) The reason you're only seeing one output from the Read command is that you're only running the read command once each time you run your VI. If you'd like to run it multiple times, you may want to read and display the serial output inside of a loop.

 

I highly recommend running your code with Highlight Execution (the light bulb on the toolbar at the top of the page) turned on, and watching how it behaves.

 

3) Event Structures will only run once (capture one event) unless you put them inside a while loop.

 

This article is a good introduction to working with event structures (http://www.ni.com/white-paper/3331/en/), and this one goes into more depth on integrating other structures into the code with your event structure (http://zone.ni.com/reference/en-XX/help/371361K-01/lvhowto/event_struct_outside_loop/). These would be good places to start.

 

As for whether this structure is the best option, that's a very subjective question, and depends on what you'd like your user's experience to be. UI design tends to work best when you start from the intended interactions and then build the back end code to match.

 

I hope that helps get you off to a good start.

 

Kathryn K.
Technical Support Engineer
National Instruments
http://ni.com/support
Message 2 of 4
(2,510 Views)

Hi Kathryn, 

 

Thanks for your reply and helpful suggestions! 

 

I did create a support request a couple of days back. I am now following up directly with NI engineers to troubleshoot the IMAQ serial read errror. 

 

FYI - the camera uses a CameraLink interface. By serial communication in this context, I meant sending/receiving data over the async serial communication lines of cameralink. Sorry about the confusion! Also, I test the serial communication with the camera from the Camera File Generator and using this camera file, I am able to get images from the camera in NI MAX. There is no actual serial communication happening in NI MAX. 

 

I tried adding a serial read after every serial write in the different event cases, but the serial read/write text boxes reinitialize to default value on each call. Is there a way to append the serial commands to/from camera from different events to the text boxes? 

 

I have also been reading about event structures and came across state machines. Implementing the VI as a state machine has already taken care of issue #3. However for certain events in my VI like 'Run', there is some parts of the action that should be executed only once and other parts that need to be executed continuously (screenshot attached). Do I place the one-time actions in the event handler and looping actions in the case handler of the state machine? 

0 Kudos
Message 3 of 4
(2,497 Views)
Solution
Accepted by topic author SaMukh

Hi SaMukh,

 

Looking over your screenshot, it looks like you've got quite a lot of complexity inside of your event structure- this is generally not a good idea. Event structures are meant to run quick sections of code in response to an event (usually a UI event). But that's more of a side note, I don't think that's what causing your issue.

 

What I would recommend is, since you are able to capture images in NI MAX, to start with one of the built-in shipping examples. This does a few things for you:

  1. It gives you known good code to test and make sure there isn't a lower-level problem with drivers or software versions
  2. It gives you a good place to start programming, so that you don't have to write your program from scratch
  3. It gives you a good idea of how the functions you're using interact with the structures around them

Examples are kept in LabVIEW's Example Finder (more information), and the ones specific to CameraLink applications will be under Hardware I/O > Vision Acquisition > NI-IMAQ. I'd start with the High Level Grab or Snap examples, depending on what you're trying to do, and then go from there.

 

Kathryn K.
Technical Support Engineer
National Instruments
http://ni.com/support
0 Kudos
Message 4 of 4
(2,480 Views)