From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Possible Rube

If anyone would like to add some insight into modifying this snippet of code which may possibly be a Rube, please feel free. If not, it's not a big deal.

 

I hope you can understand the order the data is coming in based on my comments. This data is coming over a LAN connection from an RT system. For this example, assume 2 revolutions of data are being sent in the array and the encoder resolution is 60. So, the array will be as follows:

 

Revolution 1 channel 1 (60 points of data)

Revolution 1 channel 2 (60 more points of data)

Revolution 2 channel 1 (60 more)

Revolution 2 channel 2 (60 more)

Revolution 1 channel 1 4 specific points (4 data points)

Revolution 1 channel 2 4 specific points (4 points)

Revolution 2 channel 1 4 specific poitns (4 points)

Revolution 2 channel 2 4 specific points (4 points)

 

So the total array size is 236.

 

I want to split this into two, 2D arrays as follows

Rev 1 channel 1 60 points and Rev 1 channel 1 4 points concatenated -> Row 1

Rev 2 channel 1 60 points and Rev 2 channel 1 4 points concatentated -> Row 2

 

Other array, the same but channel 2

 

Basically I'm trying to lump all this crazy interleaved data together in an expandable way, so that if encoder resolution or the number of revolutions to send changes, my code will still work without any changes.

 

Whew, that was long winded and I'm sure clarification will be needed, so just let me know.

 

0 Kudos
Message 1 of 12
(2,631 Views)

In my roll-my-own snippet creation software I have the option to disconnect all controls from their Type Def, would have helped here.  Easily fixed though. 

 

More helpful, though, would be some default data in that cluster.

0 Kudos
Message 2 of 12
(2,611 Views)

@Darin.K wrote:

In my roll-my-own snippet creation software I have the option to disconnect all controls from their Type Def, would have helped here.  Easily fixed though. 

 

More helpful, though, would be some default data in that cluster.


At least I'm using typedefs!!! haha.

 

I'll put together some default data when I get a chance, but it may not be until a bit later today.

0 Kudos
Message 3 of 12
(2,606 Views)

Either I'm misunderstanding your text, or your description of the starting DataArray format doesn't match what your code does.  Default data will help.  I suspect that the Reshape Array function will be your friend.  I would start by reshaping your DataArray into a two-dimensional array where each row corresponds to one revolution.  You can then feed that into an auto-indexing for loop and extract the portions for each channel.

0 Kudos
Message 4 of 12
(2,588 Views)

@nathand wrote:

Either I'm misunderstanding your text, or your description of the starting DataArray format doesn't match what your code does.  Default data will help.  I suspect that the Reshape Array function will be your friend.  I would start by reshaping your DataArray into a two-dimensional array where each row corresponds to one revolution.  You can then feed that into an auto-indexing for loop and extract the portions for each channel.


To avoid all confusion with what I explained, here is some deafult data outputting what I expect.  Ok, it's not data it's a for loop :). If you want to test more than 2 revolutions, the number of for loop iterations would have to be (60 * NumOfRevs * 2 channels + 4 points *2 channels *NumOfRevs) because that would be the size of the data array coming in. Maybe all of some of the confusion came from me saying the array size would be 236 in my first post, I meant 256. 

 

0 Kudos
Message 5 of 12
(2,572 Views)

Not sure if it is much simpler, but here's one possible alternative (bottom of diagram). I am sure there is quite a bit of slack left. 😄

 

 

 

Message 6 of 12
(2,548 Views)

I'll play along, except I did as you said (in your comments) and not what you did (in your code).  Of course there are also typos in the comments. Like AB, not sure if it is any simpler.  Each output array is for one channel, each row is one revolution, resolution points followed by the extra four values.

 

FixRube.png

Message 7 of 12
(2,533 Views)

 


@Darin.K wrote:

I'll play along, except I did as you said (in your comments) and not what you did (in your code). 


 

My focus was to simply refactor the existing code, keeping the results the same. Who knows what's really right 😉

 

Unbudling the same value twice to avoid crossed wires. Ha!! 😄

0 Kudos
Message 8 of 12
(2,525 Views)

Thanks to your refactoring his errors should be much easier to spot now, and it will take much less execution time to discover the error is there.  Smiley Tongue

 

As to the double unbundle, that was more a vestige of branching to run old and new code in parallel.  Lest my laziness be mistaken for vanity, here is an alternate version. Ironically with fewer wire crossings...

 

FixRube.png

 

 

 

Message 9 of 12
(2,517 Views)

What it really comes down to is normally I would not have concatenated the array in this convoluted way (the 4 points are causing the problem). I will say IMO the 4 points could have been picked out on the host rather than on the RT thus making life much simpler because they wouldn't be concatenated to the data array in the first place. Then I could just use 1 split array, 1 for loop, and 2 array subsets in the for loop. But, sometimes you just have to make a certain person out there (*cough customer cough*) happy haha. That is all I will say.

0 Kudos
Message 10 of 12
(2,500 Views)