NootNoot

Split a byte to two nybbles

5 posts in this topic

Hi guys

I am fairly new to Sysmac Studio so reaching out for some help.

I have used a union to successfully separate a Word out into its bits, bytes.  Can't get my head around how I separate a byte into two nybbles?  Can anyone suggest an easy method?

The byte of data made up of an error code in each nybble.

Thanks

Share this post


Link to post
Share on other sites

I'm not aware of a nibble data type per the IEC 61131-3 standard.

If you need the upper nibble of a Byte, you could create a function to shift the bits 4 places to the right.

Share this post


Link to post
Share on other sites

I agree with IO-Rack, nibbles do not seem to appear in IEC programming.

Share this post


Link to post
Share on other sites

Use the MoveDigit function.  You can pull a digit (Nibble) out of a word and store it in another word or byte.

Share this post


Link to post
Share on other sites

generic solution

LO = ByteVar AND 15

HI = ByteVar SHR 4; or ByteVar / 16

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now