FLL command

mtech2766

Member
Join Date
Jun 2021
Location
Indiana
Posts
20
I am using a SLC5 and need to set B3:0/2, 3, 4, & 5 to zero.
Can I use a FLL command, using my source as 0, destination B3:/2 and length of 4? Will that work? Is there a better way to do this?
I would try it, but I don't have my PLC here, as I am working from home today.
Thanks
 
The FLL command only works on whole word addresses, not individual bits. The OTU is the easiest way to write a 0 to a single bit. Just create one for each bit.

Alternatively, you could use a MVM instruction.

Source: B10:0
Mask: B10:1
Destination: B3:0

  • B10:0 in this case would be an unused word. You can use any B or N address that is unused. By default, it would have a value of zero (16 zero bits). That is what we want to send to your B3:0 bits.
  • B10:1 would be the mask address where you identify which bits you want to write to in the B3:0 word and which bits to ignore. Same as above, this should be any unused B or N word. Open the data file for this address and manually place a 1 in bits 2 through 5. The instruction shows the mask in hex so you should see 003Ch. The "h" means hex. You can also manually type that value into the mask instead of assigning an address. I always prefer to use an address as they are easier to modify down the road.
  • B3:0 is the destination word.

So the MVM would pass the zeroes from the source through the mask. Any masked bit that has a 1 passes through to the destination. Any masked bit with a 0 does not pass any data.

To be honest, for only those four bits... I would just use OTU instructions.

OG
 
Last edited:
Either
AND B3:0 -61 B3:0
or
AND B3:0 FFC3h
might work, but four OTUs will be more easily understood three months from now ...
 
Last edited:
There is a perception that OTL and OTU must be used together. And of course, that isn't the case. The OTU is a very efficient tool all on its own for resetting bits.

OG
 
There is a perception that OTL and OTU must be used together. And of course, that isn't the case. The OTU is a very efficient tool all on its own for resetting bits.

OG
I once found a Micrologix 1400 program where they only used OTL's. To turn off a bit, they exclusively used a masked move and a mask written in hexadecimal. To turn off one bit.

That wasn't even the dumbest part of that program. To this day, that program is the worst example of PLC programming I've ever seen in my life.


edit: as to the original question, the AND instruction would probably work, as would the MVM trick described above (although for the love of god write your mask in binary not hex). But I agree with the others that for the sake of four OTU's, you'd end up with a far better, more readable program. Unless you're pushing the limits of processor memory and need every last instruction, I'd use four OTU's without even thinking about it.
 
Last edited:
I once found a Micrologix 1400 program where they only used OTL's. To turn off a bit, they exclusively used a masked move and a mask written in hexadecimal. To turn off one bit.

That wasn't even the dumbest part of that program. To this day, that program is the worst example of PLC programming I've ever seen in my life.

LMAO. I didn't realize any of my code made it to Aus. :D

OG
 

Similar Topics

Structured Text does not have FLL instruction, but one can create the equivalent. SIZE(destination,0,length); FOR position := 0 TO length-1 DO...
Replies
5
Views
2,611
I'm troubleshooting this machine in the field right now. The discrete outputs of this Micrologix 1500 are wired to discrete inputs of a Siemens...
Replies
3
Views
1,535
I'm using a CompactLogix L33ER with v24 of Studio 5000. I've been noticing some odd behavior when I trigger a FLL instruction behind an ONS. It...
Replies
4
Views
1,481
Would someone be so kind as to explain the difference between the cop, mov and cop instructions and where each one may be used? The instruction...
Replies
4
Views
5,955
I have a tag dimensioned BOOL[1024]. Is there an instruction that will copy a 1 or 0 for a set length to a BOOL tags? Like fill BOOL[600] with 0...
Replies
8
Views
2,712
Back
Top Bottom