Simple switch function

bist

Member
Join Date
Oct 2005
Location
Weerde
Posts
13
Hi,

I got myself an AB PLC5

I was wondering. How can one make a standar switch function.

I mean when 1 press a button then the light goes on. When I press it again the light should go off.


I looked at the latch function. But it didn't do what i wanted.

What functions should I use?

Thnx in advance
 
What you are after is a toggle. There are a lot of ways to do this; most use a one-shot bit so the toggle only executes once when you press the button. I often use something like this (ignore the *, they are there due to formatting issues):

*****button************ toggle
|------||--------[OSR]--------()----|



***toggle*** output******* output
|----||--------||--------------(U)----|
*********|
*********|
*********| output ***** output
**********--|/|-------------(L)----|

.... Although there are a lot of other examples readily found using the search function on the title bar - use that for basic questions like this in future :) here's one to get you started...

http://www.plctalk.net/qanda/showthread.php?t=16588&page=2&pp=15&highlight=flip+flop
 
Last edited:
rsdoran said:
Latch (L) and unlatch (U) is something you should use once you have
learned when and how. This is basically the same thing http://www.patchn.com/flipflop.htm

Much of the boilerplate code we use for some of our system elements use that template for flip-flops, but I prefer the latch/unlatch form because it is more readable and harder to mess up if you are in a hurry. Otherwise, I don't think I ever use latch/unlatch instructions :)
 
Guys, thanks a million. I'll try this.

I apologize for not using the search function. So I did not know what to look for. Now I do. It's a flipflop.

Thnx
 
Guys,,One last question. Sorry to be so stupid. But I have no idea how the OSR must be set


I followed the example from the link in the post above

Can anyone help me?
 
Last edited:
could you give me an example because i'm a total newbie.

I tried the example above but error. Invalid Output instruction position!
 
Last edited:
Another slick way to do it in a PLC 5 is with a counter and bit zero of the counter.ACC word.

XIC I:1/0 CTU C5:0 0 0
XIC C5:0.ACC/0 OTE B3/0

Everytime a binary number increments, the least significant bit changes state.
0000
0001
0010
0011
0100
 
Mickey said:
A closer look at Binaural's example, I don't think it will work.

In an AB PLC it won't work.
In a Modicon PLC it will work because the modicon solves vertically first. However, since its a PLC/5 we are talking about thats moot.
 

Similar Topics

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
167
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
Hi all, I have a simple question that I have overcomplicated and gotten stuck on. I have a variable, we can call it "light" that I need to stay...
Replies
4
Views
310
Back
Top Bottom