Moving bits in a DINT

willxfmr

Lifetime Supporting Member
Join Date
Nov 2013
Location
Wisconsin
Posts
466
Hi Everyone,
I'm working on a self assigned homework project on a RSL5K and I'm stuck.

What I'm trying to do is move data from Dint_1 to Dint_2.

Dint_1 has a hex value of AAAA, and I want to move it to Dint_2 in a way that causes Dint_2 to have a hex value of FF. There is a real world reason behind all this, but it is mostly so I can be a little smarter tomorrow than I am today.

I have tried masked moves, bit field distribute, and sort file instructions, as well as going thorough the instruction help for all of the file sorting instructions.

Can this be done with a single ladder instruction, or will I have to mash the data around a bit before I get the result I'm looking for? Any and all hints would be greatly appreciated.


Thanks,
Bubba.
 
Will DINT_1 always be AAAA, or is the point that you're trying to concentrate a hex value where every other bit of an INT needs to be analyzed in a single byte? Just grind it, XIC the relative bits, OTE where you want them.
 
Will DINT_1 always be AAAA, or is the point that you're trying to concentrate a hex value where every other bit of an INT needs to be analyzed in a single byte? Just grind it, XIC the relative bits, OTE where you want them.

Yes, it would be every other bit.
The idea is to maintain the bit order of Dint_1 but compress it down to two bytes in Dint_2. In other words, Dint_1 is the raw data and Dint_2 will become the processed data. The device I'm working with would actually only need one INT compressed to 2 bytes, but I'm using two dints just for simplicity.

In a program that was going to be used in a production setting, I would just map everything to where I wanted it so that it is easier to understand 10 years from now. But the purpose of the exerciser is to learn a different way to manipulate the data. So far during the process I have learned what the BTD instruction is and how it works, and now I'm trying to expand on that.

Thanks for your reply,
Bubba.
 
Frankly, I still don't understand the goal.
Do you want to skip every other bit of the source word when moving to the destination?
If yes, it's not possible with a single instruction.
 
Frankly, I still don't understand the goal.
Do you want to skip every other bit of the source word when moving to the destination?
If yes, it's not possible with a single instruction.

That is exactly the goal. I was hoping there was an instruction that I missed, but knowing what can't be done is just as helpful as knowing what can.

Thanks,
Bubba.
 
This is an ideal application for an Add-On Instruction, done brute-force in relay ladder logic.

You can label it "Byte_Compressor" and put comments inside it explaining precisely what it's for any why you are using it.

Clever bit-masking and bit-shifting instructions are great, but when it's ten years later and somebody's trying to figure out how the program functions based on an uncommented upload, brute force is always easier to understand.
 
This is an ideal application for an Add-On Instruction, done brute-force in relay ladder logic.

You can label it "Byte_Compressor" and put comments inside it explaining precisely what it's for any why you are using it.

Clever bit-masking and bit-shifting instructions are great, but when it's ten years later and somebody's trying to figure out how the program functions based on an uncommented upload, brute force is always easier to understand.

Thanks Ken. I have never written an AOI from scratch, so now seem like as good of time as any to change that.

Thanks again to everyone for their responses
Bubba.
 

Similar Topics

Hey everyone trying to record time and date on one of our machines. But Status bits don't seem to want to be moved to the integer files I make...
Replies
4
Views
1,992
Hi Guys. Can anyone help me with this one??? I am using an Omron CJ1M,and i am transmitting control codes to a programmable power supply. The...
Replies
2
Views
2,288
I'm using PLC 5/20 and a SLC 5/03 and RSLogix 5 pro. I'm trying to take parts of words (N29:25/0-3 for example) and place them in a destination...
Replies
13
Views
4,204
I'm a Siemens person, and this is one of my first AB programs. The customer wants everything programmed in Ladder. I have a lot of data (3...
Replies
14
Views
216
Hello, I have a compact Logix plc and I have been task with configuring alarms into our SCADA when an Analog signal stops moving. The analog...
Replies
6
Views
238
Back
Top Bottom