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.

Crystal

Status
Not open for further replies.

YAN-1

New Member
Hello everyone. I was wondering, can a 20MHz crystal operating a PIC be defective in such a way that the PIC operates normally for some time and then the program gets stuck for a while and then over again? Or is it that crystals either operate perfectly or are completely damaged and my problem is not with the crystal? Thanks a lot.
 
YAN-1 said:
Hello everyone. I was wondering, can a 20MHz crystal operating a PIC be defective in such a way that the PIC operates normally for some time and then the program gets stuck for a while and then over again? Or is it that crystals either operate perfectly or are completely damaged and my problem is not with the crystal? Thanks a lot.
hi Yan,
I suspect the problem with your program 'hanging up' is most likely not the xtal. The easiest solution would be to try another xtal.

Does the problem get worse if you move your hand/fingers close too the PIC??
If Yes, then check the PIC wiring etc.
 
Yan. please ensure that the pF caps return path is direct to Vss pin instead if indirectly to earth somewhere else.
Also see that you have a 0.1:mu: F capacitor directly across Vdd and Vss pins , if necessary right on the solder side. These actions help to stabilize the oscillator.
Already Eric has pointed towards software,to have a check of it.
 
Also make sure MCLR is pulled up properly unless you have done it internally.

What is your program written in? Are you using the watchdog timer in it?

mvs_sarma's post covers the first things to check. Also, is the power clean and regulated?
 
Thank you for your replies. The thing is that I have already ensured all these precautions and the PCB was working fine until it was subjected to a good hit to the floor due to an accident yesterday. I was just wondering if the crystal could be the reason for what is happening now. I will check all tracks and sockets and proceed to replace the crystals if the problem persists. But it seems to me that if it works sometimes and doesn't some other times, then it's probably something that went loose due to the fall rather than the crystal itself.
 
Maybe get a loop and check all the pads for a crack.

But I think if the xtal died, it would be 100% dead. If you have one, they are easy to swap.
 
Oscillators are the most difficult to start. Once they start, they keep oscillating, so in my opinion if the oscillator starts in the first place, it cannot be bad crystal.

...

Update: so it can be a bad crystal after all, thanks for great explanation from kchriste below ... well, who knew ;)
 
Last edited:
Crystals are pretty fragile. Dropping it could have changed it's resonant frequency, made it intermittent, etc.
 
Crystals are pretty fragile. Dropping it could have changed it's resonant frequency, made it intermittent, etc.

So you are saying the behaviour OP is describing can actually be due to a bad crystal?
 
Yes. The leads inside the casing could have broken loose from the actual crystal or the crystal itself cracked due to being dropped. I have seen crystals go intermittent before. I wouldn't rule it out.
 
Thank you people for your replies. Well turns out that the program wasn't getting stuck at certain points. Instead, the PIC was restarting on its own when it reaches a certain part of the code. The PIC is part of a board that controls a car robot. When the gas is pressed and the wheels start turning, the PIC automatically restarts, releasing the gas pedal (the program of this PIC starts with an order to release gas and hold for 20 seconds). Now the 5 volts for this board are obtained from the +5 V rail of the computer power supply on the car that is operating a motherboard. But yesterday I discovered that when I operate the board from a separate power supply, the problem doesn't happen and the PIC doesn't restart! Any ideas? The computer power supply seems to be working fine and the computer it is driving faces no problems at all. Could there be a problem with its 5V rail only?
 
YAN-1 said:
Thank you people for your replies. Well turns out that the program wasn't getting stuck at certain points. Instead, the PIC was restarting on its own when it reaches a certain part of the code. The PIC is part of a board that controls a car robot. When the gas is pressed and the wheels start turning, the PIC automatically restarts, releasing the gas pedal (the program of this PIC starts with an order to release gas and hold for 20 seconds). Now the 5 volts for this board are obtained from the +5 V rail of the computer power supply on the car that is operating a motherboard. But yesterday I discovered that when I operate the board from a separate power supply, the problem doesn't happen and the PIC doesn't restart! Any ideas? The computer power supply seems to be working fine and the computer it is driving faces no problems at all. Could there be a problem with its 5V rail only?

Electrical noise from the engine or something else that also runs whenever your engine is running may be passing down lots of noise down to your PIC or drawing too much current for your power supply producing voltage drips which will cause your your PIC to brownout and restart. But without knowing how everything is wired up, can't really say what.

1. What exactly is powering your electronics? A regulator on the PCB? Because you say computer power supply. You actually have a power supply from the inside of computer sitting on your robot? Using the terms of parts that are inside a PC makes it confusing. You can clear things up by just calling it the "regulator" or "power supply" rather than or "computer power supply" which tend to refer to the thing inside the tower of a PC.

2. And you also say motherboard- is this just the board the PIC sits on or is it actually a motherboard from the inside of a computer? Using the terms of parts that are inside a PC makes it confusing. You can clear things up by just calling it the "PIC PCB" or "micro/controller PCB".

3. What is powering the power supply and what else is connected to this source?

4 What else is your power supply powering?

5 When you use an separate power supply, do you mean you connected a separate battery to the input of your power supply? Or do you mean you bypassed the power supply altogether?
 
