Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

DTMF Circuit needing immdiate help

Status
Not open for further replies.

TechINT

New Member
Hello all,

I am trying to program a circuit using DTMF technology. This is my first attempt at programming but I do have an electronics background.

I am running into multiple problems. I am trying to fix one problem at a time. My current problem is my timer issue.

My timer code does not appear to be working properly. When I enter 6 (my DTMF tone generator), instead of my timer functioning, the STA (Safe To Arm) begins once again.

My code is below. I would appreciate any and all help with this project. I am under a deadline which is days away and I am far from finishing. My circuit is the attachment.

'****************************************************************
'* Name : TIMER, CMD, STA v2.BAS *
'* Author : [select VIEW...EDITOR OPTIONS] *
'* Notice : Copyright (c) 2012 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 11/21/2012 *
'* Version : 1.0 *
'* Notes : *
'* : *
'****************************************************************

CMCON = 7 ; TURNS OFF COMPARATORS (PORTA.2, .3, & .4)

TRISA = %10001111 ; SET PORTA.0-.3 AND .7 TO INPUTS, REST TO OUTPUTS
TRISB = %11100001 ; SET PORTB.0, .5, .6, .7 TO INPUTS, REST TO OUTPUTS

CODEIN VAR BYTE
ACTIVATIONCODE CON $01
DET CON $04
TIMERSTART CON $06
TIMERSTOP CON $07
X VAR BYTE
TIMERCOUNT VAR WORD

PORTB.3 = 0

STA: ; SAFE TO ARM
PORTB.4 = 0 ; ENSURE OUTPUT TO LOAD IS LOW
PORTB.5 = 0 ; ENSURE LOAD LED INDICATOR IS LOW
PORTA.6 = 0 ; ENSURE BUZZER IS OFF

FOR X = 1 TO 20 ; 10 SEC STA W/ BLINKING LED
TOGGLE PORTB.3
PAUSE 500
NEXT X

START:
PORTB.3 = 1 ; SAFE TO ARM HAS EXPIRED SO LED STAYS ON
TIMERCOUNT = 0 ; RESET TIMER COUNTER

IF PORTB.0 = 0 THEN START ; WAIT FOR DTMF CODE

CODEIN = PORTA & $0F ; STORE INPUT FROM PORTA.0-.3

IF CODEIN = $05 THEN sta
IF CODEIN <> ACTIVATIONCODE THEN START ; WAITING TO RECEIVE VALIDE 1ST DIGIT

FOR X = 1 TO 20 ; IF YOU GET HERE, YOU ENTERED CORRECT ACTIVATION CODE
TOGGLE PORTB.3 ; LED FLASHES FAST FOR 2 SECONDS SO YOU KNOW
PAUSE 100 ; THE CORRECT ACTIVATION CODE WAS RECEIVED
NEXT X
PORTB.3 = 1

STDOFF3:
PAUSE 100
IF PORTB.0 = 1 THEN STDOFF3 ; WAITING FOR TONE TO STOP

COMMANDS:
if PORTB.0 = 0 THEN COMMANDS ; WAITING FOR NEW TONE

CODEIN = PORTA & $0F ; STORE INPUT FROM PORTA.0-.3

IF CODEIN = $05 THEN STA
IF CODEIN = DET THEN BANG
IF CODEIN = TIMERSTART THEN TIMER

FOR x = 1 TO 20 ; INVALID COMMAND TONE RECEIVED
TOGGLE PORTB.3
PAUSE 250
NEXT X
PORTB.3 = 1

GOTO COMMANDS ; GO BACK TO COMMAND INPUT AND TRY AGAIN (DEVICE STILL ACTIVE)

TIMER: ; 10 SECOND TIMER
IF PORTB.0 = 1 THEN TIMER ; WAIT FOR TONE TO STOP

WHILE PORTB.0 = 0 ; WHILE THERE IS NO TONE
PORTB.3 = 0
PAUSE 100
PORTB.3 = 1
PAUSE 900
IF TIMERCOUNT = 10 THEN BANG
TIMERCOUNT = TIMERCOUNT + 1
WEND

CODEIN = PORTA & $0F ; A TONE WAS DETECTED - STORE IT

IF CODEIN = $05 THEN STA
IF CODEIN = DET THEN BANG
if codein = TIMERSTOP THEN GOTO START

GOTO TIMER ; INVALID CMD, CONTINUE COUNTING

BANG:
PORTB.4 = 1 ; OUTPUT TO LOAD
PORTB.5 = 1 ; LED INDICATOR
PORTA.6 = 1 ; BUZZER
PAUSE 5000
GOTO STA

END
 
I didn't check your schematic as it is not a GIF or JPG, but one good idea is to put 4 LEDs on the 4 outputs fromt he DTMF decoder IC. Then when applying a tone you can see that the decoder has correctly sent out the right 4bit number.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top