Simple SLC500 Code

Join Date
May 2007
Location
Salt Lake City, Utah
Posts
415
I set my class a problem this week in the PLC class I teach and wondered if some of you genius types can provide your input.

How to make an output turn on when you press a pushbutton input, it stays on when you release but then when you press the same button again it goes off. Sort of like a toggle switch on an HMI.
This has to be done using the least possible rungs!

Answers on a postcard please.

I found its not quite as simple as I thought :mad:
I did get it to work though đź““
 
This has been discussed ad infinitum on this an other forums. I think you'll find plenty of examples if you use the term "flip-flop" in your search.

Now for the obvious question. What in the world are you doing teaching a PLC programming course if you don't know how to program something as basic as that?
 
Its not something I've ever had to use.
At least not on a Micrologix.

I tend to treat situations like this as a learning exercise so I can expand both my and my students knowledge. I also try to spend a little time on here helping folks (which I hope i am somewhat successful at) in the areas at which I am proficient.

I didnt realise you classed me as 'unworthy' of teaching and probably even posting on here. I assure you next time I'll keep my mouth shut and let you handle the 'hard stuff'.


Thanks for the heads up.
 
Last edited:
the least number of rungs is going to be ONE ... and as far as I know, the least number of instructions (in ladder logic at least) is three - as in this post ...

and the important thing is NOT getting it to "work" - and then "using" it ... it's understanding WHY it works - and just as important why many "common sense" methods do NOT work ...

it has to do with the way that the PLC scans its program and interprets its instructions ... the fact that many (most?) technicians do not understand the details of that process very well helps explains why PLCs often seem so hard to learn ...
 
The least number of instructions (two) would be to use a counter.

XIC I:0/0 CTU C5:0 0 0

C5:0.ACC/0 is your toggle bit, it changes state every time the counter increments. No need to reset the counter ever. One drawback tot his method is it is retentive.

There is also an example in the AB Knowledge base, ID#36630

P.S. Steve Bailey - I know SLC_integrator, his office is only a few miles away. He is quite capable of teaching and more than knowledgable enough - for everyone one of us there is probably something very basic that can be completely new to us.


edit to attach file:
Here is part of a program for a ML1K on a vacuum furnace. Rungs 11 and 13 are a variant of a flip flop modified to provide set and reset as well as the normal flip flop toggle.
 
Last edited:
SLCIntegrator,

I apologize for expressing myself so poorly. I'm accustomed to seeing students looking for solutions to their homework assignments. It's a bit disconcerting to see the teacher doing the same thing.

When I pay money to be trained on some hardware or software, I don't think it's unreasonable to expect that the teacher knows the subject better than I do. It seems to me that the time for you to ask the question is before you assign it to your students, not after.
 
Last edited:
yes, Alaric ... but when using a Counter, the "toggled bit" is not technically an "output" ... so in order to actually USE the toggled bit would require more logic ...

personally, I'm going to stick with my "three instruction" answer ... but I fully respect your differing opinion ...

(this would be a good place for a friendly little smiley face - but I just can't bring myself to use those things) ...
 
As i said, I figured it out within 10 minutes myself, pretty much the same way as most of the sample code I found when I did a search on here.

I'm not a PLC 'guru' like alot of folks on here, which is why I asked for some of the more elegant solutions.
I spend probably 75% of my time on DCS systems which dont have the scan execution issues a PLC does. I can program just fine with most brands of PLC's and when I came to my solution I was wondering if there wasnt a way of doing it much, much simpler (which turned out to be true).

Along the way some 'common sense' approaches hadnt worked and as Ron said, you have to really dig into the way the PLC actually scans and executes code in order to understand why its doing what its doing (or not doing what its supposed to).

I was trying to show the students examples of why some 'common sense' approaches wouldnt work and by using some more exotic solutions you can achieve the same end result, though getting there can be more complicated in understanding how a PLC actually functions.

Maybe I should have just shown them my solution and kept my mouth shut, but i guess we cant all be experts in everything.
 
I still like this one...

Toggle.JPG


Or this one with out the reset... point less

1flip.jpg
 

Similar Topics

Gents, I am still learning RSLOGIX-5 but I have a friend who wants to learn RSL-500. I am assuming his workplace uses SLC's. I have a used AB...
Replies
2
Views
5,887
Hello again..trying something on an existing poorly written program and just wanted to double check something system is an A-B MicroLogix 1200 In...
Replies
5
Views
165
Hi all, Writng a FB in ST on Beckhoff TC for a pulser which turns on and off on a cycle, is paused by turning bControlInput to FALSE, but resumes...
Replies
6
Views
248
I'm trying to build my Classic Step 7 programming skills this weekend. I get stuck on little things that are not covered in YouTube tutorials. I'm...
Replies
7
Views
316
I have a program that does a 7 second "scan" sensor calibration routine whenever a setting (setting is called assistance level or "AL" and ranges...
Replies
3
Views
212
Back
Top Bottom