LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

data doesn't stay in matrix

Solved!
Go to solution

Hello LabVIEW gurus,

 

I'm working on some code that fills a matrix with voltages read off of a meter. I'm picking the index that the voltages are put into because it needs to be in a specific order. My code works and the voltages are seen in the index they are supposed to be in, however they don't stay. When the meter reads another data point, the previous index is reset to zero. It only show up in the matrix before the next data point is read by the meter. I would love if the matrix was full of data when the code stopped, but I can't figure out how to do this really. 

 

I posted a piece of my code to show you all how the matrix is being made and filled.

 

Any help would really be great!

 

thanks all

0 Kudos
Message 1 of 5
(2,519 Views)
Solution
Accepted by topic author winterfresh11

Hi fresh,

 

two points:

- THINK DATAFLOW!

- Don't mix up the terms "array" and "matrix". These are similar, but different things in LabVIEW!

 

See this snippet:

check.png

 

- THINK DATAFLOW: values are stored in wires and shift registers! (Indicators are just data sinks, controls are data sources…)

- ARRAY: use array functions (like ReplaceArraySubset) to manipulate arrays!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 5
(2,513 Views)

That is going to happen every time you write default values to terminals in a loop! 

 

Your code makes very little sense- lets do a walk-through

 

  1. Get the current value of an indicator (Array2) which is likely size 0,0 and put that empty array on a tunnel so it will be used for every loop iteration.
  2. For each iteration:
    1. Write Array 2 terminal with default data (Empty array)
    2. Write Default data to terminal Y Counter (scalar 0)
    3. Write Default data to terminal X Counter (scalar 0)
    4. If True:
      1. Read Y Counter via Local Variable (its a 0)
      2. Add some element to the empty array after coeresing it to a matrix at position [0,-1] if the second case is T or [0, X Steps-1] if F (X Counter is 0 so the subtraction is moot)
      3. Coerese the matrix back to an empty array and display it in the "Intensity graph"
    5. Else: Return
  3. Iterate loop till Hell freezes over

That is not likely what you want the code to do.Smiley Surprised


"Should be" isn't "Is" -Jay
Message 3 of 5
(2,502 Views)

Thank you both for the replies!

 

Gerd that picture helped me, I figured out how to fix it and now I have an array the fills perfectly with my measured voltages. Thanks Jeff, that helped me understand the data flow better, I didn't realize what I was doing wrong until now, I'm pretty sure I get it now. I had similar problems like this before and I think I've been making the same mistake

0 Kudos
Message 4 of 5
(2,493 Views)

@winterfresh11 wrote:

Thank you both for the replies!

 . I had similar problems like this before and I think I've been making the same mistake


I suspected as much.  Thats why I took the time to walk it through.  Training is available- consider it.


"Should be" isn't "Is" -Jay
0 Kudos
Message 5 of 5
(2,482 Views)