End of year contest

Entry for Flip-Flop contest.
Incorporating strings may have gone a bit overboard but, it's kinda cool to see the state actually displayed as 'ON' or 'OFF'.

FlipFlopRubeContest.jpg
 
I'm honored to be included in that distinguished panel!

Hey Steve,

Thanks for the invite. The initial proposal sounds interesting...

"The idea is to create the most egregious example of obscure, misleading, downright ugly ladder logic you can think of."

My first suggestion regarding the rules of submission is that all entries should be submitted in PDF so that anyone, and everyone, can view the code.

Even as I was reading the challenge the gears in my head started turning while my keepers urged me - with the aid of a few well placed two-by-four shots - to enter the contest rather than judge it. I haven't made up my mind yet.

Whether I enter the contest or not, the thought occurred that it should indeed be obscure and misleading, and possibly ugly, because... rather than just being poorly written, there was an ulterior motive! That is, the code should indeed do something, but that something should somehow be lost in translation.

Even as I type this... I can "see" that many of the original, and some of you latter day Baker Street Regulars know where this is leading... and there I shall leave it.

I think that the idea of building only an ugly toggle is quite limiting. I think it better to leave the field open to... uhh... otherworld ideas.

I think it should be a case of "here's what it appears to do, I think...", in as obscure, misleading, and ugly a way as possible, only to find out what it really does is such-n-such. It might appear to be a horribly written piece of toggle-code only to find that it is actually a brilliantly disquised such-n-such code.

That is, the code is "obscure, misleading, and downright ugly" with a purpose.

And so, the challenge, as I see it, is to develop a piece of code that appears to play no part in the main scheme of the process and yet seems to do something... something which is not so apparent.

Consider this...
You are a new guy on the job. You go through the code. You find this piece of code which "appears to play no part in the main scheme of the process and yet seems to do something... something which is not so apparent."

Certainly you will ask around about that piece of code. However, you get no real information about it.

So... do you delete the code, or do you leave it?

I think you can see that I'm focusing, like a laser, on the "misleading" requirement.

What say you all?

(616)
 
Last edited:
Terry had the winner many years ago.

Terry has an example of TI505 code where he did a parity check. In stead of counting the number of bits and testing the least significant bit he used a method of divides that was weird but it worked.

Do you remember that Terry?

I would play but I just can't get myself to write kludge code.
If I were to try I would use ladder to emulate a Turing machine
http://en.wikipedia.org/wiki/Turing_machine
 
Darkman?

Hi Peter,

Long time, huh?

I do remember the parity issue... hmmm... a bit more than a couple years ago. I wonder if it is available to search for... Phil?

Peter, did you enjoy our White Christmas? (Worst snow in 35+ years!). My wife and I loved it except that we couldn't walk our working American Eskimo dogs because they... uhh... they like to work, a lot, pulling and stuff like that... on the ice... around concrete stuff... where faces and concrete don't exactly meld well together... scary as hell!

No, "whoa" does not work, not when, in order to remain in tact, you have say it between breaths! Time to get ready for the floods now. I'm sure Vernonia is gonna get hit hard again. They can't stop the rivers rising but this time they are ready with emergency equipment.

Maybe some of you have seen the "Axemen" show on Discovery. The town that was flooded on the show was Vernonia. It's just about 25-30 miles away from me.

Anyway, Peter, I look at this as a game of deception hidden behind ugly, yet feasible, code.

Hmmm... I think my darker side is coming out...


(627) Git, don't spoil it for the newbies!
 
Last edited:
Hi Peter,

Long time, huh?

I do remember the parity issue... hmmm... a bit more than a couple years ago. I wonder if it is available to search for... Phil?
I am blessed/cursed with a very good memory except I find it difficult to remember names and match them with faces.

Peter, did you enjoy our White Christmas? (Worst snow in 35+ years!).
40+ years. I have lived in Vancouver or Portland for at least that long.

My wife and I loved it except that we couldn't walk our working American Eskimo dogs because they... uhh... they like to work, a lot, pulling and stuff like that... on the ice... around concrete stuff... where faces and concrete don't exactly meld well together... scary as hell!
You should have found something that you can sit on while they pulled and did their thing.

Time to get ready for the floods now. I'm sure Vernonia is gonna get hit hard again. They can't stop the rivers rising but this time they are ready with emergency equipment.
The floods are supposed to be a problem this year because there isn't the snow pack on the ground like the did with the mid 90s flods.

