Mitel MT8870D & PIC16F628 - ATV Repeater DTMF Control Help


Closed Thread
Results 1 to 3 of 3
  1. #1
    m0cke's Avatar
    m0cke Guest

    Question Mitel MT8870D & PIC16F628 - ATV Repeater DTMF Control Help

    Hi all,

    I've been away from the PICBASIC scene for some time and only now am I trying to pick up the project where I had left off about 18 months ago!

    I had writen some untested code for a 16F628 to allow DTMF controll of a ATV Repeater using a Mitel MT8870D decoder.

    The idea was to allow basic functions by pressing *1 .. then there would be an advanced mode which would need a passcode, this would be accessable using *2 then entering the code, the final mode would be close down of transmitter by pressing *9 then entering another different code.

    As I remeber I was using lookdown tables for the access pass codes.

    I'm a little lost as to where I was at but I would appreciate if someone experienced would look through the code and see if there were any major mistakes also could I tidy up the code any?



    Here is the code ..

    -----------------------

    'Program to use data from a Teltone M957 DTMF IC to select different
    'operations on a ATV Repeater.

    ' July 2002 Copyright M0CKE

    INCLUDE "modedefs.bas"

    'Port Definition

    dt0 VAR PORTA.0 ' bit 0 of dtmf
    dt1 VAR PORTA.1 ' bit 1 of dtmf
    dt2 VAR PORTA.2 ' bit 2 of dtmf
    dt3 VAR PORTA.3 ' bit 3 of dtmf
    ST VAR PORTA.4 ' strobe input from dtmf M957
    O1 VAR PORTB.0 'Output 1
    O2 VAR PORTB.1 'Output 2
    O3 VAR PORTB.2 'Output 3
    O4 VAR PORTB.3 'Output 4
    O5 VAR PORTB.4 'Output 5
    O8 VAR PORTB.7 'Output 8

    'Variables

    dtmf VAR BYTE ' dtmf variable holder
    C VAR BYTE ' Tones rcvd counter variable
    G VAR BYTE ' Sequence counter variable
    J VAR BYTE ' Table counter variable
    A VAR BYTE ' DTMF Variable First Digit
    B VAR BYTE ' DTMF Variable Second Digit
    T VAR WORD ' Timer
    K VAR BYTE ' TX Kill Latch

    'Main Program

    Init:
    TRISA = %11111 'Set Inputs
    TRISB = %00000000 'Set Outputs
    T=3001 'Set TX ON
    high O8 'DTMF error off

    Reset:
    A=0
    B=0

    Main:
    dtmf = 0 'Reset DTMF Register
    C=0:G=0:J=0 'Clear Variables
    IF T>3000 Then 'Set TX on if Timer is more than 5 Minutes
    IF K=0 Then High O5 'Unless Kill is active
    IF T<3000 OR K=1 Then Low O5 'Set TX off if Timer is less than 5 Min
    IF T>9999 Then T=3001 'Reset Timer to 5 Minutes
    GoSub GetDtmf 'Get DTMF Code
    A=dtmf 'Var A = Sum of DTMF codes
    IF B=0 Then GoSub GetDtmf
    IF A=11 AND B=1 Then GoTo Normal 'If *1 Then Normal Mode
    IF A=11 AND B=2 Then GoTo Advanced 'If *2 Then Advanced Mode
    IF A=11 AND B=9 Then GoTo Engineer 'If *9 Then Engineer Mode
    GoSub Error
    GoTo Main

    GetDtmf:
    Pause 100
    T=T+1
    IF ST = 0 Then GetDtmf ' no digit received
    EndIF
    IF PORTA.0 = 1 Then 'Check Input port 0
    dtmf = dtmf + 1
    EndIF
    IF PORTA.1 = 1 Then 'Check Input port 1
    dtmf = dtmf + 2
    EndIF
    IF PORTA.2 = 1 Then 'Check Input port 2
    dtmf = dtmf + 4
    EndIF
    IF PORTA.3 = 1 Then 'Check Input port 3
    dtmf = dtmf + 8
    EndIF
    IF dtmf>12 Then GoSub Error
    Return

    Engineer:
    GoSub GetDTMF 'Get DTMF
    C=C+1 'Add 1 to Tone Count Register
    LookDown dtmf,["0482391756"],J 'LookDown Table
    IF J=0 Then GoSub Error
    IF J=0 Then Main
    IF C=1 AND J=1 Then Key 'Check Codes are sent in correct order
    IF C=2 AND J=2 Then Key
    IF C=3 AND J=3 Then Key
    IF C=4 AND J=4 Then Key
    IF C=5 AND J=5 Then Key
    IF C=6 AND J=6 Then Key
    IF C=7 AND J=7 Then Key
    IF C=8 AND J=8 Then Key
    IF C=9 AND J=9 Then Key
    GoSub Error
    GoTo Reset

    Key:
    G=G+1 'Add 1 to Gate Register if Codes are in correct order
    IF C=9 AND J=9 AND G=9 Then
    GoTo Shutdown 'If all counters tally do command
    EndIF
    GoTo Engineer

    Advanced:
    GoSub GetDTMF 'Get DTMF
    C=C+1 'Add 1 to Tone Count Register
    LookDown dtmf,["0814293"],J 'LookDown Table
    IF J=0 Then GoSub Error
    IF J=0 Then Main
    IF C=1 AND J=1 Then Keys 'Check Codes are sent in correct order
    IF C=2 AND J=2 Then Keys
    IF C=3 AND J=3 Then Keys
    IF C=4 AND J=4 Then Keys
    IF C=5 AND J=5 Then Keys
    IF C=6 AND J=6 Then Keys
    GoSub Error
    GoTo Reset

    Keys:
    G=G+1 'Add 1 to Gate Register if Codes are in correct order
    IF C=6 AND J=6 AND G=6 Then
    GoSub AdvCode 'If all counters tally do command
    EndIF
    GoTo Advanced

    AdvCode: 'Advanced user section
    Pause 100 'Pause for timer
    T=T+1
    A=0 'set registers to 0
    B=0
    dtmf=0
    GoSub GetDtmf 'Get DTMF tones
    A=dtmf 'Register A = value of first DTMF character
    IF B=0 Then GoSub GetDtmf 'Check Register B is empty then get second DTMF character
    IF A=10 AND B=10 Then T=0 'Commands (Kill TX for set time)
    IF A=1 AND B=1 Then T=3001 'Commands (Enable TX)
    IF A=12 AND B=12 Then GoTo Reset 'If ## then reset
    GoTo AdvCode

    Normal: 'Normal user section
    Pause 100 'Pause for timer
    T=T+1
    A=0 'set registers to 0
    B=0
    dtmf=0
    GoSub GetDtmf 'Get DTMF
    A=Dtmf 'Register A = value of first DTMF character
    IF B=0 Then GoSub GetDtmf 'Check Register B is empty then get second DTMF character
    IF A=1 AND B=1 Then High O1 'Commands
    IF A=2 AND B=1 Then Low O1
    IF A=1 AND B=2 Then High O2
    IF A=2 AND B=2 Then Low O2
    IF A=1 AND B=3 Then High O3
    IF A=2 AND B=3 Then Low O3
    IF A=1 AND B=4 Then High O4
    IF A=2 AND B=4 Then Low O4
    IF A=12 AND B=12 Then GoTo Reset 'If ## then reset
    GoSub Error
    GoTo Normal

    Shutdown: 'TX Shutdown Section
    IF O5=1 Then 'If Output is High
    Low O5:K=1 'Set Output O5 Low (Shutdown TX)
    Else
    High O5:K=0 'Set Output O5 High (Enable TX)
    EndIF
    GoTo Reset

    Error: 'DTMF Error Section
    low O8 'Set pin O8 high - Main PIC
    Pause 100 'Pause for Timer
    T=T+1
    high O8 'Set pin O8 Low
    Return





    ------------------

    Thanks for any help or advice you may have.

    Regards,

    Jim

  2. #2
    Eliasrabelo's Avatar
    Eliasrabelo Guest


    Did you find this post helpful? Yes | No

    Default I need some help

    Hello,

    I´m quite new to develop a software to use at PIC 16F628, i´m looking for code like you mention before at your project, i need a sample i would like to ask you if have any code with works 8870 decode with pic16f628???

    Elias Rabelo Brazil

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    maybe you can find some info on the following thread
    http://www.picbasic.co.uk/forum/show...highlight=dtmf
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. DTMF and PIC for Remote Control
    By doggitz in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 30th March 2010, 11:42
  2. A little DTMF help
    By Travin77 in forum mel PIC BASIC Pro
    Replies: 48
    Last Post: - 30th May 2006, 01:31
  3. DTMF Decode with Mitel 8870 & 16F628
    By m0cke in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 23rd March 2004, 07:44

Members who have read this thread : 1

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