Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
November 27, 2024, 12:25:13 00:25


Login with username, password and session length


Pages: [1]
Print
Author Topic: [REQ] have someone dtmf code for pic?  (Read 5965 times)
0 Members and 1 Guest are viewing this topic.
peppeviruz
Junior Member
**
Offline Offline

Posts: 67

Thank You
-Given: 26
-Receive: 40


« on: June 23, 2010, 08:43:21 08:43 »

Hi, I'm searching for some code to encode/decode dtmf signals for pic, in few words:
there is a command for picbasic pro "Dtmfout", and it's able to send dtmf tones only with pic and 2 10uf capacitors, but searching I never found something similiar to encode/decode dtmf signals in c or basic-like languages, maybe someone has some c or basic code, I need cos I'm afraid to need ever external hardware to decode them.
(there are many examples on net, but only in assembler language, I need some c, or better, basic code for pic. to decode and encode them if possible)
thanks to everyone has someting usefull for me!
Logged
gonzogonzo
Active Member
***
Offline Offline

Posts: 121

Thank You
-Given: 79
-Receive: 49


« Reply #1 on: June 23, 2010, 04:23:50 16:23 »

 Smiley there is an example in CCS sample  and also in mikroe site web under project!
Logged
peppeviruz
Junior Member
**
Offline Offline

Posts: 67

Thank You
-Given: 26
-Receive: 40


« Reply #2 on: June 23, 2010, 06:16:43 18:16 »

I'll search for CCS,for mikroe, I readed, but all examples into projects, seems that use external devices, like cm8870.....
Logged
peppeviruz
Junior Member
**
Offline Offline

Posts: 67

Thank You
-Given: 26
-Receive: 40


« Reply #3 on: June 23, 2010, 07:24:44 19:24 »

ok, some news (I hope) mikrobasic about dtmf_out, I didn't try,  but teorically, it have to work.....
some theory.....
sin in a circle is:
0 for 0° and 180°
1 for 90°
-1 for 270°
now, the sinusoid is like a circle, only, is open, not close, so, we can know the sin of a sinusoid in ever moment (in microseconds!), knowing how many times it make to close the sinusoid itself,
in dtmf, we can know, dividing 1 for the hz, multipling for 1.000.000, and with an interrupt every x us, we can check the state of 2 sinusoid, and simulate them with a square , now we have 2 different sinusoids, so, if the sum of sin of both in determinate time is >0 then the square at that time is 1, if the sum of both sin of the sinusoind are <=0 then the square is 0
now the code, don't know if it works, but is a beginning.....

Code:
'at xtal=4Mhz, interrupt on timer1 ever 50us, we can verify the state of 2 sinusoid
'of dtmf signals, and with portb.0, we cans et 1 if one of sinusoid is
'>0, and set it to 0 if both the sinusoids are <0
'in this way, we can simulate with squares the sum of sinusoid that compose the dtmf signal.....


program dtmf_Test

dim a,b,x,y,z as float
dim out as boolean
dim count as word
dim number as byte
dim col as float[4]
dim row as float[4]


  sub procedure interrupt()
    if intcon.t0if=1 then
       out=true
    count=count+50  'breaks ever 50 us.....
    intcon.t0if=0
    end if
  end sub
sub procedure dtmfout(dim n as byte)


  select case n
  case 1
       a=row[0]
       b=col[0]

  case 2
       a=row[0]
       b=col[1]
  case 3
       a=row[0]
       b=col[2]
  case 4
       a=row[1]
       b=col[0]
  case 5
       a=row[1]
       b=col[1]
  case 6
       a=row[1]
       b=col[2]
  case 7
       a=row[2]
       b=col[0]
  case 8
       a=row[2]
       b=col[1]
  case 9
       a=row[2]
       b=col[2]
  case "*"
       a=row[3]
       b=col[0]
  case 0
       a=row[3]
       b=col[1]

  case "#"
       a=row[3]
       b=col[2]
