Alternating relays momentary closure - Page 1
Forum section: electronics / projects

author: LKO Railroad
author_rank: Contributor
timestamp: March 11, 2017, 09:40:09 pm
content: 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?

author: Benta
author_rank: Super Contributor
timestamp: March 11, 2017, 10:19:10 pm
content: QuoteNo.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.

author: LKO Railroad
author_rank: Contributor
timestamp: March 11, 2017, 10:31:11 pm
content: QuoteI don't understand. The cap, resistor pair, and diode are my switch debouncing. Is there something wrong with this debounce approach?

author: Ian.M
author_rank: Super Contributor
timestamp: March 11, 2017, 10:45:15 pm
content: I also agree the input debouncing looks extremely sucky and that your toggle circuit is borked (needs feedback from /Q to D).Quote from: LKO Railroad on March 11, 2017, 10:31:11 pmThat'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.

author: Benta
author_rank: Super Contributor
timestamp: March 11, 2017, 11:22:13 pm
content: 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-FFGate 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.

author: tpowell1830
author_rank: Frequent Contributor
timestamp: March 12, 2017, 02:37:48 am
content: I know this is not your question, but why not use a SPDT momentary (ON-OFF-ON) toggle switch?

author: LKO Railroad
author_rank: Contributor
timestamp: March 12, 2017, 03:53:03 am
content: QuotePulse 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.QuoteQuoteA 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.

author: Seekonk
author_rank: Super Contributor
timestamp: March 12, 2017, 12:58:42 pm
content: 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.

author: LKO Railroad
author_rank: Contributor
timestamp: March 12, 2017, 04:33:31 pm
content: 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?

author: LKO Railroad
author_rank: Contributor
timestamp: March 12, 2017, 04:37:58 pm
content: For some context, here is an example existing panel.Thank you again for your assistance.

author: Benta
author_rank: Super Contributor
timestamp: March 12, 2017, 05:28:32 pm
content: 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.

author: LKO Railroad
author_rank: Contributor
timestamp: March 12, 2017, 05:37:27 pm
content: QuoteCheapie spring loaded.Can you please elaborate on why my debouncing is strange? Pg4http://www.eng.utah.edu/~cs5780/debouncing.pdfDid I do the math wrong?

author: Benta
author_rank: Super Contributor
timestamp: March 12, 2017, 07:08:38 pm
content: "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.

author: LKO Railroad
author_rank: Contributor
timestamp: March 12, 2017, 07:48:45 pm
content: QuoteI bought 100,000 of them on Alibaba. Just kiddingI understood it to be the diode causes the cap to charge faster when the switch is released. The faster charge not needed?QuoteI have it backwards as drawn?Using the 100k & 10k (reversed) then my cap should be 0.1uF = 0.01 sec?

author: Benta
author_rank: Super Contributor
timestamp: March 12, 2017, 08:27:42 pm
content: 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 msTime constant when switch opens: (R1 + R2) * C = 11 msThis 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.

author: LKO Railroad
author_rank: Contributor
timestamp: March 12, 2017, 08:52:54 pm
content: Thank you.