View previous topic :: View next topic |
Author |
Message |
DaveM Guest
|
Can a frequency be measured on the RB0 interrupt? |
Posted: Mon Dec 15, 2008 9:51 am |
|
|
Hello,
Does anyone know how to measure a frequency on the RB0 interrupt? I am trying to measure the frequency from a square wave generated from a DTMF chip (MT8889). Normally RB0 is used to read the IRQ generated from the chip but the chip also outputs a square wave on the IRQ pin (when in call progress mode).
I know this can be done with the CCP register or with timer1 but I can't use any of these because...one these pins are connected to something else and two the PIC is already on a PCB.
Thanks |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Mon Dec 15, 2008 10:22 am |
|
|
Does this have to be interrupt driven? What else does the PIC have to do while reading the frequency. How about just using B0 as a normal input pin and read any counter on the B0 edges? _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
DaveM Guest
|
Can a frequency be measured on the RB0 interrupt? |
Posted: Mon Dec 15, 2008 10:44 am |
|
|
I am using the interrupt to detect when a valid pin has been received. Nothing else is running except for a timer (used for call duration). But thats the thing... How do I measure the time of the square wave?
The MT8889 outputs a square wave that is proportional to the signal it is analyzing. For instance if a busy signal is detected it will output a square wave that has the same frequency as the busy signal. |
|
|
RLScott
Joined: 10 Jul 2007 Posts: 465
|
Re: Can a frequency be measured on the RB0 interrupt? |
Posted: Mon Dec 15, 2008 11:09 am |
|
|
DaveM wrote: | I am using the interrupt to detect when a valid pin has been received....How do I measure the time of the square wave?
|
At each interrupt, read the timer on the-fly (certain cautions apply). Then subtract one timer reading from the next timer reading and that gives you the time between interrupts. For periods that are longer than the wrap-around time of the timer, other cautions apply. But if that is not possible in your case, then there is no need to worry about it. _________________ Robert Scott
Real-Time Specialties
Embedded Systems Consulting |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1635 Location: Perth, Australia
|
Re: Can a frequency be measured on the RB0 interrupt? |
Posted: Mon Dec 15, 2008 11:27 am |
|
|
DaveM wrote: | I am using the interrupt to detect when a valid pin has been received. Nothing else is running except for a timer (used for call duration). But thats the thing... How do I measure the time of the square wave?
The MT8889 outputs a square wave that is proportional to the signal it is analyzing. For instance if a busy signal is detected it will output a square wave that has the same frequency as the busy signal. |
Another way to do this is to use a time base reference simply count the number of sensor transitions either low to high to high to low that occur during the timer period. When the timer rolls over you then have a count of transitions over the timer period and can derive the frequency from that. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
Ttelmah Guest
|
|
Posted: Tue Dec 16, 2008 5:56 am |
|
|
Multiple key things apply.
First, critical one, the frequencies you are dealing with. If they are low, then you are 'better' measuring time between edges. If they are high, then you are better counting the edges in asystem time interval.
Second, what is your system frequency?. This affects whether it is possibl to do this at all with the RB0. Basically handling interrupts takes _time_, and the amount depends on the processor involved (18 versus 16 chips), and the system clock. Also, is _any other interrupt in use_?.
Now, with those said:
What are you actually trying to do?. The MT8889, is a DTMF generator/receiver.
When acting as a receiver, the unit _does not_ generate a square wave. It outputs the decoded key pattern, in logic form, on a readable internal register.
The only 'square waves', are the decoder output signal, saying that a tone pair has been 'seen', and latter the interrupt signal saying it has been decoded. Neither contains data designed to allow you to decode the tone pair, but just signals that the chip is seeing legitimate tones.
Measuring the frequency of either signal, will only tell you how often tones have been seen, not the data in the tones.....
Best Wishes |
|
|
DaveM Guest
|
Can a frequency be measured on the RB0 interrupt? |
Posted: Tue Dec 16, 2008 3:19 pm |
|
|
Yes the MT8889 does generate a square wave. The MT8889 has a feature called a Call Progress Filter which allows you to monitor an input during a call.
Here is a quote from the data sheet
Quote: | Frequencies presented to the input, which are within the ‘accept’ bandwidth limits of the filter, are
hard-limited by a high gain comparator with the IRQ/CP pin serving as the output. The square-wave output obtained
from the schmitt trigger can be analyzed by a microprocessor or counter arrangement to determine the nature of
the call progress tone being detected. Frequencies which are in the ‘reject’ area will not be detected and
consequently the IRQ/CP pin will remain low. |
I am building an automatic Dialer/Remote. I am using a 16F876A @ 4MHz. I would like to be able to detect signals such as a busy signal etc. during a call. The frequencies the filter is able to detect are low between 300-500 hz. I got the unit functioning and the unit does output a square wave during a call (when the correct registers are set). I'm in the process of trying to read the frequency of the square wave but its a little tricky to get the timing consistent. I am working on suggestions mentioned above. Thanks for all your input by the way. |
|
|
|