1 bit from INT.

Dutchass

Member
Join Date
Mar 2005
Location
The netherlands
Posts
11
i need to substrakt the 3rd bit from a INT in a siemens300.
What is the easyest way?

Example:
the INT has the value 5.
As result i want to have,
Bit 0 = 1
Bit 1 = 0
Bit 2 = 1
Bit 3 = 0
Bit 4 = 0
'
'
'
Bit 15 = 0



The Bit 0 is outputted to q125.0
The Bit 1 is outputted to q125.1
the Bit 2 is outputted to q125.2
'
'
'
 
Last edited:
If you need bits from 0 to 2 only, so: ?

WAND_W
IN 1: your INT
IN 2: 2#0000 0000 0000 0111
OUT : Local temp_variable INT

WOR_W
IN 1: Local temp_variable INT
IN 2: QW124
OUT : QW124

is it 124 or 125 ?
 
Sorry folks, I'm practising here:teacher:.

If you need bits from 0 to 2 only, so: ?

WAND_W
IN 1: your INT
IN 2: 2#0000 0000 0000 0111
OUT : Local temp_variable_1 INT

WAND_W
IN 1: QW124
IN 2: 2#1111 1111 1111 1000
OUT : Local temp_variable_2 INT

WOR_W
IN 1: Local temp_variable_1 INT
IN 2: Local temp_variable_2 INT
OUT : QW124

Is it 124 or 125 ?
Is it working ?
 
Please show the bits before processing and then after the required processing.
The example you show gives an int of value 5, and after it is still 5. Maybe I'm missing something ?
 
In the plc there is a int that can vary from 0 to 7.

i need to transfer this information binary to a steppingmotor control card.

controlcard has 3 inputs --> Terminal 1, 2 and 3.

Output q125.0 is connected to terminal 1
output q125.1 is connected to terminal 2
output q125.2 is connected to terminal 3
 
Here's my code snippet. Note that iStepperControl is a local integer and for testing in the simulator I have put the control code into MW708.

Code:
	  L	 MW   708
	  T	 #iStepperControl
 
	  LAR1  P##iStepperControl
	  A	  [AR1,P#1.0]
	  =	 Q	125.0
	  A	  [AR1,P#1.1]
	  =	 Q	125.1
	  A	  [AR1,P#1.2]
	  =	 Q	125.2
 
Hi Dutchass

It can be done really simple.
the INT has the value 5.
As result I want to have,
Bit 0 = 1
Bit 1 = 0
Bit 2 = 1
Bit 3 = 0
Bit 4 = 0

For example Word address DB1.DBW0 is given the value 5, and now you want to extract the value bit by bit.

This means

In the first byte

Bit 0 is found in DB5.DBX1.0
Bit 1 is found in DB5.dbx1.1
.
.
Bit 7 is found in DB5.DBX1.7

In the second byte

Bit 0 is found in DB5.DBX0.0
Bit 1 is found in DB5.DBX0.1
.
.
Bit 7 is found in DB5.DBX0.7

To sum up, the value 5 gives 0000_0000_0000_0101
this means :
DB5.DBX1.0 = 1
DB5.DBX1.1 = 0
DB5.DBX1.2 = 1
DB5.DBX1.3 = 0
DB5.DBX1.4 = 0
DB5.DBX1.5 = 0
DB5.DBX1.6 = 0
DB5.DBX1.7 = 0
DB5.DBX0.0 = 0
DB5.DBX0.1 = 0
DB5.DBX0.2 = 0
DB5.DBX0.3 = 0
DB5.DBX0.4 = 0
DB5.DBX0.5 = 0
DB5.DBX0.6 = 0

So to put Bit 0 to output Q125.0

A DB5.DBX 1.0
= Q 125.0

I hope this make sense.

Regards
Brian
 

Similar Topics

I am modifying an existing Omron CJ-2H CPU66EIP using CX-Programmer version 9.63. I simply need a rung of logic that can determine if a bit is...
Replies
20
Views
8,662
Hi eveyone. I need transfer signal from system 1 to DCS via modbus. System 1 only can send 32 bit floating point. DCS receive 16 bit integer. How...
Replies
20
Views
10,543
Hi guys, I have "Light_Status_DINT", which is a DINT logged every 5s. if i trend the DINT itself no issue, i got a nice graph of it. Now i want...
Replies
7
Views
2,320
Hello, I'm using Compact Logix L33 in RSLogix 5000. I'm trying to message over modbus register that is 16bit UINT. In Rslogix 5000 do I message...
Replies
3
Views
1,485
All, Forgive my lack of attention to detail, today a student asked me why when he printed his ladder in an RSLogix 500 report, even though he had...
Replies
10
Views
1,877
Back
Top Bottom