??? 07/22/09 11:05 Modified: 07/22/09 13:45 Read: times Msg Score: +1 +1 Good Answer/Helpful |
#167684 - Find prescaler. Then find time period. Then multiply count. Responding to: ???'s previous message |
If you are fine with so low precision, then it is enough to have a divider that can handle that frequency.
If you divide by 128, and let the processor count number of cycles in a second, you can then multiply the counted value with 128 before presenting. Just remember that resolution and precision are separate. Your presented value will be truncated to nearest 128. And your precision will be affected by the timing of the chip, i.e. the precision of your "one second". If 100kHz resolution is enough, then 2.5GHz / 100k = 25000 which means that you need 5 digits to present the answer. 2.5GHz / 128 is about 20MHz so your chip must be able to count at this speed. With 1s interval, you will measure up to 20M ticks, and each tick would represent 128Hz. You need to keep track of overflows if you only have a 16-bit counter. With 0.1s interval, you will measure up to 2M ticks, and each tick would represent 1280Hz. With 0.01s interval, you will measure up to 200k ticks, and each tick would represent 12.8kHz. With 0.001s interval, you will measure up to 20k ticks, and each tick would represent 128kHz which doesn't fulfill your resolution requirements. With 0.128s interval (=128*0.001), you will measure up to 2.5M ticks, and each tick would represent 1kHz. With 0.0128s interval, you will measure up to 250k ticks, and each tick would represent 10kHz. As you can see, you must use a big enough divider that the processor can handle the frequency. Then you can decide how long interval to count. Your prescaler and your time interval will then decide the multiplication factor to convert count to frequency. If prescaler and time period matches on a ten-potence, then you will not need to multiply. You can directly present the count with one or more zeros subpressed at the end. Remember that a prescaler rounds to zero, i.e. at the end of the time interval, the prescaler is probably not zero. If the prescaler is reset on start of counting, you will on average get a 0.5 tick error. If the prescaler isn't reset, you will get a symmetrical error. Edit: fixed spelling. |
Topic | Author | Date |
Frequency Counter using prescaler | 01/01/70 00:00 | |
Find prescaler. Then find time period. Then multiply count. | 01/01/70 00:00 | |
Think about crystal stability | 01/01/70 00:00 | |
Oscillator candidate | 01/01/70 00:00 | |
i wish that would become clear to the majority | 01/01/70 00:00 | |
0.1 % | 01/01/70 00:00 | |
I'm sorry? | 01/01/70 00:00 | |
i'm sorry | 01/01/70 00:00 | |
Clearer now | 01/01/70 00:00 | |
Dividers increase the error, but... | 01/01/70 00:00 | |
if extreme precision is required ... | 01/01/70 00:00 | |
or count more seconds | 01/01/70 00:00 | |
Remember resolution != precision :) | 01/01/70 00:00 | |
Excellent - responses thanks so much![]() | 01/01/70 00:00 |