LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Not getting expected data into my array

Good evening all. I am wanting to:

 

1. acquire data from 4 channels using the parameters in the screen shot

2. scale each channel using MAX scales

3. loop each row into an array

4. take the mean from each 75 sample batch and shove it back into a global array that can be accessed throughout the program by indexing out the necessary "channel".

 

FYI without making major changes to the inherited program at hand, I must do this. Any idea what I am doing wrong? 

Download All
0 Kudos
Message 1 of 7
(545 Views)

Can you explain what specifically isn't working for you?

 

For the 4th point, when you write an array to a global variable that is already populated with data, it doesn't append the two arrays and instead it overwrites all of the data. One way you could fix this is by reading what's currently in the global variable and appending the new data to it using the build array function and then writing that back to the global variable.

 

That usually isn't the best practice but without knowing more that would be the easiest way to fix that part.

0 Kudos
Message 2 of 7
(531 Views)

I am okay with continuously overwriting the data into the array, I am just trying to make averaged data readily available for any point in the program that needs an element (pressure, flow, temp, or position) from that global array.

 

For example, if a certain sequence in the program needs to obtain fuel pressure, then it will just increment out element 0. 

0 Kudos
Message 3 of 7
(518 Views)

You will need to describe what your expected array should look like. Right now, the code looks to be producing what you described.

 

EUData and SSData right now are duplicates. Are you expecting these to be different?

 

On each iteration of your while loop you are taking the mean of each channel's 75 samples and outputting it into the two arrays above. Are these means not what you anticipate?

 

Your TC looks to be open at the moment and the analog current measurements are all averaging to 0. Are you expecting different values here?

 

Are you attempting to build 2D arrays, where you pick an index of a channel and it provides you an array of all the means you have collected for that channel?

0 Kudos
Message 4 of 7
(517 Views)

If you are attempting to access an element of that array, you need to use the index array function under the array pallete. 

 

You will wire the global to it and an integer that represents the index of the element you want. For ease of access you can use an enum control, this will allow you to bind text to a numeric value. 

 

Is this what you are looking for?

 

Kavanakt7_0-1709169474333.png

Kavanakt7_1-1709169494193.png

 

0 Kudos
Message 5 of 7
(494 Views)

No, maybe I haven't phrased well my question. Did I set up my daqmx functions correctly to aquire data from 4 separate channels?

 

0 Kudos
Message 6 of 7
(476 Views)

What are the cDAQ Mod1, 2, 3 models?  If you did not get an error, then you can group the measurement types you have specified into the single task. I would recommend wiring the Min and Max values to the scaled range you anticipate, otherwise they are likely defaulting to some value you are not expecting. I would expect LabVIEW to throw an error unless you have automatic error handling turned off for the VI (File > VI Properties > Execution) or you are running this as an executable.

 

Typically, I would recommend calling the DAQmx Start Task.vi just after you configure the sample clock and before you get into the while loop. This will finalize the configuration of the task and will generate any errors if your task is not setup properly. The DAQmx Read.vi will auto start the task in your instance but could be producing an error. The error terminals in your while loop should probably go into a shift register (right click the node on the LHS of the while loop, and select replace with shift register, make sure the same node on the RHS is the other end of the shift register, then wire it all the way through the ERROR condition of your Case Structure, and maybe set Global Stop to true in the ERROR case so the program stops immediately for now). This will pass the error from one iteration to the next, so if the DAQmx Read.vi generates an error it will stop execution.

 

Typically on TC devices, an onboard CJC is being used by default(unless you wire something different to the cjc channel terminal) so the CJC Value (value of 25) is unnecessary in this case. The CJC Value is only applicable if you specify Constant Value to the cjc source terminal.

Message 7 of 7
(447 Views)