LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Appending for loop data into the same array (waveforms)

Hello,

 

I am trying to record data from a NI DAQ USB 6210 connected to a SRS 830. I´ve got some hints from another topic published here (click here:  how to append array elements without overwriting? ) on how to do this, so I proceed with a shift register, creating a constant array, and using the "Insert into Array" function. However, instead of having a single array spawning several seconds, I have multiple arrays spanning one second (the DAQ is set to read 1ksamples per second at a rate of 1kHz.) 

What am I missing in order to obtain a collated, continuous time vs voltage array instead of this collection of arrays? The images below depict the Waveform Graph with all the collected data (several sets spanning 1 second) as well an overlook of the output array, whereas the second shows the current code pertaining to the data collection.

 

Any feedback would be most welcome!

 

Kind regards.

 

 

DAQ_array_front_view.PNG

 

DAQ_array_code_view.PNG

 

0 Kudos
Message 1 of 8
(550 Views)

Hi Flonares,

 


@Flonares wrote:

 so I proceed with a shift register, creating a constant array, and using the "Insert into Array" function. However, instead of having a single array spawning several seconds, I have multiple arrays spanning one second (the DAQ is set to read 1ksamples per second at a rate of 1kHz.) 


Because that is what you have programmed!

Your shift register contains an array of waveforms and with each iteration you "insert" even more waveforms into this array! (Btw. don't use InsertIntoArray when you want to build an array. There's a BuildArray function!)

 

Suggestion:

You read "n channels" from DAQmx and you (most probably) want to append the waveforms for each channel. Why don't you use AppendWaveforms in a loop and have this loop iterate over all those channels?

(Be aware of side effects, like handling the first iteration correctly…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 8
(528 Views)

Dear GerdW, 

 

Many thanks for your reply. I tried appending the waveform as you spoke, but I ended up with some errors I don´t fully understand, so I am definitively doing something wrong. Could you provide me with some insight?

Errors:

1) These cannot be wired together because their data types (numeric, string, array, cluster, etc.) do not match. Show the Context Help window to see what data type is required. The type of the source is 1D array of Waveform(DBL). The type of the sink is Waveform(DBL).

2) You have two or more array data types wired together, but the arrays have different numbers of dimensions. Show the Context Help window to see how many dimensions are required. The dimension of is 1. The dimension of Final Waveform is 2.

 

The last error is somewhat understandable:
3) A For Loop must have a loop count wired to the 'N' terminal, or an array input that has auto-indexing enabled. Otherwise the loop does not know how many times to iterate.

 

I still need to find out how to pass the number of loops to be executed in order to fully process the waveforms. But I don´t understand how I get a 2D Waveform - since I´m just appending data, shouldn´t it be just a single column?

Kind regards,

Flo

Wiring schematicWiring schematic

0 Kudos
Message 3 of 8
(458 Views)

Hi Flonares,

 


@Flonares wrote:

I tried appending the waveform as you spoke, but I ended up with some errors I don´t fully understand, so I am definitively doing something wrong. Could you provide me with some insight?


Your FOR loop looks different then mine!

Please check ALL input tunnels: in my suggestion BOTH are set to autoindexing!

(You cannot append an array of waveforms to an existing waveform using the WfmAppend function!)

 

It also doesn't make sense to append waveforms to a constant "empty waveform"! You need to use a shift register to store your waveforms for the next iteration.

As this is basic LabVIEW knowledge: please take note of those Training resources offered at the top of the LabVIEW board!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 8
(453 Views)

But the shift register needs to be initialized, correct? So how would I properly initialize it?

 

Kind regards,

Alcides

0 Kudos
Message 5 of 8
(442 Views)

Hi Alcides,

 


@Flonares wrote:

But the shift register needs to be initialized, correct? So how would I properly initialize it?


You could use the data from DAQmx when the sift register holds an empty array (aka: use the data of the first iteration)…

 

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 8
(439 Views)

It is prolly asking for too much, but would you be so kind as to provide me with a minimal working example of your idea? I still have some issues trying to understand how I would implement it.

 

Kind regards,

Flo

0 Kudos
Message 7 of 8
(424 Views)

Hi Flo,

 

you may use a case structure instead of the select node:

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 8
(421 Views)