Latching circuit problem

Thread Starter

gibby_z

Joined Aug 19, 2009
20
Im using a piezo switch to activate a simple single transistor latching circuit that locks in a mosfet and Im having a bouncing problem of sorts. Pressing the switch fires corectly and activates or deactivates the mosfet as intended but if the piezo is subjected to vibration or bumps over time the circuit will reverse its state. What I'm guessing is the problem is that vibrations are charging the cap in small busts that lead up to the circuit opening or closing.

It my searches it seems that a 555 circuit might be the answer.
Can anybody point me in the right direction as to what may help aleaviate this problem? If there is not a circuit that already takes care of this I thought that if a one shot circuit that discharged the cap when when the button is not depressed would make it work. The one shot could send the clean signal to the latching circuit. Am I in the right ballpark?


Thanks
G
 

CDRIVE

Joined Jul 1, 2008
2,219
Welcome to the forum gibby.

Posting your schematic will always be helpful for others when evaluating your issues.. ;)
 

Thread Starter

gibby_z

Joined Aug 19, 2009
20
Hey there and thanks for the welcome.

Here is the toggle circuit I started with.


I guess what I am trying to find is a circuit that requires the momentary switch to be held continuously for a predetermined amount of time before latching.


Thanks
G
 

Thread Starter

gibby_z

Joined Aug 19, 2009
20
It's just a copy of the circuit I modeled it from. They are just demonstrating that it can be controlled from two locations.
 

CDRIVE

Joined Jul 1, 2008
2,219
Correct the piezo switch replaces both momentary contacts represented in the diagram.
Increasing the value of the 1uF cap should slow down the response time of the trigger. Try increasing it.

Edit: Wait, I may have misspoken. Let me look at that circuit a little longer.
Edit2: OK, I was in error. It's the .1uF Base cap that needs to be increased to reduce response time.
 
Last edited:

Thread Starter

gibby_z

Joined Aug 19, 2009
20
For whatever reason when I include the .1 cap the circuit randomly starts with the load latched on. Removing it is ensures that it powers up with the load circuit off. I miss-read what you wrote and put a .07 cap in its place and of course it didn't change anything.

I'll try again by increasing the cap but I think it may still power up with the circuit on.

Is there a 555 circuit configuration that requires the momentary switch to be closed continuously for a determinate amount of time before a pulse is fired or a latching circuit is activated?
 

CDRIVE

Joined Jul 1, 2008
2,219
I should have asked this question a long time ago but here goes.. This Piezo switch that you have.. Is it a piezo or a piezo circuit that actually closes a circuit representing something near zero Ohms?
 

Thread Starter

gibby_z

Joined Aug 19, 2009
20
Here you can see for yourself.

http://www.barantec.com/s5.html

It may be that with the units I have that no matter how long or short the button is activated it fires a .25 sec signal. I talked to them today and they are going to send me the "prolonged activation" unit that fire for as long as the button is pushed. That's why I asked about a circuit that could require the switch to be closed for say 1 sec. continuously before it would latch the circuit. This way a bump or vibration would not cause the circuit to trigger.
 
Last edited:

CDRIVE

Joined Jul 1, 2008
2,219
That's why I asked about a circuit that could require the switch to be closed for say 1 sec. continuously before it would latch the circuit. This way a bump or vibration would not cause the circuit to trigger.
Yes, a 555 or a Picaxe 08M Microcontroller could do that for you.
 

CDRIVE

Joined Jul 1, 2008
2,219
I forgot to ask you what your current requirement is. I ask because an SCR can be used for the latch. A 555 can provide you with the delay but they don't latch. A Picaxe, on the other hand, can do it all.
 

Thread Starter

gibby_z

Joined Aug 19, 2009
20
We are dealing with < 5amps.

I like the picaxe idea!
Just tell the darn circuit what you want to do and when.

I spent the day learning about the picaxe chips and their program structure.
I think the 08M chip will do what I want.

Does this look like a construct that will do what its told.

'pin1 is tied to pin4
'pin1 outputs to pin4 and a mosfet
'pin2 outputs to small indicator led
'momentary switch is tied to pin3
'pin3 detects if momentary switch is on or off
'pin4 detects if pin 1 is high or low


powerup:
pause 5000 'pause to allow power to stabilize

settings:
output 1
output 2
input 4

idle_detect:
if pin3 is on the goto delay
goto idle_detect

delay:
pause 250
if pin3 is off goto idle_detect 'debounce
pause 750
if pin3 is off goto idle_detect 'debounce
if pin4 is on goto getlow
if pin4 is off goto gethigh
goto idle_detect

gethigh:
high 1
high 2
pause 250
goto idle_detect

getlow
low 1
low 2
pause 250
goto idle_detect
 
Last edited:

Thread Starter

gibby_z

Joined Aug 19, 2009
20
That is the construct I got from the manual. I'm waiting for the programmer parts and manual to arrive. I'm sure the software will keep it more correct.
 

CDRIVE

