Archie
Member
I was working on a message rotator in a SLC 5/04 when I came into a problem that seemed like it would be very easy, but turned out to be quite tricky in ladder.
I have a word (B3:0) that will have a single bit active and I need to find which corresponding bit number is active and store it in N7:0. For example
If B3:0 = 0000000000000001 , then N7:0 should be 0
If B3:0 = 0000000000000010 , then N7:0 should be 1
If B3:0 = 1000000000000000 , then N7:0 should be 15
A simple LOG base 2 would solve it easily, but I could only find a LN and LOG base 10 in the instruction set. I am thinking there is a very simple solution that evades me.
...... OK, just as I finished typing this I came up with the answer, but I would still be interested in seeing how others solve it.
I have a word (B3:0) that will have a single bit active and I need to find which corresponding bit number is active and store it in N7:0. For example
If B3:0 = 0000000000000001 , then N7:0 should be 0
If B3:0 = 0000000000000010 , then N7:0 should be 1
If B3:0 = 1000000000000000 , then N7:0 should be 15
A simple LOG base 2 would solve it easily, but I could only find a LN and LOG base 10 in the instruction set. I am thinking there is a very simple solution that evades me.
...... OK, just as I finished typing this I came up with the answer, but I would still be interested in seeing how others solve it.
Last edited: