Author Topic: Alternating relays momentary closure  (Read 4195 times)

0 Members and 1 Guest are viewing this topic.

Offline LKO RailroadTopic starter

  • Contributor
  • Posts: 41
  • Country: us
Alternating relays momentary closure
« on: March 11, 2017, 09:40:09 pm »
I have an application where a twin coil (15V 2A) latching solenoid needs to be controlled with a single momentary switch. Press once to move the solenoid left, press again to move the solenoid right. The solenoid coils must be pulsed, they are not suitable for continuous duty.

Here is what I have come up with. A flip flop connected to edge triggered non-retriggerable monostables. Pressing the switch causes relay #1 to close for a brief period and then open. Pressing the switch again causes relay #2 to close for a brief period and then open.

Before I breadboard this I kindly ask your opinion. Think it will work?
 

Offline Benta

  • Super Contributor
  • ***
  • Posts: 7176
  • Country: de
Re: Alternating relays momentary closure
« Reply #1 on: March 11, 2017, 10:19:10 pm »
Quote
Think it will work?

No.
First of all, your 4013 as you've drawn it won't toggle. But there are lots more problems.

The biggest issue you have is debouncing your pushbutton. The simplest way of doing this is if your switch has a double-throw function. In that case, feed the NO resp. the NC to a Set/Reset FF (your 4013 is fine for this).

After this, you can feed the FF output to a toggle-FF (4013) and then to your MMVs.

Personally, I don't like the approach.
I'd prefer to have the toggle-FF controlling the output, thus being 100% certain that simultaneous triggering of your coils is out of the question.
Each toggle-FF output is gated with a pulse from an MMV clocked simultaneously with the toggle-FF.
Saves you one MMV, but costs you a couple of gates.

But the first thing to think about is switch debouncing.
« Last Edit: March 11, 2017, 10:25:29 pm by Benta »
 

Offline LKO RailroadTopic starter

  • Contributor
  • Posts: 41
  • Country: us
Re: Alternating relays momentary closure
« Reply #2 on: March 11, 2017, 10:31:11 pm »
Quote
debouncing your pushbutton

I don't understand. The cap, resistor pair, and diode are my switch debouncing. Is there something wrong with this debounce approach?
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 14127
Re: Alternating relays momentary closure
« Reply #3 on: March 11, 2017, 10:45:15 pm »
I also agree the input debouncing looks extremely sucky and that your toggle circuit is borked (needs feedback from /Q to D).
I don't understand. The cap, resistor pair, and diode are my switch debouncing. Is there something wrong with this debounce approach?
That's not a debouncer, its a pulse shortener, with a time constant of 1ms. It will still slam the input with any keydown bounces significantly shorter than 1ms and any keyup bounces longer than 1ms.

If possible, I'd use the other half of the CD4013's S and R inputs to implement a fully debounced pushbutton using a  momentary SPDT switch in the classic circuit (S and R connected to the fixed contacts, with pulldpwn resistors, moving contact connected to Vcc) then feed its  output to the other CD4013's CLK input.  That will prevent the flipflop toggling more than once per push.  There are other ways of skinning this cat without a SPDT button - but few good ones.  You could probably use the spare CD4013 as a buffer, input to S, with R held high, output from Q,  then add an input resistor and a 10x higher feedback resistor to make a Schmitt trigger, and put a RC debouncing network in front of that.

I'd also interlock the CD4538 monostables by driving each RST input from the /Q of the other half - when one triggers, it prevents the other triggering for the pulse duration so the solenoid doen't get competing drives if the lUser frobs the button.
« Last Edit: March 12, 2017, 05:03:11 am by Ian.M »
 

Offline Benta

  • Super Contributor
  • ***
  • Posts: 7176
  • Country: de
Re: Alternating relays momentary closure
« Reply #4 on: March 11, 2017, 11:22:13 pm »
Actually, if the pushbutton is only an SPST, there is another option.

Using a level-triggered MMV for debouncing. A simple Schmitt trigger gate will do this.

Switch to ground with 10k pullup, just like in your schematic.
From there, an RC lowpass, then into a 4093 Schmitt-trigger gate. For the RC, I'd aim for a time-constant of 10 ms or higher (depends on the quality of your switch), say 470k and 22 nF.

Now you should have a clean "button on/off" signal.

Use the output of the 4093 to trigger your 4538 MMV, and to clock your 4013 toggle-FF

Gate the two outputs of your 4013 toggle-FF with the output of the 4538 MMV (using two spare 4093 gates) and it's done!

The logic outputs will be active low, so use PNP transistors to drive your relays instead.

« Last Edit: March 11, 2017, 11:36:25 pm by Benta »
 

Offline tpowell1830

  • Frequent Contributor
  • **
  • Posts: 863
  • Country: us
  • Peacefully retired from industry, active in life
Re: Alternating relays momentary closure
« Reply #5 on: March 12, 2017, 02:37:48 am »
I know this is not your question, but why not use a SPDT momentary (ON-OFF-ON) toggle switch?
PEACE===>T
 

Offline LKO RailroadTopic starter

  • Contributor
  • Posts: 41
  • Country: us
Re: Alternating relays momentary closure
« Reply #6 on: March 12, 2017, 03:53:03 am »
Quote
That's not a debouncer, its a pulse shortener,

