arnoldzw

Bit to word

10 posts in this topic

Hi all,

 

I was trying to write some bits to an data register, but when compiling i`ll get an error that there is an type mismatch.

The bit "STORING_Netfout"  is declared as BIT, see attachement

Naamloos.png.4273f94c8fadf30679ff45f639f

 

 

In Schneider Unity there is an function block BIT_AS_WORD to do these things, do GX works2 also have something like this?

W2B.jpg.662b5ed2bc6569a001366d1a48f6ba21

Share this post


Link to post
Share on other sites

You cannot use "MOVE" on a bit. Use ladder or a suitable instruction if needed to trigger bits. Ladder example below:
[STORING_Netfout]--(D401.0)
You can also specify in GVL these addresses, e.g. define TestDataBit = D401.0:
[STORING_Netfout]--(TestDataBit)

If you want to batchmove a lot, use "INT_TO_BITARR" instruction. You'll need to create an array of the bits if you are using labels either in local header, or in GVL.

Share this post


Link to post
Share on other sites

did not touch Mitsubshi in a while but something like this sure used to work:

MOV D0 K4M0

MOV K4M0 D0

Share this post


Link to post
Share on other sites

Thank you for replying,

is there also an function block available for this kind of instruction?

Share this post


Link to post
Share on other sites

Why use function block when you can use function, or even better -> instruction?

If you want the "Schneider-style" function block or function I would recommend you to create a function (FUN), inside it you take 16 bits and use "SET_BIT_OF_INT" to set status to the individual bits in the FUN. THen you can have 16 bit inputs freely selectable and 1 INT output that you can connect to whatever you would like...

Share this post


Link to post
Share on other sites

See here for a FB I already made at the request of another poster previously, just import the ASCII to your project.

The only difference is it only takes in the lowest 8 bits but you can easily expand this yourself if you need to examine for a value over 255 decimal.

 

 

Regards

Daniel

Edited by collinsd70

Share this post


Link to post
Share on other sites
1 hour ago, collinsd70 said:

See here for a FB I already made at the request of another poster previously, just import the ASCII to your project.

The only difference is it only takes in the lowest 8 bits but you can easily expand this yourself if you need to examine for a value over 255 decimal.

 

 

Regards

Daniel

Hi @collinsd70

 

Thank you, i have started to make my own FUN now indeed.

Thank you for helping.

 

Share this post


Link to post
Share on other sites
On 20-2-2019 at 8:18 AM, kaare_t said:

Why use function block when you can use function, or even better -> instruction?

If you want the "Schneider-style" function block or function I would recommend you to create a function (FUN), inside it you take 16 bits and use "SET_BIT_OF_INT" to set status to the individual bits in the FUN. THen you can have 16 bit inputs freely selectable and 1 INT output that you can connect to whatever you would like...

Hi @kaare_t,

Can you show me how this instruction would look like?

I would split the 16 bits from an word to additional bits.

 

D100.0=bit0

D100.1=bit1

...

D100.15=bit15

 

 

Regards

 

Share this post


Link to post
Share on other sites

Move Word to bit range

D100 -> MOV -> K4M0

Will move the content of D100 to boolean bit memory area M0 -> M15.

 

 

Share this post


Link to post
Share on other sites

In GX Works 3 this is quite easy..? Pic attached..

bit_to_word.jpg

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