LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

creating a 2d array from 1d data

i have a created  a 1 d array with 2 elments, the VI completes 21 cycles and on each iteration the vales in the 2 elemnts change. what i would like to do is to create an array that after the 21 itertaions will have 21 rows of data in 2 columns.

0 Kudos
Message 1 of 6
(2,486 Views)

Simply autoindex the 1D array at the right loop boundary.

 

(Overall, it seems like your code cound be reduce to 10% of the currrent size :D).

Message 2 of 6
(2,485 Views)

Thanks for the fix, it works a treat and also thanks for the adivce. you can probably tell from my code that im quite new to labview, just in the past few hours i have found some different VIs that could cut down atleast half the code. But as i am tryng to get the code completed asap i thnk ill leave it and then ammed it latter.

 

not sure if i should be creating a new post for this or carry on with this post??  your see from the attachment that i have ended up with a 2d array, the first coloum is a channel number and the secound column is the data for that channel. what i want to end up do is plotting all the data for channel 1 on  graph and on the same graph plot all the data from channel 2 etc. once the test system is up and running there will only ever be channel 0,1,2 and 3.

 

what way would you recomend to extract the data from the data column of the 2d array for all channel 0 data, channel 1 data, channel 2 data and channel 3 data.

 

any advice would truely be appreciated

 

🙂

0 Kudos
Message 3 of 6
(2,440 Views)

Could you explain your data?  From what I can gather is that you are recieving a 16 bit word.  The first nibble (MSB) is the channel number and then you have 3 nibbles of data.  Is this assumption correct?

 

If so, your VI can be simplified to this:


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 6
(2,422 Views)

i have 4 ADC's named channel 0-4.  These feed into a bunch of electronics which output a 12 bit wide word which makes up a 12 bit by 16 deep 'Packet'. if a sample was taken on chanel 3 ADC and the sample aquired was B3D xh ( 12 bit ADC) then the 16 12 bit packet is shown in the attached picture. the 4 MSB are can be competely ignored as they are only used as a refrence for the electronics im working with

 

The first  12 bit word outputed represents the ADC channel number, as there are only 4 ADC i will only be intrested in the 1st 2 LSB

 

Another 12 bit word will be outptted this time the 4 LSB ripressents the LS nibble of the adc (D = 1101)

 

then another 12 bit word will be outputted, once again 4 LSB repressents the midle nibble of the adc (3= 0011)

 

once again another 12 bit word will be outputtes, this time the 4 LSB represnt the MS nibble ( B= 1011)

 

another 12 bits will be outputted but this will be padded out with zeros as there is no data, these 12 bits will be outputted untill 16 x 12 bits have been outputted.

 

Then the process starts again i.e the 17th 12 bit word will be the channel number of the next ADC that taks a sample.

 

I hope this makes sense, any advice for a newbie would be great.

0 Kudos
Message 5 of 6
(2,412 Views)

Ok, let's start with making a data stream that mimics what you should actually be seeing.  Once we have good data to look at, we can then test out the code.

 

I recommend using a FOR loop that runs for 16 times.  Inside of the FOR loop we have a case structure with the iteration terminal wired up to the selection terminal.  Now you just fill in the data for each case.

 

And then figure out how to parse the 16 words into channel ID and data.  Index Array and Array Subset with another FOR loop and offsetting should do the trick.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 6
(2,385 Views)