LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial Input 2D Array Replacing Element and Re-initializing Problem

Solved!
Go to solution

I have a project with data coming in from a PIC18f microcontroller that's streaming data through USB.  The data incoming into LabVIEW is delimited in a certain way and replaces one row of a 9x6 array of data.

 

The issue I'm having is that each row that I wish to update, updates properly but all other rows re-initialize to zero where I'd like to keep all the previous data in the other rows in addition to the newly updated row. The reason why I update each row is that the serial data coming in from my microcontroller has a max buffer size so it streams into LabVIEW with certain delimiters that the program in LabVIEW will recognize for each row/column and update the data into the corresponding cell (but it does so by also deleting all other other entries which isn't what I want!).  

 

I've been using shift registers and still the issue persists.  Attached is my code and to emulate my serial input as a string, I've copied and pasted what my serial data is below.  So all that's needed to be done is to change between the different strings in the "String Indicator (Hex Display) input as the program is running.

 

Any help would be greatly appreciated!  Thanks 🙂

Candice

 

String 1:

:1'1,11B0:1'1,2FFA0:1'1,33DD0:1'1,40:1'2,11A0:1'2,2B0:1'2,340A0:1'2,4380:1'3,1FFFF:1'3,2FFFF:1'3,3FFFF:1'3,4FFFF:1'4,1FFFF:1'4,2FFFF:1'4,3FFFF:1'4,4FFFF:1'5,1FFFF:1'5,2FFFF:1'5,3FFFF:1'5,4FFFF:1'6,1FFFF:1'6,2FFFF:1'6,3FFFF:1'6,4FFFF

 

String 2:

:2'1,1330:2'1,2FFF0:2'1,33DF0:2'1,4700:2'2,1FFFF:2'2,2FFFF:2'2,3FFFF:2'2,4FFFF:2'3,1FFFF:2'3,2FFFF:2'3,3FFFF:2'3,4FFFF:2'4,1FFFF:2'4,2FFFF:2'4,3FFFF:2'4,4FFFF:2'5,1FFFF:2'5,2FFFF:2'5,3FFFF:2'5,4FFFF:2'6,1FFFF:2'6,2FFFF:2'6,3FFFF:2'6,4FFFF

 

String 3:

:3'1,1FFFF:3'1,2FFFF:3'1,3FFFF:3'1,4FFFF:3'2,1FFFF:3'2,2FFFF:3'2,3FFFF:3'2,4FFFF:3'3,1FFFF:3'3,2FFFF:3'3,3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FF:7'4,3FFFF:7'4,4FFFF:7'5,1FFFF:7'5,2FFFF:7'5,3FFFF:7'5,4FFFF:7'6,1FFFF:7'6,2FFFF:7'6,3FFFF:7'6,4FFFF

 

String 8:

:8'1,1FFFF:8'1,2FFFF:8'1,3FFFF:8'1,4FFFF:8'2,1FFFF:8'2,2FFFF:8'2,3FFFF:8'2,4FFFF:8'3,1FFFF:8'3,2FFFF:8'3,3FFFF:8'3,4FFFF:8'4,1FFFF:8'4,2FFFF:8'4,3FFFF:8'4,4FFFF:8'5,1FFFF:8'5,2FFFF:8'5,3FFFF:8'5,4FFFF:8'6,1FFFF:8'6,2FFFF:8'6,3FFFF:8'6,4FFFF

 

String 9:

:9'1,1FFFF:9'1,2FFFF:9'1,3FFFF:9'1,4FFFF:9'2,1FFFF:9'2,2FFFF:9'2,3FFFF:9'2,4FFFF:9'3,1FFFF:9'3,2FFFF:9'3,3FFFF:9'3,4FFFF:9'4,1FFFF:9'4,2FFFF:9'4,3FFFF:9'4,4FFFF:9'5,1FFFF:9'5,2FFFF:9'5,3FFFF:9'5,4FFFF:9'6,1FFFF:9'6,2FFFF:9'6,3FFFF:9'6,4FFFF

0 Kudos
Message 1 of 8
(6,652 Views)
Solution
Accepted by topic author cjxi

Hi Candice,

Try the VI attached.  I think the while loop loops for each row(?)  If so, you needed one more set of shift registers on the border of the while-loop.

 

Hope it helps!

 

Message 2 of 8
(6,624 Views)

I'm a little confused by your problem, which I think you are approaching in the wrong manner.  One question is "Is there a repetition or periodicity to the data"?  This has two parts -- is the number of entries for each "row" the same for all rows, and are there a fixed (possibly repeating) pattern of rows?  For example, your code looks like it is set up for 9 rows -- do you collect exactly 9 rows, or do you collect them 1, 2,3, 4, 5, 6,7,8,9,1,2,3,4, etc. where you want to have a 9-row structure where the "current row" only is updated.

 

The simplest case is "Each row is the same length, and there is a finite, but undetermined, number of them (and we want them all).

 

Write a sub-VI whose job it is to take a single row of data and return a 1D-Array of values corresponding to the data in this row.  Note, by assumption, that for subsequent data, it will return the same size 1D array.  Now all you have to do is start with an empty 2D array and Build Array with your new 1D array to its end.

 

If you have a finite (say, 9) row 2D array in mind, start the same way, but initialize your 2D array as 9xN.  Use the same sub-VI to get your 1D array, and use Replace Array Subset to insert the new Row into the proper place in your 9-row array (use the Quotient/Remainder function with the Loop Index, "i", and the number 9 to get the correct replacement row).

 

Bob Schor

0 Kudos
Message 3 of 8
(6,599 Views)

Hi 550nm,

 

Unfortunately, I have an older version of LabVIEW and can't open your VI.  Is it possible to share a screenshot of your code?  I'm not sure which area would need another set of shift registers.

 

Many Thanks,

Candice 🙂

0 Kudos
Message 4 of 8
(6,569 Views)

Hi Bob,

 

Thanks for reply.  So I think my situtation is most similar to the second case except I know my sensors are layed out by 9x6 and any order of data may come in.  There is a finite amount of rows, and I just want to update the one row (actually, I also want it to be able to update one element at one row/column location, if the stream of data just so happens to be set that way too).

 

With the first case, wouldn't building an empty 2D array initialize a blank 2D array and then placing the 1D array would just insert it into that certain row but keep all others still at it's initialized number? (leading to the same situtation I have currently)

And with the second case, I don't think it would work since the incoming row number may come in at random and it isn't always in the order of 1,2,3,4,5,6,7,8,9. It could potentially come in at 3, 3, 4,1, 7,7,9, etc.  

 

Apologies if I'm not quite understanding quite yet but maybe you could help me work through it! 🙂

Cheers,

Canidce

0 Kudos
Message 5 of 8
(6,567 Views)

Hi Candice,

Here's a copy saved for LV2011.

 

Hope it helps! Smiley Happy

0 Kudos
Message 6 of 8
(6,560 Views)

Thank you! Actually, my LabVIEW is 2010, the other computer which I don't have access to this afternoon has 2011 but I think I understood what you meant by the shift registers and added them to the larger While Loop and I have my VI working!

 

Thank you so much for you help!

0 Kudos
Message 7 of 8
(6,553 Views)

Hi Candice,

Thank you for the Kudo and for sharing the good news! Smiley Happy

 

Cheers!

0 Kudos
Message 8 of 8
(6,550 Views)