LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

must be an easier way...

Solved!
Go to solution

Hi for(imstuck),

 

here's my try:

try1.png

Incoming numbers are masked, shifted to correct position and added in a register. (Hopefully no big errors, I got the same result..)

 

Why do you write you're using LV7.1, when the VI comes in LV8.5???

 

The 2^x code part can surely be replaced by an array constant, it's just for showing concept here...

Message Edited by GerdW on 01-28-2010 07:17 PM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 11 of 28
(1,542 Views)

I'll play too.

 

sample_get_status.png

Message 12 of 28
(1,536 Views)

GerdW wrote:

 

here's my try:

 

 

Why do you write you're using LV7.1, when the VI comes in LV8.5???

 


I noted in an earlier post to ignore my signature stating 7.1. I usually use 7.1 but in this case was given 8.5 to use and didn't bother changing my signature. 

0 Kudos
Message 13 of 28
(1,527 Views)

Hey, can I play too? Here's my version. See if it works as expected. No guarantees. 🙂

 

 

 

 

Message Edited by altenbach on 01-28-2010 11:08 AM
Download All
0 Kudos
Message 14 of 28
(1,510 Views)

Hi for(imstuck),

 

why don't you change your signature then??? Like "Using mainly LV7.1, but sometimes forced to use LV8.5" Smiley Wink

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 15 of 28
(1,500 Views)
Solution
Accepted by GregFreeman

... slight improvement. Of course the masking should be done in U8. 😄

 

Message Edited by altenbach on 01-28-2010 11:24 AM
Message 16 of 28
(1,497 Views)
I'm glad I could ask a question that got some good responses. This is a little better than those "why wont my logging work!?!" questions that show up on here day after day haha. Thanks guys, kudos.
0 Kudos
Message 17 of 28
(1,480 Views)

Altenbach, I'll take your solution. But I really had to think it through to understand it. Comments are going in my (your) code before I forget!

0 Kudos
Message 18 of 28
(1,463 Views)

altenbach wrote:

... slight improvement. Of course the masking should be done in U8. 😄

 

Message Edited by altenbach on 01-28-2010 11:24 AM

 

Here is a comment I put in my code. I figured it may be helpful if someone comes across these byte operations and has trouble figuring out what's going on. I know I did at first 🙂

 

Example to make the above more clear:

Lets say the U8 array's first 5 elements are 2,73,68,64,65...
The loop is set up to ignore the 2, so lets just focus on 73,68,64,65
In binary these are 1001001,1000100,1000000,1000001 respectively
63 in binary is 111111 and 7 in binary is 11. So...

Logical AND with 73 and 63 is...

          1001001
AND     111111
---------------------
                1001 - OR with zero = 1001, stored in shift register

Logical AND with 68 and 63 is...
           1000100
AND      111111
---------------------
                   100

This 100 is shifted 6 bytes (becomes 100000000) and then an OR is done with what's stored

in the shift register. In this case it is 1001. The operation is below

        100000000
OR             1001
--------------------
        100001001

As you can see, by shifting and using an OR, this number was "prepended" to the existing number.
This method continues on until what was a byte array is now all 1's and zero's in the form of a boolean array

and can be typecast into the proper cluster

0 Kudos
Message 19 of 28
(1,451 Views)

for(imstuck) wrote:

...and 7 in binary is 11.


 

7 is 111 in binary.

 

Yes, it's easier to just skip the first elements by spinning the loop once, so we don't need to slice&dice the input array, which would require another buffer allocation in memory. The loop iterations are given by the size of the array constants.

 

Notice that I used a diagram constant for the typecast. Your original code (first picture you posted above) iterates over an array of clusters, causing a lot of work, even thought the data is irrelevant because we only need the type, which is the same in each iteration of your outer for loop. You are also setting yourself up for potential problems, for example if the array is too short it would limit the number of iteration of the outer FOR loop for no good reason. 

 

 

0 Kudos
Message 20 of 28
(1,436 Views)