- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello
So I try to count time using a CY8C24123A
I use an 8bit counter running on 32 khz and make it interrupt at terminal count. Every time it interrupts, I add 1 to an integer, 1 is equal to 0,008s or 8ms.
32000/256=125
1s/125=0,008
But if I try and count 60 seconds, it will count 63 seconds. And the longer I count, the more wrong it will get. 90 will be 94,5
I cant figure out where I can have a problem. The counter is running sync with the processor.
- Labels:
-
PSoC 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The specs in the datasheet tells that accuracy of IMO is +- 5% wich is consistent with the counting error you've got.
To improve accuracy there are two choices coming to my mind:
1st: Using an external oscillator or a 32kHz chrystal
2nd: Calibrating the needed counts/s by measurement and programming the value individually for every device. Here the EEProm usermodule comes in handy to have that information stored
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Really 😮 I allways thought 24mhz would be 24 mhz exactly.
It could be the problem since 5% is 3 sec of 60sec. So it might "fail" like 3-4%.
Thanks for the help, greaaat help.
Ill consider what to do.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your design goals for accuracy, repeatability, set approach and HW you use
to determine design performance. A xtal is most common approach. The next
step up would be to use a precision external osciullator. For even better results
the following is very effective.
One approach to getting very high accuracy is at production test. Basically you
have a routine inside of PSOC that talks to a high precision external freq counter
and feed an onboard PSOC clk to a pin for the external counter to read. GPIB, USB, UART
commonly used to external counter. PSOC drives a testbed heater/cooler, and records
the external counter and onboard die temp values building a table for generation of
the coefficients to a power fit equation. The table or power curve equation then become
the means for interpreting any value read by PSOC timer/counter. This essentially takes
device to device variation out and corrects for temp. Its only drawback is it does not fix
component aging, but that usually is the lesser problem, or can be characterized and
compensated for. Sounds complicated but really quite simple.
The attached pic shows general idea, in this case replace the precision ref source with
a freq cntr. This pic shows approach to correct A/D and Reference accuracy of a PSOC.
This approach is general.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you 🙂
Ofcourse I want it to be effective, but I also need to keep it abit simplified since I do alot different projects. I will use the oscilator idea 🙂
But thanks for your time, it is awesome that i can get such help in here.
Simon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello SimonTHK,
As bob pointed out the issue is because of inaccuracy, but the inaccuracy is around +/- 50% for ILO or 32 KHz clock (IMO has +/- 2.5%). So, you can expect a lot of deviation from the intended time period from device to device and over temperature/voltage range.
And yes, the best solution would be to use an External Crystal Oscillator and use the 32 KHz source. For details on how to use an ECO - refer AN2027 - PSoC® 1 - 32.768 kHz External Crystal Oscillator.
Regards,
MSUR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can also use an external osc feeding a clock to P1_4, in the Mhz range,
24 Mhz for example on a 5V 29xxx type part. See datasheets on other families
for pin and allowed freq in.
http://www.cypress.com/?rID=2773
Regards, Dana.