A little DTMF help


Closed Thread
Results 1 to 40 of 49

Hybrid View

  1. #1
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    Travin,

    For starters, in your Select Case section

    change all the

    dtmf = password [0], dtmf = password[1], etc
    to
    password[0] = dtmf, password[1]=dtmf, etc

    otherwise you are setting the dtmf value you just converted to ASCII to some unknown value stored in your uninitialized password array.

    Cheers,

    Paul Borgmeier
    Salt Lake City, Utah USA
    www.cruxanalysis.com

  2. #2
    Join Date
    Feb 2006
    Posts
    89


    Did you find this post helpful? Yes | No

    Default Thanks

    I changed the format, as I had no idea that mattered. However, it still doesn't work. I know for sure that it is decoding the numbers, because it tells me what number is entered verbally. When I placed that section of the code after the select case for the password entry, it stopped telling me the values which leads me to believe the select case statement doesn't work for the passsword portion. Would it be easier if I didn't convert the data to ascii? Thanks for the help. Here is the code I have now if anyone feels like looking at it. Thanks for all the help.

    @ 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
    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:
    High reset
    pause 100
    high ce
    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 20
    gosub play 'play welcome statement
    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 Then dtmf_wait1 ' Loop here until DTMF signal stops
    select_dtmf = 0 ' Disable the MT8870 data output
    low reset
    high reset

    select case c 'places number in an array
    case 0
    password [0]=dtmf
    case 1
    password [1]=dtmf
    case 2
    password [2]=dtmf
    case 3
    password [3]=dtmf
    case 4
    password [4]=dtmf
    case 5
    password [5]=dtmf
    case 6
    password [6]=dtmf
    case 7
    password [7]=dtmf
    end select
    Select case dtmf
    case "1"
    portc = %10010111
    pause 200
    low ce
    pause 200
    High ce
    case "2"
    portc = %10011001
    pause 200
    low ce
    pause 200
    high ce
    case "3"
    portc = %10011011
    pause 200
    low ce
    pause 200
    high ce
    case "4"
    portc = %10011101
    pause 200
    low ce
    pause 200
    high ce
    case "5"
    portc = %10011111
    pause 200
    low ce
    pause 200
    high ce
    case "6"
    portc = %10100001
    pause 200
    low ce
    pause 200
    high ce
    case "7"
    portc = %10100011
    pause 200
    low ce
    pause 200
    high ce
    case "8"
    portc = %10100101
    pause 200
    low ce
    pause 200
    high ce
    case "9"
    portc = %10100111
    pause 200
    low ce
    pause 200
    high ce
    case "0"
    portc = %10101001
    pause 200
    low ce
    pause 200
    high ce
    end select
    c = c + 1
    if c =< 7 then begin
    if password [0] = "1" then
    goto password1
    else
    goto user_password
    endif
    password1:
    if password [1] = "2" then
    goto password2
    else
    goto error
    endif
    password2:
    if password [2] = "3" then
    goto password3
    else
    goto error
    endif
    password3:
    if password [3] = "4" then
    goto password4
    else
    goto error
    endif
    password4:
    if password [4] = "5" then
    goto password5
    else
    goto error
    endif
    password5:
    if password [5] = "6" then
    goto password6
    else
    goto error
    endif
    password6:
    if password [6] = "7" then
    goto password7
    else
    goto error
    endif
    password7:
    if password [7] = "8" then
    goto play_menu_message
    else
    goto error
    endif

    Travin
    Last edited by Travin77; - 22nd May 2006 at 22:01.

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


    Did you find this post helpful? Yes | No

    Arrow

    Your code is very "unoptimal".

    3 Tips:
    Replace the whole "select case"-statement by 1 command:
    password[c]=dtmf

    The if-then-else for checking the password may be shortened:
    if password[1]<>"1" then goto error
    if password[2]<>"2" then goto error
    ...

    and the last select-case-statement could be shortened a lot by placing the low-pause-high-sequence in one part at the end ...



    The datasheet of the mc145436a tells a minimum time of 18us for the Guardtime-input. Maybe they mean the minimum pulselength for reset. Your pulse is to short, PICs are fast !!!
    PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2

  4. #4
    Join Date
    Feb 2006
    Posts
    89


    Did you find this post helpful? Yes | No

    Default Nope

    Well I tried your ideas to much avail, they didn't solve the problem. Its like the program won't compare the parts of the array to constant values. Thanks for the help. I just don't know what else to try. Also, once the password doesn't pass the if then statement, the program should play the error message and advance the variable "e" by one. Instead, the program just jumps back to the beginning and plays the welcome statement. Here is the updated code that still doesn't work. thanks.

    start:
    pause 100
    High reset
    high ce
    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 20
    gosub play 'play welcome statement
    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
    low reset
    high reset

    password[c]=dtmf

    Select case dtmf
    case "1"
    portc = %10010111
    pause 200
    low ce
    pause 200
    High ce
    case "2"
    portc = %10011001
    pause 200
    low ce
    pause 200
    high ce
    case "3"
    portc = %10011011
    pause 200
    low ce
    pause 200
    high ce
    case "4"
    portc = %10011101
    pause 200
    low ce
    pause 200
    high ce
    case "5"
    portc = %10011111
    pause 200
    low ce
    pause 200
    high ce
    case "6"
    portc = %10100001
    pause 200
    low ce
    pause 200
    high ce
    case "7"
    portc = %10100011
    pause 200
    low ce
    pause 200
    high ce
    case "8"
    portc = %10100101
    pause 200
    low ce
    pause 200
    high ce
    case "9"
    portc = %10100111
    pause 200
    low ce
    pause 200
    high ce
    case "0"
    portc = %10101001
    pause 200
    low ce
    pause 200
    high ce
    end select
    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
    portc = %00001000
    pause 20
    gosub play'play error message
    goto begin
    play_menu_message:
    portc = %00010010
    pause 20
    gosub play 'play menu message

    Travin
    Last edited by Travin77; - 23rd May 2006 at 03:39.

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


    Did you find this post helpful? Yes | No

    Default

    "if c =< 7 then begin"

    maybe this must be written "if c<= 7 then begin"
    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
    Oct 2004
    Location
    Hangover, Germany
    Posts
    289


    Did you find this post helpful? Yes | No

    Default

    Only when you are playing the single keys, you use the ce-signal. On all other places, only portc ist filled and then.... ?
    PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2

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