Binary

Join Date
Aug 2018
Location
Sharjah
Posts
49
Hi,
I want to extract every second bit of a double word and place it in a new word but the position of placement should be from 0,1,2......15.

For example:

Test word : 1110001010110101


Results Word: 11011100
 
What controller platform are you using ?

What datatype is the source word stored in ?

Is there a reason you can't just do it with eight simple bit assignment instructions ?
 
First of all, what you show is not a double word but a word or double byte a double word is 32 bits & your result seems to be a byte (8 bits), in the above case what if more than 8 bits are one's, how do you fit that into a byte or even if it is a double word i.e. 32 bits how do you fit that into a word, it would have to be a case that the convertion of a word/double word must not have more bits than the resultant word.
 
Oppsss.. I think I mis-read it a little Mised the bit about every other bit but still stands that shown is a single word 16 bit not 32.
But as LD has posted, just brute force is probably best.
 
Hi,

Yes I wrote only a word portion of my Double word in the example. Just wanted to explain what I was actually looking for.

First of all, what you show is not a double word but a word or double byte a double word is 32 bits & your result seems to be a byte (8 bits), in the above case what if more than 8 bits are one's, how do you fit that into a byte or even if it is a double word i.e. 32 bits how do you fit that into a word, it would have to be a case that the convertion of a word/double word must not have more bits than the resultant word.
 
Hi,

There are multiple words require similar conversion. Just don't want to increase program length with individual assignments.

What controller platform are you using ?

What datatype is the source word stored in ?

Is there a reason you can't just do it with eight simple bit assignment instructions ?
 
Do you want to transfer the bits' values in one scan cycle, or would it be acceptable to detect an edge of a trigger bit and execute the transfers over the next few dozen scan cycles or so?
 
Best thing to do is create a function or AOI & in that do a loop incrementing a pointer by 2 each time & indirect address them indirect pointing to bit level can be used in the PLC. Perhaps tell us what PLc are you using.
 
Hi,

Like permanent mapping sort of thing..
New word should continuously read the data from Old word in every scan cycle.


Do you want to transfer the bits' values in one scan cycle, or would it be acceptable to detect an ed
ge of a trigger bit and execute the transfers over the next few dozen scan cycles or so?
 
Last edited:
Perhaps create a FB pass the 32 bit & 16 bit words to the FB & do something like the attached.
I do not have TIA on this PC so this is done in Mitsubishi using built in functions of BitSet & BitReset, not tried indirect addressing but I think in siemens you could indirectly point to bit level in a DW, if not transfer the Double dataword to a double Mw & same for the 16 bit word i.e. transfer DDxx to MD xx
then do indirect addressing of the bits in M bits transfer the resulting 16 bits to the DW.
Not done Siemens for a number of years bu assume you cn indirectly point to a bit in a DW or DD word

Loop1.png
 
Best thing to do is create a function or AOI & in that do a loop incrementing a pointer by 2 each time & indirect address them indirect pointing to bit level can be used in the PLC. Perhaps tell us what PLc are you using.

This; in TIA it's called a function.

Then you can pass it multiple 32- and 16-bit tags as input/output pairs.
 

Similar Topics

Hi folks, I'm trying to parse a binary string on a Red Lion DA30D using a Raw UDP/IP input port. I've done this before with ASCII strings so I do...
Replies
38
Views
961
So here's my situation, I have been tasked with modifying the logic to mimic a button press in the PLC. I have two identical machines however one...
Replies
6
Views
534
Hello, I am trying to convert a incoming string that is in Binary format (See attachment) to a DINT. Any ideas? When I use the STOD command it...
Replies
6
Views
2,192
How can I read individual binary bits from a SLC500 within FTH SE? With the Tag Browser I can get to the Binary Files and get each Integer from...
Replies
5
Views
1,587
Guys, I have googled this for about an hour now and can't find what I am looking for. I need a module which will take 8 inputs, and convert this...
Replies
8
Views
2,710
Back
Top Bottom