Joined Jul 1, 2008
2,219
That is the construct I got from the manual. I'm waiting for the programmer parts and manual to arrive. I'm sure the software will keep it more correct.
I'm not sure of what you're saying. The Interpreter is downloadable and includes multiple pdf manuals.

This weekend I will test some code for you and post the results. The Interpreter is slick and lets you simulate your code without the chip or any connection to the chip.
 

Thread Starter

gibby_z

Joined Aug 19, 2009
20
I like it and it.
It showed me the error and its cleaned up


'momentary switch is tied to pin3
'pin3 detects if momentary switch is on or off
'pin0 is output to small red "Busy" led
'pin1 is tied to pin4
'pin1 outputs to a mosfet
'pin2 outputs to small indicator led

powerup:
high 0 'turn on the wait light
pause 5000 'pause to allow power to stabilize

settings:
output 1,2
low 0,1,2 'turn off wait light and make sure all others are off

idl_dtct:
if pin3 is on THEN goto dly:'detect if momentary is pushed & go toggle if true
goto idl_dtct

dly:
high 0 'turn on the wait light
pause 250
if pin3 is off THEN goto idl_dtct 'debounce
pause 750
if pin3 is off THEN goto idl_dtct 'debounce
toggle 1,2 'toggle outputs to opposite state
low 0 'turn off the wait light
pause 2000 'give a chance for the button to be released
if pin3 is on THEN goto release_button 'if the bhutton if still on go to the release button wait loop
goto idl_dtct

release_button:
if pin3 is off THEN goto idl_dtct: 'if the button is off go back to the de
high 0: pause 50: low 0 'flash the wait button
goto release_button
 
Last edited:

CDRIVE

Joined Jul 1, 2008
2,219
Ok Gibby, if you're going to write code it's a SOP for programmers to use 'White Space' and 'Indentation'. It will make your code more readable to you and other programmers that read your code. The idea is to make it easier to see procedure blocks like If, Then, ElseIf, Else & End If statements and the entry and exit points of a loop For (code) Next. Straight line code with no white space and no indentation makes the eyes glaze over, especially with complex programs.

You will also note that I capitalize reserved Keywords because it also makes code easier to read. This is a VB convention that's done automatically in VB. Hopefully Picaxe will incorporate the same someday.

I tested this code using the simulator. You may want to play with the Pause values. As you can see, the same Piezo Switch is used to turn on Pin2 and to turn it off.

Keep in mind that your simulator stretches real time so you can view what's happening. The simulation speed is user adjustable in your Options.

(1) Copy and paste the code and run this.
(2) Note the procedure that the program is looping through
(3) Click Pin1 to simulate a Piezo closure.
(4) Click Pin1 again to simulate that is was a false trigger.
Note how b0 resets to 1.
(5) Click Pin1 again and let the counter reach >99. Pin2 will go high & stay High.
(6) Click Pin1 again to simulate an open Piezo switch.
(7) Clicking Pin1 again will cause the program to jump into the SwitchPin2Lo block. If Pin1 remains Hi the second counter will also count up and trigger Pin2 Low when >99.
Note: Since the simulator doesn't provide a momentary switch you must remember to switch Pin1 On or Off after the counters have counted up >99.

Rich (BB code):
' Project: Debounce.Bas  Chipset: Picaxe 08M  Author: CDRIVE  Date: 08/29/09
' Function: Discriminate between false closure and legitimate closure of Piezo Switch.
' Post URL: http://forum.allaboutcircuits.com/newreply.php?do=postreply&t=26840
SwitchPin2Hi:
 
 For b0=1 To 100 
    If Pin1=1 And Pin2=1 Then     'If Output is Hi check to see if Piezo is pressed
      GoTo SwitchPin2Lo
    ElseIF Pin1=1 And Pin2=0 Then    'Check Piezo switch for closure every 10mS for 1Sec 
      b0=b0+1
      Pause 10
 Next
     End IF
   If b0>99 Then
         High 2         'If Piezo is closed for >1sec then switch (Pin2) Output High.
           b1=1
        End If
GoTo SwitchPin2Hi
 
SwitchPin2Lo:              
 
  For b0=1 To 100 
    If Pin1=1 Then       'Check Piezo switch for closure every 10mS for 1Sec
      b0=b0+1
      Pause 10
 Next
     End IF
   If b0>99 Then
         Low 2          'If Piezo is closed for >1sec then switch (Pin2) Output Low.
           b1=1         
        End If
GoTo SwitchPin2Hi
Good luck! ;)
 
Last edited:

Thread Starter

gibby_z

Joined Aug 19, 2009
20
Thanks for your help so far.
Programming the pic is a breeze.

I've run into one last hurdle.
While making the circuit to trigger the mosfet the powers the load I made the attached circuit but its not working right. I think how I have the mosfet attached to the transistors must be wrong. As I goofed around with it im either getting an opposite sate of the mosfet that I intended or the transistors are overloaded and heat up. Either way i'm just trying to get the transistors to trigger the mosfet. What do I need to do to get this done?

 
Top