Does RS5000 have a decode instruction

If the tag Bit_Number holds the bit to turn on (let's say 0 - 31) And the tag BITS is a DINT you wish to set a particular bit in I do

If Bit_Number is 0 - 31 (use a LIM test) then

CLR BITS
OTL BITS.Bit_Number

Obviously the same thing can be used with a SINT if Bit_Number is constrained from 0 - 15.
 
Attached to the following technote is a DCD Add On Instruction...

42004 - How to implement RSLogix 500 DCD and ENC instructions in RSLogix 5000
Access Level: Everyone

It uses several Mask Equal To (MEQ) instructions...

Each instruction takes the same user-defined Source value and a pre-defined Compare value and passes both of them through the same mask value and then evaluates the two results for a match. A pre-defined hex mask of 16#F ((2#1111) is used in each instruction so only the first 4 bits, or first nibble, of the Source and Compare values are passed through the mask for evaluation.

There are 16 instructions on separate rungs. This is because there are 16 possible permutations for the 4 bit nibble (0000 - 1111). The MEQ instructions have uniquely pre-defined binary Compare values from 2#0 - 2#1111.

Each rung also has a Move (MOV) instruction after each MEQ instruction. A user-defined Destination is selected and is used for all the MOV instructions. The MOV instructions have pre-defined Source values from 2#1 - 2#1000000000000000 to represent the 16 x bit positions in the destination integer.

The MEQ instruction that matches its Source and Compare nibbles, via the mask, will be evaluated TRUE and so will execute its MOV instruction. This will place a 1 in the equivalent bit position in the destination integer.

Example:

MEQ on rung 12...

Source = 12 =2#0000 0000 0000 1100 ("TagSource" - tag for AOI)
_Mask = 15 = 2#0000 0000 0000 1111 (Entered as hex 16#F)
Compare=12= 2#0000 0000 0000 1100 (Displays as 2#1100)

Source = Compare, instruction evaluates TRUE.

MOV on rung 12 is executed...

Source = 2#0001 0000 0000 0000 (Displays as 2#1000000000000)

Destination = 0001 0000 0000 0000 (Bit 12 in "TagDest" is set; displays as 4096)

This AOI is just an example using a 16-bit INT as the destination data type. You can of course roll your own and use a SINT or DINT as the destination. You could, for instance, compare all 32 bits of a Source DINT (mask 16#FFFFFFFF) and set any one of 32 bits in a destination DINT.

Regards,
George

MEQ_DCD.jpg
 
I erred yesterday in my solution to this problem

If the tag Bit_Number holds the bit to turn on (let's say 0 - 32) And the tag BITS is a DINT you wish to set a particular bit in I do

TEMP = Bit_Number - 1

CLR BITS - note, if 'Bit_Number' held 0 then clearing is all that will happen

If Temp is 0 - 31 (use a LIM test) then

OTL BITS.Temp

Obviously the same thing can be used with a SINT if Bit_Number is constrained from 0 - 16.
 

Similar Topics

Hi I have a ifix 5.5 application where the operator opens a valve by clicking on a screen object. I can trace from object to data base that it is...
Replies
2
Views
42
Hi, i am using DVP-14SS2 PLC, after program written to plc, when power is reset, plc doesn't run. always need to connect to pc for the run mode.
Replies
0
Views
34
I am trying to connect with a Schneider plc which has a firmware version only available in Somachine v4.2. In Machine expert After taking upload...
Replies
0
Views
122
They are installed in a control panel that was made in France and are intended for the termination of analog inputs. Each of the red capped...
Replies
4
Views
432
Back
Top Bottom