Push button detection through a very long wire

ronv

Joined Nov 12, 2008
3,770
Just did... but now I'm getting the following error:



It seems that VDD belongs to the schmidt gate:

Sorry, Poor instructions. :(
The thing that's neat about this set is that you can hook them up to your supply, be it 5, 10 or 15 volts. The requirement is that you add a label to the supply you want to hook it to named Vdd. So if your power supply for the circuit is 12 volts add a label to the 12 volts calling it Vdd.
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,218
For some reason it was set to DC operating point.
Go to edit spice analysis and set it to transient.
Then adjust the switch voltage so it will switch.
Just made it work! thanks!
It wasn't only that, but the switch was connected with the wrong polarity.
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,218
For some reason it was set to DC operating point.
Go to edit spice analysis and set it to transient.
Then adjust the switch voltage so it will switch.
Alrighty... here's your circuit finally working the way I like it, and I've simmed it along with Joey's design... with my abominable cap added, but this time connected to ground.
Your circuit is of the normally closed push-button type, and Joey's normally open.

Capture.JPG


IMHO, I can't help but observe that your circuit has 7 components (some of which are a little unusual), while Joey's components are only four (plus my cap), and they're all of the common vanilla variety.

Nevertheless, I plan to test both circuits... and will do so while a friend of mine is welding something close to the buttons... see how it goes.

My many thanks to everyone who tried to help me out in this thread.
 

Attachments

joeyd999

Joined Jun 6, 2011
5,234
IMHO, I can't help but observe that your circuit has 7 components (some of which are a little unusual), while Joey's components are only four (plus my cap), and they're all of the common vanilla variety.
And, @ronv's circuit requires Vdd to be sent on a lead to outer space. This will cause a significant, possibly catastrophic, fault when the lead someday shorts to the grounded chassis.
 

ronv

Joined Nov 12, 2008
3,770
IMHO, I can't help but observe that your circuit has 7 components (some of which are a little unusual), while Joey's components are only four (plus my cap), and they're all of the common vanilla variety.
I guess I should get some real life models in my Spice library.:rolleyes::D
The main advantage of circuit one over circuit two is the schmitt trigger. The rise time is very slow from the cap so is subject to noise and chatter if it is just driving a standard CMOS gate.
A more modern CMOS IC could/should be subbed for the one I showed. The CD4000 family is slow so is good for noise, but is a bit more sensitive to latch up. I like schottky diodes as clamps, but with the 470 ohm in series with the gate 1N914s would be ok.
Notice in circuit 2 the transistor could be replaced with another diode if you reverse the switch. The transistor doesn't really do anything except clamp the input.
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,218
Notice in circuit 2 the transistor could be replaced with another diode if you reverse the switch. The transistor doesn't really do anything except clamp the input.
That sounds like an interesting idea... though I don't quite follow.
How exactly could one replace the transistor for a diode?
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,218
Maybe I've been a little stupid here, and have been complicating things too much. The AT89LP4052 already has a schmitt trigger at its inputs:

Capture.JPG

So maybe if I use @ronv 's circuit, omitting the schmitt trigger, things should be alright?
 

ronv

Joined Nov 12, 2008
3,770

Thread Starter

cmartinez

Joined Jan 17, 2007
8,218
Did you say:
Yep, I think so.

because I said:
So maybe if I use @ronv 's circuit, omitting the schmitt trigger, things should be alright?

or because I said :
Maybe I've been a little stupid here
?​

Emoji Smiley-12.png just kidding...

Thank you very much for the link... it's amazing that after all these years I hadn't read something like it before... now I've seen the light! Emoji Objects-57.png ... and BTW, I've already ordered a couple of hundred smt BAT54's to have handy for my future circuits.

thanks again!
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,218
I kind of like this circuit for pushbuttons, it seems to have it all:


External clipping diodes


To eliminate the use of the microcontroller’s internal diodes, external Schottky clipping diodes can be used. This is shown in Figure 11. Schottky diodes are implemented because they conduct before the internal diodes of the microcontroller (Schottky diodes forward bias at about 0.2 V as opposed to the 0.7 V of the internal diodes). Note that a small series resistor is used to protect the Schottky diodes from overcurrent. As these diodes are only on for a short time, a small resistor works well; something on the order of 10 Ω usually works fine. Alternatively, the 10 Ω resistor can be omitted if the Schottky diodes are beefy enough to handle short-duration, high current pulses.

article2012-protecting-inputs-in-digital-fig11.jpg

Figure 11: External clipping diode circuit.

Figure 12 shows the results of this circuit with the input switch circuit. The yellow trace is the positive side of the capacitor, while the green trace is where the resistor meets the Schottky diodes. Note the negative spike is -0.650 V, which is below the forward bias voltage of the microcontroller. A voltage of this level on a well-designed PCB should not cause any problems.

article2012-protecting-inputs-in-digital-fig12.jpg

Figure 12: External diode protection results.

So for the most ruggedized digital input protection, a combination of external resistors, capacitors, and diodes should be used.

And for 12V sensors, the next circuit in the link seems to be perfect, sans the 0.01 µF capacitor.
 

ronv

Joined Nov 12, 2008
3,770
I kind of like this circuit for pushbuttons, it seems to have it all:




And for 12V sensors, the next circuit in the link seems to be perfect, sans the 0.01 µF capacitor.
It's ok if you don't need debounce. But if you want to debounce you need to charge quickly and discharge slowly (or vice versa) so another diode is needed or be careful with the size of the input resistors.
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,218
It's ok if you don't need debounce. But if you want to debounce you need to charge quickly and discharge slowly (or vice versa) so another diode is needed or be careful with the size of the input resistors.
With a sensor I don't think I need to debounce, since practically all of them have an inherent hysteresis at their outputs... unless I want to filter their signals, in which case I guess I'd just have to use a much lower cap value, right?
 

ronv

Joined Nov 12, 2008
3,770
With a sensor I don't think I need to debounce, since practically all of them have an inherent hysteresis at their outputs... unless I want to filter their signals, in which case I guess I'd just have to use a much lower cap value, right?
Hard to say. Most noise pick up is pretty high frequency so the 0.01 is maybe plenty with a 1k resistor. If the noise is at 1 megahertz the cap looks like 15 ohms so not much would get thru to the micro.
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,218
Hard to say. Most noise pick up is pretty high frequency so the 0.01 is maybe plenty with a 1k resistor. If the noise is at 1 megahertz the cap looks like 15 ohms so not much would get thru to the micro.
guess I'm gonna have to experiment and see... thanks!
 
Top