A little DTMF help


Closed Thread
Results 1 to 40 of 49

Hybrid View

  1. #1
    Join Date
    Oct 2004
    Location
    Hangover, Germany
    Posts
    289


    Did you find this post helpful? Yes | No

    Arrow

    Just do some debugging !


    1. Put the speaking of the single digits in a subroutine.

    2. After collecting 8 digits, play each digit (with a pause!) through this subroutine in order to check the collected password.

    3. put some LEDs to the PIC in order to see the handshakes from your chips.

    4. fill the password by hardcoding:
    After collecting 8 digits insert:
    Password[0]="1"
    Password[1]="2"...

    I think, you are loosing digits, or there is some noise, so you get whorse digits.
    PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2

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


    Did you find this post helpful? Yes | No

    Cool Had a thought

    I had a thought, but over looked the lookup command
    Last edited by Wink; - 27th May 2006 at 16:42.

  3. #3
    Join Date
    Feb 2006
    Posts
    89


    Did you find this post helpful? Yes | No

    Default Interesting results

    I changed the loop at the beginning from its original to a repeat:until loop. This didn't change anything. So, I made a rountine that allows the entry of 8 digits to be input. It then speaks them back to me. They are sometimes different than what I pressed into the keypad. Most of the mistakes are duplicates. All things being equal, that still doesn't explain why the error message doesn't play in the normal program. I guess I need to "debounce" the input section of the code with the software, but I am not sure how. Any ideas other than a whole lot of pauses? Thanks for the help. Here is the code I used:

    @ 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
    select_dtmf = 0
    c = 0
    e = 0

    loop:
    iF dtmf_ready = 1 Then
    goto welcome
    else
    goto loop
    endif
    welcome:
    portc = %00000000
    pause 20
    ce = 0
    pause 20
    ce = 1
    pause 2000
    c = 0
    repeat
    begin:
    if dtmf_ready = 0 then begin 'waits for number to be depressed
    select_dtmf = 1 ' Enable the data output from the MT8870
    Pause 10 ' Pause 100 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
    reset = 0
    PAUSEUS 30 ' Hold GT for > 18mS
    reset = 1
    select_dtmf = 0 ' Disable the MT8870 data output
    PAUSEUS 400 ' Allows time for DV transition

    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 20
    ce = 0
    pause 20
    ce = 1
    c = c + 1
    until c > 7
    Select case password[0]
    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 20
    ce = 0
    pause 20
    ce = 1
    pause 1500
    Select case password[1]
    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 20
    ce = 0
    pause 20
    ce = 1
    pause 1500
    Select case password[2]
    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 20
    ce = 0
    pause 20
    ce = 1
    pause 1500
    Select case password[3]
    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 20
    ce = 0
    pause 20
    ce = 1
    pause 1500
    Select case password[4]
    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 20
    ce = 0
    pause 20
    ce = 1
    pause 1500
    Select case password[5]
    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 20
    ce = 0
    pause 20
    ce = 1
    pause 1500
    Select case password[6]
    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 20
    ce = 0
    pause 20
    ce = 1
    pause 1500
    Select case password[7]
    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 20
    ce = 0
    pause 20
    ce = 1
    pause 1500
    goto start

    Travin

    P.S. I also added another 1600ma 4.5v power source in parallel to make sure that power wasn't an issue.
    Last edited by Travin77; - 27th May 2006 at 17:32.

  4. #4
    Join Date
    Feb 2006
    Posts
    89


    Did you find this post helpful? Yes | No

    Default Cause of errors?

    If you hold the numbers depressed too long, the program puts the same number in the next array space. So, I am going to have to revisit the decode section. It is interesting that the dtmf chip is disabled at the time of data entry of the decoded number into the array. Also, only one verbal response plays.

    Travin

    No need to post a reply to myself. I debounced the software with a Pause 500 just before "until c > 7", and it worked like a champ. I tried several different pauses during tone entry and never had another repeat. So, thinking I had it solved, I placed the corrected code into the original code and whalla, the same problem. So, I guess the if then statements on the password section are bunk. It still won't play the error message if the entry is wrong, it won't go to the menu message if the entry is right, and it still starts over after pressing a random number of buttons on the phone after all eight digits of the password have been input.
    Last edited by Travin77; - 27th May 2006 at 18:22.

  5. #5
    Join Date
    Oct 2004
    Location
    Hangover, Germany
    Posts
    289


    Did you find this post helpful? Yes | No

    Default

    You wrote:

    reset = 0
    PAUSEUS 30 ' Hold GT for > 18mS
    reset = 1


    Remember, you wrote a 30uS pause, but you need a 18mS pause !



    PS: How to write your Programm in 40 lines ?
    PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2

  6. #6
    Join Date
    Feb 2006
    Posts
    89


    Did you find this post helpful? Yes | No

    Default Thanks

    Thanks for the catch. I guess I just wasn't careful. I know my program is incredibally long for something so easy, I just figured since the pic couldn't do something as simple as play the damn error message or menu message, why should I trust it to jump to a subroutine. I figure my next step is to start removing chips from the equation. I am going to hook up the ol LCD screen and use the lcdout command instead of the audio. That way I can try to se if what is going on visually.

    Travin
    Last edited by Travin77; - 27th May 2006 at 19:59.

  7. #7
    Join Date
    Oct 2004
    Location
    Hangover, Germany
    Posts
    289


    Did you find this post helpful? Yes | No

    Default

    You wrote:

    DT0 VAR PORTB.4 'pin 2 (D1)
    DT1 VAR PORTB.5 'pin 1 (D2)

    out of the manual of the chip, I think you have mixed up Pin1 and Pin2.
    PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2

  8. #8
    Join Date
    Feb 2006
    Posts
    89


    Did you find this post helpful? Yes | No

    Default Confusing

    Those pins are correct. I used someone elses code off of this forum and never updated the note. There is now no problem with decoding or the tone entry into the array as far as I can tell. I tried about twenty different combonations leaving the keys pressed for different amounts of time and every time it played back without any problems. The only change I made was the pause 500 before "until c > 7", which solved the entry problem Now the issue seems to be the if password[0] <> "1" then error. I am not sure why but it can't manange to do something that simple.

  9. #9
    Join Date
    Oct 2004
    Location
    Hangover, Germany
    Posts
    289


    Did you find this post helpful? Yes | No

    Talking

    maybe:

    @ device pic16F876A, hs_osc, wdt_on, lvp_off, protect_off

    include "MODEDEFS.BAS"
    define OSC 20
    adcon1=7
    trisc = %00000000

    '_________pic to mc145436a assignments______________________
    dtmf_ready VAR PORTA.0 'pin 12 (DV)
    select_dtmf VAR PORTA.1 'pin 3 (Enable)
    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:high ce:high reset:Low select_dtmf:e = 0
    repeat
    until dtmf_ready
    portc = %00000000:ce = 0: pause 20:ce = 1: pause 2000:c = 0
    repeat
    Repeat
    until dtmf_ready 'waits for number to be depressed
    select_dtmf = 1 ' Enable the data output from the MT8870
    dtmf = 0:dtmf.0=DT0:dtmf.1=DT1:dtmf.2=DT2:dtmf.3=DT3
    LookUp dtmf,["_1234567890*#"],dtmfassword[c]=dtmf
    Repeat : until dtmf_ready=0 ' Loop here until DTMF signal stops
    reset = 0: PAUSEUS 30:Reset=1 ' Hold GT for > 18mS
    select_dtmf = 0 ' Disable the MT8870 data output
    gosub Output_DTMF:c = c + 1
    until c > 7
    c=0:repeat:dtmf=password[c]:gosub output_DTMF: Pause 1000:c=c+1:until c>7
    goto start
    end

    Output_DTMF:
    Lookup dtmf-"0",[%10101001,%10010111,%10011001,%10011011,%10011101, %10011111,%10100001,%10100011,%10100101,%10100111],PortC
    pause 1:ce = 0: pause 1:ce = 1
    return
    Last edited by BigWumpus; - 27th May 2006 at 20:37.
    PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2

  10. #10
    Join Date
    Feb 2006
    Posts
    89


    Did you find this post helpful? Yes | No

    Default Errors

    Your code compiles with errors. I don't quite understand it enough to change either. it doesn't like you lookup table, either of them. Also, it apprears you may have an extra repeat so I removed it. Thanks for the code, I am going to fiddle with it for a while.

    Travin

    I see know what you were doing. My compiler says it is missing an end block on the repeat.
    Last edited by Travin77; - 27th May 2006 at 20:39.

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