LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to reverse an order of an 8 bit value

Solved!
Go to solution

Hi,

   I want to produce an mirror value of an 8 bit numeric. suppose my value is 11101100, my output should be 00110111. how can i get this??

0 Kudos
Message 1 of 14
(10,771 Views)
Solution
Accepted by topic author esaravanan85

Here is a solution.

 

Reverse U8.png

Message 2 of 14
(10,765 Views)
Use Numeric->Data Manipulation -> Rotate
0 Kudos
Message 3 of 14
(10,764 Views)

I'd solve it through a small for-loop, bitshift the incoming in one direction (e.g. left) through a shift register and build an outvalue by shifting in values (the output from the former shift) in the other direction (e.g. right).

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 4 of 14
(10,759 Views)

Sanad MM a écrit:
Use Numeric->Data Manipulation -> Rotate

No, this will not produce the expected mirror !

0 Kudos
Message 5 of 14
(10,752 Views)

My vi works. It has minor changes to the one posted above.

They're explained in the front panel.

 

 

 

//edit: version for LV8.6 added

Message Edited by ST5 on 03-23-2010 06:54 AM
Download All
0 Kudos
Message 6 of 14
(10,712 Views)
Thanks JB 🙂 i got my solution....
0 Kudos
Message 7 of 14
(10,666 Views)

What we've learned from the bit twiddling challenge, doing the detour over the boolean array is not very efficient. If this is used on huge amounts of data in tight loops, it might be better to use a lookup table instead. Look ma, no green!!! 🙂

 

(Of course you would create the lookup table once using a FOR loop with N=256, and containing the above code.)

 

 

 

 

 

 

Message Edited by altenbach on 03-24-2010 12:19 AM
Download All
Message 8 of 14
(10,649 Views)

I still find my little loop suggestion fun. 😉

Bit reversal.PNG

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 9 of 14
(10,617 Views)

Yamaeda wrote:

I still find my little loop suggestion fun. 😉


 

 

Very cute. That's probably the fastest you can do with explicit code.

 

Here are some benchmarks (5M U8 numbers, LabVIEW 8.0, debugging disabled).

 

Green (reverse boolean array): 385ms 10x slower

Yamaeda:                       272ms  7x slower

My Lookup table:                39ms     winner.

 

Clearly, the LUT wins hands down. 😉 

 

 

Message 10 of 14
(10,587 Views)