Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

18F4550 resetting randomly....sort of

Status
Not open for further replies.

burgerfeet

New Member
Hi all,

Has anybody had problems with the 18F4550 resetting when it is not supposed to??

After developing my software and hardware with MikroC Pro and using the EasyPIC development board, I produced the PCB. All work perfectly on the development board.

I have 2 buttons connected to Port D0,D1 then pulse the inputs high. Each time I pressed them the PIC would reset. I removed the debounce capacitors that were close to the oscillator 22pF's capacitor and found the problem went away. I thought I woould deal with that issue later.

I had ports A0...A2 configured as A/D inputs. Port C1 then switches a relay via a BC548 when inputs are at a predetermined level. Each time the relay switched the PIC would again reset. During the switching I noticed a 500mV transient on the 0V line. I temporarily fixed this by placed a 100uF capacitor across the contacts. This fixed the problem but then I noticed the A/D results were not quite right on the LCD. I then realised that the impedance of the voltage divider was to high so change the values and all good. After changing the resistor network I was then able to remove the temporary fitted 100uF capacitor and found that the resetting problem had gone away.

Are these PIC's known to be twitchy or is there a config bit that I am missing???? I cannot understand as to why the impedance of the A/D being too high would cause the PIC to reset. I cannot test any further as the PIC then died, new one with me tomorrow.

The MCLR pin is connected to a 10k/100nF. All IC's are decoupled. +5V provided using an LM2940 as they are excellent at providing the 5V (typ 4.99V) which is good for the A/D reference.

I have many numerous PCB's for the 16F877A's and never had any problem like this before. This is the first time I have used the 18F series PIC. I thought this would be a straight forward from development to PCB exercise as before.

Any tips would be appreciated.

Many thanks,
Andrew
 
I used the 18f4550 once and it was a while ago but I seem to remember having problems with it being touchy with resets. This guy was having similar problems: https://www.electro-tech-online.com/threads/pic-supply-using-a-dc-dc-converter.110821/. It may be an issue with that particular chip or a coincidence. It is not a problem with the 18 series in general, if that's what you are wondering.

You need a protection diode across the relay. When you cut the voltage to an inductor, it makes a negative voltage spike. google "relay protection diode". This is most likely what killed your PIC. A capacitor would provide some protection similar to the diode, removing it is probably what got you.

It's quite doubtful that the A/D input impedance had anything to do with your reset. It's more likely that placing additional load on the power supply by using low value resistors stabilized something. If you are curious, you can put the old values back but then also load the power with the same resistance.

Instead of using low value resistors, you may want to look at using an op-amp to buffer the voltage (voltage-follower). This would be a good idea if you were running on batteries.
 
Last edited by a moderator:
Thankyou for your reply!

I am wondering if it is an 18F4550 issue. I quickly modified the code for the 18F452 and it works absolutely perfectly. They relay does have a catch diode across the coil. As current consumption isn't an issue nor is the impedance of the source voltage into the A/D I just used went for the simple divider network with zener over voltage protection. I normally use an MC619 configured as a follower which works well but did not think it necessary in this application. I modified the code so that all it does is switch the relay rapidly hoping to induce the problem as I saw with the 18F4550. It doesn't matter what I do it works as designed. Even the 500mV transient I saw has disappeared. A real puzzler ?????? Scoped the rails, inputs etc, no noise found.

I went for the 18F4550 only for the USB application but it is not required here. I will stick with the 18F452 for now as it is looking good. I will go back to the 18F4550 soon and see what I can find.

Many thanks,
Andrew
 
Hi, andrew

looks your PIC decoupling is too weak ...

place 0.1µF ceramic between the supply PINS of the Pic ans a 10/22 µF Tantalum bead as close as possible from these pins ...

Also have a look to the 2940 datasheet ... that need STRONG decoupling !!! ( it's written ... soooooo .... )

Now, powering your relay from the same supply as the Pic is " not so good ". you could try a LoPass RC filter ( R sets the relay min hold current and C gives a .1 sec Time constant ) in series with the relay supply.

this way, your relay activated draws minimum current and there's max voltage for it to engage.

I've also seen RC series snubbers ( in // with the coil ) that leave the supply perfectly neat - R was equal to coil resistance and C ... choosen to give satisfaction ( !!! )

Alain
 
Not sure what happened. lets try again: https://www.electro-tech-online.com/threads/pic-supply-using-a-dc-dc-converter.110821/. If not the link is wrong but the text is correct (the post took out /microcontollers/) so you can copy and paste into the address box.

Wierd, maybe the chip does have an issue or maybe you got a bad one. I have used many other USB 18 series including the 18F14k50 (very cheap), and the 18f25j50 without any issues. I think the 4550 was one of their earlier USB models.
 
Last edited:
Cannot believe I didn't try pasting. I have read that post before. The common thing is the resetting again. Sometime ago I read another article on the problem but don't know where. I never envisaged me having the problem so took no notice?!?!?! I will certainly look into a different 18F when I have a need for a USB application.

Alain.....the relay is actually 12V thus powered independently. You are correct about the LM2940 decoupling; get it wrong the output from it is awful. The only thing that I don't have as you suggested is the 10/22uF tantalum. The problem with the resetting occured even before switching the relay, just simple tactile switches were causing a reset. I have a new one on the way so I will give it a try with the extra capacitor. I agree with you that RC filtering can provide 'clean' switching but it is working a treat with just the diode (certainly with the 18F452).

Thanks both, Andrew
 
just simple tactile switches were causing a reset.

One could think to the oscillator ... BTW do you use the PLL ???

BTW did you carefully clean the PCB ???

I suppose you do not use the Watchdog ( MikroCPro ...). so not a WDT reset ...

Could you provide an actualized scheme , may be a shot of your PCB ??? the .c Program + Configs would be nice too and would help a lot.

and remember a so looking "reset" may also come from a Prog Counter overflow ...


I've used 4550 and similars for long time ... but never had such behaviour.

Alain
 
Last edited:
Find attached the PCB and the code and configs for the 18F4550. The PCB is clean!
 

Attachments

  • 07092010174.jpg
    07092010174.jpg
    432.7 KB · Views: 827
Last edited:
Further to the above....

The set you set is with the LCD 20x4 removed and an 18F452 in situ. This setup works. The RA0 network resistors have been removed ready for replacement, but in or out work with the 18F452. The tactile switches are each connected to the 2off molex headers (blue wires) just out of view.

The decoupling for the PIC is underneath the PCB, 100nF within a few thou' of the +5V/0V. An additional SM tantalum is underneath the regulator also.
 
Last edited:
Hi,

What if you disable the stack overflow reset ??? ...

May be your switch inputs act as glitches antennas ( see upper line ...) ... I'd use STRONG pullups or Pulldowns !!! ( Always when long PCB tracks )

also try to increase the debounce time for BUTTON ... some are really awful ...

Alain
 
Last edited:
Thanks again.

I have tested the stack and all seems good, well in simulation. I will wait until the 4550 arrives tomorrow and have a tinker. Will also adjust the debounce time. It might be that I have had a bad 4550 as no problems what so ever are seen with the 452.

Andrew
 
Hi Alain,

The new 18F4550 turned up today. Programmed it up and away it went....working perfectly. I appreciate your pointers and head scratching. I have absolutely no idea why the thing didn't work as it should unless in the development board. I have been looking at other PIC's to. As a drop in replacement the 18F4553 looks good as it has 12-bit ADC, so maybe it is worth moving away from the twitchy 4550's.

Thanks again,
Andrew
 
Status
Not open for further replies.

Latest threads

Back
Top