LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

insert into array is faulty?

Hi everybody.

I acquire data from a DAQ instrument, and at an initial stage - denoted in the staqued sequence structure (ignore the rest of the code, it may appear messy) - I gather the inputs(array of data inputs) into an array using the ''insert into array' function. Each new array is added at the first position of the existing one. The reason of this stage is calibration, which stops when I press a labeled stop button. At this point, I want to compute the minimum and maximum from this whole array that I have been collecting so far.
 
What I get, nonetheless, is not what I should. From my observations, it keeps the maximum from the first gathered array(the last one in the collection, according to the indexing) and the minimum from the last gathered array(the first in the collection). But there are greater values than the extracted  maximum and lesser values than the minimum inbetween.
Do one has an explanation for such behavior?

Thanks a lot,
Dana
0 Kudos
Message 1 of 8
(3,381 Views)

Hi Dana,

change the tunnels in your while loop to a shift register, i think this will sovle your problem. With the tunnels, your array starts every iteration with the same values.

Mike



Message Edited by MikeS81 on 02-08-2008 09:23 AM
0 Kudos
Message 2 of 8
(3,364 Views)
"Do one has an explanation for such behavior?"

Yes. Because that's the way you coded it. In your while loop (which seems to have tunnels to nowhere, like the sequence structure), you are always operating on the initial array. That's because you're tunneling the output of the Initialize Array function. The while loop boundary has this as the array, and it is always this array which gets fed to the Insert Into Array function. You need to replace that tunnel with a shift register.

That said, even though you said to ingore the rest of the code, that's not going to happen: Smiley Wink
  • Your sequence frame serves no purpose. It is not forcing any kind of execution order, and removing it will not affect operation of the code.
  • You have way too many stop buttons. In the while loop where you're doing the calibration you're using one stop button, and looking at another and performing an OR operation with the error status, but not doing anything with that.
  • You have tunnels going nowhere.
  • You are directly linking to an example VI that's distributed with DAQmx. You should, instead copy that example VI to your source code directory. The reason is that examples change with different versions of DAQmx. In fact, when I opened your VI with LabVIEW 8.2 that example VI doesn't exist. Hence, broken code.
  • You are misunderstanding the concept of producer/consumer. You do not have a producer/consumer architecture. You just have a loop that's running after you've finished your calibration. Are you intending to use a producer/consumer architecture?
  • You can replace the Quotient & Remainder with the Equal to 0? and the Select functions that you're using to control the case structure with a singleTo Long Integer (I32) function.

0 Kudos
Message 3 of 8
(3,360 Views)
Hi Dana,

instead of inserting at the first element you should use a simple "build array" node (in concat mode) - see attachment.

I don't understand your problem of min/max-values... In the first loop you collect an array of data, in the second loop you process the data. Here you should get the min/max of the full array. If this is not the case provide a (simpler) example vi with some example data!


Message Edited by GerdW on 02-08-2008 04:31 PM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 8
(3,357 Views)
Hello, Mike
- it worked, thank you.
But I don;t have the knowledge of working with this shift register instead of the simple tunnel - no read help provided me with such remarks. Where should I know these things from?

Best regards,
Dana
0 Kudos
Message 5 of 8
(3,349 Views)
Hello and thank you very much for your broad and detailed response.
The program is a big draft, I keep modifying it, for example I started from a PC template, and then the program took another shape. Or in some parts, as I don't know how to comment some parts of the program, I let them there for the moment. With respect to the user interface, one can find a mess of buttons spread all over.
However, there are some of your remarks that I will consider. Thanks again.
The proposed solution worked, but still I claim that there is a gap in the help, taking into account that I found no explanation of how to use the tunnel - I thought it's only to connect structures, and had no idea how and in what cases I should change it in something else, i.e. a switch register. Moreover, I didn't know and didn;t find documentation on what is the purpose of the shift register...

Kind regards,
Dana
0 Kudos
Message 6 of 8
(3,345 Views)
Hi Dana,

it can be found in the LabView help:
-> Fundamentals
  -> Loops and structures
     -> Concepts
        -> For loop and While loop structures

On the NI website you can also find 3h and 6h courses to learn LV fundamentals!
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 8
(3,344 Views)
Thanks for the guidelines, GerdW. I'll put a 'bookmark' with this in my mind.

Kind regards,
Dana
0 Kudos
Message 8 of 8
(3,337 Views)