LumberJack818
Member
Currently I have a vision system inspection feeding a shift register in a Compactlogix. Right now the vision system determines that part is good or bad and the shift register tracks the part and diverts it accordingly.
What I've been asked to do is upon a particular failure dump all the parts from the vision system to the diverter. The number of parts being dumped varies depending on the length of part being produced. I know I can write a series of move statements to fill the shift register based on all the possible length options but I was curious to know if anyone had an idea on a shorter more elegant way to do this? Like is there a quick way to convert a decimal number into a series of bits. Like if the number of parts to be dumped was 25 then the last 25 positions of the shift register become 1's.
This is kinda more of an academic question, I know that I can do this with a bunch of move statements. But I am thinking that there must be a better way.
Thank you for any advice you can offer.
What I've been asked to do is upon a particular failure dump all the parts from the vision system to the diverter. The number of parts being dumped varies depending on the length of part being produced. I know I can write a series of move statements to fill the shift register based on all the possible length options but I was curious to know if anyone had an idea on a shorter more elegant way to do this? Like is there a quick way to convert a decimal number into a series of bits. Like if the number of parts to be dumped was 25 then the last 25 positions of the shift register become 1's.
This is kinda more of an academic question, I know that I can do this with a bunch of move statements. But I am thinking that there must be a better way.
Thank you for any advice you can offer.