View previous topic :: View next topic |
Author |
Message |
aaronik19
Joined: 25 Apr 2011 Posts: 297
|
PIC freezes |
Posted: Sat Dec 22, 2012 11:15 am |
|
|
Dear Friends, I made a project (RTC) with the DS1337 and PIC18F4550. The code seems to be fine and working good but I am experience a funny thing. When I give supply to the board, nothing appears on the LCD, but when I touch the regulator or a filtering capacitor, it starts to work normally. When I remove my finger from the regulator of capacitor, the program freeze. I replaced the regulator and the capacitor (10uF), but the problem still persist. What could be the problem? I am making this breadboard, but even when I soldered the same circuit on pcb.
Thanks
aaronik19! |
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Sat Dec 22, 2012 11:37 am |
|
|
Hi,
Post your Fuses, and tell us what is connected to the MCLR pin. Also, verify that you have several bypass caps across the supply rails close to the PIC.
Are you using an external crystal, or the internal oscillator?
John |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19513
|
|
Posted: Sat Dec 22, 2012 12:13 pm |
|
|
Describe your regulator circuit.
What is the regulator?.
What are the decoupling capacitors, and where are they?.
What is feeding the regulator?.
The 'standard' circuit, is something like a 78L05, with perhaps 10uF on the input (depends on what is feeding it), perhaps 1uF on the output. Then something with good HF response (ceramic or polyester non polarised capacitors), close to the PIC. Then a similar capacitor across the LCD. The supply needs to be decoupled _before_ it gets to the regulator. The capacitor after the regulator are to smooth instantaneous load changes, and prevent oscillation. Big capacitors after the regulator, are potentially dangerous (can kill the regulator). If you need them to cope with large load changes, then you should add a reverse diode across the regulator, to prevent it being destroyed if the incoming supply discharges before the outgoing rail.
Best Wishes |
|
|
aaronik19
Joined: 25 Apr 2011 Posts: 297
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19513
|
|
Posted: Sat Dec 22, 2012 1:45 pm |
|
|
Several comments then:
You don't tell us what voltage the supply you have gives. There are a lot of different versions of this. TMP part number?.
None of the capacitors you use will block HF at all significantly. It is one of those 'bigger in not better' things. Electrolytic capacitors give large capacities in small sizes, but have characteristics which tail off at high frequencies. Study something like a PC motherboard. Group of large electrolytic capacitors round the supply, but then literally dozens of small capacitors across the board. Typically one by just about every IC. Remember these people are after saving every penny they can. These small capacitors are _essential_.
You need an input capacitor to the regulator. Pull the Texas data sheet for the 7805, and look at their example circuits.
Problem is that a voltage regulator is effectively a very high gain amplifier. As such it is inherently quite prone to instability. The capacitors close to the regulator control this. Then the PIC itself produces very high frequency changes in load, encouraging HF noise. The local HF capacitor by the chip controls this.
Best Wishes |
|
|
aaronik19
Joined: 25 Apr 2011 Posts: 297
|
|
Posted: Wed Dec 26, 2012 5:37 am |
|
|
dear all,
I wired all the circuit on a new BreadBoard and made a regulator 7805 and some capacitors along the supply line +5V and GND but the problem still persisted! I also reduced the crystal to 4MHz instead of 20MHz because I read that 20MHz is too high for BreadBoard.
This is a very funny problem! Photo: [/img] |
|
|
aaronik19
Joined: 25 Apr 2011 Posts: 297
|
|
Posted: Wed Dec 26, 2012 5:37 am |
|
|
Sorry I forgot..I am using PIC18F4550 and DS1302 RTC |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9226 Location: Greensville,Ontario
|
|
Posted: Wed Dec 26, 2012 6:41 am |
|
|
comments..
1) I don't see any caps from the xtal to gnd.Usually 22pfd.
2) 20MHz xtal /PIC do work on my breadboards(EXP300).
3)try to buy some 10 conductor,22ga solid wire ,it'll really help when wiring and debugging .right now you have mess of yellow wires and that has to be hard to check! Even 4 conductor 'quad'( telephone cable) will help.
hth
jay |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Wed Dec 26, 2012 7:01 am |
|
|
Sigh....
Several important questions were asked that you didn't answer.
ezflyr wrote: | Post your Fuses | We are still waiting for these...
A wrong crystal amplification fuse makes your circuit unstable.
Ttelmah wrote: | You don't tell us what voltage the supply you have gives. There are a lot of different versions of this. TMP part number?. | Important info, because the 78xx regulators require an input voltage of minimum 3V higher than the output voltage.
More details about the TMP part number helps us to determine the power supplies stability and output filters.
Quote: | I made a project (RTC) with the DS1337 and PIC18F4550. |
Quote: | I am using PIC18F4550 and DS1302 RTC | At the moment it's not important which RTC you are using, but it worries me that you changed the type within a few days.
I still see only 1 small capacitor on your board. Why? Didn't Ttelmah tell you to add more? The 78xx are known to oscillate without capacitors and your symptom description sounds like this, touching the circuit fixing the problem is a typical oscillation symptom. The electrolytic capacitors you use are perfect for the larger capacitances (> 1uF) but have poor performance in the higher frequencies. That's why you often see an electrolytic capacitor accompanied by a 100nf Ceramic capacitor; the elco for the large capacity and the ceramic for the high frequency response.
Add at minimum a 100 - 330nf ceramic capacitor as close as possible to the 7805 output pins. Also add a 100nf ceramic as close as possible to the PIC power pins (2 times, between pin 11 & 12 but also 31 & 32 ). And a 100uf electrolytic to 7805 input.
Then another thing... I'm missing the ultra important crystal capacitors. Did you even have a look into the PIC datasheet???
Perhaps you are lucky your circuit is working because the breadboard has a large stray capacitance but still this is bad design by you. Check the datasheet of your crystal, should be around 27pf each for a 4MHz crystal, then subtract a bit because you are using a breadboard.
Just a tip: when building with breadboards you make it yourself a lot easier by using multiple wire colours: red for positive, black for ground and several other colours for signals. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
aaronik19
Joined: 25 Apr 2011 Posts: 297
|
|
Posted: Wed Dec 26, 2012 1:30 pm |
|
|
thanks to all. This is just a quick prototyping not the real design. That's why I made a "mess"
I solved the problem after some more investigation. I also added the 230VAC's Earth to the GND and the circuit worked perfect! |
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Wed Dec 26, 2012 2:17 pm |
|
|
Hi,
After all the help you've received, why not be courteous and provide the
"solution" for later forum users who come across this thread? It's much more
satisfying than just a "problem solved" report!
Prototype or not, there are certain things you can/cannot do if you want to
build a reliable circuit. Taking shortcuts while prototyping is not the way you
are going to learn good engineering practices, and if your prototype does not
have good fidelity to the final product, what good is it?
Pardon my skepticism, but without any additional information, and based on
your demonstrated reluctance to follow the advise of more experienced
forum members, my guess is that you've just blundered onto a "solution"
that happens to work in this instance. Unless you can show us otherwise, I
doubt that there is much you've learned from all the helpful advise you've
received! Too bad!
Cheers,
John |
|
|
rikotech8
Joined: 10 Dec 2011 Posts: 376 Location: Sofiq,Bulgariq
|
|
Posted: Wed Dec 26, 2012 2:29 pm |
|
|
Might be the MCLR. If you have declared MCLR but not tied to 5V it could be the problem. _________________ A person who never made a mistake never tried anything new. |
|
|
aaronik19
Joined: 25 Apr 2011 Posts: 297
|
|
Posted: Wed Dec 26, 2012 4:59 pm |
|
|
First I would like to thank to all who advice me and helped me to solve this problem. I made a design which involves PIC18F4550 and the Dallas Semiconductors DS1302 (sorry but in the first thread I mentioned the DS1337 by mistake).
When I completed the code using the DS1302.c, I made the simulation using the IDE software it worked fine. I designed the PCB and assembled all the components. When I power up the board, I experienced problems with the supply. To be 100% safe, I replaced the power components (Regulator 7805 and the two capacitors 10uF), but the problem persisted.
I build everything again on breadbaord and the problem mapped itself and started to investigate. I inserted more 10nF capacitors and also changed the crystal of the circuit from 20MHz to 4MHz to avoid problems with capacitance. Than I was consulting with my friend to connect the 230VAC's earth with the Supply Ground (DC Ground) and the circuit worked perfectly. Than i add a track on the pcb to connect the ground with Earth and everything worked fine. Even the DS1302 is very accurate. When I have some photos I will share them. |
|
|
gpsmikey
Joined: 16 Nov 2010 Posts: 588 Location: Kirkland, WA
|
|
Posted: Thu Dec 27, 2012 12:15 am |
|
|
While the 10ufd caps are handy for filtering the supply, unfortunately, in the real world, they look more like open circuits at high frequencies. You need some .1 ufd or in that range ceramic caps across the supply lines, the 10 ufd caps and across the supply/ground pins on the chips. If you don't put some bypass caps like that in critical areas, you WILL have problems later on.
mikey _________________ mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3 |
|
|
|