PIC16F877A EMI and Noise protection

Discussion in 'The Projects Forum' started by TalkAboutCircuit, Apr 6, 2015.

Please help me check my diagram for any correction? having problem with EMI and Noise

  1. N/A

    2 vote(s)
    50.0%
  2. N/A

    2 vote(s)
    50.0%
  1. TalkAboutCircuit

    Thread Starter New Member

    Apr 6, 2015
    8
    0
    PORT RA0 = 0 and goes high once push button is pressed to extend the cylinder. the problem is sometimes cylinder extend without pressing the push button. Please help me im just a begineer.


    Thanks,
     
  2. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    2,674
    2,724
    Without a schematic or code, I'd have to use my crystal ball.

    And that's at the shop today for repair.

    But I did vote "N/A" in your poll.
     
  3. blueroomelectronics

    AAC Fanatic!

    Jul 22, 2007
    1,758
    98
    I also voted N/A :)

    My crystal ball says, "OP unlikely to clarify"
     
  4. TalkAboutCircuit

    Thread Starter New Member

    Apr 6, 2015
    8
    0
    sorry im new here. and i dont know what should i put in my poll. i uploaded my schematic.
     
  5. R!f@@

    AAC Fanatic!

    Apr 2, 2009
    8,750
    759
    And I lost my Crystal Ball. So I dunno anything....!

    Still I had to ask where is this push button you are talking about. Can you point it out.
     
  6. blueroomelectronics

    AAC Fanatic!

    Jul 22, 2007
    1,758
    98
    Wow, what a strange design. What's it supposed to do? Why use the 4017 instead of the extra I/O ports? Why use an ancient 16F877A instead of a 16F887 or 18F4620? Why the opto isolated 7805? Why relays everywhere? Who designed this?
     
    TalkAboutCircuit likes this.
  7. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    2,674
    2,724
    Thanks. Am I correct in assuming CON1 is a break-out connector to which your switch is attached? And the switch connects pin 17 to 16 when pressed?

    And tell me the history of R2 and C7, and their purpose.

    FYI, you've not posted code. Should I just assume your problem is noise/emi related and not code related?
     
  8. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    2,674
    2,724
    Try this network (and eliminate R2 and C7). It eats just about any noise you can throw at it, and protects the MCU at the same time.

    Route "DIGIN0" to RA0, and the switch between pin 17 and ground. You'll have to add a ground to one of your free pins on CON1, as you don't seem to have one.

    The circuit *will not* alleviate the need for software debouncing, if you haven't done it.

    [​IMG]
     
    cmartinez and TalkAboutCircuit like this.
  9. TalkAboutCircuit

    Thread Starter New Member

    Apr 6, 2015
    8
    0
    Hi joey, your right for the CON1. R2 and C7 is my pulldown resistor and filter. i put this thinking that it will solve the issue for the noise problem.\

    For the code. i used flowcode V5? should i post it?

    ok will give you feedback if it works.

    Hi R!f, DB25 pin 16 and 17 is connected to the push button.
     
    Last edited by a moderator: Apr 6, 2015
  10. blueroomelectronics

    AAC Fanatic!

    Jul 22, 2007
    1,758
    98
    No decoupling caps? Ahh, saw one.

    Put them across the CD4017 too. Also post your layout / PCB.
     
    TalkAboutCircuit likes this.
  11. TalkAboutCircuit

    Thread Starter New Member

    Apr 6, 2015
    8
    0



    Would it solve the problem if i put a debouncing in my software?IF yes?should i still eliminate R2 and C7?
     
  12. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    2,674
    2,724
    I don't know what flowcode is....so I can't help you there.
     
  13. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    2,674
    2,724
    You will continue to require R2 as the pullup (if you don't use the proffered network). I don't like putting caps on inputs -- I prefer sharp edges.

    You should *always* debounce mechanical inputs, either through hardware or software. Software is easier and more reliable.

    I don't know if your flowcode package incorporates debouncing for you, but, yes, if it doesn't, you should add it.
     
  14. TalkAboutCircuit

    Thread Starter New Member

    Apr 6, 2015
    8
    0
    Yes my flowcode have debouncing on it.but no idea how long the interval im gonna use. and for the R2?should i use it as a pullup?or a pulldown?
     
  15. blueroomelectronics

    AAC Fanatic!

    Jul 22, 2007
    1,758
    98
    30ms is good for debouncing. Also the 16F877A has a weak pull-up option on PORTB. Ideal for pushbuttons. Any reason you're using the CD4017?
     
  16. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    2,674
    2,724
    Normally, I treat mechanical switches as "active low," meaning they pull an input to ground. This way I don't need my PCB's Vdd flying out into space risking shorts. In this case, I'd use a pullup resistor (or, the weak pullups incorporated into some of the MCU pins).

    You designed for "active high", which means you need pulldown resistors.

    The network I showed you is active low from the point of view of the switch, *but* there is an inversion through the 2222. Therefore, the MCU input will see it as active high. No code changes will be necessary.

    BTW, I prefer to call the network a "contact-closure" input. I'd usually have two pins on my break-out connector for each switch. One, naturally, would be tied to ground on the PCB, and the other to the input of the network. To activate, it is only necessary to cross the two wires -- i.e. close the contact. This prevents the possibility of inadvertently creating a ground-loop. In your case, if you had multiple switch inputs, you'd need to snake a ground (or, wrt your schematic, +5V) to lots of different places. This is asking for trouble down the road.
     
    TalkAboutCircuit likes this.
  17. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    2,674
    2,724
    Also, the network provides two additional advantages:

    1. The open circuit voltage (the voltage across the switch contacts) never exceeds 0.7V.
    2. The short circuit current (the current through the closed switch, or an inadvertent short to ground) never exceeds 500uA.

    This is sometimes important for safety or certification reasons.
     
  18. TalkAboutCircuit

    Thread Starter New Member

    Apr 6, 2015
    8
    0
    ok my project is about multiplexing. where using a one machine
    Ok thnx. To bad that i use most of my PORTA as input. and PORTB as output. the problem is that prototype is already running on the production line. CD4017 use as a switching of relay every time it receive signal from the machine. do you want me to explain how may project works?
     
  19. TalkAboutCircuit

    Thread Starter New Member

    Apr 6, 2015
    8
    0

    Ok. i think i need to reconstruct my schematic and implement what i learn today. i still have a long way to go.
     
  20. TalkAboutCircuit

    Thread Starter New Member

    Apr 6, 2015
    8
    0
    To all thank you.will update you once done and if solve the issue.
     
Loading...