Thanks (and a challenge)

Allen Nelson

Member
Join Date
Apr 2002
Location
West Chester, PA
Posts
1,368
For those who have mastered the flip-flop (aka: toggle an output with a single pushbutton), I needed a variation on it.

I've got a motorized valve, with separate OPEN and CLOSE outputs, and I wanted to control it with only 2 pushbuttons. It's easy to do if the pushbuttons are programmed "jog" style - Energize the OPEN output while the OPEN_PB is pressed, etc.

But I wanted to do the following:
  • Pressing (and releasing, eventually) the OPEN_PB energizes the OPEN output.
  • Pressing the CLOSE_PB halts the open operation, keeping the valve in place.
  • Pressing the CLOSE_PB starts the valve closing.
  • But if OPEN_PB had been pressed, the valve would have started opening again instead.
    Etc.

I whipped up something pretty quick, but didn't like the look of it - it relied heavily on one-shots. The PB's are on an HMI, and although I convert all HMI commands to one-shots, because of asynchronous scanning, those oneshots are really, what I call, one-and-a-half shots (i.e., they can be on from anywhere from 1 to 2 scans). Normally it doesn't matter, but here it would, and so I'd have to oneshot my "oneshots", which seemed wrong.

So, I brushed up on all the Karnaugh map lessons, and did the code the RIGHT way (if there is such a thing).

So I just want to express my thanks to Terry & the Pirates (- am I dating myself with that allusion?) and to Archie Jacobs (whom I haven't seen around in a while).

I invite others to post their solution (I'm always on the lookout for new code - I'll plagiarize anything worthwhile. Code I've gotten on this site has saved my, -er-, performance review, a number of times.)

If there's interest, I'll post my solution (along with a step-by-step of how I approached it).

Allen
 
Alan,

I would like to confirm (and possibly reword) your sequence:

1) Under any condition, pressing the open PB causes the valve the open. I will assume that 'open' has the highest priority i.e. if both the open and closed PB's are pressed at the same time, the valve always opens.

2) If the valve is opening, then a momentary press of the close PB will cause the valve to stop.

3) If the valve is stopped, then a momentary press of the close PB will cause the valve to close. So two distinct presses of the close PB are required to close the valve.

As an option, I would suggest the following: If the cylinder is stopped by the first initial pressing of the close PB, and this PB is maintained for a brief time delay i.e. 2 seconds, it should trigger the close logic. If the close PB somehow got stuck, the valve can still be opened with the open PB since 'open' overrides 'closed', and the transition of the close PB is required to stop the opening.
 
A few more details