Last edited:
dknguyen, thank you for your reply. I actually meant computer power supply and computer motherboard. Ok here's the arrangement on the car. There are 2 12V batteries connected in parallel and also to the car's dynamo (generator) so they would charge when the car is moving. These batteries operate a voltage inverter used to get 220V AC out of them and this operates a computer tower with a computer power supply in it. The motherboard runs an intelligence algorithm for navigation purposes. It communicates with a remote laptop wirelessly. It is a complete PC! The computer power supply operating this PC is also used to operate the PICs board and an electronic compass (5V for the board, 12V for the compass). The PC (motherboard) also communicates with this PICs board through a serial cable using RS232. Now the PICs board executes many functions to control the car's steering and speed through motors on the pedals and steering wheel. The motors get their power from the DC batteries, and interface with the PICs through opto-couplers. The PICs can also ignite the car through relays connected to the switch. There is also a GPS device and a laser range finder but these are operating fine and never caused problems.

I was trying to conduct simple tests after the accident that the car had but for some reason now, the speed control PIC restarts when the car is supposed to go. I thought there was physically something loose at the MCLR pad or the push button used to restart the PIC, so I re-enforced the soldering there and checked for problems but the problem persisted. Only when I detached the PICs board from the PC power supply and operated it from a normal laboratory power supply did it stop restarting...

That is basically the situation at hand.
 
So, if I read this right, then the PIC restarts, but the rest of the PC does not? even though they are both powered from the same power supply?

Is it possible the PIC is not properly decouples from the power supply? It doesn't sound like you are powering anything realy noisy from the power supply and if the PC isn't affected then I don't see why the power supply itself would the problem.

Perhaps the program causes the PIC to require too much current and it is not properly decouples so the increased current draw causes a voltage drip that brownouts the PIC. Maybe driving the optocouplers and relays (if the coils are also being powered from 5V) and whatever else is too much. Does the problem go away if you stick a big capacitor on the PIC board where the power enters the board? Maybe you could pull 12V from the power supply isntead and then linearly regulate it down to 5V locally on the PIC board just to make sure there isn't a problem with regulation between power supply and PIC.
 
Last edited:
Sorry for the late reply. Yeah you read that right. Well I don't think that the program requires too much current becuase this problem is only recent. It used to function properly before. Yes I was thinking of increasing the capacitor I already have or regulating the 12V rail into 5V instead of using the 12V one..
 
Hello again. Merry Christmas everyone.

Well I tried to regulate 12V from the PC power supply into 5V using several voltage regulators and capacitors to drive the PICs instead of directly using the 5V rail of the PC power supply. But the problem remained. Then I tried taking the 12V input of my new regulator straight from the car batteries but nothing changed. The Speed Control PIC restarts (causing the pedals to reset) when the gas is pulled a little. This problem doesn't happen if the car is not turned on. If the car is off and I start the PIC programs, the gas pedal presses normally and the brake one lifts normally as well! So I think that some sort of electrical problem occurs when the dynamo of the car is on. The only way in which everything works properly and the PIC doesn't restart while the car is on is if I use a completely different power supply unit, independent of the car power, to operate the PICs. Any advice or thoughts? I appreciate it.
 
Please see whether the IC base , if any used , didnt develop dry joints-the cheap ones are really notorious.
with independent battery is the circuit working s expected without freezing intermittently?

if so try to power the circuit thro' some 0.1uH inductors on the Vdd and Vsss lines and implement a power line filter even at the input of the regulator. you definitely need spike suppression caps from the Vdd and Vss to ground or chasis of the car to be effective.

However it appears the dynamo or alternator is likely to produce lot of noise ans the ignition circuitry ,in case it is Petrol version.
perhaps you can try a 12-14 input and 5V output dc-dc converter. Such converter circuits are published in EPE, Silicon chip and Elektor mags.this will be better i feel for the computer part.
 
It does sound like alternator/gen noise.

The coils as stated and make sure you have the decoupling cap in place.

I did a circuit for a motorcycle once, and the persons cellphone in the same compartment as the circuit would freak the pic out.

Try the chokes, they were standard when installing speakers and a radio way back.
 
Alright I am going out of mind.. I have no explanation for what is going on. Maybe someone can help me. Almost everything is causing the Speed Control PIC to restart. I got a separate battery and operated the car from it. I used 2 other batteries for the computers and the PIC board to completely separate the boards from the car electricity. But still, when the car switches on, the speed PIC restarts. And unless the car is turned off, the PIC will keep restarting and eventually the I2C master loop will fail.

I have no idea why the PIC restarts. I removed the PIC board (for the millionth time) and am testing it. It's the size of an A4 sheet with 7 PICs on it. Made sure of the master clear again and all the tracks. Replaced the crystal and the PIC itself. Then I tried powering the board from the lab power supply. I just gave it 5V and it worked fine. I tried shaking it but it kept working. One of the PICs on the board communicates with the PC through the serial port (MAX232 and DB9). When I attempt to connect the serial cable to the computer port, the speed PIC (NOT THE PIC CONNECTED TO THE SERIAL ANYWAYS!) restarted again!! When I attempt to test the power signals with the oscilloscope, and as soon as I touch the ground of the probe with the ground of the board, the PIC restarts! (I can tell when it restarts from its blinking LED). I have no idea how this is happening. I mean it seems when the board touches anything through its ports like it's supposed to, this PIC restarts.. Please help. Thanks a lot.
 
I think I solved the problem. I attached a capacitor between the master clear pin of each PIC and the ground, and the Speed Control PIC is no longer restarting... Also added an extra capacitor between the main VDD and VSS. Looks good for now.. :)
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top