| ??? 09/28/01 17:02 Read: times |
#15245 - RE: Frequency Counter |
I have used a rather more complicated method, but it was what my project required. However using my method I could measure frequency highly accurately with a resolution of 0.01Hz, within a range of 8 - 208 Hz
What I did was use a 4 mHz crystal on a AT89c51. I fed the pulses to pin 3.2 (external interrupt 0, edge triggered) and counted the time period between two successive pulses as a 16 bit value in T0 in mode 1. Thus I had the time period as a multiple of 3 microseconds, which I manipulated in a rather complicated series of 16 bit by 8 bit divisions as 1/time period, to give a highly accurate frequency count. However there are readymade 8051 assembly codes available on the net which allow perform even 32 bit division on 8-bit microcontrollers, which could make things easier. If resolution is not your main concern, simply right shift the divisor and dividend until both values become manageable 8-bit values. this method gives a very accurate count 1 Hz. All this leaves the other timer T1 free. This you can configure in gated mode to measure the on-time of the pulse. As San Bergman mentioned, it is then fairly easy to derive the duty cycle, since you now have the timer period as well as on-time The limitation in this method is that @4Mhz, the timer register oveflows below a frequency of 8 Hz. In this case (and also for higher frequencies) I reconfigured T0 as a 1 second timer when an overflow interrupt was generated,and counted the pulses received per second to derive the frequency. There is a problem with gating error here, but that can be eliminated by synchronising the timer with the pulses (timer is started in external interrupt)However, duty cycle measurement in this range is something I can't figure out, unless you use both timers as one, or use a register to count the number of overflows, and use the combination as a 32-bit count I must warn you though that 32-bit divisions on '51 units are difficult to implement Kunal |
| Topic | Author | Date |
| Frequency Counter | 01/01/70 00:00 | |
| RE: Frequency Counter | 01/01/70 00:00 | |
| RE: Frequency Counter | 01/01/70 00:00 | |
| RE: Frequency Counter | 01/01/70 00:00 | |
| RE: Frequency Counter | 01/01/70 00:00 | |
| RE: Frequency Counter | 01/01/70 00:00 | |
| RE: Frequency Counter | 01/01/70 00:00 | |
| RE: Frequency Counter | 01/01/70 00:00 | |
| RE: Frequency Counter | 01/01/70 00:00 | |
| RE: Frequency Counter | 01/01/70 00:00 | |
| RE: Frequency Counter | 01/01/70 00:00 | |
| RE: Frequency Counter | 01/01/70 00:00 | |
| RE: Frequency Counter | 01/01/70 00:00 | |
| plz mail me the code | 01/01/70 00:00 | |
| frequency measure | 01/01/70 00:00 | |
| Frequency measurement (Range .1Hz to .00 | 01/01/70 00:00 | |
RE: Frequency measurement (Range .1Hz to .00 | 01/01/70 00:00 |



