LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Flat sequence structure in labview while using same DAQ at different instances

Solved!
Go to solution
Solution
Accepted by topic author Arunr88

Gerd is probably having the same problem understanding your (strange-looking) code as I did before I removed the Frame Sequence (see attached).  Now the structure looks clearer, and I have some observations and questions.

  • Use the Error Line!!!
  • It is generally much easier to view a VI if you use fewer icons.  I recommend you turn off "Place Front Panel terminals as Icons" in the Block Diagram page found on Tools/Options.  I also changed the huge, unwieldy DAQ Assistant, to an Icon (which placed the Error Lines in the correct, lower-corners, position).
  • Observation -- for both Vertical and Horizontal scans, you appear to do two sequential scans, the first 4 channels then the last 4 channels.  Was this your intent?  There is no (obvious) timing between channels 0-3 and 4-7.  
  • For maybe a decade, the easiest way to generate an array of values is to use the Indexing tunnel on the output edge of the While/For loop, and not to add values one at a time to an "Initialized to 0" array.  Also, you seem to build the Array by adding columns (instead of the usual rows), only to have to do lots to manipulations at the end (including doing transpose arrays at the end).  Notice how much "cleaner" the code is when you do it a row at a time.
  • You do a Fourier Transform, but only keep one frequency value.  Seems very curious, makes no "obvious" sense.
  • You can use "Stall" (from the Timing palette) to put a "wait" between functions separated (and connected) by the Error Line.
  • I'm not quite sure what you are trying to do after you have the Vertical and Horizontal data.  I think (but am not sure) you are trying to concatenate two Array results, so that's what I put in the final For loop.

I hope you will agree with me that this "frameless" version of your VI is much easier to read, much easier to figure out what is going on, and possibly easier to find where it does something different than what you expect (suggesting you found a bug).  I've attached my version.  Let us know if you can get it to work, now.

 

Bob Schor

0 Kudos
Message 11 of 19
(635 Views)

Hi Bob Schor,

 

Thank you so much. Now the error has been solved and able to get exact values from the DAQ.

 

Regarding your comments, I will try to explain my intention. Not sure whether it makes sense or not.

 

First of all, I am a beginner at LabVIEW. Hence, don't know about the usual procedures and simple methods. That was the main reason "why the code seems to be so drastic". 

 

My work is to obtain an image of a metallic object using MMW imaging using a row detector of 8 sensor elements. So, by mounting the row detector on a step motor and by making 16 vertical steps (0-15) and 02 horizontal steps (0 and next step according to the step size selected) during each vertical step. Thus, my plan is to generate a 16x16 grayscale image using the row detector.

 

Regarding the FFT magnitude corresponding to one frequency value - Here I am using a square wave signal of 10KHz frequency so as to modulate the radiation source used for imaging. So, I am only concentrated on that particular value corresponding to the mentioned frequency component.

 

Also, for the array manipulation my plan was to merge two 16x8 matrix in such a way that first column of the first array will be the first column of the appended array. Then first column of the second array will be the second column of the appended array.. For example if first matrix A is like A01 A02 A03.....and second matrix B is B01 B02 B03 .... Then the final appended matrix will be like A01 B01 A02 B02 A03 B03.......

 

I think I need to work something in your code to achieve this...right?

 

Anyway, the main headache was resolved.............. and now the code looks a professional touch and more easy to work with it...

 

Thank you so much ...Brother

 

Regards,

Arun

0 Kudos
Message 12 of 19
(607 Views)

Hi Arunr,

 


@Arunr88 wrote:

Also, for the array manipulation my plan was to merge two 16x8 matrix in such a way that first column of the first array will be the first column of the appended array. Then first column of the second array will be the second column of the appended array.. For example if first matrix A is like A01 A02 A03.....and second matrix B is B01 B02 B03 .... Then the final appended matrix will be like A01 B01 A02 B02 A03 B03.......


Like this:

The snippet shows how to concat two arrays row-wise.

When you need column-wise you  need to transpose them…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 13 of 19
(604 Views)

Hi GerdW,

 

Thank you for your quick prompt response. I will try to modify the code as you suggested.

 

Thank you.

 

Regards,

Arun

0 Kudos
Message 14 of 19
(600 Views)

Hello, Arun.  Glad that it is now working better.

 

     I could easily have gotten the ordering mixed up in the final combination.  Note that I assumed that the data coming in from the DAQ devices was organized so that the rows represent different A/D Channels, and the columns represent equally-spaced time samples of the data.  I'll leave it to you to be sure the values are in the order you want.

 

     A trick I find useful when dealing with such Array problems is to create a set of Dummy Arrays with unique values in all the cells.  Combine them and see if the combination is correct.  So Array A might be [A11 A12 (next row) A21 A22] and Array B would be similar.  Now combine them, and see if "what you get is what you want".

 

     How would you like to speed up your code by a factor of "a lot", and make it much more accurate?  Do not do an FFT to estimate the height of a square wave.  Take advantage of the fact that essentially all your data values are either +1 or -1 (scale as appropriate).  Use a For Loop surrounding a Case Statement to separate the Positives from the Negatives and create two arrays, Positives and Negatives.  Take the mean of each array and subtract them -- this gives you the amplitude without knowing (or caring, for that matter) anything about the sampling rate or the frequency of the square wave.

 

Bob Schor

0 Kudos
Message 15 of 19
(585 Views)

Hi,

 

I would like to know how can I modify the code so as to generate a 64X64 matrix. The same circuit with 8 sensors. But now I have to move 8 horizontal steps at a single row position and 64 vertical steps too. By doing so there will be eight 64x8 matrix. Finally I have have to merge those to form a 64x64 matrix.

0 Kudos
Message 16 of 19
(508 Views)

Here I am attaching the Sub VIs

0 Kudos
Message 17 of 19
(504 Views)

Also, in this code, I am facing some issues while combining the two 16x8 matrices. I am attaching a model pic of the required combined matrix. 

0 Kudos
Message 18 of 19
(494 Views)

Hi Bob,

 

Did you notice my post?

0 Kudos
Message 19 of 19
(448 Views)