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


Closed Thread
Results 1 to 36 of 36

Hybrid View

  1. #1
    Join Date
    Jun 2015
    Posts
    18


    Did you find this post helpful? Yes | No

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

    No offense taken.

    Nobody has ever accused ME of being a genius but my tenacity has lead me to many learning opportunities.

    I will try several of the strategies offered by the contributors and hopefully if the problem gets resolved soon, I will report back.

  2. #2
    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

  3. #3
    Join Date
    Jun 2015
    Posts
    18


    Did you find this post helpful? Yes | No

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

    Hi Richard,

    This a very interesting strategy and I have added it to my collection of code snippets.

    On this project my approach is to try the hardware methods first since they (like ground shielding the signal line, etc.) are just good practice anyway. If that doesn't do the trick I will try some of the software solutions. I hope this method will be a way to somewhat isolate the cause of the false triggering or at least give an idea what might be going on.

    This project has even forced me to get out my really old and clunky oscilloscope and get some new probes for it. Now I just have to figure out how to set it up to check for noise on the signal line. I'm a bit rusty on using the scope for diagnostics. It's been quite a while since my last class in EE.

    Thanks for your thoughts,
    Allan

  4. #4


    Did you find this post helpful? Yes | No

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

    There are a lot of good suggestions here. One possible cause could be a magnetic field being set up by current passing through the rails.
    This could be causing the reed switches to randomly close. Or magnetic coupling into the long leads. Google "Right Hand Rule"

    It would be easy to test. Leave everything connected as is, but move the reed switches a few inches away from the tracks.

    Hope you figure it out

  5. #5
    Join Date
    Oct 2009
    Location
    Utah, USA
    Posts
    427


    Did you find this post helpful? Yes | No

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

    @mark_s
    I would add that moving the reed switches a few inches away but leaving all the wiring as is would likely cause the reed switches to stop functioning but that is OK as it would allow you to determine if mark_s's theory holds true.

    If you still have false trigering then it was because of either the magnetic coupling or possibly vibration.

    At least that is what it seems you were getting at with your suggestion (or am I missing your point Mark?)

    @richard

    Here is how I devised a software debounce that would not block the rest of my main code loop
    Code:
    Main:
    if swflag = 1 and sw1=open then swflg = 0  '(sw debounce) clear swflg only when switch released
       
    if swflag = 0 and sw1=closed then   'sw1 button detected and valid
            swflag = 1      'set flag that switch has been closed
            (code goes here that you wanted the switch to do)
    endif
    
    (more main code loop goes here)
    GOTO Main
    it requires the swflag = 0 before it will acknowledge the sw1 is pressed. Other wise the switch will be ignored.
    the only way for swflag to return to 0 is for you to release sw1
    Last edited by Heckler; - 21st February 2016 at 01:54.
    Dwight
    These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.

  6. #6


    Did you find this post helpful? Yes | No

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

    Quote Originally Posted by Heckler View Post
    @mark_s
    I would add that moving the reed switches a few inches away but leaving all the wiring as is would likely cause the reed switches to stop functioning but that is OK as it would allow you to determine if mark_s's theory holds true.

    If you still have false trigering then it was because of either the magnetic coupling or possibly vibration.

    At least that is what it seems you were getting at with your suggestion (or am I missing your point Mark?)
    Dwight,

    Yes, just move the reeds temporary to see if they are triggering. If that is causing the problem, maybe just by rotating the reeds 90 degrees would solve the problem? Abecker made two statements that are key - "It worked superbly on the bench" and installed with the reeds disconnected, it quit triggering. So it's probably interference entering the cable or the reeds closing?

    Abecker should take note when it is triggering. On acceleration the motor will be drawing the most current. On deceleration it could be generating inductive spikes back into the power supply. Does it false when the train is not moving?

    Brings back memories, my dad had a large H0 gauge train table when I was a kid. We couldn't wait for him to get home from work
    so we could run it.

  7. #7
    Join Date
    Jun 2015
    Posts
    18


    Did you find this post helpful? Yes | No

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

    Mark,

    I'll address the second remark in this reply. The first time I discovered the problem (and it did occur consistently) I would have to say there is no acceleration or deceleration possible because the speed control is set and remains at a preset DC voltage (I have no means of attenuating the speed control, electrically or mechanically.) Knowing this I suppose it is safe to conclude that there is a considerable inrush of current when the control relay closes.

    As I recall from the first real run the PIC firmware closed the "Run" relay contacts and the trolley moved a few inches in the correct direction. Then operation jumped to the next logical state which was sensing the trolley position and stopping at the station. The only problem being, it was not near enough to the reed switch to activate it using the magnet below the car.

    You ask a very good diagnostic question which I have not tried yet. I should test for false triggering without the trolley (dc motor) running but voltage applied to the track and overhead wire. This should rule out any influence of those objects. Lately I have been asking myself the uncomfortable question as to whether I have been wrongly suspecting DC motor EMI of causing the problem. This test would help eliminate the transmission sources from the cause.

    I hope my work later today will shed more light. Thanks for your insights.

  8. #8
    Join Date
    Jun 2015
    Posts
    18


    Did you find this post helpful? Yes | No

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

    Hello Mark,

    I have invested some time in running the long signal leads in shielded cable and grounding it and everything I can think of to the earth ground of my 110vAC power cord. The main control board being in a plastic enclosure also now has a ground strap to the same ground. If I don't get positive results from this and other remedies offered here my last recourse is to fabricate a steel enclosure and ground it as well.

    There is one construction hitch to moving the reed switches (although I agree it would be a sensible test) in that the two lead wires run down through holes in the table. I would have to fasten some type of disconnect there to make them removable. I soldered the leads to the grounded cable with the shortest possible length to reduce the chance for EMI pickup. I try to avoid many connectors for I feel each one is a potential weak point.

    Later today I will have everything wired and ready to test except the adding of inductors since they are still on their way from Mouser.

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