Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[PIC] external oscillator not stable for pi16f676

Status
Not open for further replies.

JAI PRAKASH LAMBA

Newbie level 5
Newbie level 5
Joined
Nov 12, 2013
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
81
hello all,

i need a help i am using a pic16f676 for which i am using external oscillator for time calculation but it is not stable i have used 8 mhz osc and also 32.768.khz also but getting not getting the correct calculated time
 

i have attached my code below

i will brief about that in my code i am calculating the total run time of motor when it is running otherwise not, depending on the hours calculated i have to turn ON three led's with buzzer but it does not work when i try it with internal oscillator of pic16f676 then i also tried external oscillators i.e 8 Mhz and 32.768Khz but the problem remains same i am not getting the correct o/p i.e led's are not turning ON at the right time instead of that it will turn ON at 285 hrs 5 mins and some times 285 hrs 5mins 45 sec means oscillator is of varying nature, same i tried to turn on the led's at the 1 hrs interval then in first hour one led is ON but at 1 hr 20 sec, in 2nd hr it turn ON at 2hrs 40 sec ..... then 3 hrs 1 min .... then 4 hrs 1 min 15 sec i have observed that every hour 20 sec delay is added in my time calculation every hour ----> in this case i have forcefully call my led turn ON function( EOL func ) in which i observed that scenario.

but when i call my EOL function from my pump_control_module then i delay addition is more and more delay is added every hour
 

Attachments

  • Defines.txt
    2.4 KB · Views: 74
  • Init.txt
    1.8 KB · Views: 103
  • main.txt
    15 KB · Views: 72
  • interrupt routine.txt
    5.9 KB · Views: 169

Hi,

Before anyone tries to debug your code, have you tired any basic tests on the oscillator ?

Have you done a simple program for just a one second / one minute/ one hour led flasher running from the F676s internal 4mhz oscillator and then on your both your external crystals.
I would put money on them working ok.
Assume they have the correct load capacitors ?
 
  • Like
Reactions: PA3040

    PA3040

    Points: 2
    Helpful Answer Positive Rating
Hi,

I haven't done simple testing for 1 min, i hr, but when i tested the 1 sec simple test to toggle led the o/p is not accurate in isr, when checked on oscilloscope also every controller gives me different o/p on scope for 1 sec when 1 test it after every 3 to 4 hrs it gives different o/p on scope for 1 sec every time.

i have used 22pf cap.
 

Hi,

Best thing to do is write a totally separate simple program with a simple delay of 1 second to flash a led, making sure you do Not use the ISR in your code.
Most compiler tutorials start you off with such a simple hello world/ led flasher program

Bet that will work ok, which probably means your main code has some basic bugs in it, probably around your ISR section ..?

You do not say if your crystal is soldered in a pcb or on a breadboard ? - if on a breadboard, solder the crystal and caps together and fit two very short breadboard thickness wires to them so the assembly makes good contact with the breadboard sockets and is as close as possible to the pics pins.
 

Hi,

flashing works well in my code with 1 sec delay but problem with isr, i am new to microcontroller so i am not able to detect where is the problem in isr if you find error in my isr then let me know where to change the code
 

Hi,

Well you have proved that the fault is in the software and not your hardware.

Cannot properly help with the C code though a quick look at your ISR code, it does look like you have a lot in there.

The whole idea of the ISR is that when a certain condition occurs your main program is diverted to the ISR to complete a specific task which should be done quickly otherwise other Interrupts like Timers could be missed/delayed because your ISR code is taking too long.

If no one comes in to help you with this thread start a new one off titled ISR Code Problem
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top