ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How delete last bit (LSB)

I have array with bits in each row and in one column. Now I ned to delete LSB (parity bit) and then assemble all 7 bits back together and split them in parts by 8 bits.

 

My idea was to put bits in matrix and then take from matrix first 7 columns. Problem is that I don't know hot put each bit in his own column. Next problem is how to convert this in bytes.

0 Kudos
Message 1 of 10
(6,611 Views)

Can you give an example of what you want.  Posting a VI with default data is the best way.

 

What does your initial data look like (what data types)?  What is the end result you want?  Are you supposed to just use 7 bits in your byte or are you supposed to shift bits in from other bytes?



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 10
(6,603 Views)

I will tray explain. I get 144 bytes from server. Those 144 bytes are separated in frames by 8 bits (7 data +1 parity). On the end I need to read message that is sent from server in ASCII code. Now I need delete parity bit so I can read message.

 

I have numbers in array like this

1.jpg

 

What I want is this

2.jpg

 

I must delete last column and put rest 7 bits together. This suposed to be my message. First 7 bytes is header.

 

I can post server and client. Server is in matlab. Main file of server in matlab is oddajnik.m. Server we got from professor.

 

I can't attach server.rar so I uploaded it on sendspace

Server in matlab

 

0 Kudos
Message 3 of 10
(6,588 Views)

The simplest way would be to just use the Logical Shift function.  It can accept your array of bytes and perform a shift on each byte.  Set N to be -1 to perform a shift to the right (LSB is removed).



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 10
(6,568 Views)

Now I need to put all bits together and make parts of 8 bits. I forget to write this in last post. Like you sad before I need shift bits in from other bytes.

 

If I have now 

1011011

1000110

1001111

 

then I should have

101101110001101001111 and from this parts of 8 bits

 

10110111

00011010

01111... and so on

 

Now I have 144 bytes. On the end I should have about 120 bytes. 

0 Kudos
Message 5 of 10
(6,560 Views)

Hi arozma, 

Please check the screenshot i have added and if it helps to solve your problem.

Thanks
uday
0 Kudos
Message 6 of 10
(6,551 Views)

While it would not be too diffiicult to combine the bits with numeric, it would need some extra code (e.g. similar to the old bit twiddling challenge) ;).

 

Unless performance is critical, It might be easier to convert to a boolean array, concatenate the subsets, and then convert back to a shorter U8 array. 

 

As a first step you need to tell us how your "bits" are represented in your code. Whatever you showed us made no sense:

 

 

 

You get a string. What is the format of the string? Is this a binary string (each byte representing 8 bits) or a string containing characters 0 and 1? You convert it to a U8 array, then into a 2D U8 array with one row, then back to the 1D array you originally had. This makes absolutely no sense.

0 Kudos
Message 7 of 10
(6,548 Views)

This isn't exactly a simple task.  You can do with with boolean arrays.  I'm not happy with it, but it works.

 

I'm sure we can get this to work without changing data types, but I don't have the time to play with it right now.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 8 of 10
(6,533 Views)

This should convert the string to an array of U8, remove the parity bit, shift the remaining bits to the right, and change it back to a string.

 

Lynn

 

Parity Stripper.png

0 Kudos
Message 9 of 10
(6,520 Views)

@altenbach wrote:

While it would not be too diffiicult to combine the bits with numeric, it would need some extra code (e.g. similar to the old bit twiddling challenge) ;).

 

Unless performance is critical, It might be easier to convert to a boolean array, concatenate the subsets, and then convert back to a shorter U8 array. 

 

As a first step you need to tell us how your "bits" are represented in your code. Whatever you showed us made no sense:

 

 

 

You get a string. What is the format of the string? Is this a binary string (each byte representing 8 bits) or a string containing characters 0 and 1? You convert it to a U8 array, then into a 2D U8 array with one row, then back to the 1D array you originally had. This makes absolutely no sense.


It suposed to be a binary string. 

 

Yes, you have right. I tried many things before I get all data in one array. When I finaly made what I want, I leaved the code like it was. I fixed it now.

 

I learned basics of Labview a few years back. Since then I didn't worked with Labview. I tod I don't need to look basics again. Apparently I was wrong. 

 

Thank you all for your time and help. Now its on me to implement your code.

0 Kudos
Message 10 of 10
(6,474 Views)