Rotary Dial to DTMF


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Aug 2003
    Posts
    985

    Default Rotary Dial to DTMF

    Hi Guys,
    Did this just for kicks.. and I got an old phone.
    Apparently there's a commercial product for it called "RotoTone",
    and is legal in some countries, and not others.

    Works both ways.. either buffer the entire phone number first, or pass digit at a time.

    Last edited by Art; - 17th November 2013 at 10:41.

  2. #2
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: Rotary Dial to DTMF

    Source:

    Code:
    '
    '***********************************************************************************
    '*                                                                                 *
    '*                                 Telephony                                       *
    '*                          Rotary to DTMF converter                               *
    '*                        Microchip Pic 16F628 @ 8MHz                              *
    '*                              (c) Art 2013                                       *
    '*                                                                                 *
    '*                          [email protected]                               *
    '*                                                                                 *
    '***********************************************************************************
    '
    '
    DEFINE OSC 20								' but we are really using 8 MHz
    DEFINE NO_CLRWDT							' watchdog is cleared manually
    LCD_DATAUS CON 50							' LCD timing
    LCD_COMMANDUS CON 2000						'
    '
    DATA  " Art 2013 " ' Rotary to DTMF - (c) Brek Martin 2013
    '
    '
    number var byte[18]	' number entry array
    fnum var byte[18]	' phone number array
    digcnt var byte		' phone number entry counter
    fcount var byte		' phone number digit counter
    i var byte			' counter
    digit var byte		' dtmf digit
    pulses var byte 	' rotary pulse count
    tcount var word 	' cycle counter
    shiftcount var word	' timer to accept a phone number digit
    longcount var word	' timer to dial DTMF number
    emergency var bit 	' emergency speed dial status
    pressed var bit		' hangup  button status
    donedtmf var bit	' dialed number status
    '
    '
    ' execution time!
    '
    '
    '
    CMCON = 7	' set portb to digital
    trisb.6 = 0	' set LCD backlight output
    trisb.4 = 0	' set DTMF output
    trisb.5 = 1	' set button input
    portb.6 = 1	' turn on LCD backlight
    '
    '
    PAUSE 500			'pause for LCD to start
    @ clrwdt			; clear watchdog timer manually
    PAUSE 500			'
    @ clrwdt			;
    PAUSE 200			'
    '
    LCDOUT $FE,$80
    LCDOUT "  ROTARTY DIAL  "
    LCDOUT $FE,$C0
    LCDOUT " DTMF CONVERTER "
    '
    PAUSE 500			'pause to display message
    @ clrwdt			; clear watchdog timer manually
    PAUSE 500			'
    @ clrwdt			;
    PAUSE 300			'
    '
    
    '
    resetx:
    donedtmf = 0	' reset status
    emergency = 0	' reset emergency speed dial
    reset:
    digit = 0	' reset digit variable
    digcnt = 0	' reset phone number entry counter
    pulses = 0	' reset pulse count
    tcount = 0	' reset cycle counter
    fcount = 0	' reset phone number digit counter
    shiftcount = 0 ' reset digit accept timer
    longcount = 0	' reset timer
    pressed = 0	' reset hangup button status
    '
    FOR i = 0 TO 17	' reset number arrays
    number[i] = 0
    fnum[i] = $FF
    NEXT i
    '
    LCDOUT $FE,1		'clear LCD
    LCDOUT $FE,$80		'set to start of first line
    '
    '
    cycle:				' main routine - user program
    @ clrwdt			; clear watchdog timer manually
    '
    '
    IF pressed = 0 THEN
    IF portb.5 = 0 THEN ' reversed
    pressed = 1	' set status
    tcount = 0	' start counter
    shiftcount = 0
    IF pulses < 10 THEN ' valid count only
    pulses = pulses + 1
    ENDIF
    
    ENDIF ' button pushed
    ENDIF ' ignore if button already down
    '
    '
    '
    IF pressed = 1 THEN	' increment counter while button is down
    IF tcount < 2500 && portb.5 = 0 THEN ' reversed
    tcount = tcount + 1
    ENDIF
    
    IF tcount > 2499 && portb.5 = 0 THEN ' reversed
    gosub printerror		' hangup held down too long
    IF portb.5 = 1 THEN		' wait for off hook again to restart
    goto resetx				' restart properly
    ENDIF
    ENDIF
    
    IF tcount < 2500 && portb.5 = 1 && pressed = 1 THEN ' reversed
    IF tcount > 20 THEN					'debounce button
    
    IF pulses < 10 THEN
    number[digcnt] = pulses
    ELSE
    number[digcnt] = 0
    ENDIF
    
    gosub senddigit
    digcnt = digcnt + 1
    tcount = 0
    pressed = 0
    ENDIF
    ENDIF ' debounce
    '
    ENDIF
    '
    '
    '
    
    IF shiftcount > 0 && digcnt > 0 THEN
    IF pressed = 0 THEN
    shiftcount = shiftcount + 1
    IF shiftcount > 9999 THEN
    shiftcount = 0
    fnum[fcount] = number[digcnt-1]
    gosub acceptdigit
    fcount = fcount + 1
    longcount = 0
    pulses = 0 : digcnt = 0
    ENDIF
    ENDIF
    
    ENDIF
    
    
    '
    '
    
    IF fcount != 0 && shiftcount = 0 && donedtmf = 0 THEN
    longcount = longcount + 1
    IF longcount > 65000 THEN
    IF donedtmf = 0 THEN
    gosub dodtmf
    @ clrwdt			; clear watchdog timer manually
    PAUSE 500
    @ clrwdt			; clear watchdog timer manually
    PAUSE 500
    donedtmf = 1
    goto reset
    ENDIF
    ENDIF
    ENDIF
    
    
    
    '
    '
    '
    goto cycle			' end main routine - do the next frame
    '
    '
    senddigit:
    LCDOUT $FE,$80
    IF fcount > 0 THEN
    FOR i = 0 TO fcount-1
    LCDOUT " "
    NEXT i
    ENDIF
    LCDOUT #number[digcnt]
    shiftcount = 1
    return
    '
    acceptdigit:
    LCDOUT $FE,$01
    LCDOUT $FE,$C0
    FOR i = 0 TO fcount
    LCDOUT #fnum[i]
    NEXT i
    tcount = 0
    
    IF donedtmf = 1 THEN
    DTMFOUT portb.4,[fnum[fcount]]
    ENDIF
    
    
    return
    '
    dodtmf:
    
    IF fnum[0] = 1 && fnum[1] = 1 THEN
    IF fnum[2] = 1 && fnum[3] = $FF THEN
    fnum[0] = 0 : fnum[1] = 0 : fnum[2] = 0
    emergency = 1
    ENDIF
    ENDIF
    
    
    LCDOUT $FE,$01
    LCDOUT $FE,$80
    IF emergency = 0 THEN
    LCDOUT "    DIALING...  "
    ELSE
    LCDOUT "   EMERGENCY!   "
    ENDIF
    
    LCDOUT $FE,$C0
    FOR i = 0 TO fcount-1
    LCDOUT #fnum[i]
    NEXT i
    FOR i = 0 TO fcount-1
    @ clrwdt			; clear watchdog timer manually
    DTMFOUT portb.4,[fnum[i]]
    NEXT i
    return
    '
    printerror:
    'LCDOUT $FE,$01
    LCDOUT $FE,$80
    LCDOUT "                "
    LCDOUT $FE,$C0
    LCDOUT "    ON HOOK     "
    LCDOUT $FE,$80
    return
    '
    '
    Cheers, Art.

  3. #3
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,154


    Did you find this post helpful? Yes | No

    Default Re: Rotary Dial to DTMF

    Cool as always.

    Robert

  4. #4
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: Rotary Dial to DTMF

    Thanks
    The law is tight in my country, anything connected to the phone network must be Ctick approved,
    even if your circuit is isolated I think.

    I thought it a good start for beginners.
    To finish it, you'd want a DTMF chip (this is minimal PBP software DTMF),
    and decide which of the two ways it will work.

    It was a practice, I might get a nicer old phone one day,
    but I will go the way of sacrificing a modern cordless handset.
    The pic controlling that is a different program.

  5. #5
    Join Date
    Dec 2010
    Posts
    409


    Did you find this post helpful? Yes | No

    Default Re: Rotary Dial to DTMF

    Almost all telephone systems will still work with rotary dial, so converting to DTMF is fun, but not actually necessary... I suppose it's possible your telephone provider managed to turn it off for some reason, although I can't imagine why they would.

  6. #6
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: Rotary Dial to DTMF

    Because we don't have a real phone line,
    only an emulated phone port to keep old phones working (existing cordless and such) that port is provided by our router.
    Our phone given to us by the communications provider is an IP phone.
    If we plug a phone directly into the phone line it doesn't do anything.

  7. #7
    Join Date
    Dec 2010
    Posts
    409


    Did you find this post helpful? Yes | No

    Default Re: Rotary Dial to DTMF

    Ah yes, VOIP is usually the exception.

  8. #8
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: Rotary Dial to DTMF

    Quote Originally Posted by Art View Post
    It was a practice, I might get a nicer old phone one day,
    but I will go the way of sacrificing a modern cordless handset.
    The pic controlling that is a different program.
    Moving up in the world!

    Looks like the project is back on


Similar Threads

  1. Dial switch diemna... need more ANalog ports
    By lerameur in forum General
    Replies: 5
    Last Post: - 11th November 2010, 13:12
  2. DTMF dial tone
    By lerameur in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 20th October 2007, 01:40
  3. Rotary BCD
    By Tobias in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th October 2007, 03:04
  4. Rotary encoders
    By mister_e in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 21st February 2007, 16:57
  5. Round Dial, Electronic Combination Lock
    By Pic_User in forum Off Topic
    Replies: 5
    Last Post: - 6th July 2006, 13:34

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