05-30-2014 06:34 PM
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.
05-30-2014 06:36 PM - edited 05-30-2014 06:38 PM
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).
05-31-2014 09:43 AM
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
🙂
05-31-2014 11:24 AM - edited 05-31-2014 11:24 AM
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:
05-31-2014 12:16 PM
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.
05-31-2014 07:08 PM - edited 05-31-2014 07:09 PM
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.