motor on and off with single push button

Actually, Johnny...
There were actually a couple of earlier versions. And I have to admit that originally there was a second rung... where the WAS_PB signal was RST after the PB was released.

The original version of this particular version addressed the issue of two alternating outputs. Again, the original had two rungs... the second was to RST WAS_PB.

This latest version has been modified to put it all into one rung. It still applies to a single output... OUT_1, or a dual, alternating, output.

Initial conditions, PB = OFF, WAS_PB = OFF, OUT_1 = OFF, OUT_2 = OFF
Push/Release once, OUT_1 = ON, OUT_2 = OFF (Already OFF)
Then Push/Release again, OUT_1 = OFF, OUT_2 = ON
Then Push/Release again, OUT_1 = ON, OUT_2 = OFF
...etc.

WAS
PB PB
---| |---+---|/|------------+-----( SET ) WAS PB
| |
| +-----( SET ) FLIP
WAS |
PB | FLIP OUT_1
---| |---+---| |-----| |----+-----( RST ) OUT_1
| |
| +-----( SET ) OUT_2
| |
| +-----( RST ) FLIP
|
| FLIP OUT_1
+---| |-----|/|----+-----( SET ) OUT_1
| |
| +-----( RST ) OUT_2
| |
| +-----( RST ) FLIP
| PB
+---|/|------------------( RST ) WAS PB


I get a kick out of seeing how far things can be... stretched? ...manipulated? It might be confusing to some of the inexperienced, and yet... it is still functional... and, if one just takes the time to understand how these damned things work, it is still rational!

This will not work in all PLCs. However, it will certainly work in an S7-200. I have it in place, and operating, at this moment.

I wouldn't try to guarantee this with a sloppy (normal-type?) switch. But I do guarantee it with a well-acting "snap-switch" (toggle-type).

A sloppy switch (a normal, left-right, rotating switch with a cam) would probably need a debouncer (extra line of code with a timer).

Granted... this could have been done with several rungs... but the original challenge, way-way-back-when, was to do it with as little code as possible.

(345)
 
Last edited:
Johnny T said:
I think the most eloquent solution to this problem I ever saw was posted by S7Guy about 4 months ago. It was using S7 and involved the Xor function.

I think it was only three lines long...

Hey Johnny, I can't take credit for that. I can't remember who posted it originally, but it went like this:

A #PushButton
FP #AuxPB
X #PBStatus
= #PBStatus

It doesn't convert to S7 ladder, but it converts to S7 FBD.
 
Terry Woods said:
...It might be confusing to some of the inexperienced...

Granted... this could have been done with several rungs... but the original challenge, way-way-back-when, was to do it with as little code as possible.

Unfortunately I work with several of those inexperienced types and if I coded that way I would simply be programming my cell phone to ring at dinner time... or a worse time.
 
Rube

All the calls would take your mind off this years race season.

Rusty finnally gets a fair year, well, his last year, and it's in a dodge. Oh well.

While I would like to see M. Waltrip do better, I resolved myself several years ago that he was a 25th place driver.

Hey, I would settle for 25th in Nascar.

While Junior and so many others are doing so well, look wher "24" is.

Yes, there is some justice.

regards.....casey
 
Yeah after Indy, not a chance in hell that Junior or Gordon can make the Chase so they can concentrate on TV commercials now. I can't explain why two good drivers are so far back in points except lack of focus. Rusty and Mark are having good end of careers and Stewart is driving like he wants the Cup and if he gets it he'll damn sure have earned it.

But I still don't want those phone calls.....

It's too close too hunting season and we're finishing up a brand new conveyor system (71 motors, 16 scanners, 14 diverting pushers--pictures to come soon). PLUS we're reconfiguring an existing line, adding accumulation, diverts based on labels or box height. When I get home at night nowadays, I just want to eat and relax, thinking about hunting, not work.

So I program in, shall we say, more elementary ways than Terry's example.
 
Terry

Nice work. One rung in ladder... very well done. (must admit it took a bit to work through it in my head).

S7Guy, I thought that you weren't the originator of the post but, lets face it, if the other guy hadn't of thought of it, you probably would have... :D

