Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > PSoC® 1 > Measuring time with counter on CY8C24123A

Bookmark and Share
Cypress Developer CommunityTM
Forums | Videos | Blogs | Training | Rewards Program | Community Components



Measuring time with counter on CY8C24123A
Moderator:
ARVI

Post Reply
Follow this topic



Measuring time with counter on CY8C24123A

SimonTHK posted on 04 Jan 2013 3:50 PM PST
Member
3 Forum Posts

 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.




Re: Measuring time with counter on CY8C24123A

Bob Marlowe posted on 05 Jan 2013 11:45 PM PST
Top Contributor
1768 Forum Posts

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



Re: Measuring time with counter on CY8C24123A

SimonTHK posted on 05 Jan 2013 02:46 AM PST
Member
3 Forum Posts

 Really :O 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. 



Re: Measuring time with counter on CY8C24123A

danaaknight posted on 05 Jan 2013 04:00 AM PST
Top Contributor
1773 Forum Posts

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.



Re: Measuring time with counter on CY8C24123A

danaaknight posted on 05 Jan 2013 04:05 AM PST
Top Contributor
1773 Forum Posts

More than you want to know on frequency counters, and reciprocal

counters. Attached.

 

Regards, Dana.



Re: Measuring time with counter on CY8C24123A

danaaknight posted on 05 Jan 2013 04:09 AM PST
Top Contributor
1773 Forum Posts

And a PSOC ap note on period counters -

 

http://www.cypress.com/?docID=30074

 

Regards, Dana.



Re: Measuring time with counter on CY8C24123A

SimonTHK posted on 05 Jan 2013 05:15 AM PST
Member
3 Forum Posts

 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



Re: Measuring time with counter on CY8C24123A

MSUR posted on 06 Jan 2013 07:54 PM PST
Cypress Employee
29 Forum Posts

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



Re: Measuring time with counter on CY8C24123A

danaaknight posted on 06 Jan 2013 08:19 PM PST
Top Contributor
1773 Forum Posts

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.






ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Spec No: None; Sunset Owner: GRAA; Secondary Owner: RAIK; Sunset Date: 01/01/20