LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

shifting binary values

Hi ,

 

I was wondering if someone is still awake and can help me out here. I am trying to do Right Shift operation on the attached values. I need to shift the values by 2 places to the Right.

for example,  1110011011111  will become 0011100110111.

 

meaning add  two 0 at the front  and remove the last 2 digit.

Download All
0 Kudos
Message 1 of 11
(2,659 Views)

Do you want to do this shifting on your string data which is a set of 1's and 0's you are displaying?  Or do you want to convert these 1's and 0's to a numerical value such as in a 16 bit integer (since it looks like you have 13 1's or 0's in each line) and do the bit shifting on the numeric value?

 

If the former, convert the string to an array (Spreadsheet string to array), autoindex it through a For Loop, and do string operations on it it to peel off the data you want and concatenate "0" characters to the front.

 

If the latter, use Scan from String on the String palette, to convert it to a U16, then use Logical Shift on the Numeric / Data Manipulatin palette.

0 Kudos
Message 2 of 11
(2,640 Views)

Is that your actual data? A sequence of the characters "1" and "0" (not the actual numbers 0 and 1), with tabs in between? The Logical Shift function only works with numbers. So, if that's your actual data, you first need to convert it to an array of numbers, and then you can use the Logical Shift function. You can convert the string to an array using the Spreadsheet String to Array and then use Scan From String to convert the sequence of character to a number.

 

EDIT: Was creating my response while RF was posting his reply.

0 Kudos
Message 3 of 11
(2,638 Views)

Hi,

 

I tried the solution from Smercurio, but cannot get things rigth. Any further help?

0 Kudos
Message 4 of 11
(2,621 Views)

Post your VI so we can then see what you did wrong.

 

Also, before saving it, put the data into your string control and choose Save Values as Default, so we have real data to work with.

0 Kudos
Message 5 of 11
(2,619 Views)

If I had to make a guess, you probably entered the "\t\t\t" as normal text, rather than as '\' codes. If you did, right-click on the string constant and select '\' codes. You'll see two backslashes in front of each "t". Remove one from each.

 

Just a guess, but a pretty educated guess.

0 Kudos
Message 6 of 11
(2,616 Views)

Yes, I did so, but I cannot still get it right.

0 Kudos
Message 7 of 11
(2,602 Views)

Here is what I did.

0 Kudos
Message 8 of 11
(2,601 Views)

Changing your delimiter string from \t  to \t\t\r as smercurio_fc pointed out should get you there.

 

JohnCS

0 Kudos
Message 9 of 11
(2,591 Views)

 


@gembo wrote:

Here is what I did.


Your data has 3 tabs between numbers, not one. That's why I indicated "\t\t\t", and not "\t". I wasn't stuttering. Smiley Wink

 

0 Kudos
Message 10 of 11
(2,584 Views)