JT :)
 
Rube said...

"Unfortunately I work with several of those inexperienced types and if I coded that way I would simply be programming my cell phone to ring at dinner time... or a worse time."

Rube...
Would that mean that you're not even interested in considering the concept?

If so...
I'm saddened by your lack of curiosity... your lack of interest in "What if...", your lack of "I wonder..."

Wouldn't that attitude be kinda like saying... "I can't appreciate the idea of speaking in English because, after all, most of my clients speak Spanish." Couldn't we still discuss ideas and concepts in English?

This site is not only an AB Hardware/Software How-to-Use site, nor only a "Here's the correct code for Dummies" site.

It's also a place where experienced programmers and developers can discus and explore ideas and concepts.

Ultimately, our job is to drag the PLC-nay-sayers, while they kick and scream, into the future present!

Believe it or not... for those maintenance-folks that are really interested in PLCs, it's simply a matter of, once they know, then they know! However, for those that are not interested... they will never get it... no matter how simple you make it.

Meanwhile, what in the world is wrong with discussing the capabilities of PLCs, on this site, as they exist?

Your attitude sounds pretty closed-minded, and it gives no intellectual credit to those end-users that are truely interested.

BTW, the code I posted is self-contained and self-maintaining. If there is a problem at all, it is with the pushbutton. How simple can that be? The button works... or the button doesn't work.

The deal with this type of coding is that it has multiple-outputs, through multiple re-entrant(?) paths. In this case, the entire rung needs to be solved... left-to-right and top-to-bottom, not just in terms of the first path that causes any output to go ON.

Come up to speed... this is the way new recent ladder (in decent PLCs) works these days.
 
Johnny...