Pressing both buttons at the same time should have the valve do nothing (i.e., stay put.

If anything, CLOSE_PB should override OPEN_PB (since this is a discharge valve (for drum filling), and I'd rather keep product stuck in the vessel than create a mess on the floor.

Again, I'm not too worried about stuck buttons, since the PBs are actually HMI objects, although since the goal is to come up with a general solution, you can/should think of them as hard-wired momentary PBs, with the capablilty of getting stuck. (The state logic I created in solving this DOES take stuck buttons into account).
 
Pressing both buttons at the same time should have the valve do nothing (i.e., stay put.

On the HMI can you actually push both buttons at once?

Here is my experience with panelviews when you have a function key set up as a momentary button.
You press the Function button, say F4, the other function keys do nothing if pressed at the same time.

Is there a setting that you can change to allow simultaneous pushing of buttons on an HMI?
I don't know.
Thanks
George Bradley
 
Here's my quick attempt



OPEN PB ONE SHOT CLOSE PB CLOSE V OPEN V
I:1 B3:0 I:1 O:2 O:2
------| |------[ONS]-------|/|-------|/|--------------( )-----
| 1 | 1 2 2 1
| |
| OPEN V |
| O:2 |
---| |---
1


CLOSE PB ONE SHOT OPEN PB OPEN V CLOSE V
I:1 B3:0 I:1 O:2 O:2
------| |------[ONS]-------|/|-------|/|--------------( )-----
| 2 | 2 1 1 2
| |
| CLOSE V |
| O:2 |
---| |---
2



The only thing I didn't account for (since it wasn't mentioned) were limit switches, etc, that would stop the output when the valve is all the way open or closed.

This is my first code posting, so go easy on me.
 
The "standard" way to do this is with three pushbuttons - Open, Stop, and Close. I'm curious as to why you didn't want to use this logic, since the "buttons" were on an HMI anyway.
 
There needs to be a good 'Dopeslap' smilie

Tom Jenkins said:
The "standard" way to do this is with three pushbuttons - Open, Stop, and Close. I'm curious as to why you didn't want to use this logic, since the "buttons" were on an HMI anyway.

<center><img src="http://www.plctalk.net/qanda/images/smilies/banghead.gif" border="0" alt="D'oh" height=100 width=155></center>

The existing code is so bad, as to be unworkable. I'm rewriting the entire thing from scratch, and redoing the HMI as well. But as there is no functional spec (or rather, there is, but it was written by the same guy who wrote the code), I'm using what he did for guidance. (and so they don't have to re-train the operators).

He only had OPEN and CLOSE (with logic that wouldn't do what it was obviously supposd to), and I got trapped into conventional thinking.

Thanks, Tom. The screen now has 3 buttons.

This is why this excercise is like the Toggle one - it imposes artificial constraints on the programmer.

Anyone in the market for some unused code?
 
List program useing SET/RES

Hi Allen.

You didn't say that it wasn't allowed to use the dangerous SET/RESET (latch/unlatch) commands....

This is how I would have programmed the task:
(This ASCII file can be assembled and downloaded to my favourite brand...)

Code:
Open_PB 	EQU	I 0		;PushButton: Open / Stop Closing
Close_PB	EQU	I 1		;PushButton: Close / Stop Opening
open		EQU	O 10		;Output: Open coil
close		EQU	O 11		;Output: Close coil
OpenEdge	EQU	F 0		;Internal bit: Oneshot of Open_PB
CloseEdge	EQU	F 1		;Internal bit: Oneshot of Close_PB
StartHr 	EQU	F 10		;Internal bit: Hr
StopHr		EQU	F 11		;Internal bit: Hr
Hr		EQU	F 15		;Internal bit: Hr
Maintask	EQU	COB 0		;Main program
;; 
;
	COB	Maintask
		0
;
; Edge detect Start_PB:
; (Can be replaced with a PLC specific Edge-instruction)
	STH	Open_PB
	OUT	Hr
;
	STH	Hr
	ANL	StartHr
	OUT	OpenEdge
;
	STH	Hr
	OUT	StartHr
;
; Edge detect Stop_PB:
	STH	Close_PB
	OUT	Hr
;
	STH	Hr
	ANL	StopHr
	OUT	CloseEdge
;
	STH	Hr
	OUT	StopHr
;
;----------------------------
;
; StartPB: Open
	STH	OpenEdge
	ANL	StopHr
	ANL	close
	SET	open
; StartPB: Stop Closing
	STH	OpenEdge
	ANH	close
	RES	close
;
; StopPB: Close
	STH	CloseEdge
	ANL	open
	SET	close
; StopPB: Stop Opening
	STH	CloseEdge
	ANH	open
	RES	open
;
	ECOB


BTW
GBradley: With Proface touchscreens you can push 2 buttons simultaneous. Ideal for safety, interlocks etc
 
I was curious about the reason for 2 buttons too but was trying to see if I could create the code for it, easier with 3 buttons though.

Vetteboy, a reminder: The ONS instruction is an input instruction that makes the rung true for one program scan upon a false-to-true transition of the conditions preceding the ONS instruction on the rung.

Therefore your holding circuit wont work.

One of the rules pertaining to ONS is that you cant branch around it either.
 
Oh, so it isn't a classroom exercise. :p

Regarding my comment about priority of opening vs closing, I was thinking in terms of a garage door. Down is considered hazardous, up is considered safe. I didn't consider what the valve was actually controlling so in that respect closing would probably have a higher priority than opening
 
Allen Wrote:
I brushed up on all the Karnaugh map lessons

Is that the new in-dash navigation system :p
Note: Karnaugh is pronounced "CAR-KNOW"

Another useful thing from EECS 101 class is D'Morgans Theorems:

NOT(A AND B) = (NOT A) OR (NOT B)
NOT(A OR B) = (NOT A) AND (NOT B)
 
Greg Gauper:

You're right! This IS the garage door problem. I hadn't seen it that way.

Hmmm. It's still a few weeks before midterms, where the traffic light/garage door/elevator/car wash are usually assigned.

Maybe if a student asks real nicely, I'll show how to generate one of the 4 rungs of logic that my solution took. (The other three would be generated using the same technique, but would be a good exercise for the student).
 
I've posted a couple questions in the near past so here's my crack at an answer.

As I understand it, the task is that when the valve is opening, the close PB will first act like a stop pb (until released) then pressing close again will close the valve. And the opposite would be true for the opening.

Here's my unverified answer:

/* Pressing the Open PB when the Close valve is on */
/* Latches up the Stop Close internal until the */
/* PB is released */

Close Valve Stop Close &
Open PB OUTPUT Disable Open
-----] [---+----] [-----+--------( )--
| |
| Stop Close |
| Disab. Open|
+----] [-----+

/* Pressing the Close PB when the Close valve is on */
/* Latches up the Stop Open internal until the */
/* PB is released */

Open Valve Stop Open &
Close PB OUTPUT Disable Close
-----] [---+----] [-----+--------( )--
| |
| Stop Open |
|Disab. Close|
+----] [-----+


Stop Open & Stop Close & Close Valve Open Valve
Open PB Disable Close Disable Open Output Output
-----] [---+----]/[-------------]/[-----------]/[----------( )--
|
Open Valve |
Output |
-----] [---+



Stop Open & Stop Close & Open Valve Close Valve
Close PB Disable Close Disable Open Output Output
-----] [----+----]/[-------------]/[----------]/[-----------( )--
|
Close Valve |
Output |
-----] [----+



Hope that was readable. In Netscape 6.2.3 there are spaces between every line for some reason :unsure: and makes it darn hard to get things to line up.
 
Looks good

Looks good, Norm.

Take a look at how Terry and I solved it HERE

(I also get doublespacing effect using IE 4.0, but not in IE 5. I usually create ladder in Notepad and paste it in. It's especially useful when you've got a long rung and it tries to wrap in the Reply window.)

I guess that's why so many post using RSLogix screen captures. But you can only get one attachment per post (unless, like Terry, you cheat).
 
Cheat??? CHEAT??? I DON'T CHEAT !!!

I STAY COMPLETELY WITHIN THE CONFINES SPECIFIED BY THOSE TAX LAWS !!!
(Al Capone, 1920-something)

BTW, there still seems to be a problem with text immediately following a non-text section. We still end up with text running off the right side of the screen. Sometimes it just ends (truncated) at the right side.

If, when I PREVIEW, I see this problem, I place a dummy-character (such as a period) on the first line following the non-text thing and then "Return".

NON-TEXT (including ladder?)
. <--- Dummy Character followed by "Return"
begin new text here.
 

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
Just wanted to throw a big thank you to everyone who contributes to this site. The information here has helped me so many times and is much easier...
Replies
4
Views
2,031
Ive been a member here for quite sometime and i think i never thanked this community. Phil, youre doing a wonderful job administrating this site...
Replies
1
Views
1,698
Realised today I'm about to clock up 1000 posts, and just thought I should take the opportunity to thank everyone here for sharing the knowledge...
Replies
10
Views
3,619
Wanted to throw a big thank you out to Lancie1 for all of the direct and indirect help offered to myself and others here. 10,000 posts is a lot of...
Replies
16
Views
5,110
Back
Top Bottom