Author Topic: Timer with a dsPIC33FJ128GP804  (Read 3642 times)

0 Members and 1 Guest are viewing this topic.

Offline richcj10Topic starter

  • Supporter
  • ****
  • Posts: 201
  • Country: us
Timer with a dsPIC33FJ128GP804
« on: July 10, 2013, 05:14:17 am »
I need to track time over a hour and 1/2 period to the second.
It needs to be pretty accurate.
I would like to use Timer1 with a external crystal.
Has anyone had any experience with this? 
 

Offline adam1213

  • Regular Contributor
  • *
  • Posts: 120
  • Country: au
Re: Timer with a dsPIC33FJ128GP804
« Reply #1 on: July 10, 2013, 09:00:27 am »
It needs to be pretty accurate.
What accuracy do you need? e.g. over 1.5 hours would an error of less than +- 0.1 seconds be adequate?

 

Offline richcj10Topic starter

  • Supporter
  • ****
  • Posts: 201
  • Country: us
Re: Timer with a dsPIC33FJ128GP804
« Reply #2 on: July 10, 2013, 09:20:41 am »
yes
 

Offline adam1213

  • Regular Contributor
  • *
  • Posts: 120
  • Country: au
Re: Timer with a dsPIC33FJ128GP804
« Reply #3 on: July 10, 2013, 09:45:34 am »
I have experience with using the internal oscillator on PICs (not external).

Essentially you just need to work out the requirements for the crystal (e.g. stability in terms of ppm)

Do you have any specific questions?

Semi relevant video: http://www.eevblog.com/2010/02/14/eevblog-61-crystal-oscillator-drift/
 

Offline richcj10Topic starter

  • Supporter
  • ****
  • Posts: 201
  • Country: us
Re: Timer with a dsPIC33FJ128GP804
« Reply #4 on: July 10, 2013, 01:51:07 pm »
Well, I usually set up timers to run on the external clock for the pic with a /4. Is it more accurate to say use something like this:
http://www.digikey.com/product-detail/en/CM200C-32.768KHZF-UT/300-8742-1-ND/2108134
I understand the drift problem. For this application I don't think it will matter. When not in the 1.5 hour period, I don't care how much time has passed.
As long as I have a tight ppm. I think it will be ok.
This is what I use for my main crystal:
http://www.digikey.com/product-detail/en/XRCGB25M000F0L00R0/490-5577-1-ND/2368391
 

Offline fcb

  • Super Contributor
  • ***
  • Posts: 2117
  • Country: gb
  • Test instrument designer/G1YWC
    • Electron Plus
Re: Timer with a dsPIC33FJ128GP804
« Reply #5 on: July 10, 2013, 03:52:05 pm »
+/-0.5 seconds over 90 minutes is +/-93ppm

You should be good with almost any crystal - although you'll have to watch the initial frequency tolerance.

I'd look at a 32.768Hz watch crystal (connected to secondary oscillator pins), they tend to be something like +/-20ppm intial tolerance and have a well defined temp coefficient. Use the recommended Microchip circuit in the notes and your done.
https://electron.plus Power Analysers, VI Signature Testers, Voltage References, Picoammeters, Curve Tracers.
 

Offline richcj10Topic starter

  • Supporter
  • ****
  • Posts: 201
  • Country: us
Re: Timer with a dsPIC33FJ128GP804
« Reply #6 on: July 10, 2013, 04:07:16 pm »
Thanks
 

Offline richcj10Topic starter

  • Supporter
  • ****
  • Posts: 201
  • Country: us
Re: Timer with a dsPIC33FJ128GP804
« Reply #7 on: July 10, 2013, 04:46:36 pm »
When using a secondary oscillator, can you only use a external clock source instead of a crystal?
I am looking at this datasheet:
http://ww1.microchip.com/downloads/en/DeviceDoc/70292G.pdf
Page 189
What is T1CK?

+/-0.5 seconds over 90 minutes is +/-93ppm

You should be good with almost any crystal - although you'll have to watch the initial frequency tolerance.

I'd look at a 32.768Hz watch crystal (connected to secondary oscillator pins), they tend to be something like +/-20ppm intial tolerance and have a well defined temp coefficient. Use the recommended Microchip circuit in the notes and your done.


By chance, do you know where this is?
 
 

Offline Niklas

  • Frequent Contributor
  • **
  • Posts: 395
  • Country: se
Re: Timer with a dsPIC33FJ128GP804
« Reply #8 on: July 11, 2013, 11:57:23 am »
On page 8 in the same datasheet. Look at pins 33 and 34, SOSCI and SOSCO. You can also have a look at the more detailed reference manuals and the code examples available from the product page at
Microchip.

http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en532311#1

Scroll down to Documentation & Software and check sections 11, 37 and 39 and code example CE153.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf