one button two functions

bulletin blues

Lifetime Supporting Member
Join Date
Mar 2003
Location
out there
Posts
223
One pushbutton turns on output, same p.b turns off output. Tooling around on our simulator at work and my partner says, " i want to use one pushbutton to turn on an output and then hit the same button to turn off the output" He did it in 4 rungs using a one-shot. I did it in 3 rungs using a counter. P.B. to counter. Counter equals 1 turn on. Count equals 2 reset counter. methinx thats too many rungs. Can we do this in 2 rungs? I know you all live for this stuff. We are using A.B.6200. Why do we want to do this? Because its there.
 
Make a oneshot of your button - 1 line
Next line:
BST XIC oneshot XIO output NXB XIO oneshot XIC output BND OTE output

There's a way with one line but the code is very ugly. It's in a previous post on here if you have the inclination to search.
 
1-Button / 1-Rung

This won't work on all PLC's. It is working on my S7, however.

Ladder
.
3d1cfe6d4acaac97.gif

.
.
Flow Chart
.
3d1cfec24b300d7f.gif
 
You can do it with Mitsubish plcs on one line with two instructions.

LD X0 : ALT Y0

The ALT inverts the last output state and debounce is taken into account but I have never used it. I just dont trust it somehow.
 
how about this

Pushbutton n/o n/c B
-------[ ]---------------[/]----------(A) use A as your output
' '
' n/o A '
-----[ ]------

n/o A Pushbutton n/o
-------[ ]---------------[ ]----------(B)

OR


Pushbutton n/o n/c B
-------[ ]---------------[/]----------(latch A)

n/o A Pushbutton n/o
-------[ ]---------------[ ]----------(unlatch A)
'------(output B)
 
Steve,

This code has been installed and running on an S7 for the past several months. It works EXACTLY as shown.

As I said, this code doesn't work on all PLC's.

Look at the rung as if it is a Function... where ALL paths are examined and executed. Left-to-Right and Top-to-Bottom.

Initial Conditions:
  • PB is OFF
  • Was (as in Was-PB) is OFF
  • Flip is OFF
OK, so, assuming the Light is OFF and no PB activity...

SCAN X :

Starting at the top-left...

The PB is OFF. This means that any outputs on the rung will fall to their "default" conditions... if they have one.

Since WAS is the only output that has a "default" condition, WAS is turned OFF.

So, a few scans later, the PB is pushed...

SCAN X + 1000 :

Starting again at the top-left...
The PB contact is TRUE. This means that the entire rung will be examined and manipulated as required.

Since this is the first scan that the PB is ON, then the PB was OFF on the previous scan, therefore WAS is still OFF as a result of the last scan.

PB is TRUE and NOT-WAS is TRUE, therefore, FLIP is SET

Moving down to the next branch, FLIP is TRUE and NOT-LIGHT is TRUE (initial condition), therefore, SET the LIGHT Output and RESET FLIP.

The Light that was OFF is now ON.

Moving down to the next branch, FLIP was RESET in the previous branch, so it is FALSE. The LIGHT is TRUE. Since the outputs on this branch are the Set/Reset type, you need a path-of-TRUE's to perform the indicated action. Since the path-of Trues does not exist... no actions occur. These outputs do not "default" to a particular state - they have to be "driven" to act.

The last branch... PB is TRUE, so WAS is Turned ON.

End of Rung / End of Scan X + 1000

SCAN X + 1001 :

Current Conditions:
  • PB is ON (it takes more than a scan or two for you to remove your finger from the button)
  • Was is ON
  • Flip is OFF
  • Light is ON


PB is TRUE, so the entire rung will be examined.

PB is TRUE and NOT-WAS is FALSE, therefore FLIP is not Set.

Next branch, FLIP is OFF so there will be no path-of-Trues and the outputs are the set/reset type and so there will be no action here.

Ditto for the next branch, FLIP is OFF so there will be no path-of-Trues and the outputs are the set/reset type and so there will be no action here.

The last branch... PB is TRUE, so WAS is Turned ON (it already is ON).

End of Rung / End of Scan-2

Several scans later, ya finally get yer big fat finger off of the button...

tick...
tock...
tick...
tock...

