Latching circuit problem

Discussion in 'The Projects Forum' started by gibby_z, Aug 19, 2009.

  1. gibby_z

    Thread Starter Member

    Aug 19, 2009
    20
    0
    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
     
  2. CDRIVE

    Senior Member

    Jul 1, 2008
    2,223
    99
    Welcome to the forum gibby.

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

    Thread Starter Member

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

    Here is the toggle circuit I started with.
    [​IMG]

    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
     
  4. CDRIVE

    Senior Member

    Jul 1, 2008
    2,223
    99
    Why are there two push button (N/O) switches in parallel and where is the Piezo you mentioned?
     
  5. gibby_z

    Thread Starter Member

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

    Senior Member

    Jul 1, 2008
    2,223
    99
    Are you saying that your Piezo Pressure Switches are used in place of those push button switches?
     
  7. gibby_z

    Thread Starter Member

    Aug 19, 2009
    20
    0
    Correct the piezo switch replaces both momentary contacts represented in the diagram.
     
  8. CDRIVE

    Senior Member

    Jul 1, 2008
    2,223
    99
    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: Aug 20, 2009
  9. gibby_z

    Thread Starter Member

    Aug 19, 2009
    20
    0
    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?
     
  10. CDRIVE

    Senior Member

    Jul 1, 2008
    2,223
    99
    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?
     
  11. gibby_z

    Thread Starter Member

    Aug 19, 2009
    20
    0
    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: Aug 26, 2009
  12. CDRIVE

    Senior Member

    Jul 1, 2008
    2,223
    99
    Yes, a 555 or a Picaxe 08M Microcontroller could do that for you.
     
  13. CDRIVE

    Senior Member

    Jul 1, 2008
    2,223
    99
    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.
     
  14. gibby_z

    Thread Starter Member

    Aug 19, 2009
    20
    0
    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: Aug 27, 2009
  15. CDRIVE

    Senior Member

    Jul 1, 2008
    2,223
    99
    I'm assuming that this is pseudo code, as I don't recognize it as Picaxe Basic. Did you download the interpreter?
     
  16. gibby_z

    Thread Starter Member

    Aug 19, 2009
    20
    0
    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.
     
  17. CDRIVE

    Senior Member

    Jul 1, 2008
    2,223
    99
    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.
     
  18. gibby_z

    Thread Starter Member

    Aug 19, 2009
    20
    0
    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: Aug 28, 2009
  19. CDRIVE

    Senior Member

    Jul 1, 2008
    2,223
    99
    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.

    Code ( (Unknown Language)):
    1.  
    2. ' Project: Debounce.Bas  Chipset: Picaxe 08M  Author: CDRIVE  Date: 08/29/09
    3. ' Function: Discriminate between false closure and legitimate closure of Piezo Switch.
    4. ' Post URL: [URL]http://forum.allaboutcircuits.com/newreply.php?do=postreply&t=26840[/URL]
    5. SwitchPin2Hi:
    6.  
    7.  For b0=1 To 100
    8.     If Pin1=1 And Pin2=1 Then     'If Output is Hi check to see if Piezo is pressed
    9.       GoTo SwitchPin2Lo
    10.     ElseIF Pin1=1 And Pin2=0 Then    'Check Piezo switch for closure every 10mS for 1Sec
    11.       b0=b0+1
    12.       Pause 10
    13.  Next
    14.      End IF
    15.    If b0>99 Then
    16.          High 2         'If Piezo is closed for >1sec then switch (Pin2) Output High.
    17.            b1=1
    18.         End If
    19. GoTo SwitchPin2Hi
    20.  
    21. SwitchPin2Lo:              
    22.  
    23.   For b0=1 To 100
    24.     If Pin1=1 Then       'Check Piezo switch for closure every 10mS for 1Sec
    25.       b0=b0+1
    26.       Pause 10
    27.  Next
    28.      End IF
    29.    If b0>99 Then
    30.          Low 2          'If Piezo is closed for >1sec then switch (Pin2) Output Low.
    31.            b1=1        
    32.         End If
    33. GoTo SwitchPin2Hi  
    34.  
    35.  
    Good luck! ;)
     
    Last edited: Aug 29, 2009
  20. gibby_z

    Thread Starter Member

    Aug 19, 2009
    20
    0
    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?

    [​IMG]
     
Loading...