Maybe some of you have seen the "Axemen" show on Discovery. The town that was flooded on the show was Vernonia. It's just about 25-30 miles away from me.
Yes, I know.

Anyway, Peter, I look at this as a game of deception hidden behind ugly, yet feasible, code.

Hmmm... I think my darker side is coming out...
I remember 5TI code where a delay was implement by having a lot of rungs in reverse order so it took a whole scan to activate the rung before it. Ten rungs in reverse order would cause a 10 scan delay. Is that obscure?

I can remember a system integrator saying our controller was the biggest pain in the butt to program. He used a LDC to each of the registers for a move command. If the 4 axes were going to move at the same time he did 24 LDC boxes instead of 1 movw block that copied 24 words which would move 4 axes at once. He cursed me and our controller. I explained to the mill manager the machine required only 6 states and therefore 6 rungs to activate the motion controllers. All the system integrator hand to do was activate the rungs at the right time. As you know the constants in a LDC can't be edit by a program like Wonderware whereas a commands store in VMEM can be edited by Wonderware.

I have seen applications where our controllers were accused of moving or not moving when they were supposed to. After traveling all the way to Appomatox, VA from Vancouver, WA is discovered that the system integrator used the same one shot multiple times.

I find it hard to be interested in kludge code. I have seen too much already. Both times it was an expensive trip into the field.
 
Hi Peter,

Long time, huh?

I do remember the parity issue... hmmm... a bit more than a couple years ago. I wonder if it is available to search for... Phil?
I am blessed/cursed with a very good memory except I find it difficult to remember names and match them with faces.

Peter, did you enjoy our White Christmas? (Worst snow in 35+ years!).
40+ years. I have lived in Vancouver or Portland for at least that long.

My wife and I loved it except that we couldn't walk our working American Eskimo dogs because they... uhh... they like to work, a lot, pulling and stuff like that... on the ice... around concrete stuff... where faces and concrete don't exactly meld well together... scary as hell!
You should have found something that you can sit on while they pulled and did their thing.

Time to get ready for the floods now. I'm sure Vernonia is gonna get hit hard again. They can't stop the rivers rising but this time they are ready with emergency equipment.
The floods are supposed to be a problem this year because there isn't the snow pack on the ground like the did with the mid 90s flods.

Maybe some of you have seen the "Axemen" show on Discovery. The town that was flooded on the show was Vernonia. It's just about 25-30 miles away from me.
Yes, I know. I couldn't relate to the axemen to much. They use chain saws and have been ever since I was a little kid. I know because my father sold them the chain saws. I just remember that it was very dangerous.

Anyway, Peter, I look at this as a game of deception hidden behind ugly, yet feasible, code.

Hmmm... I think my darker side is coming out...
I remember 5TI code where a delay was implement by having a lot of rungs in reverse order so it took a whole scan to activate the rung before it. Ten rungs in reverse order would cause a 10 scan delay. Is that obscure?

I can remember a system integrator saying our controller was the biggest pain in the butt to program. He used a LDC to each of the registers for a move command. If the 4 axes were going to move at the same time he did 24 LDC boxes instead of 1 movw block that copied 24 words which would move 4 axes at once. He cursed me and our controller. I explained to the mill manager the machine required only 6 states and therefore 6 rungs to activate the motion controllers. All the system integrator hand to do was activate the rungs at the right time. As you know the constants in a LDC can't be edit by a program like Wonderware whereas a commands store in VMEM can be edited by Wonderware.

I have seen applications where our controllers were accused of moving or not moving when they were supposed to. After traveling all the way to Appomattox, VA from Vancouver, WA is discovered that the system integrator used the same one shot multiple times.

I find it hard to be interested in kludge code. I have seen too much already. Both times it was an expensive trip into the field.
 
Terry
What does the 616, or 627 stand for?

I am the new guy at a PLC5 plant it is riddled with left overcode. I have spent way to much time tracking down rungs that go out to a Basic card to a chart recorder that counts pulses from a flowmeter and back. Then I found a Highspeed counter card that is counting the same pulses. The oldtimer says Oh yea I couldn't findout where the signal was coming from so I hired a SI to get it going.

I love reverse engineering a junk system.
 
