Jump to content

Recommended Posts

Lets say I have variable DW150 and DW is 32bit variable so:

DW150 = 0000 0000 0000 0000 0000 0000 0000 0000 (is this correct?)

How can I store "1" into 4th bit of DW150?

Lets say I have variable MB50 = 1 and I want to store value of MB50 into 4th bit of DW150, how can I achieve that?

Result after storing should be:

DW150 = 0000 1000 0000 0000 0000 0000 0000 0000

Share this post


Link to post
Share on other sites

You may be able to use the "Toggle Register Bit" function under the "Logic" ladder menu for this purpose. What are you trying to do? Typically in VisiLogic, bit vectors are employed to do this rather than trying to manipulate the bits in an integer register.

Share this post


Link to post
Share on other sites

Do it elegantly as Flex said or:
1000 0000 0000 0000 0000 0000 0000  in decimal is 134217728. If you store this number in DW150 4th bit (or 28th depends how you count) will be zero.

I remember working with older ladder software that didn't have bits manipulation. If you needed to make a certain combination of 1s and 0s in register, first you reset register (store 0), than if  bit 1 is 1 add 1, if bit 2 is 1 add 2, if bit 3 is 1 add 4, if bit 4 is 1 add 8.... Good times.

Share this post


Link to post
Share on other sites
4 hours ago, Isakovic said:

Do it elegantly as Flex said or:
1000 0000 0000 0000 0000 0000 0000  in decimal is 134217728. If you store this number in DW150 4th bit (or 28th depends how you count) will be zero.

I remember working with older ladder software that didn't have bits manipulation. If you needed to make a certain combination of 1s and 0s in register, first you reset register (store 0), than if  bit 1 is 1 add 1, if bit 2 is 1 add 2, if bit 3 is 1 add 4, if bit 4 is 1 add 8.... Good times.

I need bits because I am working with WinCC Flexible 2008 and when I want to configure alarms I need bits, can't use tags, only bits.

So I need all my alarms of visilogic to be stored in "Word" in format of 0 and 1 (0000 1000 0010 ... )

Wincc Flexible can only work with bits when configuring alarms, that is problem

Share this post


Link to post
Share on other sites
12 hours ago, Flex727 said:

You may be able to use the "Toggle Register Bit" function under the "Logic" ladder menu for this purpose. What are you trying to do? Typically in VisiLogic, bit vectors are employed to do this rather than trying to manipulate the bits in an integer register.

I need bits because I am working with WinCC Flexible 2008 and when I want to configure alarms I need bits, can't use tags, only bits.

So I need all my alarms of visilogic to be stored in "Word" in format of 0 and 1 (0000 1000 0010 ... )

Wincc Flexible can only work with bits when configuring alarms, that is problem

Share this post


Link to post
Share on other sites

Define an array of MB's say, MB101 through MB132, these are the bit coils that your alarms will trigger.

Use the Bit to Num FB (under vectors);

A = the starting MB of your array, MB101
B = the DW where you want to store your "bit word", DW1
C = the length of you MB array, const 32

if MB104 is on, then the forth number of the DW will be 1
if MB128 is on, then the 28th number of the DW will be 1

and so on....

 

 

image.png.ff7ecb4985d94f268d4ae83f5750890b.png

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...