ControlLogix BTDT Instruction


Introduction to the ControlLogix BTDT Instruction

The ControlLogix BTDT Instruction is a type of Bit Field Distributor. This is an acronym for “Bit Field Distributor with Target”. We use this type of instruction in Function Block Programming. If you use ladder logic programming, check out the post on the BTD Instruction.

We use the BTDT instruction to distribute bits from one area into another area of memory. In this case, we’ll combine two INT’s into one DINT. INTs are 16 bit tags. On the other hand, DINTs are 32 bit tags. Older processors such as the SLC-500 or PLC-5 used 16 bit integers. At times, its’ necessary to move two of these 16 bit tags into a single 32 bit tag. Another example would be data from a Modbus network. DeviceNet is another example of when we might combine smaller amounts of data into a single 32 bit integer.

How the BTDT Works

Consider the following example:

In this case, we’ll move the data from mySourceArray[0] into the lower 16 bits of “myDestination”. Likewise, we’ll move the data from mySourceArray[1] into the upper 16 bits of the “myDestination” tag. We’ll need two BTDT instructions to make this happen. Keep in mind the Source and Target inputs are not changed.

First BTDT Instruction

There are a few things we will need to consider before setting up our first instruction. We need to know our source tag, which is mySourceArray[0]. Additionally, we need to know the starting bit in this tag that we wish to move. In this case, it’s bit 0. We also need to know the length of the data we wish to move. This will be 16 bits. At the same time, we need to know a couple things about our destination. The starting bit number in the destination is 0. With this in mind, we’ll set up our first BTDT instruction.

In this case, since we want to start with a “Blank Slate” when building our final result, the target value is 0. The target value writes to the instruction’s destination prior to distributing the bits.

The second BTDT instruction

At this time, we’ll move mySourceArray[1] starting at bit 0. The length again is 16 bits. However, in our destination, we start at bit #16. Since we want to build from the value of our previous BTDT instruction, we’ll tie the destination of BTDT_01 into the target of BTDT_02.

We’ll end up with logic that looks similar to this example:

Check the Result

Finally, we’re ready to see if our logic works as we anticipated. Let’s take a look at the tag database.

As you would expect, mySourceArray[0] appears on bits 0 to 15 of “myDestination”. Likewise, the 16 bits of mySourceArray[1] appear on bits 16 to 31 of “myDestination”.

Converting a 32 bit integer into two 16 bit integers

Let’s try this the other way. At this time, we’ll simply reverse the process. Let’s take bits 0 to 15 of “myDestination”, and move these bits into mySourceArray[0]. Likewise, we’ll take bits 15 to 31 of “myDestination”, and copy these bits into “mySourceArray[1]”. The logic will appear a little bit different. I’ll modify the value of “myDestination” first, so we can ensure the logic is working.

Now that our logic is all set up, let’s see how well we did. Remember, the Source and Target values do not change. The only tag that changes here is mySourceArray[0], and mySourceArray[1].

As you can see, our logic worked very well.

For other ControlLogix information, visit the Category Page!

— Ricky Bryce

For Customized automation training, visit my employer's website at http://atifortraining.com!

Leave a comment

Your email address will not be published. Required fields are marked *