Saffa
Member
i've just given this a go in RSEmulate and it seems to work (but whether it's good programming practice, we'll have to wait and see who shouts at me )
check out the MVM instruction - Masked Move (under move / logical tab).
I set up the Source to be I:0.0 - my digital inputs.
I set the mask to be 0000000000001111 (binary)
I set the Destination to be N7:0
this assumes your four inputs are starting at I:0.0 and are sequential, i.e. I:0.0, I:0.1, I:0.2 etc. If you only want 3 inputs, then change the mask to be only three 1's on the end.
Basically what this instruction does is look at the word starting at I:0.0 and copies 16 bits (1 word) to the memory location specified in the destination. The trick is, that it applies a mask to the source data. If the bit in the mask is a 1, then whatever the corresponding bit in the source is will be copied as it was. if the mask is a 0, then the destination will be a zero no matter what the source was.
Now go look at N7:0 in your data table. Make sure your radix is decimal. Put input 1 and 3 on, and you'll see 5. Put 1 and 2 on, you'll see 3.
This of course only works if the inputs you're using are sequential.
You could now do some maths on the memory location at N7:0, i.e. compares etc.
hope that's not too complicated, but in my head its a simple one rung instruction that gets you an integer to play with from as many binary inputs as you like.
Can send you a .RSS file if you need, just don't have RSlogix on this machine.
Steve
check out the MVM instruction - Masked Move (under move / logical tab).
I set up the Source to be I:0.0 - my digital inputs.
I set the mask to be 0000000000001111 (binary)
I set the Destination to be N7:0
this assumes your four inputs are starting at I:0.0 and are sequential, i.e. I:0.0, I:0.1, I:0.2 etc. If you only want 3 inputs, then change the mask to be only three 1's on the end.
Basically what this instruction does is look at the word starting at I:0.0 and copies 16 bits (1 word) to the memory location specified in the destination. The trick is, that it applies a mask to the source data. If the bit in the mask is a 1, then whatever the corresponding bit in the source is will be copied as it was. if the mask is a 0, then the destination will be a zero no matter what the source was.
Now go look at N7:0 in your data table. Make sure your radix is decimal. Put input 1 and 3 on, and you'll see 5. Put 1 and 2 on, you'll see 3.
This of course only works if the inputs you're using are sequential.
You could now do some maths on the memory location at N7:0, i.e. compares etc.
hope that's not too complicated, but in my head its a simple one rung instruction that gets you an integer to play with from as many binary inputs as you like.
Can send you a .RSS file if you need, just don't have RSlogix on this machine.
Steve