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.

how to get precise time with pic - help needed

Status
Not open for further replies.

AriHell

Junior Member level 1
Joined
Jul 7, 2009
Messages
19
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,412
pic precise timing

I'm working on a small project and precise time is critical issue.

How can i get precise time?

Thank you.
 

precise time with pic

Well, you can use a crystal or an external oscillator with a very small deviance.

How precise do you want to be? Even the internal oscillator on a PIC is stable and precise enough down to the <10nS range I believe.
 

precise time with pic

I need it to be one sec precision.
Will i get it with 4Mhz oscillator?
 

precise time with pic

Unless you use an R/C oscillator at that speed you will definitely be precise enough. That will give 1MIPS, so every 1,000,000 instructions will be one second.

If you are trying to time something within a second (really really slow) you may consider using an external 32.767Khz oscillator like a watch crystal on your TMR1 and have it interrupt every time it overflows. Or, use a RTC (look up the MAX1337) and have it assert one of its interrupt pins every second on an alarm.

Trying to count 1,000,000 cycles accurately with C or ASM is difficult because C introduces extra code you didn't intend to be there and ASM requires that you figure out how to do 24-bit or 32-bit math using 8-bit registers.
 

precise time with pic

I'm will probably use 4 MHz quartz crystal resonator (HC-49S)

what is R/C oscillator ? how is it look like?
 

precise time with pic

Stick with the crystal, far more accurate than a resonator or R/C osc.

If 1 second is what you're after use a crystal that divides evenly in binary such as.
4.9152MHz it's commonly available.

It's also possible (if you don't need speed) to use a 32768Hz watch crystal.
 

precise time with pic

Crsytals give better accuracy. If you are using any crystal, try to use more accurate as possible with the values for better accuracy. Mean if you use 4 mhz, use a crystal with 4.000mhz marked on it. Good luck
 

precise time with pic

it all depends on how "precise" you want your clock to be precise.

you can thermally insulate the devices / crystals, you can calibrate the internal r/c, etc.

without knowing more precisely your requirements, it is tough to help you.

I need it to be one sec precision.

one second over what period of time? 1 second over an hour / 24 hours is nothing. 1 second over a month is doable. 1 second over a year is pretty much out of the possibilities for most of us.
 

precise time with pic

It suppose to work over a month.
Deviation of few minutes won't kill nobody however, I want the deviation to be as small as possible.
 

Re: precise time with pic

Quartz crystals provide u d best accuracy
Check out the ppm rating while choosing ur crystal
Lowest ppm offer better stability

I have a small question.
Suppose, i have a external 32.768KHz crystal connected.How can i maintain accurate timing if i want to run a normal clock?
I havn't worked much with this crystal so i don't have any idea behind using this crystal for RTC.
 

precise time with pic

1 second over a month equates to less than 1ppm, and I don't think you will find any affordable crystals at that kind of precision.

1 minute over a month is about 20ppm and that's quite doable with regular crystals and no thermal compensation.

if you really need 1 second / month type precision, the least expensive solution is likely to get a high precision watch. Citizen I think used to produce a watch that they claim is good for less than 12 seconds a year.

that's going to cost you thousands of dollars.
 

precise time with pic

I don't think you have any choice to use achieve high precision timing accuracy (let say 1ppm) without calibration and without temperature compensation if the device is to be exposed to large temperature variations.

I once saw a design using a silab DDS that uses a to220 transistor mounted to the oscillator as a heater to maintain temperature. Pretty cleaver if you ask me.
 

precise time with pic

I put 4Mhz Quartz but the seconds go slower than what it suppose to go.

Is it because i use 30pf and not 22pf?
 

Re: precise time with pic

AriHell said:
I put 4Mhz Quartz but the seconds go slower than what it suppose to go.

Is it because i use 30pf and not 22pf?

I guess it has something to do with how you implemented the concept rather than the concept itself.
 

precise time with pic

Any ideaes how to fix the deviation?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top