Autor Tema: Como Generar Los Tonos del Celular Con un Pic?  (Leído 1440 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado darck_khronos

  • PIC18
  • ****
  • Mensajes: 493
Como Generar Los Tonos del Celular Con un Pic?
« en: 15 de Diciembre de 2009, 02:49:10 »
Ahorita que estaba hablando de Frecuencias recorde que los tonos del telefono y del Celular tienen diferentes tonos dependiendo el numero que Marquemos.

Como se pueden generar estos mismo tonos con algun pic, alguien podria ayudarme con eso ?

Desconectado migsantiago

  • Colaborador
  • DsPIC33
  • *****
  • Mensajes: 8257
    • Sitio de MigSantiago
Re: Como Generar Los Tonos del Celular Con un Pic?
« Respuesta #1 en: 15 de Diciembre de 2009, 11:01:12 »
Según leo en esta página...

http://nemesis.lonestar.org/reference/telecom/signaling/dtmf.html

Debes generar 2 frecuencias según la tecla que se presione. Puedes generarlas con pwm, timers o con simples delays. Necesitarás dos salidas del pic para generar las señales y después un ampop que sume ambas salidas.

Eso es lo que se me ocurre al vapor.

Desconectado darck_khronos

  • PIC18
  • ****
  • Mensajes: 493
Re: Como Generar Los Tonos del Celular Con un Pic?
« Respuesta #2 en: 15 de Diciembre de 2009, 13:46:19 »
Encontré este programa donde ya habían realizado algo parecido pero no encuentro como genero los tonos

Código: C
  1. #include <16f88.h>
  2. #fuses NOWDT,NOPROTECT,PUT    
  3. #fuses NOMCLR,INTRC_IO
  4. #ZERO_RAM
  5. #use delay(clock = 4000000)
  6. #use rs232(baud=9600,rcv=PIN_B0, parity=N, bits=8, errors)
  7. #use fast_io(A)
  8. #use fast_io(B)
  9. /************************************************************************
  10. * I/O
  11. ************************************************************************/
  12. #byte PORTA = 5 // Salida
  13. #byte PORTB = 6 // Entradas
  14. #byte PCL = 2
  15. #bit Act_linea = PORTA.2 // Activa línea telefónica
  16. #bit LED = PORTA.3 // LED Tiempo de grabación EEPROM
  17. #bit IN1 = PORTB.1 // Entrada 1
  18. #bit IN2 = PORTB.2 // Entrada 2
  19. #bit DS1 = PORTB.4 // DIP Switch 1
  20. #bit DS2 = PORTB.4 // DIP Switch 2
  21.  
  22. /***********************************************************************
  23. * Definicion de Variables
  24. ***********************************************************************/
  25. #define HI_PIN 0x02 // RA1 Tono alto
  26. #define LOW_PIN 0x01 // RA0 Tono Bajo
  27. unsigned char temp[40];
  28. unsigned int i;
  29. unsigned long j;
  30. int EEADR;
  31. unsigned long timeout;
  32. int NumTelf;
  33. int ttono;
  34. /***********************************************************************
  35. * Prototipos
  36. ***********************************************************************/
  37. void delay_seg(int n);
  38. void dtmfsend(int NumTelf, ttono);
  39. void LeerEEprom(int EEADR);
  40. /*-----------------------------------------------------------------------*/
  41. void main(void) {
  42. /*-----------------------------------------------------------------------*/
  43. int NumRep;
  44. set_tris_a(0x00);
  45. set_tris_b(0xFF);
  46. EEADR = 0;
  47. LED = 1;
  48. i = 0;
  49. for(j=0; j < 100; j++)
  50. {
  51. timeout =0;
  52. while(!kbhit()&&(++timeout<5000))
  53. delay_us(10);
  54. if(kbhit())
  55. temp[i++] = getchar();
  56. }
  57. LED = 0; // Fin tiempo lectura puerto Serial
  58. if(i != 0) // si i = 0 go to continuar.......
  59. {
  60. for(j=0; j< i; j++)
  61. {
  62. write_eeprom(EEADR,temp[j]);
  63. EEADR++; // incrementa direccion EEPROM
  64. }
  65. }
  66. if(!DS1 && !DS2)
  67. while(IN2 == 1);
  68. else
  69. if(!DS1 && DS2)
  70. while(IN2 == 0);
  71. else
  72. if(DS1 && DS2)
  73. while(IN1 == 1 || IN2 == 1);
  74. else
  75. if(DS1 && DS2)
  76. while(IN1 == 1 || IN2 == 0);
  77. EEADR = 0x00;
  78. LeerEEprom(EEADR);
  79. NumRep = NumTelf;
  80. do{
  81. i = 1;
  82. EEADR =0x02;
  83. while(i < 4){
  84. Act_linea = 1;
  85. delay_seg(3);
  86. LeerEEprom(EEADR);
  87. while(NumTelf != 0x2f) {
  88. dtmfsend(NumTelf, 0x41);
  89. delay_ms(300);
  90. EEADR++;
  91. LeerEEprom(EEADR);
  92. }
  93. delay_seg(5);
  94. for(j=0;j<20;j++)
  95. {
  96. dtmfsend(12, 0xff);
  97. delay_seg(1);
  98. }
  99. i++;
  100. EEADR++;
  101. Act_linea = 0;
  102. delay_seg(5);
  103. }
  104. Act_linea = 0;
  105. delay_seg(5);
  106. NumRep--;
  107. } while(NumRep !=0);
  108. }
  109. void dtmfsend(int NumTelf, ttono) {
  110. int low_count;
  111. int high_count;
  112. int salva_low_count;
  113. int salva_high_count;
  114. int high_tone_count;
  115. int low_tone_count;
  116. int temporal;
  117.  
  118. #asm
  119. inicio:
  120. movf NumTelf,0
  121. andlw 0x0f ; key en W
  122. movwf temporal ; Salva Key en tmp
  123. call tabla_low_count ; Contador retardo tono bajo -> w
  124. movwf salva_low_count ; Salva contador retardo tono bajo
  125. movwf low_count
  126. movf temporal,0 ; Key -> w
  127. call tabla_high_count ; Contador retardo tono alto -> w
  128. movwf salva_high_count ; Salva contador retardo tono alto
  129. movwf high_count
  130. clrf low_tone_count ; Tiempo tono 255 +
  131. movlw ttono ; ttono en hdcnt
  132. movwf high_tone_count ;
  133. bucle:
  134. clrwdt
  135. nop
  136. bucle1:
  137. movlw (HI_PIN + LOW_PIN)
  138. decfsz low_count,1 ; Si ambos contadores (lowcnt, highcnt)
  139. andlw HI_PIN ; no han llegado a cero, w = B'00000000'
  140. decfsz high_count,1 ; Si lowcnt llega a cero w = B'00000001'
  141. andlw LOW_PIN ; Selecionado RB0. Si highcnt llega a cero
  142. ; w = B'00000010' seleccionando RB1
  143. movwf temporal ; Salva w en tmp
  144. xorwf PORTA,1 ; toggle RB selecionado
  145. movf salva_low_count,0 ; Contador de retardo tono bajo -> w
  146. btfsc temporal,0 ; Si RB0 selecionado
  147. movwf low_count ; W -> lowcnt
  148. movf salva_high_count,0 ; Contador de Retardo tono Alto -> w
  149. btfsc temporal,1 ; Si Rb1 selecionado
  150. movwf high_count ; W -> highcnt
  151. decfsz low_tone_count,1 ; 1/2
  152. goto bucle ; 2 3x255x hdcnt
  153. decfsz high_tone_count,1 ; 1/2
  154. goto bucle1 ; 2
  155. goto fin
  156. tabla_low_count: ; Contadores de retardo tonos bajos
  157. addwf PCL,1
  158. retlw 29
  159. retlw 40
  160. retlw 40
  161. retlw 40
  162. retlw 36
  163. retlw 36
  164. retlw 36
  165. retlw 32
  166. retlw 32
  167. retlw 32
  168. retlw 40
  169. retlw 36
  170. retlw 32
  171. retlw 29
  172. retlw 29
  173. retlw 29
  174. tabla_high_count: ; Contadores de retardo tonos altos
  175. addwf PCL,1
  176. retlw 21
  177. retlw 23
  178. retlw 21
  179. retlw 19
  180. retlw 23
  181. retlw 21
  182. retlw 19
  183. retlw 23
  184. retlw 21
  185. retlw 19
  186. retlw 17
  187. retlw 17
  188. retlw 17
  189. retlw 17
  190. retlw 23
  191. retlw 19
  192. fin:
  193. #endasm
  194. }
  195. void LeerEEprom(int EEADR){
  196. int eedata;
  197. eedata=read_eeprom(EEADR);
  198. switch(eedata) {
  199. case 0x30:
  200. NumTelf = 0;
  201. break;
  202. case 0x31:
  203. NumTelf = 1;
  204. break;
  205. case 0x32:
  206. NumTelf = 2;
  207. break;
  208. case 0x33:
  209. NumTelf = 3;
  210. break;
  211. case 0x34:
  212. NumTelf = 4;
  213. break;
  214. case 0x35:
  215. NumTelf = 5;
  216. break;
  217. case 0x36:
  218. NumTelf = 6;
  219. break;
  220. case 0x37:
  221. NumTelf = 7;
  222. break;
  223. case 0x38:
  224. NumTelf = 8;
  225. break;
  226. case 0x39:
  227. NumTelf = 9;
  228. break;
  229. case 0x2f:
  230. NumTelf = eedata;
  231. break;
  232. }
  233. }
  234. void delay_seg(int n) {
  235. for(;n!=0; n--)
  236. delay_ms(1000);
  237. }

Tambien dejo el Pdf

Desconectado jhozate

  • Colaborador
  • PIC24H
  • *****
  • Mensajes: 1698
Re: Como Generar Los Tonos del Celular Con un Pic?
« Respuesta #3 en: 15 de Diciembre de 2009, 14:42:26 »
sino estoy mal, PBP tiene una instruccion unica y exclusivamente para sacar tonos DTMF
saludos
Ser Colombiano es un Premio, Saludos desde CALI-COLOMBIA