Electric Automation Forum
Forum » General Discussion » How would you code this in logic controller? » Reply Thead


Your name:



Put the result (2 + 7) in      

Start by
David Stonier-Gibson
01-03-2014 10:37 PM

How would you code this in logic controller?

In logic controller design *sequence* is very important. So is *context*. A logic controller is essentially something that responds to inputs by altering outputs in the right sequence, where the sequence may vary with context. (Use the terms "history" or "past events" instead of "context", if that is more comfortable.

My job includes studying and designing programming methods that can express sequence and context.

So here is my question: How would you code the following in the language(s) you use ...

A controller has one push button switch wired to an input, and one lamp wired to an output. The first time the button is pressed the lamp must come on. The next time the button is pressed, the lamp must turn off. On the next press the lamp comes on, etc. etc. Don't forget to allow for the button to be released before it is pressed again.

This is not a trick question or "test". I am simply interested in how a simple example involving sequence and context is handled by different professionals in various languages. I would also be interested in opinions as to how easily a given solution would be to explain to a colleague who is not familiar with the specific language (or operating system)