LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Some error when saving scanned data to an array

I mentioned this in my other topic, but since the question is kind of different I am creating a new one. If it's not okay, then please move it to the previous one.

So I build this imaging program, which scans the needed area column by column and saves the data to an array which is displayed as an intensity graph and also saves to a file after the program is done. 
The problem is when the whole scan is finished, I can see a bottom of the whole array is cut off and moved to the top of the picture:

scan image.jpg
My program should work like this:
You manually find a spot where the signal is the strongest, then you run the program. It says, that the spot of the strongest signal is the center of the square, moves a detector to an upper left corner of the square and a little bit outside(done by subVi called Homing) of it and then scans the area like this: 

 

scheme of scan.jpg

Green arrow is performed in the first loop, the scan is performed at the beginning of every red arrow(second loop), then last subVi brings everything back to start and moves to another column. I double-checked everything and still can not find the issue here...

0 Kudos
Message 1 of 3
(2,468 Views)

By using a few Style Rules (and almost always following them), you will possibly solve a lot of your problems yourself.

 

I started to look at your code, but found I didn't understand what you were doing nor how you were doing it.  As it happened, I started with Homing, which I rewrote and have attached.  The following are some Style Rules you should follow:

  • Always use the 4-2-2-4 Connector Pattern, with Error In and Error Out in the lower corners.
  • Give your Front Panel Controls "meaningful names", like Device Number In and Device Number Out.  "function_return" is a terrible name -- what is it?
  • A dirt-simple Icon for your VI will identify it when you use it.  The generic NI Icon is pretty useless in telling you (or someone else) what that VI is supposed to be.
  • I recommend turning off "View as Icon" for Front Panel Controls and Indicators.  You can do this by going to Tool, Options, Block Diagram, and unchecking the first box.  [You'll need to turn this off "by hand" for connectors you've already created].
  • Use the Error Line to serialize your code (when necessary).  You should almost never need to use a Sequence Frame (one exception is to "anchor" a Timed Wait, which you do correctly in MultiMetras).
  • Keep your wires as straight as possible, particularly the Error Line.
  • Keep your code "compact".  Use sub-VIs when necessary to "hide" details.
  • Try to keep information flowing left-to-right.  Try to avoid information "coming in from the top".  The "mess" at the center of Imaging needs some serious simplifying.  Start by making all of your VIs follow the 4-2-2-4 pattern and use the Error Lines to set the order of execution (rather than Frames).  There should be a single Error Out indicator, not multiple ones.  [See how you can merge errors in the attached Homing rewrite].

If you make your code more transparent, not only will others be able to better understand it (and help you find the bugs), but you will be able to follow your logic (which you presumably know much better than we do) and can have that famous "Aha!" moment when you see your own mistake.  [One possibility is that you don't wire all of the inputs to Homing -- did you mean to do that?]

 

Bob Schor

Message 2 of 3
(2,402 Views)

So yesterday I took my time to clean my code a little bit according to your recommendations, I ended up with this:
final version.jpgIt was, in fact, easier to follow my code right now and still I ended up with nothing-no error in my code causing the whole image to shift. Still I was lucky enough to find that the problem was in the analyzer-somehow it managed to load a buffer with more than one response leading to all of data being shifted by about 10 iterations, so the lower part of the image was being acquired later, when the detector was already at the top. So, I guess problem is solved for now 🙂 Thanks for your advices about cleaning my code! 

0 Kudos
Message 3 of 3
(2,372 Views)