The S-7 (2XX) PLC will do what you did in very short order (much less painfully). I can't vouch for the 3XX or 4XX... they are too much like the S5... there's something really wrong with the basic programming philosophy behind the S5. (Maybe it's too much like... "Eastern-Western" thinking (European thinking?), as opposed to "Western" thinking (American-type?).

I don't know... there's just something really different in the thought process.

Don't forget, a PLC will do exactly as it is told... however, it will do so one hell of a lot faster than we could hope to do manually!

That means that a PLC can rush to the next screw-up much faster than we can.
 
Terry, I just tried it with the other S7 in ladder, and it is do-able. It's a good exercise in applying an understanding on how PLC scans work, but in real life I would prefer a solution that used a third or less of the instructions.
 
So...

Using PB as the entry, break each set of outputs into a separate rung.

Then, using WAS_PB and NOT PB, RESET WAS_PB.

It's all the same.

Again, the original exercise was for the least number of rungs.

But even still... what is the difference... really?
 
For what it's worth, I use this.
The toggle happens as the PB is released.
NB: Requires 2 networks. Works for S7-200 and Step7.



-- OUT -----PB----------------- OUT
---|/|------| |-----|N|---------(S)



---OUT----- PB -----------------OUT
---| |------| |-----|N|---------(R)
 
Last edited:
Terry Woods said:
Would that mean that you're not even interested in considering the concept?...

...I'm saddened by your lack of curiosity... your lack of interest in "What if...", your lack of "I wonder..."

...for those maintenance-folks that are really interested in PLCs, it's simply a matter of, once they know, then they know! However, for those that are not interested... they will never get it... no matter how simple you make it.

Your attitude sounds pretty closed-minded, and it gives no intellectual credit to those end-users that are truely interested.

It's amazing all the things you presume to know or estimate from my post Terry. I simply commented on how elegant your logic was and I'm "close-minded"? Was my humorous attempt lost on you when you deduced that I have a "lack of curiosity"?

I would not even be in the business of using PLCs if I were close minded or lacking in curiosity--no, I'd still be milking cows like I did when growing up. I write my own programs, some elegant and complicated because in all likelihood I will be the only eyes to ever view the code. Other programs I write may have eyes of people less experienced in logic (let alone programming) PLCs.

One of ways I program is to "what if" it to death. And for the same reason I originally posted--so my phone doesn't ring (as well as safety).

I have more than once complimented you on your programming--I respect those, like you, that know and those that don't want to know as much as you or I, and I try to write programs to help each. I think that's a pretty open-minded approach.
 
Rube...

I didn't catch the post where you said...
"So I program in, shall we say, more elementary ways than Terry's example."

Well... I did catch it, sorta, but... it lead off immediately to NASCAR, Huntin' and Fishin'... I didn't see any PLC stuff (right away) so I passed on it.

Having seen only your original comment...

"Unfortunately I work with several of those inexperienced types and if I coded that way I would simply be programming my cell phone to ring at dinner time... or a worse time."

...I thought your position was that it wasn't worth entertaining the idea, even for the sake of a simple discussion in concepts. As in, "If I can't use it with my particular clients, then why bother?"

If I misread your position then I apologize.
 
S7GUY...

The interesting thing about that particular piece of code is that it follows the human thought process. It examines conditions and produces results, and remembers things in the same way that we would mentally. This rung points out the little pieces of information that we would use to proceed forward to complete a process even as simple as this.

There is a lot more in the thought process of handling a simple exercise like this than many people recognize. (Try describing to someone, over the phone, how to tie their shoestrings!)

Verbalizing the first branch... (PB Just pressed) (Let's ignore Output-2)

If PB is ON, and it wasn't ON, then... REMEMBER that it Was ON, and REMEMBER that we are going to Flip the State of the Output.

Verbalizing the second branch...

So, do we REMEMBER that we are gonna Flip the Output? If so, and the Output is ON, then... Turn the Output OFF and FORGET that we are gonna Flip the Output! (After all, we just flipped the damned thing!)

Verbalizing the third branch...

So, do we REMEMBER that we are gonna Flip the Output? If we just flipped it then we decided to FORGET that we are gonna Flip the Output. If we didn't just flip the Output, then we still REMEMBER that we are gonna Flip the Output. So, if we still REMEMBER that we are gonna Flip the Output and the Output is OFF, then... Turn the Output ON and FORGET that we are gonna Flip the Output!

At this point, the output has been changed to the appropriate new state and we have FORGOTTEN that we are gonna Flip the state of the Output.

Since the PB is in fact ON, the fourth branch is ignored... until the first scan after the PB is released.

In terms of decision making, with facts at hand, we can make these little PLC-Ba$tard thingees think just like a human thinks!

As far as having a PLC incorporate things like "Inspiration" and "Ah-Ha!"... well, that kinda stuff is still down the road a bit... but it is getting closer... every day!

Should we think more like machines? Or... should we get machines to think more like we do?

Of course, if we are gonna be the model for machine-think, then we had damned well better think clearly and rationally!

I can think of a few folks that I would NEVER use as the human model!
 
The interesting thing about that particular piece of code is that it follows the human thought process.

Yes, but all functional logic follows the human thought process. That's why there are hundreds of different solutions to the same problem, many of which are just as good as the next. The logic in your example is easily followed, and as I said it is a good example for someone who needs to learn how a PLC scan works, but it isn't an efficient solution to the problem. Then again, the original question (making a toggle with a single rung) is kind of trivial anyway, and is more of a function of the strength of the editor than the skill and understanding of the programmer.

I still like the XOR solution. :)
 

Similar Topics

Hi everyone, This is my first time posting, so please forgive any omissions or mistakes. I am attempting to control the velocity of a stepper...
Replies
18
Views
1,043
This is the motor nameplate from one of the powder hoist motors on the USS Texas an older generation battle ship, built in 1911-1914 ish. The...
Replies
1
Views
295
Im trying to diagnose a loud vibrating/humming noise coming from my companies Kollmorgen Cartride Direct-Drive Rotary motor. The motor is being...
Replies
4
Views
604
hi guys i have a problem, i have five motors and my coustmer want me to start the motor at random sequence and stop the motor in the same sequence...
Replies
5
Views
2,028
I'm sorry to bother you guys, I have been battling this random issue for weeks. We have 14 - Kinetix 6000 drives. When the operator sometimes...
Replies
3
Views
4,179
Back
Top Bottom