A little DTMF help


Closed Thread
Results 1 to 40 of 49

Hybrid View

  1. #1
    Join Date
    Mar 2006
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    Hello,

    I looked at your code and had a couple of questions you might look into. They are marked with <--
    Hope this is helpfull.

    Keith

    if c <= 7 then begin
    if password [0] <> "1" then user_password ' <-- Why isn't this "then error" ?
    if password [1] <> "2" then error
    if password [2] <> "3" then error
    if password [3] <> "4" then error
    if password [4] <> "5" then error
    if password [5] <> "6" then error
    if password [6] <> "7" then error
    if password [7] <> "8" then
    goto error
    else
    goto play_menu_message ' <-- This is where the code gets to if the password was "12345678" Can you tell if the code ever gets here ?
    endif
    user_password:
    if password [0] <> codeword [0] then error ' <-- The value of codeword[0] is undefined.
    if password [1] <> codeword [1] then error ' <-- The value of codeword[1] is undefined etc.
    if password [2] <> codeword [2] then error
    if password [3] <> codeword [3] then error
    if password [4] <> codeword [4] then error
    if password [5] <> codeword [5] then error
    if password [6] <> codeword [6] then error
    if password [7] <> codeword [7] then error
    goto play_menu_message
    error:
    e = e + 1
    if e >= 2 then end_call <-- someof your code seems to be missing, where is end_call defined ?
    c = 0
    portc = %00001000
    pause 200
    ce = 0
    pause 200
    ce = 1
    goto begin
    play_menu_message:
    portc = %00010010
    pause 200
    ce = 0
    pause 200
    ce = 1
    menu:
    if dtmf_ready = 0 then menu'waits for number to be depressed
    gosub GetDtmf 'gets number

  2. #2
    Join Date
    Feb 2006
    Posts
    89


    Did you find this post helpful? Yes | No

    Default Answers

    As for the LCD, I had the LCD hooked up. All of the decode works. Now, when the number is decoded, the isd25120 chip repeats the number entered. When the program initiates, the welcome statement plays when the user pushes any button. This prompts him to enter a password. The pic starts repeating the digits decoded after 5 digits have been input( for this I have no explanation why). Every tone decoded after is announced perfectly. That section of the code is after the password[c]. So I reason that the tone is being input into the array. When c = 8 the code should compare the array to the constants but it doesn't. It also doesn't play the error message. It allows about 7-8 more characters to be input and then starts over with the welcome message.

    if password [0] <> "1" then user_password ' <-- Why isn't this "then error" ?
    If password[0] doesn't equal "1", then I want the program to check codeword[0] to see if they equal.

    goto play_menu_message ' <-- This is where the code gets to if the password was "12345678" Can you tell if the code ever gets here ?

    As far as I can tell, The code never gets here.

    if password [0] <> codeword [0] then error ' <-- The value of codeword[0] is undefined.
    if password [1] <> codeword [1] then error ' <-- The value of codeword[1] is undefined etc.

    These are undefined because in the play_menu_message the option is given to set this. I will post this section of the code. Here is the entire program:

    @ device pic16F876A, hs_osc, wdt_on, lvp_off, protect_off
    include "MODEDEFS.BAS"
    define OSC 20
    adcon1=7
    trisa.0 = 1
    trisa.1 = 0
    trisa.2 = 0
    trisa.3 = 0
    trisb = %11111111
    trisc = %00000000


    '_________pic to mc145436a assignments______________________

    dtmf_ready VAR PORTA.0 'pin 12 (DV)
    select_dtmf VAR PORTA.1 'pin 3 (Enamble)
    reset VAR PORTA.2 'pin 5 (GT)
    DT0 VAR PORTB.4 'pin 2 (D1)
    DT1 VAR PORTB.5 'pin 1 (D2)
    DT2 VAR PORTB.6 'pin 14 (D4)
    DT3 VAR PORTB.3 'pin 13 (D8)
    ce var portA.3 'pin from isd chip
    '____________________variables____________________ ______

    dtmf VAR byte ' Stores most recent DTMF digit
    dtmf1 var byte
    password var byte [8]
    codeword var byte [8]
    codeword1 var byte [8]
    c var byte
    e var byte

    '___________________Initial Conditions__________________
    start:
    pause 100
    ce = 1
    reset = 1
    low select_dtmf
    c = 0
    e = 0

    loop:
    iF dtmf_ready = 0 Then loop ' Check for DTMF present, if none loop again
    welcome:
    portc = %00000000
    pause 200
    ce = 0
    pause 200
    ce = 1
    begin:
    if dtmf_ready = 0 then begin 'waits for number to be depressed
    select_dtmf = 1 ' Enable the data output from the MT8870
    Pause 1 ' Pause 1 mS to let data settle
    dtmf = 0
    IF DT0 = 1 Then 'Check Input port 0
    dtmf = dtmf + 1
    EndIF
    IF DT1 = 1 Then 'Check Input port 1
    dtmf = dtmf + 2
    EndIF
    IF DT2 = 1 Then 'Check Input port 2
    dtmf = dtmf + 4
    EndIF
    IF DT3 = 1 Then 'Check Input port 3
    dtmf = dtmf + 8
    EndIF
    LookUp dtmf,["_1234567890*#"],dtmf
    dtmf_wait1:
    IF dtmf_ready = 1 Then dtmf_wait1 ' Loop here until DTMF signal stops
    select_dtmf = 0 ' Disable the MT8870 data output
    reset = 0
    reset = 1

    password[c]=dtmf

    Select case dtmf
    case "1"
    portc = %10010111
    case "2"
    portc = %10011001
    case "3"
    portc = %10011011
    case "4"
    portc = %10011101
    case "5"
    portc = %10011111
    case "6"
    portc = %10100001
    case "7"
    portc = %10100011
    case "8"
    portc = %10100101
    case "9"
    portc = %10100111
    case "0"
    portc = %10101001
    end select
    pause 200
    ce = 0
    pause 200
    ce = 1
    c = c + 1
    if c <= 7 then begin
    if password [0] <> "1" then user_password
    if password [1] <> "2" then error
    if password [2] <> "3" then error
    if password [3] <> "4" then error
    if password [4] <> "5" then error
    if password [5] <> "6" then error
    if password [6] <> "7" then error
    if password [7] <> "8" then
    goto error
    else
    goto play_menu_message
    endif
    user_password:
    if password [0] <> codeword [0] then error
    if password [1] <> codeword [1] then error
    if password [2] <> codeword [2] then error
    if password [3] <> codeword [3] then error
    if password [4] <> codeword [4] then error
    if password [5] <> codeword [5] then error
    if password [6] <> codeword [6] then error
    if password [7] <> codeword [7] then error
    goto play_menu_message
    error:
    e = e + 1
    if e >= 2 then end_call
    c = 0
    portc = %00001000
    pause 200
    ce = 0
    pause 200
    ce = 1
    goto begin
    play_menu_message:
    portc = %00010010
    pause 200
    ce = 0
    pause 200
    ce = 1
    menu:
    if dtmf_ready = 0 then menu'waits for number to be depressed
    gosub GetDtmf 'gets number

    If dtmf = "1" then set_password
    else
    goto play_menu_message:
    endif

    set_password:
    c = 0
    portc = %01100101
    pause 20
    gosub play 'play enter password message
    hold:
    if dtmf_ready = 0 then hold
    gosub getdtmf
    codeword[c] = dtmf
    c = c + 1
    if c =< 7 then hold
    c = 0
    portc = %11011010
    pause 20
    gosub play 'play re-enter password message
    hold1:
    if dtmf_ready = 0 then hold1
    gosub getdtmf
    codeword1[c]=dtmf
    c = c + 1
    if c =< 7 then hold1
    if codeword[0] <> codeword1[0] then password_entry_error
    if codeword[1] <> codeword1[1] then password_entry_error
    if codeword[2] <> codeword1[2] then password_entry_error
    if codeword[3] <> codeword1[3] then password_entry_error
    if codeword[4] <> codeword1[4] then password_entry_error
    if codeword[5] <> codeword1[5] then password_entry_error
    if codeword[6] <> codeword1[6] then password_entry_error
    if codeword[7] <> codeword1[7] then password_entry_error
    password_correct:
    portc = %01111110
    pause 20
    gosub play 'play password has been changed message
    pause 3000
    goto play_menu_message
    password_entry_error:
    portc = %01110101
    pause 20
    gosub play 'plays entries do not match
    pause 3000
    goto play_menu_message
    end_call:
    portc = %10010001
    pause 20
    gosub play'play finish message
    goto start
    play:
    ce = 0
    pause 200
    ce = 1
    return
    GetDtmf:
    select_dtmf = 1 ' Enable the data output from the MT8870
    Pause 1 ' Pause 1 mS to let data settle
    dtmf = 0
    IF DT0 = 1 Then 'Check Input port 0
    dtmf = dtmf + 1
    EndIF
    IF DT1 = 1 Then 'Check Input port 1
    dtmf = dtmf + 2
    EndIF
    IF DT2 = 1 Then 'Check Input port 2
    dtmf = dtmf + 4
    EndIF
    IF DT3 = 1 Then 'Check Input port 3
    dtmf = dtmf + 8
    EndIF
    LookUp dtmf,["_1234567890*#"],dtmf
    dtmf_wait:
    IF dtmf_ready = 0 Then dtmf_wait ' Loop here until DTMF signal stops
    select_dtmf = 0 ' Disable the MT8870 data output
    reset = 0
    reset = 1
    Select case dtmf
    case "1"
    portc = %10010111
    case "2"
    portc = %10011001
    case "3"
    portc = %10011011
    case "4"
    portc = %10011101
    case "5"
    portc = %10011111
    case "6"
    portc = %10100001
    case "7"
    portc = %10100011
    case "8"
    portc = %10100101
    case "9"
    portc = %10100111
    case "0"
    portc = %10101001
    end select
    pause 200
    ce = 0
    pause 200
    ce = 1
    return
    Last edited by Travin77; - 25th May 2006 at 22:30.

  3. #3
    Join Date
    May 2005
    Location
    San Diego, CA
    Posts
    8


    Did you find this post helpful? Yes | No

    Lightbulb A couple of things

    After your program senses the first button push, your isd25120 message plays, but you are not cycling out that button push, you are going straight to another loop (BEGIN).

    loop:
    iF dtmf_ready = 0 Then loop ' Check for DTMF present, if none loop again
    welcome:
    portc = %00000000
    pause 200
    ce = 0
    pause 200
    ce = 1
    begin:
    if dtmf_ready = 0 then begin 'waits for number to be depressed

    Try adding the following just after ( ce = 1 ) and just before ( begin: ) :

    select_dtmf = 1 ' Enable the data output from the MT8870
    Pause 1 ' Pause 1 mS to let data settle
    dtmf_wait2:
    IF dtmf_ready = 1 Then dtmf_wait2 ' Loop here until DTMF signal stops
    select_dtmf = 0 ' Disable the MT8870 data output
    reset = 0
    pause 100
    reset = 1

    Also, lower down in the program you have more than once:

    reset = 0
    reset = 1

    That is a very fast blip to the GT pin. Try giving it a chance to see it!

    Add a PAUSE 100 between the trasistion.

    reset = 0
    pause 100
    reset = 1

    You probably notice I added this pause in the upper portion of the program too!

    I am still trying to figure out how the routines for the password work, that sure is some creative programming! Maybe some comments beside them would help others (and me) understand it. (Or is it just me?) It does compile, but not sure how it works, or even it it does?!

    Hope this helps
    Last edited by Wink; - 26th May 2006 at 07:13.

  4. #4
    Join Date
    May 2005
    Location
    San Diego, CA
    Posts
    8


    Did you find this post helpful? Yes | No

    Lightbulb A couple of things

    After your program senses the first button push, your isd25120 message plays, but you are not cycling out that button push, you are going straight to another loop (BEGIN).

    loop:
    iF dtmf_ready = 0 Then loop ' Check for DTMF present, if none loop again
    welcome:
    portc = %00000000
    pause 200
    ce = 0
    pause 200
    ce = 1
    begin:
    if dtmf_ready = 0 then begin 'waits for number to be depressed

    Try adding the following just after (ce = 1) and just before (begin:

    select_dtmf = 1 ' Enable the data output from the MT8870
    Pause 1 ' Pause 1 mS to let data settle
    dtmf_wait2:
    IF dtmf_ready = 1 Then dtmf_wait1 ' Loop here until DTMF signal stops
    select_dtmf = 0 ' Disable the MT8870 data output
    reset = 0
    pause 100
    reset = 1

    Also, lower down in the program you have a couple of times:

    reset = 0
    reset = 1

    That is a very fast blip to the GT pin. Try giving it a chance to see it!

    Add a PAUSE 100 between the trasistion.

    reset = 0
    pause 100
    reset = 1

    You probably notice I added this pause in the upper portion of the program too!

    I am still trying to figure out how the routines for the password work, that sure is some creative programming! Maybe some comments beside them would help others (and me) understand it. (Or is it just me?) It does compile, but not sure how it works, or even it it does?!

    Hope this helps

  5. #5
    Join Date
    Feb 2006
    Posts
    89


    Did you find this post helpful? Yes | No

    Default Password theory

    Here was my logic (if you can call it that) for the password:

    In the beginning, I make an array (password[8])
    After the welcome message plays, the pic waits for a tone. Once it sees the tone, it is decoded and placed in "password[c]=dtmf", where c is initially "0".
    The program then advances c ( c = c + 1) and compares it to this statement "if c <= 7 then begin". Since c is only at 1, the program goes back up to wait for another tone. Once that tone is decoded, it places it in password[c], which this time is password[1] since c = 1. This goes on until all eight sections of the array are filled, in other words "c = 8". The program then goes to the next part of the program:

    if password [0] <> "1" then error
    if password [1] <> "2" then error
    if password [2] <> "3" then error
    if password [3] <> "4" then error
    if password [4] <> "5" then error
    if password [5] <> "6" then error
    if password [6] <> "7" then error
    if password [7] <> "8" then
    goto error
    else
    goto play_menu_message
    endif

    each section of the array is compared to a hard coded value. If any of the single sections of the array fail the comparison, the program skips to the error routine. That is how it is supposed to work, however, at this point it doesn't work yet. Thanks for the advice.

    Travin

  6. #6
    Join Date
    May 2005
    Location
    San Diego, CA
    Posts
    8


    Did you find this post helpful? Yes | No

    Cool To pinpoint

    So I understand, does the following section play a sound for each number that is pressed? If so, does it work? Or is the problem before this section of code?

    Select case dtmf
    case "1"
    portc = %10010111
    case "2"
    portc = %10011001
    case "3"
    portc = %10011011
    case "4"
    portc = %10011101
    case "5"
    portc = %10011111
    case "6"
    portc = %10100001
    case "7"
    portc = %10100011
    case "8"
    portc = %10100101
    case "9"
    portc = %10100111
    case "0"
    portc = %10101001
    end select
    pause 200
    ce = 0
    pause 200
    ce = 1

  7. #7
    Join Date
    Feb 2006
    Posts
    89


    Did you find this post helpful? Yes | No

    Default Sorta

    Yes, those are the addresses for the individual number sounds on the isd25120.
    This section works sometimes, allow me to explain.

    I call the pic and the phone answers.
    I press any button and the welcome message plays.
    I start entering my password (1,2,3,4,5,6,7,8)
    On the first try, I do not have a verbal reply until after the number 5 is decoded. Everytime after it works like a champ. Then randomly, the welcome menu message plays. Once it plays, I enter the password again, this time I have a verbal response everytime. Once all eight numbers are entered, the program should play the menu message, but it doesn't happen. I just press a few more numbers and then we start all over at the welcome message. I am boggled. I thought it may be the power supply, but I have caps on the pic, the op amp (lm 741), and the dtmf decoder. I know all the sound recordings work as I wrote a program to verify that. I know the decode sequence works as well as I have checked this out as well. It is this damn password and array that seems to be the problem. Thanks.

    Travin

  8. #8
    Join Date
    May 2005
    Location
    San Diego, CA
    Posts
    8


    Did you find this post helpful? Yes | No

    Cool Array format

    Remove the spaces in your arrays and see if this changes anything.

    For example, change this (and others). . .

    if password [0] <> "1" then user_password
    if password [1] <> "2" then error
    if password [2] <> "3" then error
    if password [3] <> "4" then error
    if password [4] <> "5" then error
    if password [5] <> "6" then error
    if password [6] <> "7" then error
    if password [7] <> "8" then
    goto error


    to this. . .

    if password[0] <> "1" then user_password
    if password[1] <> "2" then error
    if password[2] <> "3" then error
    if password[3] <> "4" then error
    if password[4] <> "5" then error
    if password[5] <> "6" then error
    if password[6] <> "7" then error
    if password[7] <> "8" then
    goto error

    and also change this (and others). . .

    password var byte [8]
    codeword var byte [8]
    codeword1 var byte [8]


    to this . . .

    password var byte[8]
    codeword var byte[8]
    codeword1 var byte[8]

    I always thought that they had to be together without a space, but I could be wrong. Doesn’t hurt to try it.

    Let me know.

Similar Threads

  1. DTMF on a 12V car system
    By Jumper in forum Schematics
    Replies: 1
    Last Post: - 7th December 2008, 15:41
  2. DTMF output
    By din_kt in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 28th February 2008, 15:24
  3. DTMF Decoding?
    By muddy0409 in forum General
    Replies: 1
    Last Post: - 19th December 2007, 16:28
  4. Replies: 2
    Last Post: - 31st July 2006, 17:06
  5. Problems with DTMF Generatiom
    By Angus Anderson in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 30th May 2006, 22:12

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts