text
stringlengths
1
330k
3. Count the periods and allocate weighted points into 16 byte result accumulators
4. The accumulator with the highest number is the DTMF Tone, but only if;
5. that number is within a "safe window" to eliminate non-DTMF signals
Sampling only 30 periods takes under 45 mS and complies good enough with the standard minimum DTMF tone length of 51mS. The decoder seems to work well enough to find the highest points to match the DTMF Tone, but a "window" is needed to reject non-DTMF signals like solid tones and complex tones (like voice).
Note! I recorded the 30 periods into RAM, then did post-processing to allocate the weighted points. This was done because I also wanted to chart the results and needed to record them. For a practical decoder the recording is not needed, it can analyse each period easily in real time and only needs the 16 RAM bytes for ...
Results of testing;
The numbers on the right of the display show the 16 result accumulators.
Above is an example of what most of the tones look like, there is a clear winner, in this case it is Tone 10 (852 1477).
Tone 3 (941 1209) shows a clear winner. Again this is pretty typical.
Tone 6 (852 1336) is one of the worst cases, it's reliable enough but there is not a very large safety margin.
Here are the weighted points values I used for the different periods; DTMF_simple_points.c
This is looking promising. Although it is not fully practical, this simple decoder uses no input hardware, very litle ROM, only TMR0 set to a low 16uS resolution, very little RAM, no interrupts, and only needs a slow PIC (assuming it does the weighted points in real time after each period capture). And it gives a worki...
It's not a great decoder but it's working and would be possible even on a 4MHz PIC 10F, 12F or 16F, ie the bottom end PICs!
Decoder version 2 - a major improvement
The simple decoder above is basically just a crude spectrum analyser. All its decoding is based on the number of periods that fall within specific zones, and it JUST has enough information to decode the 16 DTMF Tones.
It occurred to me when making the top waveform diagram on this page that my HI-LO debounce actually performs a crude pattern recognition task as it will only synchronise to certain characteristics of the DTMF waveform. But the benefits of this pattern recognition are largely wasted as the simple decoder above makes no ...
So if the decoder could evaluate the order that the periods were captured in it would provide a lot more data to improve the separation between detecting individual DTMF Tones, and also improve the noise rejection so the decoder can more easily eliminate non-DTMF sounds.
How would this extra pattern recognition work?
Below are the two DTMF tone waveforms that the simple decoder was having some difficulty separating. The captured periods (in purple) are almost identical on each DTMF tone. It was separating the two tones based on the fact that Tone 3 has a lot more of the shorter periods than the longer period, a ratio of about 5:2. ...
Above in Tone 3 you can see the new data, with some "double" periods drawn in orange and brown. These demonstrate the most basic pattern that is present; the 2 consecutive periods.
If we call the short period S and the long period L, most double periods consist of an SL pair with SS pairs too. The frequency of the patterns in Tone 3 is; SL/LS=4, SS=3, LL=0.
Above in Tone 6 the period pairs look very different! They are mostly SL pairs with one LL pair, the pair frequency is; SL/LS=6, SS=0, LL=1.
Making the best of the pattern data
Some system of allocating weighted points for each pattern that appears would quickly identify each DTMF tone signature. However if the points are based mainly on the SL pairs these will be common to more than one tone (see Tone 3 and Tone 6 example above), and also if points are allocated for SS and LL pairs this will...
The first solution I tried was to allocate points for tiplets. Triplets like SSL, LSS will be extremely common in Tone 3, but never appear in Tone 6 which will be full of LSL, SLL and LLS pairs that never appear in Tone 3.
Itentifying triplets can be done extremely fast and efficiently in real time as each new period is captured. It only needs 32 captured periods to make 30 triplets in real time. It should be possible to add weighted points for "good" triplets and maybe subtract weighted points for "bad" triplets. This will give excellen...
I built a DTMF period triplet analyser;
This uses the same hardware as the spectrum analyser, and really it is a triplet sepctrum analyser. It identifies the DTMF tone, then records 1002 periods (1000 triplets) which are then displayed to show how popular the Short and Long periods are, and then the 8 possible triplets.
Here are the triplet analysis results for Tone 3 and Tone 6, the triplets are exactly as predicted by the theory waveform. This is data for 1000 triplets.
Here is data from hardware testing 1000 triplets for each DTMF Tone. It shows periods as Short/Long periods, and shows the most common triplets by percentage;
Tone DTMF pair Short % Long % SSS LLL SSL LSS LLS SLL SLS LSL BAD
0 697 1209 66 29 98 57 9 19 19 20 32
1 770 1209 63.3 43 94 49 10 10 27 32 19
2 852 1209 60.7 58 90.4 39 16 16 39 22 8
3 941 1209 58.1 71 86.5 28 14 28 28 28 1
4 697 1336 62 10 92 77 53 7 7 4 23
5 770 1336 60 27 88.7 66 16 23 23 23 13
6 852 1336 57.6 43 85 56 13 13 29 42 3
7 941 1336 55 58 82 42 16 16 42 26 1
8 697 1477 86 84 114 9 58 10 10 10 11
9 770 1477 56.8 8 83 91 75 8 8 8 1
10 852 1477 54 26 80 73 20 26 26 26 1
11 941 1477 52.1 43 76.9 57 14 14 29 43 1
The triplet pattern recognition seems very reliable! Surprisingly, I did not see one false positive triplet even after many tests.
The only DTMF tones that may cause issues are Tones 4, 8 and 9, these have a very low incidence of one period.
The Black DTMF triplet decoder
1. the debounce system produces 2 distinct periods from any DTMF waveform
2. these 24 specific periods are detected with narrow windows (very high rejection)
3. a "triplet" of the last 3 periods is checked for a match
4. if it matches, it allocates points scores for the 12 DTMF signatures
The algorithm procedure;
1. HI-LO debouncing on the input signal, both must be stable for 220uS
2. Capture the period using TMR0 with resolution 16uS
3. See if that period matches one of the 24 periods in the table,
4. if so, test for a valid triplet and allocate weighted points
5. Repeat 1-4 until 30 triplets have been tested
6. The accumulator with the highest score is the DTMF Tone!
7. (That highest number can be further checked within a window if needed)
Triplet weighted points
The triplets that match a DTMF tone will cause points to be added to the accumulator for that DTMF tone. If a tone is perfect (like in testing above) the points should equal about 150 but they should never be high enough to roll the variable, ie they will always be under 256.
Practical testing
I coded the new DTMF triplet algorithm into the same hardware. It still displays the spectrum analysis of the periods (like the first algorithm) but this is not used for the decoding. Now it uses the period triplet decoding. Some results are shown below.
Tone 3 and Tone 5 are shown.
The display shows the spectrum chart of the 30 period samples, then text showing the periods and the number of periods, and on the right it shows the 12 DTMF points scores.
All 12 DTMF signatures have extremely high separation as seen in the two examples above. Even from a short 45mS sample time, with as little as 32 periods (30 triplets) it looks to be a solid reliable DTMF detection. The particular triplets I chose for the tests have both a Short and Long period so this new decoder is c...
Here is the crude system I used for decoding triplets into weighted points; DTMF_decode_triplet_points.c
Using the decoder
This decoder will run on extremely limited hardware and has the benefit of having very high rejection of non-DTMF waveforms. It is also very open-ended and can be optimised to detect a single DTMF tone (or just a couple of DTMF tones) to save code space. Both these features can make it ideal for a cheap DTMF remote con...
It also forms a companion to my DTMF dual sine generator PIC code, so it provides the ability to use a couple of low-end PICs to do both the DTMF generation and decoding without needing specialty chips.
The strong period filters and pattern recognition should mean that this system will outperform standard analog DTMF decoder ICs and Goertzel systems for rejection of non-DTMF waveforms (ie remote control use), but they will be superior to it for accepting DTMF in a very noisy environment. If needed, my system can be ma...
Optimising the decoder
HI-LO debounce time. This needs to be right around 220uS for best triggering from the DTMF waveform. Also test very often within the 220uS, I used 5uS samples. If this is done right the decoder will detect 2 very dominant periods from any DTMF tone, as seen in examples above.
Period filtering. I used +/- 1 count, so if the period was 80 it would detect 79-81 and reject everything else. This gives a very high rejection of non-DTMF signals. You can go to +/-2 or even more if needed which improves detection in a noisy environment. Just watch for overlap as some tones use similar triplets so th...
Triplet analysing for pattern recognition. You probably don't need to adjust these, my code gives good performance by picking the right triplets to match for each DTMF signature and I have tuned the weighted points for a sample size of 30 triplets, so that's done.
Testing the points result. All you need to do here is find the highest score out of the 12 results, and check it is >X. For my code above >50 would work well.
A working decoder in a PIC 12F675!
As a proof of concept here is a complete project, it is a DTMF remote control decoder using a PIC 12F675 and 8MHz xtal. It would also work with a 4MHz xtal if you change TMR0 to 1:8 prescale. A xtal is recommended as the internal 4MHz osc may not maintain a good enough frequency reference.
It receives DTMF audio into pin GP1 (comparator input) and needs a 0.1uF to 1uF input cap (AC coupling cap). It also needs a 4k7 or 10k resistor from GP1 to ground. That's about it, it works fine with DTMF amplitude from about 0.4v peak to peak to over 2v peak to peak.
This DTMF decoder uses 25 RAM (and the C stack) and 318 ROM. If you need to decode all 12 DTMF tones it will fit in this PICs 1k ROM but you need to reduce or remove the make_beeps() function. I have not tried to shrink any of the code, as that should be quite possible.
All the PIC does is continually test the incoming signal in groups of 60 periods (60 triplets) which takes about 95mS for each group. The triplet decoding and points allocating is done in real time after each period capture and there is plenty of time even on this little PIC.
Two DTMF tones can be detected;
Tone 0 (the phone "1" key) = set output GP0 HI
Tone 7 (the phone "0" key) = set output GP0 LO
Also, after the GPO output has been changed the PIC makes one or two "beeps" confirmation on GP2, these beeps can be to a LED or a speaker to tell the user the signal has been received.
The project will decode any or all of the 12 DTMF tones, but the 10 tones not used are commented out to save ROM and processing time.
It worked very well in testing, and should work for you too provided the DTMF waveform is reasonably clean. If you have dirty DTMF waveform you can clean it up a lot by adding a RC low-pass filter of 1k5 and 0.033uF or 2 filters of 1k2 and 0.033uF. But this should not be needed in most cases as the algorithm itself wil...
An obvious use for this would be as a remote receiver connected to a radio or other audio system, to turn something on or off with a DTMF tone. Likewise it could be used as a phone remote to turn something on-off at home when you ring home from work. However you must check the legality of connecting equipment to the ph...
Here is the MikroC source code for the PIC 16F675;   DTMF_remote.c
Here is the HEX file if you just want to program a PIC;   DTMF_remote.hex
- end -
[Back to Home Page]
Protests in Anaheim Escalate Over Police Shooting of Unarmed Man
Last night, Anaheim residents continued their protests over the the police shooting of two latino men, and seem poised to do so again tonight. Nearly 1,000 people took part in last night's demonstration, which began when 200 residents attended a city council meeting earlier that evening. A larger crower crowd was denie...
The protests are in response to the police's shooting of Manuel Diaz, 25, on Saturday afternoon. Anaheim police spokesman Sgt. Bob Dunn reported the shooting occurred after Diaz ran from police, a charge Diaz's niece doesn't dispute, according to CBS Los Angeles.
His niece, 16-year-old Daisy Gonzalez, said her uncle likely ran away from officers when they approached him because of his past experience with law enforcement. "He (doesn't) like cops. He never liked them because all they do is harass and arrest anyone," Gonzalez said.
Witnesses say Diaz was shot twice, both times from behind.
Another witness described a gruesome scene:
On Sunday, a second man was shot dead by police, which lead to further demonstrations, during which, according to various reports, police lost control of their K-9 dog, which then attacked protesters. Here's video of the incident:
Tuesday afternoon, Diaz's mother, Genevieve Huizar, filed a $50 million wrongful death suit agains the city. After Tuesday's violence, she called for calmer demonstrations: "Let's be peaceful. Peaceful demonstrations for everyone."
Her lawyer, Dana Douglas, echoed Huizar's sentiment, but added: "The police are arresting people who threw rocks and bottles, but not the officers who killed Manuel Diaz. That's not justice."