Pulse shortener, yes. I thought it would provide a single short pulse regardless of how long the user presses the switch. I mistakenly thought it would also debounce. I'll change it.

Quote
Using a level-triggered MMV for debouncing. A simple Schmitt trigger gate will do this.
Quote
but why not use a SPDT momentary (ON-OFF-ON) toggle switch?

A SPST push button switch is desired to permit multiple switch locations with minimum interconnecting wiring.

I'll work on the schematic and post a revised version. Thanks to everyone for the comments. It would be so much easier if I actually knew what I am doing.  :-//
 

Offline Seekonk

  • Super Contributor
  • ***
  • Posts: 2149
  • Country: us
Re: Alternating relays momentary closure
« Reply #7 on: March 12, 2017, 12:58:42 pm »
I've become very lazy.  This is the kind of thing I like to do with a $2.50 NANO.  Adding a couple transistors and you are done.  Count the number of loops the switch is pressed.  When it reaches X number, you transition a relay. If it detects the switch unpressed, reset the counter.  Easy to make it ignore any brushing against the button trips. A good 1 second or more could be required.   Multiple buttons can use the same micro.  I've done some neat animation with these using the RANDOM function to make flaming lights and operate things periodically in totally random pattern. Once you have done it you will never go back.
 

Offline LKO RailroadTopic starter

  • Contributor
  • Posts: 41
  • Country: us
Re: Alternating relays momentary closure
« Reply #8 on: March 12, 2017, 04:33:31 pm »
The same type push button switch is used many times on existing panels to control other things. There is a desire to have all switches on the panels be identical, hence the SPST push button.

Here is my revised circuit. Hopefully I now have a FF that actually flips and flops along with switch debouncing. Am I getting closer?

 

Offline LKO RailroadTopic starter

  • Contributor
  • Posts: 41
  • Country: us
Re: Alternating relays momentary closure
« Reply #9 on: March 12, 2017, 04:37:58 pm »
For some context, here is an example existing panel.

Thank you again for your assistance.
 

Offline Benta

  • Super Contributor
  • ***
  • Posts: 7176
  • Country: de
Re: Alternating relays momentary closure
« Reply #10 on: March 12, 2017, 05:28:32 pm »
Looking at your photo, I'd like to know a bit about the switches. Do they have snap action? I mean a click that you really feel in both directions.
Or are they just spring loaded?

Yes, your FF will flip and flop now. But your debounce is still strange. Keep in mind that you need to debounce both press and release. And release is often the worst.

 

Offline LKO RailroadTopic starter

  • Contributor
  • Posts: 41
  • Country: us
Re: Alternating relays momentary closure
« Reply #11 on: March 12, 2017, 05:37:27 pm »
Quote
Do they have snap action? I mean a click that you really feel in both directions. Or are they just spring loaded?

Cheapie spring loaded.

Can you please elaborate on why my debouncing is strange? Pg4 http://www.eng.utah.edu/~cs5780/debouncing.pdf Did I do the math wrong?
 

Offline Benta

  • Super Contributor
  • ***
  • Posts: 7176
  • Country: de
Re: Alternating relays momentary closure
« Reply #12 on: March 12, 2017, 07:08:38 pm »
"Can you please elaborate on why my debouncing is strange?"

Just use the RC debounce on p12 like I wrote in my earlier post. Don't understand why you insist on including unnecessary diodes.

The maths in the note is wonky and over-analysed. It's not rocket science.

Regard the switch and R1 as one circuit, simply switching towards ground (switch) or towards plus (R1).

From there you connect your RC. Select R2 to be >10x larger than R1 and calculate C from there. Target a time constant of around 10 ms.
Using a 4093 Schmitt trigger gate will work, bias currents are negligible unless you move into the megaohm range.

 

Offline LKO RailroadTopic starter

  • Contributor
  • Posts: 41
  • Country: us
Re: Alternating relays momentary closure
« Reply #13 on: March 12, 2017, 07:48:45 pm »
Quote
Don't understand why you insist on including unnecessary diodes.

I bought 100,000 of them on Alibaba. Just kidding :-DD  I understood it to be the diode causes the cap to charge faster when the switch is released. The faster charge not needed?

Quote
Select R2 to be >10x larger than R1

I have it backwards as drawn?

Using the 100k & 10k (reversed) then my cap should be 0.1uF = 0.01 sec?
 

Offline Benta

  • Super Contributor
  • ***
  • Posts: 7176
  • Country: de
Re: Alternating relays momentary closure
« Reply #14 on: March 12, 2017, 08:27:42 pm »
No, the faster charge is not needed and even unwanted.

With R1 = 10k, R2 = 100k and C = 100n you have:

Time constant when switch closes: R2 * C = 10 ms
Time constant when switch opens: (R1 + R2) * C = 11 ms

This is fine. Test it with the 4093 and the 4027. If you get stable changeovers on the 4027 outputs, go with it. If you still have unpredictable behaviour of the 4027, increase R2 to 220k. Play around with it, but you're in ballpark now.

It's all really uncritical, don't break out 10-digit precision here.

 

Offline LKO RailroadTopic starter

  • Contributor
  • Posts: 41
  • Country: us
Re: Alternating relays momentary closure
« Reply #15 on: March 12, 2017, 08:52:54 pm »
Thank you.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

-->