end select

x= sin((360*count)/a)
y= sin((360*count)/b)
z=x+y

'option 1
'''if z>=0 then
'''    portb.0=1
'''else
'''    portb.0=0
'''end if

'option 2 maybe better!
if (x>0) or (y>0) then
   portb.0=1
end if
if (x<=0) and (y<=0) then
    portb.0=0
end if

end sub
sub procedure select_number

  if portb.1=1 then
     intcon.t0ie=1
     count=0
     number=1
  end if

   if portb.2=1 then
     intcon.t0ie=1
      count=0
     number=2
  end if
  
   if portb.3=1 then
      intcon.t0ie=1
     count=0
     number=3
  end if
  
   if portb.4=1 then
      intcon.t0ie=1
     count=0
     number=4
  end if
  
   if portb.5=1 then
      intcon.t0ie=1
     count=0
     number=5
  end if
end sub
sub procedure initmain
' Timer0 Registers:
' Prescaler=1:1; TMR0 Preset=206; Freq=20.000,00Hz; Period=50.000 ns
OPTION_REG.T0CS = 0 ' bit 5 TMR0 Clock Source Select bit:0=Internal Clock (CLKO) / 1=Transition on T0CKI pin
OPTION_REG.T0SE = 0 ' bit 4 TMR0 Source Edge Select bit: 0=low/high / 1=high/low
OPTION_REG.PSA  = 1 ' bit 3 Prescaler Assignment bit: 0=Prescaler is assigned to the Timer0
OPTION_REG.PS2  = 0 ' bits 2-0  PS2:PS0: Prescaler Rate Select bits
OPTION_REG.PS1  = 0
OPTION_REG.PS0  = 0
TMR0 = 206            ' preset for timer register

 intcon.gie=1
 intcon.T0IE=0
 count=0
 out=false
end sub

sub procedure dtmf_init()
'697hz in us=1/697*1000000=1434.72 us to close the sinusoid.....
row[0]=1434.72
col[0]=827.12
row[1]=1298.70
col[1]=748.50
row[2]=1173.70
col[2]=677.04
row[3]=1062.69
col[3]=612.36
end sub
main:
  InitMain()

  dtmf_init()
  while true
  select_number


  if (out=true)  then
     out=false
     tmr0=206
     dtmfout(number)
  end if
  
  '100 ms.....
   if count>2000 then
      intcon.t0ie=0
      TMR0=206
   end if
  wend
  
end.

and above of all, how many delays takes the timer0 interrupt?Huh, maybe there is something to adjust, to have interrupt perfectly ever 50 us to check the sinusoins state.....
every kind of suggestions will be usefull.
« Last Edit: June 23, 2010, 07:33:04 19:33 by peppeviruz » Logged
Parmin
Hero Member
*****
Offline Offline

Posts: 582

Thank You
-Given: 496
-Receive: 133


Very Wise (and grouchy) Old Man


« Reply #4 on: June 24, 2010, 12:35:42 00:35 »

There is a bloke, his name is radu contaniscu or something that publish DTMF decoding using PIC..
I am too lazy to read it.. but you can defintely search google using "RADU DTMF" as keyword.
Logged

If I have said something that offends you, please let me know, so I can say it again later.
LabVIEWguru
Senior Member
****
Offline Offline

Posts: 300

Thank You
-Given: 272
-Receive: 593



« Reply #5 on: June 24, 2010, 02:41:35 02:41 »

Search using Google for the keywords: dtmf generator 6805
There are several app notes for encoding/decoding DTMF using 6805 series micros, and a lot of discussion on how to do it. I realize it's not a PIC, but it will show you how it's done in great detail. Years ago some people made a "Blue Box" using this app note and a 68hc705C8 micro. Holtek makes receivers & generators as well as the Motorola MT8870. If you have access to a library with Radio-Electronics or Popular Electronics I remember a number of articles were in there using hardware - one of them was mine!
Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC