Shop OBEX P1 Docs P2 Docs Learn Events
DTMF decode question — Parallax Forums

DTMF decode question

lfreezelfreeze Posts: 174
edited 2005-03-17 06:15 in BASIC Stamp
I am using a bs2 to generate dtmf. I am using an cm8870 receiver to decode
the dtmf. All works well with with exception of dtmf "0", "1" or "11". I tried
replacing all the components including the stamp. The result is always the
same. The dtmf all decode correctly with the exception "0", "1" or "11"
I tried a couple of cap filters (.1 uf to .001 uf ) with no luck.
Can anyone help. I've reached the point where I am going to try a
different decode chip, but would rather avoid the time and expense
I tried the California Micro devices website, but they do not offer technical
help.
Hope someone can help
Thanks.......

Larry

Comments

  • RickBRickB Posts: 395
    edited 2005-03-15 16:29
    Do you have the data sheet? Have you verified that the the dtmf burst length gap length are not too short? Can you post the code? Also, there is no code for "11" in dtmf. Are you refering to binary 0011 which = bcd 3. Need more info.

    Rick
  • lfreezelfreeze Posts: 174
    edited 2005-03-15 17:13
    Rick,
    thanks for the response. Yes I have the data sheet. I played with various gap lengths
    but it did not help.· The binary values and freqs for the ones that are causing problems are:

    freq-low······· freq-high······· binary value······ key
    697·············· 1209············· 0001················· 0
    941·············· 1336············· 1010················· 1
    941·············· 1209············· 1011················· *
    This info was extracted from the cm8870 data sheet

    HERE IS THE CODE i AM USING


    'FIRST STAMP GENERATES DTMF TONES

    top

    ·'dtmfout 9,300,300,[noparse][[/noparse]0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]

    dtmfout 9,500,500,[noparse][[/noparse]1,1,1]

    pause 1000

    dtmfout 9,500,500,[noparse][[/noparse]0,0,0]

    pause 1000

    goto top



    'SECOND STAMP SET UP TO READ DTMF GENERATED BY FIRST

    top

    debug " ",dec inc, " ",bin inc, cr

    pause 1000

    goto top


    ·
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-03-15 17:30
    Have you tried FREQOUT to isolate what the filter is doing? Since it gives you control over the two frequencies, you can experiment with it to give you a better idea of what's happening in your circuit.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • lfreezelfreeze Posts: 174
    edited 2005-03-15 18:23
    I have not tried freqout. I thought that freqout would provide a harmonic of the
    dual tones. I'll look at the manual and try it.
    Thanks ...

    Larry
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-03-15 18:50
    In actual fact, DTMF is a specialized version of FREQOUT.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • JeffreyJeffrey Posts: 9
    edited 2005-03-15 19:13
    Hi,

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}

    Spkr PIN 10 ' Speaker / amplifier pin
    Freq1 VAR Word
    Freq2 VAR Word
    digit VAR Byte ' DTMF digit
    eePtr VAR Byte ' EEPROM pointer

    Phone DATA "", 0 ' Phone #

    eePtr = Phone
    Dial_Phone:
    DEBUG "Calling: "
    DO
    READ eePtr, digit ' read a digit
    eePtr = eePtr + 1 ' update eePtr pointer
    IF (digit = 0) THEN EXIT ' when zero, number is done
    IF (digit >= "0") AND (digit <= "9") THEN
    DEBUG digit
    digit = digit - 48
    GOSUB DTMF
    ENDIF
    LOOP
    DEBUG CR, CR
    END

    DTMF:
    IF (Digit = 0) THEN
    Freq1 = 934
    ENDIF
    IF (Digit >= 7) AND (Digit <= 9) THEN
    Freq1 = 845
    ENDIF
    IF (Digit >= 4) AND (Digit <= 6) THEN
    Freq1 = 763
    ENDIF
    IF (Digit >= 1) AND (Digit <= 3) THEN
    Freq1 = 690
    ENDIF
    IF (Digit = 1) OR (Digit = 4) OR (Digit = 7) THEN
    Freq2 = 1202
    ENDIF
    IF (Digit = 2) OR (Digit = 5) OR (Digit = 8) OR (Digit = 0) THEN
    Freq2 = 1329
    ENDIF
    IF (Digit = 3) OR (Digit = 6) OR (Digit = 9) THEN
    Freq2 = 1468
    ENDIF
    FREQOUT Spkr, 150, Freq1, Freq2
    PAUSE 45
    RETURN


    Post Edited (Jeffrey) : 3/15/2005 7:17:27 PM GMT
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-03-15 20:24
    Let me give you another strategy for converting a character or digit to DTMF tones for FREQOUT -- this method puts the tones in a table so that the code is easier to edit/update.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • RickBRickB Posts: 395
    edited 2005-03-16 06:42
    Larry:
    I don't see any code to read the data valid (StD) pin or the 4 data lines. Is the code for the 2nd bs2 complete? Something is missing.

    Rick
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2005-03-16 07:51
    Rick -

    The "INC" will grab the four data pins and diplay it in binary (presuming it's wired correctly), but indeed the data valid is not picked up as far as I can see. I can see how it could be overlooked, as StD is hardly mentioned in the datasheet.

    Regards,

    Bruce Bates
  • RickBRickB Posts: 395
    edited 2005-03-16 15:35
    I do believe I see the light regarding the inc var in the debug statement. (amazing, what coffee and a shower will do) I think the problem is in the lack of monitoring the data valid pin. That pin should be polled untill it goes high. Then execute the debug statement. Then monitor the data valid pin untill it goes low, note that, and then look for a high again and execute debug statement. You need to do this to know when one dtmf burst ends and another begins. With the artificial example, it almost works, but not quite. In the real world with real data rates, not checking the data valid pin is a no no.
    In the real world, the next tone burst may arrive before the stamp can finish the debug statement depending on baud rate and dtmf rep rate.
    Rick

    Post Edited (RickB) : 3/16/2005 5:00:27 PM GMT
  • lfreezelfreeze Posts: 174
    edited 2005-03-16 17:49
    I think I made a simple dumb assumption with the problem I described.
    After scratching my head for several hours it dawned on me the
    binary decoded values were all correct. The debug was showing
    the correct decimal value for the binary number that was decoded.
    What I need to create is a debug statement that will show the dtmf number and the decimal value.
    The table below shows the values I got when running my program for·dtmf 3,0,7, and 10.

    DTMF from stamp----debug shows dec value·----debug shows binary value·

    ········ 3························ 3······································ 0011
    ········ 0························ 10···································· 1010
    ········ 7·························7······································ 0111
    ········ 10······················ 11····································· 1011
    · The program I am using to read the dtmf is:


    top

    code var byte

    code=inc

    if in14=0 then hhhh 'std of cm8870

    goto top

    hhhh

    if in14=0 then decode

    goto top

    decode

    debug " ",dec code," ",bin code,cr

    goto top

    ·Thank you for all the help....
    LArry

    ·
  • duckieduckie Posts: 12
    edited 2005-03-17 06:15
    Hi!

    Point of interest. I'm pretty sure DTMF has 16 tones, but only 12 are used by most systems, like a telephone, has 0 though 9 and then # and * The other 4 tones are reserved in phone systems for system functions.
Sign In or Register to comment.