I was willing to include any examples, but if limiting this year's contest to the toggle (aka flip-flop) function results in more responses, I'm all for it.

As a self-nominated judge, I'm not eligible for the grand prize, but here's a modest contribution to help stimulate the creative juices.


Pushbutton _____ _____ ______
--]P[-----| ADD |----------| > |--------| MOVE |
| | | | | |
R1 -| |- R1 R1-| | 0 -| |- R1
| | | | |______|
1 -|_____| 1-|_____|
_____ Out
----------| EQ |-------( )-
R1 -| |
| |
1 -|_____|


Well......I think his suggestion was to take something simple like a toggle and convolute it to the point where it worked but was nearly impossible to follow how.

Yours works and is nice to look at...............and I can't quickly come up with a simplier solution....................but I am still thinking..........
 
Kluge you say

Terry has an example of TI505 code where he did a parity check. In stead of counting the number of bits and testing the least significant bit he used a method of divides that was weird but it worked.

Do you remember that Terry?

I would play but I just can't get myself to write kludge code.
If I were to try I would use ladder to emulate a Turing machine
http://en.wikipedia.org/wiki/Turing_machine

Peter.......were you ever in the military?

I have never heard a civilian use "kluge" before..............except Tom Clancey in Hunt for Red Oktober...........why do I remember that?
 
I once had a boss that would write "block diagrams" in a bas*ter*ized function block diagram format. He would then expect us programmers to convert it to plc code.

Not a horrible idea, but sometimes it led to some really sloppy code.

I once reduced an entire page of his FBD code using boolean algebra.

It equated to ....

-----| | ---------( )

Just for fun, I wrote his code as designed, and sure enough, it worked exactly like
my above result.

Boy do I wish that I still had that FBD diagram!
 
Last edited:
Re inventing the wheel

I do feel that the rules will need to get pretty specific about the instructions and processors used. The fun stuff happens when you take advantages of nuiancess in the platform.

Check out my Beta entry.

I call it re inventing the wheel.

spoke 1 > spoke 2 > spoke 3 > spoke 4 > spoke 1, etc. etc.
 
This plc programmer (who reminded me of the garbage mouth guy from the saturday morning cartoons), who advised me to never sprinkle hot pepper flakes on my
pizza, as it would most definitely tear up my insides.. (is this true? cuz i sure do like them pepper flakes)

anyhoo, He would program a wonderware button to a oneshot address in the plc as such...

Code:
    HMI Button                   HMI Button pulse
       b3/0                        b3/1
------[ons]-------------------------( )

b3/0 would always be 1 because the previous scan would solve the oneshot true

The HMI button was set to write a 0 to b3/0.

When you write a zero to a oneshot, the oneshot is inherently reset.

Next scan, you get a pulsed b3/1.

Now for the why:

This was actually, kind of genious....

Since the momentary function in wondeware, could miss a button press, especially since there were often delays in communication in the oil field using radio modems...

Most wonderware programmers were aware of this, and would set the HMI to set a bit, and for the plc to reset the bit once it received it. And use a separate coil for button lamp indication.

This code accomplishes the same thing rather simply.

The bit b3/0 even serves as a good lamp indicator for the wonderware button.

But to walk up on the code for the first time........


One little caveat...

The AB PLC5 sets all of its false/true type instructions' EN bit to 1 on pre-scan.

The AB SLC does not.

Yet, this code did not produce the extra pulse on slc start that i expected.

Hmmm, because i am using the simulator?
 
Last edited:

Similar Topics

Hi , Where i can find Mitsubishi PLC Card end of line & replacement model details. i am looking for Q02CPU replacement model. Please advice. thanks
Replies
2
Views
126
So I had an odd request from a customer for the above. I have written the logic and tested it all in one PLC with only using 7 outputs and 7...
Replies
15
Views
421
Our punch press has a SLC500 with HELM weight module (HM-604-WM) for tonnage monitoring. The operator enters the weight range on the HMI, which is...
Replies
9
Views
200
I am converting a SLC 500 to a Compact Logix. I plan on using a Compact Logix 5380 with conversion Kit. The problem is that the analog input cards...
Replies
1
Views
144
Hello. I am working in FTVSE v8. I have many trends set up some of them work others do not. The ones that don't work show the foot print of the...
Replies
3
Views
236
Back
Top Bottom