PDA

View Full Version : DTMF and PIC for Remote Control



doggitz
- 28th October 2009, 13:41
Recently started playing with PICs and am just fascinated at what they can do.

I am trying to build a simple remote control system for an amateur radio remote receiver using a DTMF decoder chip like an 8870 and a PIC such as a 16F877A. Does anyone have a code example of how the PIC would handle the input lines from the DTMF decoder? There is a valid digit line and 4 "decode" lines from the decoder. All I need is the BASICPRO program which would strobe the input lines, and when the valid signal is received determine which digit it represents. I can write the code for passwords, and determining what function the received number is to execute. I have looked through the code example part of the site and found one for a matrix keypad, but it does not include the use of a "valid" signal line.

There is at least one example on the web, but it is written in assembly language and I got too discouraged trying to "decode" it.

Thanx

Darrel Taylor
- 28th October 2009, 16:21
There's an example for the LAB-XT Telephony Experimenter Board (MT8870) on the meLabs samples page.

http://melabs.com/resources/samples.htm#xtpbp

grabrxt.bas
<br>

mike1939
- 12th February 2010, 10:35
Hello Doggitz
I am just starting out on a DTMF for remote control via telephone.
I am using 8870 DTMF receiver and PIC 16F628 to do the work.
So far DTMF receiver works fine but as usual the software is slowing me down. I want to be able to enter a PIN code..>...then a Function code...>.. the the Action code. Stuck on first part, even using PBP hasn't made things easier. I gave up on assembler ages ago..too tricky to get right.
If you have any shortcut ideas or pointers from your work I would be most appreciative.
Rgds
Mike
12/2/2010

Dave
- 12th February 2010, 12:22
doggitz, Attached is a first cut program I wrote about 8 years ago for our repeater system. It is one of the first programs I wrote using PBP so don't laugh....It is a remote link control program that worked the first time.... I used a simillar tt decoder to the 8870. I hope this will help you get a start.

Dave Purola,
N8NTA

ScaleRobotics
- 12th February 2010, 14:35
Recently started playing with PICs and am just fascinated at what they can do.

I am trying to build a simple remote control system for an amateur radio remote receiver using a DTMF decoder chip like an 8870 and a PIC such as a 16F877A.

PICs are pretty amazing. Here is an application note from Microchip on using PIC18 devices to decode DTMF without a decoder chip. I still recommend the 8870, but thought you would be interested to know that it can.

http://ww1.microchip.com/downloads/en/AppNotes/MCHP_DTMFDetv1.2.zip

mike1939
- 15th February 2010, 15:32
Why doesn't
pincode1 = PORTB && $0F...work in PBP ?

When PORTB lower 4 bits are 0010 && 00001111 I should get 0010
I get $9C...????
How weird?

Bob, from across the road, has gone on his final mission.
Mike1939

Bruce
- 15th February 2010, 17:05
It doesn't work because you're using a logical operator instead of the bitwise operator.

pincode1 = (PORTB & $0F) would return the right value.

Logical operators can only return true or false.

mackrackit
- 15th February 2010, 20:13
Bob, from across the road, has gone on his final mission.


Bob who???

mike1939
- 16th February 2010, 07:43
Thank you, & NOT &&, well spotted. Progress is being made, I learn a new thing every day

Bob Pierson was a WW2 rear gunner in Lancasters, A "Tail End Charlie".
Sad loss for us here.

Mike

mackrackit
- 16th February 2010, 09:26
Me respects to Bob.
We owe so much to our Veterans.

mike1939
- 6th March 2010, 15:54
DTMF now working satisfactorily. Thanks for all your help.

Next project, how to emulate TV IR remote function?
I want to replicate two Video remote control functions viz Fast Forward and Play. Where is the best place to start?
I thought I could copy the IR output, via digiscope, and implement in PIC?
This involves a lot of work to program in all the pulse train so recorded?
Mike

mike1939
- 7th March 2010, 12:09
My DTMF software works fine using 16F628A.
I can make PIN1 go HIGH and PIN1 go LOW; what doesn't work is MCLR?
I was expecting MCLR, on grounding, to reset the micro and make PIN1 LOW.
It does temporarily but goes HIGH again when I let go. What's Up?
Mike
BTW.......
Nice sunny cloudless day here in UK

Archangel
- 7th March 2010, 17:42
My DTMF software works fine using 16F628A.
I can make PIN1 go HIGH and PIN1 go LOW; what doesn't work is MCLR?
I was expecting MCLR, on grounding, to reset the micro and make PIN1 LOW.
It does temporarily but goes HIGH again when I let go. What's Up?
Mike
BTW.......
Nice sunny cloudless day here in UK
Hi Mike1939,
Did you set MCLRE_ON in your config statement ?
PM compiler: @ DEVICE pic16F628, MCLR_ON
http://www.picbasic.co.uk/forum/showthread.php?t=543

