Author Topic: PIC 18 resets on switch input  (Read 2248 times)

0 Members and 1 Guest are viewing this topic.

Offline Puffie40Topic starter

  • Regular Contributor
  • *
  • Posts: 54
  • Country: ca
  • Irregular Logic
PIC 18 resets on switch input
« on: May 10, 2016, 07:18:48 am »
I have a PIC18F4520 that I am trying to use as a 2 axis motor controller - it has two limit switches on B5 and B4 that are hooked up like the attached picture.

I'm having a problem where the PIC resets when the switch on B5 is pressed.  I've tried adding current limiting resistors and a filter cap, thinking it was a switch bounce issue. I have ensured BOREN and WDT are off, and portB is set as a digital input.  VSS has 100nF coupling caps right next to the socket

the really confusing part is that the other three switches do not cause a reset when they are pressed,  and I can't find any indication of a short, either visually or by multimeter. 

Any ideas?
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: PIC 18 resets on switch input
« Reply #1 on: May 10, 2016, 07:57:07 am »
Is LVP disabled in the CONFIG?  RB5 is also the PGM pin used for low voltage programming . . .
N.B. never let a switch connected to a MCU input directly short a capacitor. The high pulse current is not only bad for the switch, but the ringing with the trace or wiring inductance can crash or even damage the MCU.  100R in series with the switch or the cap to limit the peak current prevents many problems.
 

Offline Andreas

  • Super Contributor
  • ***
  • Posts: 3248
  • Country: de
Re: PIC 18 resets on switch input
« Reply #2 on: May 10, 2016, 08:06:43 am »
Try a 1nF capacitor betwen MCLR and VSS pin. (short wires).
Had a similar problem with 18F2520 when using a noisy (SCR controlled) power supply.

With best regards

Andreas
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: PIC 18 resets on switch input
« Reply #3 on: May 10, 2016, 12:12:54 pm »
maybe there is something specially about that input pin?

I would put the 1k resistor serial with the input pin.
================================
https://dannyelectronics.wordpress.com/
 

Offline DTJ

  • Frequent Contributor
  • **
  • Posts: 997
  • Country: au
Re: PIC 18 resets on switch input
« Reply #4 on: May 10, 2016, 12:43:58 pm »
These are limit switches for a motor controller - does pressing the limit switch still cause a reset when the motor is disconnected. ie is the reset caused by noise / back emf from the motor?
 

Offline Puffie40Topic starter

  • Regular Contributor
  • *
  • Posts: 54
  • Country: ca
  • Irregular Logic
Re: PIC 18 resets on switch input
« Reply #5 on: May 10, 2016, 03:05:33 pm »
During my troubleshooting, the motors have been off, so it's not emf related.
 

Offline Kalvin

  • Super Contributor
  • ***
  • Posts: 2145
  • Country: fi
  • Embedded SW/HW.
Re: PIC 18 resets on switch input
« Reply #6 on: May 10, 2016, 03:14:14 pm »
From the datasheet page 266 http://ww1.microchip.com/downloads/en/devicedoc/39631a.pdf: "When Single-Supply Programming is enabled,  the  RB5  pin  can  no  longer  be used as a general purpose I/O pin.".
 

Offline Puffie40Topic starter

  • Regular Contributor
  • *
  • Posts: 54
  • Country: ca
  • Irregular Logic
Re: PIC 18 resets on switch input
« Reply #7 on: May 11, 2016, 08:01:36 pm »
 Yep! It was the LVP Config bit!  Once I turned that off, the resetting stopped.
:-+
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf