# Ladder Diagram bit stream manipulation help

## Recommended Posts

Hi,

I am using US7-B5-TR22 and the UniLogic program.

In the ladder diagram , i am trying to use bits manipulation on information i read from a Modbus Slave.

The information i read is a 16 BITS long and according to the slave component's datasheet i should divide the 16 bits information into 4 nibbles (4 bits each) by some bits manipulations .

Every nibble contains a different type of alarm

For example :

If i receive the following information :

1110 0010 0011 0001

the MSB nibble is : emergency stop alarm.

the second nibble is : Low Oil Level

the third nibble is : High Coolant Temperature.

The LSB nibble is : Low Coolant Temperature.

So let's say that i would like to check the Low Oil level alarm's status, Therefore , according to the datasheet , i should Right Shift Register by 8 and then multiple the result by a 16 bits mask.

which supposed to be : 0000 0000 0000 1111.

As i'm new to UniLogic i need a little help on how to perform those manipulations in the ladder diagram.

##### Share on other sites

2 hours ago, Omerdf34 said:

Hi,

I am using US7-B5-TR22 and the UniLogic program.

In the ladder diagram , i am trying to use bits manipulation on information i read from a Modbus Slave.

The information i read is a 16 BITS long and according to the slave component's datasheet i should divide the 16 bits information into 4 nibbles (4 bits each) by some bits manipulations .

Every nibble contains a different type of alarm

For example :

If i receive the following information :

the MSB nibble is : emergency stop alarm.

the second nibble is : Low Oil Level

the third nibble is : High Coolant Temperature.

The LSB nibble is : Low Coolant Temperature.

So let's say that i would like to check the Low Oil level alarm's status, Therefore , according to the datasheet , i should Right Shift Register by 8 and then multiple the result by a 16 bits mask.

which supposed to be : 0000 0000 0000 1111.

As i'm new to UniLogic i need a little help on how to perform those manipulations in the ladder diagram.

Can’t you just read those as individual coils without doing any bit manipulation?

Use Modscan to read it as coils and see if you can figure it out from there.

##### Share on other sites

There are two functions you can use: Test Bit (to test specific bit on an integer tag) and Num To Bits, to convert integer to bits.

## 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.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

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

×
×