Host Engineering Forum
General Category => General Discussion => Topic started by: PLCGuy on November 09, 2017, 10:39:00 AM
-
I have a DWORD coming from a drive that shows the status of the outputs. Bit 0=Enable, Bit 1=Ready,.. and so on.
The binary may look like this 000_000_000_000_0111. So I was thinking I want to look at bit 0 and if TRUE set C0. If bit 1 is TRUE then set C1,... etc. I was going to use a math box but confused how to use brackets and the such. How would one of you do it?
-
Are you simply doing a MOVE? If so
MOVE SourceDWORD C0:SD
If you want to set/latch, then use MATH
MATH C0:SD "SourceDWORD | C0:SD"
-
If the data were located in D0, you could use a simple bit cast like D0:n where n = bits 0-31. So read or write the third bit in D0, it is D0:2.
-
Forgot to mention is it being loaded into my made up memory. ormectrx6, it is a dword.
So would it I use a math box? Result would be C0, Calculation would be: if(ormectrx6:0,1,0)
-
Forgot to mention is it being loaded into my made up memory. ormectrx6, it is a dword.
So would it I use a math box? Result would be C0, Calculation would be: if(ormectrx6:0,1,0)
MATH box works, but not needed. STR ormectrx:8 OUT C0 works fine, or a MOVE, INIT, or any other instruction that will do the assignment.
-
Forgot to mention is it being loaded into my made up memory. ormectrx6, it is a dword.
So would it I use a math box? Result would be C0, Calculation would be: if(ormectrx6:0,1,0)
MATH box works, but not needed. STR ormectrx:8 OUT C0 works fine, or a MOVE, INIT, or any other instruction that will do the assignment.
And if you did a MATH box you don't need the IF(). Just MATH C0 ormectrx:6 works.
-
Are you simply doing a MOVE? If so
MOVE SourceDWORD C0:SD
If you want to set/latch, then use MATH
MATH C0:SD "SourceDWORD | C0:SD"
or the new COPY instruction in lieu of MOVE
-
Ended up using Copy. I did not realize to treat the bits as STR.
Thanks, you both got me thinking.
-
Take 2
Since both the Source and the Destination are both contiguous, just set the Count to 6
-
Thanks that works great. I did not know I could write C0-C5 like that in the box.
I tried to show this stuff to a die hard AB guy and he just walked away, lol.