mike1939
- 8th March 2010, 09:06
I have now set in my PBP code, @ DEVICE pic16F628, MCLR_ON
This still doesn't allow chip to reset properly, only whilst MCLR is held low does PIN1 stay LOW. If I remove the 5V power completely it does reset OK.
I do apologise for being a nuisance, I think I have slowed down a bit in recent years, there's a clue to my age in my username.
Rgds
Mike

mike1939
- 28th March 2010, 09:05
I have new coding problem, using TMR0 I do not understand........put simply


loop1:
if intcon.2 = 0 then loop1
intcon.2 = 0
clicks=clicks+1
if clicks >=1900 then
clicks=0
high pin11:pause 100:low pin11 'Flash LED for 10th of second
secs=secs+1
endif
if secs>=5 then
high pin10:pause 100:low pin10
gosub nowt
secs=0 'Reset secs
endif
goto loop1
end
nowt:
return

But fails if
gosub nowt
endif
goto loop1
end
nowt:
secs=0 'Reset secs
return

The inclusion of any code in the sub-routine at nowt: causes whole to fail?

mackrackit
- 28th March 2010, 10:49
Can you post the whole code, using code tags, so we can see how everything is setup? TMRO is "normally" set to trigger an interrupt handler so I am not sure what you are doing with what I see posted.

Might just be running out of time???

mike1939
- 29th March 2010, 11:15
Hello....All of the code is shown below......

'************************************************* ***************
'* Name : TIMER01.INC *
'* Author : Michael Denton *
'* Notice : *
'* Date : 27/03/2010 *
'* Version : 1.0 *
'* Notes : *
'************************************************* ***************
cmcon = %00000111 'Make portA all digital I/O otherwise ADC
intcon = %10110000 'R/W Reg Bit2 is T0IF TMRO overflow bit
'must be reset in software
option_reg = %10010000 'prescaler for TMR0 set at 1:1
vrcon = %00000000 'Turn off reference voltage
eecon1 = %00001111 'EEPROM data register

'================================================= ======
PIN6 VAR PORTB.0 ' Rename all port names with physical PIN number
PIN7 VAR PORTB.1 ' Makes it easier to wire up
PIN8 VAR PORTB.2
PIN9 VAR PORTB.3
PIN10 VAR PORTB.4
PIN11 VAR PORTB.5
PIN12 VAR PORTB.6
PIN13 VAR PORTB.7
PIN17 VAR PORTA.0
PIN18 VAR PORTA.1
PIN1 VAR PORTA.2
PIN2 VAR PORTA.3
PIN3 VAR PORTA.4
'================================================= ======

INPUT PIN2 '
input pin6 '
input PIN7 '
input PIN8 '
input PIN9 '
input PIN12 '
input PIN13 '

output pin1 '
output pin3 '
output pin10 '
output PIN11 '
OUTPUT PIN17 '
OUTPUT PIN18 '

'================= Check functionality ==========================
m var word :n var word
clicks var word: secs var word

' ================================================== =============
pause 1000 'Do nothing for a while
main:
loop1:
if intcon.2 = 0 then loop1 'TMR0 must be enabled to get out of this loop1
intcon.2 = 0
clicks=clicks+1
if clicks >=1900 then
clicks=0
high pin11:pause 100:low pin11 'Flash LED for 10th of second
secs=secs+1
endif
if secs>=5 then
high pin10:pause 100:low pin10
gosub nowt
secs=0 'Reset secs
endif
goto loop1
end
nowt: 'm=m+1 ' Why does this one extra instruction cause Pin11 High
' And cause progam to FAIL!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
return

mackrackit
- 29th March 2010, 11:52
Maybe this will help. Scroll down to post #125 to start.
http://www.picbasic.co.uk/forum/showthread.php?t=12677&page=4

In your code, where does the value of "m" come from?

And... Look at using code tags when you post code. Makes it easier to read...
http://www.picbasic.co.uk/forum/misc.php?do=bbcode#code

mike1939
- 30th March 2010, 11:39
Maybe this will help. Scroll down to post #125 to start.
http://www.picbasic.co.uk/forum/showthread.php?t=12677&page=4

In your code, where does the value of "m" come from?

And... Look at using code tags when you post code. Makes it easier to read...
http://www.picbasic.co.uk/forum/misc.php?do=bbcode#code


Right, m comes out of the blue, just a byte variable as demonstration that inclusion of m=m+1 causes failure.
How do you use code tags when posting code?
Rgds

mackrackit
- 30th March 2010, 11:42
Right, m comes out of the blue, just a byte variable as demonstration that inclusion of m=m+1 causes failure.
How do you use code tags when posting code?
Rgds

Code Tags:

[_code]
Anything here will be in the tag.
Remove the _ to make it work.
[_/code]