Sign in to follow this  
Followers 0
Jean20

BYTE TO BITs

3 posts in this topic

Hi,

I am using Sysmac Studio. I want create a function block to convert a BYTE into 8 bits. How can I create that FB?

Thank you,

Jean

Edited by Jean20

Share this post


Link to post
Share on other sites

I assume that your difficulty is with creating the code to do it, not with the actual creation of a function block. So, I am just showing the code below.

You can use the Union functionality.

First, open up Data Types and create a union:

Union.jpg.1592b785684abeeebfca484b8a2344

Then create a variable of that union type (MyUnion in this example):

UnionVars.jpg.6aea8ea5aebbdd7e4eadf3df7c

Then you can do a move from the byte variable that you want to convert into MyUnion.ByteLevel as shown below in rung 0.  Then you can use the bits within that byte as shown in rung 1 as MyUnion.BitLevel[0].

ladder.jpg.a2b9c0867e0d0d9179b0ed181f808

 

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
Sign in to follow this  
Followers 0