Electrical Issue: PIC input false triggering, Signal Noise suspected.


Results 1 to 36 of 36

Threaded View

  1. #20
    Join Date
    May 2013
    Location
    australia
    Posts
    2,644


    Did you find this post helpful? Yes | No

    Default Re: Electrical Issue: PIC input false triggering, Signal Noise suspected.

    I discovered this curious method of debounce/noise filtering on the arduino forum this week . the idea translated to pbp easily and makes my worst cheap and nasty tactile switches perform as smooth as silk.
    here is a little demo (might add there is no cap used at all on the switch )

    Code:
    '****************************************************************
    '*  Name    : debounce.BAS                                      *
    '*  Author  : richard                   *
    '*  Date    : 2/17/2016                                         *
    '*  Version : 1.0                                               *
    '*  Notes   :  pic16f1825                                       *
    '*          :   switch debounce                                 *
    '****************************************************************
    #CONFIG
                 __config        _CONFIG1,    _FOSC_INTOSC & _CP_OFF & _WDTE_ON  &  _PWRTE_ON  &  _MCLRE_OFF  & _CLKOUTEN_OFF
                  __config      _CONFIG2, _PLLEN_ON & _LVP_OFF            
    #ENDCONFIG
     
    OSCCON=$70 
    DEFINE OSC 32
    ANSELA=0
    ANSELC=0
    TRISA = %011010
    TRISC = 0 
     
     
    led1 var lata.5    ;  lit when  sw operated
    led2 var lata.2    ; toggle when sw   operated
    sw var porta.3     ;  the switch (active low ie has pull up resistor)
    old_sw_state var bit
    sw_state var bit
    sw_buff  var byte
    clear
    
    main :
        gosub ck_sw
        if  sw_state != old_sw_state then   ; the sw has changed either on or off
            led2 = !led2
            if !sw_state then led1 = !led1      ; if state is changed to on
            old_sw_state=sw_state            ;remember state
        endif
    goto main
    
    ck_sw:
        sw_buff= (sw_buff<<1) | sw
        if (sw_buff=$7f ) and sw then
           sw_state=1
        elseif  (sw_buff=$80 )and !sw  then
                sw_state=0
        endif
    return
    Last edited by richard; - 17th February 2016 at 02:33. Reason: no capacitor used

Similar Threads

  1. Intermittent reset of 16C6440 - possible noise issue
    By Christopher4187 in forum General
    Replies: 4
    Last Post: - 16th May 2012, 12:43
  2. Noise on input signal
    By fanman in forum mel PIC BASIC Pro
    Replies: 17
    Last Post: - 28th February 2012, 02:55
  3. Electrical noise problem with PIC 16f84
    By Snap in forum General
    Replies: 11
    Last Post: - 26th September 2007, 09:36
  4. Input Noise
    By PJALM in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 28th February 2006, 19:26
  5. False Triggering I/O
    By pdegior in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 17th July 2005, 09:02

Members who have read this thread : 0

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts