Thanks for reply. Yea, but why didnt the time is constant?..I refer to the data sheet, the time for the oscillation to stable is 1024Tosc. Which is around 51.2 us.
Another circuit of mine, which have the same function does not have such problem..What are the possible cause for such uncertainty?..
The start up times should be listed in the PDF, but there's a high degree of uncertainty to them. I'm not sure how easy it is to change the clock speed dynamically on a PIC but if you want to lower power usage without turning the clock off just switch to the internal oscilator with the highest prescaler you can. The slower the pic runs the less power it uses. This may or may not be acceptable for your application though.
Thanks for reply. Hmmmm..Is there any document that i could read about on the randomness of the oscillation to become stable?
I really have to put the PIC into sleep. Is not for power saving purposes. BUt is for turning the oscillator off. I wanted to calculate the time of flight of RF wave thus if i dint turn off the PIC the sampling rate would be of 200ns. This is not desirable...
One weird thing is, one of my circuit which used the sleep instruction as well does not have such problem..Could it be the difference in stray capacitance in the circuit larger than the working circuit till the choice of capacitor for the crystal is wrong?..I have not tried it though...
Could be ealee, if the oscillator is loaded it'll take it longer to start up. Nigel is right though measuring the time of flight of RF on a pic is not particularly practical unless you're talking extremely long distances. If your pic is running at 20mhz, you have a clock of 5mhz, even if you could somehow send and detect RF signals perfectly you would have a granularity of 60meters and the minimum distance you could detect would be at least several hundred meters. I've thought about doing a time domain reflectometer for fun with an AVR, a 20mhz AVR would have a granularity of about 15 meters, with a minimum distance of 50 or so.
Actually, I somehow think PIC cannot achieve the objective i wanted to achieve. Regarding the accuracy, I have a Time Delay element which is MAxim DS1124 of accuracy 0.25ns which allow me to calculate the distance up to 3.5 cm provided all propagation delay in the circuit is constant..
Is there any document i can read on to get more information on the distribution of the response time..For instance, the time for oscillation to stablize is stated to be 1024 Tosc but how it would varied in practically.
Actually, I somehow think PIC cannot achieve the objective i wanted to achieve. Regarding the accuracy, I have a Time Delay element which is MAxim DS1124 of accuracy 0.25ns which allow me to calculate the distance up to 3.5 cm provided all propagation delay in the circuit is constant..
Is there any document i can read on to get more information on the distribution of the response time..For instance, the time for oscillation to stablize is stated to be 1024 Tosc but how it would varied in practically.
To measure the time of flight accurately, i need the PIC to off the oscillator so that when the PIC only wake up when the wave arrive. If PIC is not in sleep mode, the sampling rate would be 200ns....But the choice of using sleep might be wrong since the uncertainty in stabilizing the oscillator is so great,,,,
External oscillator?..Do u mean RC oscillator?..But from the datasheet. RC oscillator will have frequency that will vary with parameter of C and R as well as temperature...Wil this give uncertainty as well?..
To measure the time of flight accurately, i need the PIC to off the oscillator so that when the PIC only wake up when the wave arrive. If PIC is not in sleep mode, the sampling rate would be 200ns....But the choice of using sleep might be wrong since the uncertainty in stabilizing the oscillator is so great,,,,
=.=''. I am not rich,, dun think i can afford that in my project...yea..PIC indeed wont wake up from sleep fast..just that i dun understand the time between PIC wake up and the first instruction it run can be so different for everytime it run...
I am using a delay element in my project, this delay would be representing the time of flight of the RF wave. I would run a counter to cancel the propagation delay in the circuitry. Once all the propagation delay is cleared, i will send a signal A to the delay element. After delay for T0 ns, the signal A will be at the output pin. The PIC would read this output once it wake up from sleep. If the output is zero, this indicates that the time of flight is shorter than the time delay set, but if the output is A, this indicates the time of flight is longer that the time delay set.
By using successive approximation, correct delay can be determined and this would be the time of flight...I used LED as indicator, just to see how fast does the PIC react after wake up from sleep