# popquiz

MrPLC Member

11

0 Neutral

• Rank
Sparky

## Profile Information

• Country United States
1. ## Simple Click For Loop

Thank you for the replies and the elegant code.
2. ## Simple Click For Loop

To populate the first eight DS registers, I might use a For loop.  In python it would look like: DS = {} index = range(1,9) for i in index:   DS = i print(DS)  {DS1:1, DS2:2, ... DS8:8} To accomplish the same with a 'Click' For loop, I need to be able to use indirect addressing in the result field of the Math instruction.  For ex: If I could replace DS1 with DS[DS9] below, then the python loop and the Click loop would be functionaly equivalent.  Without this capability, I don't see a concise way of going about this.  Any ideas?

5. ## Are Allen Bradley PLC's manufactured in the U.S.A.?

I just read that some economists consider the manufacturing sector as the wealth producing sector of the economy and the sevice sector as the wealth consuming sector of the economy. Hmmm. Are Allen Bradley PLC's manufactured in the U.S.A.? Are any PLC's manufactured in the U.S.A.? And I don't mean assembled in the U.S.A.
6. ## Math question !

Peter, are you referring to a MSB, divide and conquer, algorithm? If you are, then I found a pretty good link which provides the method in C#. If not, please advise. Thank you. http://www.answers.com/topic/most-significant-bit
7. ## Math question !

This is an interesting question in the general sense. And in the general sense isn't the solution just an iterated bit shift right, easily adapted to most plcs, as in the following C# example: using System; class BitLocator { public static void Main(string[] args) { double TWO = 2; double exponent = 0; int value = 0; int locOfBit = 0; //get integer value do { Console.WriteLine("Enter an integer 0 thru 15: "); exponent = Math.Round(double.Parse(Console.ReadLine())); } while (exponent < 0 || exponent > 15); value = (int)(Math.Pow(TWO, exponent)); //get location of bit while (value != 0) { value = value >> 1; //bit shift right locOfBit++; Console.WriteLine(value); } //send the result somewhere Console.WriteLine("The location of the bit is {0}", locOfBit); } }
8. ## I need to toggle an output with only 4 instructions

Oh that's right. I wired up and ran the code in post #4 a few days ago. It didn't work before I changed STR to STRPD. I'll edit my previous posts. Thanks again.
9. ## I need to toggle an output with only 4 instructions

I see. So the final answer is: STRPD X7 LD K20 XOR V40500 OUT V40500 And if I wanted to toggle all the odd outputs Y0 thru Y15: STRPD X0 LD KAAAA XOR V40500 OUT V40500 And if I replace X0 with a sequence of T0 accumulated values, I'd have a DRUM. I think we're going to have some fancy Christmas decorations this year! Thank you bcarlton
10. ## I need to toggle an output with only 4 instructions

I did go to Allen Bradley's PLC2 school once upon a time. I've searched the web and most toggle logic requires 7 instructions. Of coarse there is the IBox (PONOFF), but really, how many layers of abstraction do we need? I came up with: STRPD X0 LD K1 SUB V40500 OUT V40500 ->but this means you can ONLY use output Y0. I suppose you could use some internal word from some remote quadrant of the control relay bit map in place of V40500 and then slave any real world output you like, but now your code contains 6 instructions. 6 < 7, but I seek 4.
11. ## I need to toggle an output with only 4 instructions

I have a busy DL05 application with available ladder memory limited to just four more instructions, five including the "END" instruction. I need to toggle Y5 on and off with one remaining unused input. Any suggestions?