SCAN X + 2000 : (you seem to have a heavy finger)
Current Conditions:
  • PB is OFF (finally!)
  • Was is ON
  • Flip is OFF
  • Light is ON

The PB contact is FALSE. This means that any outputs on the rung will fall to their "default" conditions... if they have one.

Since WAS is the only output that has a "default" condition, WAS is turned OFF.

tick...
tock...
tick...
tock...
tick...
tock...
tick...
tock...

SCAN X + 10,000,000 : (Hey, Where ya been?)

Current Conditions:
  • PB is ON
  • Was is OFF
  • Flip is OFF
  • Light is ON

The PB contact is TRUE again. This means that the entire rung will be examined and manipulated as required.

Since this is the first scan (after your long... lunch-break?) that the PB is ON, then the PB was OFF on the previous scan, therefore WAS is still OFF as a result of the last scan.

Starting again at the top-left...

PB is TRUE and NOT-WAS is TRUE, therefore, FLIP is SET

Moving down to the next branch, FLIP is TRUE and NOT-LIGHT is FALSE (it was turned On the last time you pressed the button), therefore, this branch does not have a Path-of-Trues and no actions occur on the set/reset type outputs.

Moving down to the next branch, FLIP is TRUE and LIGHT is TRUE, therefore, RESET LIGHT and RESET FLIP.

The Light that was ON is now OFF.

The last branch... PB is TRUE, so WAS is Turned ON.

End of Rung / End of Scan-10,000,000

tick...
tock...

SCAN X + 10,000,500 : (say... you're gettin' a little quicker!)

Current Conditions:
  • PB is OFF
  • Was is ON
  • Flip is OFF
  • Light is OFF

The PB contact is FALSE. This means that any outputs on the rung will fall to their "default" conditions... if they have one.

Since WAS is the only output that has a "default" condition, WAS is turned OFF.

End of Rung / End of Scan X + 10,000,500

Again, this doesn't work on all PLC's. As far as having an "edge-detector", that's what the WAS is all about.
 
Try this version of the Flip-Flop. The Output will Flip-Flop On with one push of the button then Off with the next push of the same button.
This runs fine on Allen Bradley PLC's.
 
KISS principle
Can do with 3 rungs of code, not 2
Counter or Latch/Unlatch (Set/Reset) will suffice only the instruction would be changed but with same result, as a task write down on a piece of paper the "Booleen expression" or change of states of the inputs and outputs and you will find it can only be done with 3 rungs.

Two ways I have written this code is (Depending on length of program)
is:
PB
-[ ]-----[OSR]---[Work bit]-----------------------{INT}
PB
-[ ]-----[OSR]---NOT[Work bit]---NOT[INT]----Latch{Work bit}

-[INT]-------------------------------------UnLatch{Work bit}

or

PB
-[ ]-----NOT[INT_2]---[Work bit]------------------{INT_1}--

PB
-[ ]-----NOT[INT_2]-------NOT[INT_1]--------------{Work bit}
!
!
--[Work bit]----------

PB
-[ ]----------------------------------------------{INT_2}

If still in disbelief look through the archives and this question has arisen before.
 
--] [--+--]/[--+--] [---( ) flip
pb I was I Light
I +--------(S) Light
I I
I +--] [---(R) Light
I flip
+----------------( ) was

Scanning 1'st from left to right and then down and
from left to right again etc.. must work in any plc ?
'Pb' and not 'was' is as 'natural' one shot.
 

Similar Topics

Hello, I am currently trying to control a motor in my plc. I've made a simple on/off button logic. And it works pretty well, when i press the...
Replies
25
Views
5,891
Hello, I have 2 screens that I can call up from the PLC. The reason I am calling them from the PLC is the customer wants to touch a button to...
Replies
3
Views
2,999
FactoryTalk View ME running on PanelView Plus 7, connected to Compact GuardLogix 5380 PLC Customer is asking for a physical push button to be...
Replies
6
Views
169
Hi everyone Is it possible to change a button image in FactoryTalk View SE (v13.00) using VBA?
Replies
0
Views
69
I was looking for this function, so that i doesn´t need to do it in the PLC. If there are an alarm in the alarm list, i want to flash the...
Replies
2
Views
424
Back
Top Bottom