Autor Tema: Grabadora de sonido  (Leído 7680 veces)

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

Desconectado churrinfunflais

  • PIC12
  • **
  • Mensajes: 68
Grabadora de sonido
« en: 30 de Mayo de 2012, 15:48:47 »
Hola amigos!!!

Tengo una duda con respecto a un proyecto en el que estoy trabajando ¿es posible grabar sonido en una memoria SD ?
Supongo que hay que hacer una conversión analogía a digital con un muy alto muestreo y bit por bit guardarlo en en la SD, lo que me trae otra duda, es si estos datos que recopilo del convertidor analógico seria posible de guardarlos en un mp3 wav o algún formato de audio reconocible para un pc en la sd? hay librerías de esto??

Saludos.

Desconectado Suky

  • Moderador Local
  • DsPIC33
  • *****
  • Mensajes: 6758
Re: Grabadora de sonido
« Respuesta #1 en: 30 de Mayo de 2012, 17:44:34 »
Que seria a muy alto muestreo?  :?

Pensemos que se utiliza una EEPROM F-RAM a 40 MHz SPI, entonces muestreando y guardando directamente en la memoria con ayuda del DMA (si es posible) para reducir tiempos tendrías que  8x(1/40 MHz) = 200 ns. Entonces sin tener en cuenta los ciclos adicionales que se ocupan leer la convesion y enviar el datos tendrias como máximo 1/200ns= 5kHz.  :tongue:

Con una memoria RAM?

Saludos!
No contesto mensajes privados, las consultas en el foro

Desconectado tannke

  • PIC16
  • ***
  • Mensajes: 176
Re: Grabadora de sonido
« Respuesta #2 en: 31 de Mayo de 2012, 09:28:24 »
Yo hace ya algunos meses (poco menos de un año) realicé un proyecto parecido, pic18f2550 para trabajar a 48Mhz, muestreo el sonido de la línea telefonica a 8Khz y gravo en la sd en formato WAV. Gracias a Suky que me aconsejo con las resistencias pude mejorar la velocidad de escritura en la SD, pero ahun así para ese muestreo me quedo corto, tengo algún cuello de botella por algun lado, la cuestión es que cada 2 o 3 segundos se me pisan los buffers y al oir el sonido se escucha el saltito.

No lo depuré a fondo ya que lo hice para aprender el manejo de la sd y para experimentar algunas cosas.

Un saludo

Desconectado migsantiago

  • Colaborador
  • DsPIC33
  • *****
  • Mensajes: 8257
    • Sitio de MigSantiago
Re: Grabadora de sonido
« Respuesta #3 en: 31 de Mayo de 2012, 11:10:35 »
Talvez puedas usar una I2C EEPROM en modo escritura de página. En lo que graba la página tú recopilas muestras.
« Última modificación: 31 de Mayo de 2012, 14:47:07 por migsantiago »

Desconectado churrinfunflais

  • PIC12
  • **
  • Mensajes: 68
Re: Grabadora de sonido
« Respuesta #4 en: 31 de Mayo de 2012, 11:31:56 »
Yo hace ya algunos meses (poco menos de un año) realicé un proyecto parecido, pic18f2550 para trabajar a 48Mhz, muestreo el sonido de la línea telefonica a 8Khz y gravo en la sd en formato WAV. Gracias a Suky que me aconsejo con las resistencias pude mejorar la velocidad de escritura en la SD, pero ahun así para ese muestreo me quedo corto, tengo algún cuello de botella por algun lado, la cuestión es que cada 2 o 3 segundos se me pisan los buffers y al oir el sonido se escucha el saltito.

No lo depuré a fondo ya que lo hice para aprender el manejo de la sd y para experimentar algunas cosas.

Un saludo
Tannke crees que me puedas guiar un pokito , seria de gran ayuda ando un poko perdido nunca eh implementado memorias sd.

Talvez puedas usar una I2C EEPROM en modo escritura de página. En lo que graba la página tu recopilas muestras.
Creo que una EPROM se quedaría corta para los tamaños de información que se guardarían, el objetivo es guardar una gran cantidad de audio, lo que quepa en la sd tal ves en archivos de 5min o ago similar.

Saludos amigos...

Desconectado tannke

  • PIC16
  • ***
  • Mensajes: 176
Re: Grabadora de sonido
« Respuesta #5 en: 01 de Junio de 2012, 07:32:43 »
Tannke crees que me puedas guiar un pokito , seria de gran ayuda ando un poko perdido nunca eh implementado memorias sd.

No hay problema en guiarte y ayudarte en lo que pueda, de todos modos si es por el tema sd, suky en este mismo foro tiene un tema donde lo explica perfectamente: http://www.todopic.com.ar/foros/index.php?topic=27786.0

Yo el tema sd lo realicé con las librerias de MikroC, ya que este es el compilador que uso. Un saludo

Desconectado Suky

  • Moderador Local
  • DsPIC33
  • *****
  • Mensajes: 6758
Re: Grabadora de sonido
« Respuesta #6 en: 01 de Junio de 2012, 15:00:16 »
Talvez puedas usar una I2C EEPROM en modo escritura de página. En lo que graba la página tú recopilas muestras.

Si con una EEPROM F-RAM SPI a 40 MHz (no requieren esperar tiempo para una próxima escritura) obviando varios ciclos de reloj solo puede guardar a 5kHz, dudo que con una I2C  :?

Primero que nada tenes que plantearte a que velocidad de muestreo vas a guardar el sonido y en base a eso que memoria vas a utilizar. Con un PIC24/PIC32 seguramente podes utilizar una memoria RAM, tiene el módulo PMP. Luego de almacenada la información puedes leerla e ir creando el archivo en la SD Card.


Saludos!
No contesto mensajes privados, las consultas en el foro

Desconectado churrinfunflais

  • PIC12
  • **
  • Mensajes: 68
Re: Grabadora de sonido
« Respuesta #7 en: 01 de Junio de 2012, 16:03:08 »
Eh estado pensando en como hacerlo y creo que seria mejor hacer la codificacion a un formato wav o mp3 en la PC, lo que pienso es guardar los datos crudos del ADC directo en la SD (tal ves en un txt o algo similar) y transmitirlo a la PC via Serial y en la PC realizar la codificación a formato audio.

Tal ves así consuma menos recursos del micro y quede mejor ya que no me es esencial el reproducir el sonido o sacar la memoria sd del micro mi plan es mandar la información por algún método inalambrico a la pc, y donde se desea colocar el dispositivo sera en un lugar inaccesible.

Saludos.

Desconectado RICHI777

  • Colaborador
  • PIC24H
  • *****
  • Mensajes: 1498
Re: Grabadora de sonido
« Respuesta #8 en: 01 de Junio de 2012, 17:21:41 »
Hola, no soy un especialista en la materia, pero para un micro de 8 bits es bastante complicado manejar directamente un MP3 ( por la matemática que requiere ). También debes considerar cual es la calidad que deseas porque si deseas cubrir todo el ancho de la voz humana que va de 20 Hz a 20 Khz deberías muestrar minimamente a 40 Khz según el teorena de Nysquit. Te dejo una nota de aplicación de Atmel donde hacen una apliación para las memorias Data Flash ( Alto storage y muy rápidas ) .

http://www.atmel.com/Images/doc1456.pdf

Creo que para bajar la cantidad de muestras requeridas para la reconstrucción también se utiliza el ADPCM.

Saludos !

Desconectado tannke

  • PIC16
  • ***
  • Mensajes: 176
Re: Grabadora de sonido
« Respuesta #9 en: 02 de Junio de 2012, 06:25:20 »
Te dejo lo que pude conseguir yo. Ya verás (oirás) que el sonido no va muy hayá y se van escuchando los cortes. Te recomiendo hagas caso a los expertos y utilices algun tipo de memoria ram. Incluso no te hará falta SD ya que comentas que una vez guardado quieres lanzar los datos a una pc.



Está bastante guarrete, en proteus este modelo de SD no está y al crearlo me equivoque con el patillage, por lo que una vez hecha la placa (cuando me di cuenta) tuve que cortar pistas...

En el video se ve que empieza a gravar al descolgar el telefono y corta al colgar.

Dejo la gravación comprimida en rar.  Un saludo

Edit. oimos un ancho de +- lo que ha dicho RICHI777, pero la voz es muchisimo menor, creo andaba +- 80Hz a 1KHz
« Última modificación: 02 de Junio de 2012, 08:31:38 por tannke »

Desconectado churrinfunflais

  • PIC12
  • **
  • Mensajes: 68
Re: Grabadora de sonido
« Respuesta #10 en: 06 de Junio de 2012, 15:20:42 »
Hola!!!

Eh estado tratando de implementar una memoria SD en el proyectos pero no lo logro, eh seguido el AN1045 y nada también la guia de Suky y no logro compilar también eh intentado el ejemplo que biene en el stack de microchip , sera que tengo algo mal??

ejemplo del Stack:
Código: [Seleccionar]
/******************************************************************************
 *
 *               Microchip Memory Disk Drive File System
 *
 ******************************************************************************
 * FileName:        Demonstration.c
 * Dependencies:    FSIO.h
 * Processor:       PIC18
 * Compiler:        C18
 * Company:         Microchip Technology, Inc.
 *
 * Software License Agreement
 *
 * The software supplied herewith by Microchip Technology Incorporated
 * (the �Company�) for its PICmicro� Microcontroller is intended and
 * supplied to you, the Company�s customer, for use solely and
 * exclusively on Microchip PICmicro Microcontroller products. The
 * software is owned by the Company and/or its supplier, and is
 * protected under applicable copyright laws. All rights are reserved.
 * Any use in violation of the foregoing restrictions may subject the
 * user to criminal sanctions under applicable laws, as well as to
 * civil liability for the breach of the terms and conditions of this
 * license.
 *
 * THIS SOFTWARE IS PROVIDED IN AN �AS IS� CONDITION. NO WARRANTIES,
 * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
 * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
 * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
 * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
 * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
 *
 *****************************************************************************/


/*****************************************************************************
        Note:  This file is included to give you a basic demonstration of how the
           functions in this library work.  Prototypes for these functions,
           along with more information about them, can be found in FSIO.h
 *****************************************************************************/

//DOM-IGNORE-BEGIN
/********************************************************************
 Change History:
  Rev            Description
  ----           -----------------------
  1.2.4 - 1.2.6  No Change
  1.2.6          Add support for the PIC18F46J50_PIM
  1.3.4          Added support for PIC18F8722 on PIC18 Explorer Board
 ********************************************************************/
//DOM-IGNORE-END


#include "FSIO.h"


#if defined(PIC18F87J50_PIM) // Configuration bits for PIC18F87J50 FS USB Plug-In Module board
#pragma config XINST    = OFF   // Extended instruction set
#pragma config STVREN   = ON       // Stack overflow reset
#pragma config PLLDIV   = 3         // (12 MHz crystal used on this board)
#pragma config WDTEN    = OFF       // Watch Dog Timer (WDT)
#pragma config CP0      = OFF       // Code protect
#pragma config CPUDIV   = OSC1      // OSC1 = divide by 1 mode
#pragma config IESO     = OFF       // Internal External (clock) Switchover
#pragma config FCMEN    = OFF       // Fail Safe Clock Monitor
#pragma config FOSC     = HSPLL     // Firmware must also set OSCTUNE<PLLEN> to start PLL!
#pragma config WDTPS    = 32768
//      #pragma config WAIT     = OFF       // Commented choices are
//      #pragma config BW       = 16       // only available on the
//      #pragma config MODE     = MM       // 80 pin devices in the
//      #pragma config EASHFT   = OFF       // family.
#pragma config MSSPMSK  = MSK5
//      #pragma config PMPMX    = DEFAULT
//      #pragma config ECCPMX   = DEFAULT
#pragma config CCP2MX   = DEFAULT  
#elif defined(PIC18F46J50_PIM)
#pragma config WDTEN = OFF          //WDT disabled (enabled by SWDTEN bit)
#pragma config PLLDIV = 3           //Divide by 3 (12 MHz oscillator input)
#pragma config STVREN = ON            //stack overflow/underflow reset enabled
#pragma config XINST = OFF          //Extended instruction set disabled
#pragma config CPUDIV = OSC1        //No CPU system clock divide
#pragma config CP0 = OFF            //Program memory is not code-protected
#pragma config OSC = HSPLL          //HS oscillator, PLL enabled, HSPLL used by USB
#pragma config T1DIG = ON           //Sec Osc clock source may be selected
#pragma config LPT1OSC = OFF        //high power Timer1 mode
#pragma config FCMEN = OFF          //Fail-Safe Clock Monitor disabled
#pragma config IESO = OFF           //Two-Speed Start-up disabled
#pragma config WDTPS = 32768        //1:32768
#pragma config DSWDTOSC = INTOSCREF //DSWDT uses INTOSC/INTRC as clock
#pragma config RTCOSC = T1OSCREF    //RTCC uses T1OSC/T1CKI as clock
#pragma config DSBOREN = OFF        //Zero-Power BOR disabled in Deep Sleep
#pragma config DSWDTEN = OFF        //Disabled
#pragma config DSWDTPS = 8192       //1:8,192 (8.5 seconds)
#pragma config IOL1WAY = OFF        //IOLOCK bit can be set and cleared
#pragma config MSSP7B_EN = MSK7     //7 Bit address masking
#pragma config WPFP = PAGE_1        //Write Protect Program Flash Page 0
#pragma config WPEND = PAGE_0       //Start protection at page 0
#pragma config WPCFG = OFF          //Write/Erase last page protect Disabled
#pragma config WPDIS = OFF          //WPFP[5:0], WPEND, and WPCFG bits ignored
#elif defined(__18F8722)
#pragma config OSC=HSPLL, FCMEN=OFF, IESO=OFF, PWRT=OFF, WDT=OFF, LVP=OFF, XINST=OFF
#else
#endif

char sendBuffer[22] = "This is test string 1";
char send2[2] = "2";
char receiveBuffer[50];

char dirname1[16] = ".\\ONE\\TWO\\THREE";
char dirname2[14] = "ONE\\TWO\\THREE";
char dirname3[14] = "FOUR\\FIVE\\SIX";
char dirname4[60] = "FOUR\\FIVE\\SEVEN\\..\\EIGHT\\..\\..\\NINE\\TEN\\..\\ELEVEN\\..\\TWELVE";
char dirname5[31] = "\\ONE\\TWO\\THREE\\FOUR\\FIVE\\EIGHT";
char dirname6[10] = "FOUR\\NINE";
char dirname7[2];

void main(void) {
    FSFILE * pointer;
    char path[30];
    char count = 30;
    char * pointer2;
    SearchRec rec;
    unsigned char attributes;
    unsigned char size = 0, i;

#if (defined(__18CXX) & !defined(PIC18F87J50_PIM)) || defined(__18F8722)
    ADCON1 |= 0x0F; // Default all pins to digital
#elif !defined(PIC18F87J50_PIM)
    AD1PCFG = 0xFFFF;
#endif
#if defined(PIC18F87J50_PIM)
    WDTCONbits.ADSHR = 1; // Select alternate SFR location to access ANCONx registers
    ANCON0 = 0xFF; // Default all pins to digital
    ANCON1 = 0xFF; // Default all pins to digital
    WDTCONbits.ADSHR = 0; // Select normal SFR locations
#endif
#if defined(PIC18F46J50_PIM)
    ANCON0 = 0xFF; // Default all pins to digital
    ANCON1 = 0xFF; // Default all pins to digital
#endif
    //********* Initialize Peripheral Pin Select (PPS) *************************
    //  This section only pertains to devices that have the PPS capabilities.
    //    When migrating code into an application, please verify that the PPS
    //    setting is correct for the port pins that are used in the application.
#if defined(PIC18F46J50_PIM)
    RPINR21 = 1; //SDI = RP1
    RPOR4 = 10; //RP4 = SCK
    RPOR2 = 9; //RP2 = SDO
    RPINR22 = 4; //SCK = RP4

    //enable a pull-up for the card detect, just in case the SD-Card isn't attached
    //  then lets have a pull-up to make sure we don't think it is there.
    INTCON2bits.RBPU = 0;

#endif
    while (!MDD_MediaDetect());

    // Initialize the library
    while (!FSInit());

#ifdef ALLOW_WRITES
    // Set the clock value
    // This will determine the create time for the file we're about to make
    // This will set the time and date to 3:05:26 PM on July 27, 2007.
    if (SetClockVars(2007, 7, 27, 15, 5, 26))
        while (1);

    // Create a file
    pointer = FSfopenpgm("FILE3.TXT", "w");
    if (pointer == NULL)
        while (1);

    // Write 21 1-byte objects from sendBuffer into the file
    if (FSfwrite((void *) sendBuffer, 1, 21, pointer) != 21)
        while (1);

    // FSftell returns the file's current position
    if (FSftell(pointer) != 21)
        while (1);

    // FSfseek sets the position one byte before the end
    // It can also set the position of a file forward from the
    // beginning or forward from the current position
    if (FSfseek(pointer, 1, SEEK_END))
        while (1);

    // Write a 2 at the end of the string
    if (FSfwrite((void*) send2, 1, 1, pointer) != 1)
        while (1);

    // Set the time again
    // When called before fclose, this will determine the last time
    // accessed and modified.  This time will be 4 seconds after the last one.
    if (SetClockVars(2007, 7, 27, 15, 5, 30))
        while (1);

    // Close the file
    if (FSfclose(pointer))
        while (1);

    // Set the clock again
    // This time is the last one possible with the FAT file system
    // 11:59:59 PM, December 31, 2106.
    if (SetClockVars(2107, 12, 31, 23, 59, 59))
        while (1);

    // Create a second file
    pointer = FSfopenpgm("FILE1.TXT", "w");
    if (pointer == NULL)
        while (1);

    // Write the string to it again
    if (FSfwrite((void *) sendBuffer, 1, 21, pointer) != 21)
        while (1);

    // Close the file
    if (FSfclose(pointer))
        while (1);
#endif

    // Open file 1 in read mode
    pointer = FSfopenpgm("FILE3.TXT", "r");
    if (pointer == NULL)
        while (1);

    if (FSrenamepgm("FILE2.TXT", pointer))
        while (1);

    // Read one four-byte object
    if (FSfread(receiveBuffer, 4, 1, pointer) != 1)
        while (1);

    // Check if this is the end of the file- it shouldn't be
    if (FSfeof(pointer))
        while (1);

    // Close the file
    if (FSfclose(pointer))
        while (1);

    // Make sure we read correctly
    if ((receiveBuffer[0] != 'T') ||
            (receiveBuffer[1] != 'h') ||
            (receiveBuffer[2] != 'i') ||
            (receiveBuffer[3] != 's')) {
        while (1);
    }

#ifdef ALLOW_DIRS
    // Create a small directory tree
    // Beginning the path string with a '.' will create the tree in
    // the current directory.  Beginning with a '..' would create the
    // tree in the previous directory.  Beginning with just a '\' would
    // create the tree in the root directory.  Beginning with a dir name
    // would also create the tree in the current directory
    if (FSmkdir(dirname1))
        while (1);

    // Change to directory THREE in our new tree
    if (FSchdir(dirname2))
        while (1);

    // Create another tree in directory THREE
    if (FSmkdir(dirname3))
        while (1);

    // Create a third file in directory THREE
    pointer = FSfopenpgm("FILE3.TXT", "w");
    if (pointer == NULL)
        while (1);

    // Get the name of the current working directory
    /* it should be "\ONE\TWO\THREE"       */
    pointer2 = FSgetcwd(path, count);
    if (pointer2 != path)
        while (1);

    // Simple string length calculation
    i = 0;
    while (*(path + i) != 0x00) {
        size++;
        i++;
    }
    // Write the name to FILE3.TXT
    if (FSfwrite((void *) path, size, 1, pointer) != 1)
        while (1);

    // Close the file
    if (FSfclose(pointer))
        while (1);

    // Create some more directories
    if (FSmkdir(dirname4))
        while (1);

    /*******************************************************************
            Now our tree looks like this

            \ -> ONE -> TWO -> THREE -> FOUR -> FIVE -> SIX
                                             -> SEVEN
                                             -> EIGHT
                                        NINE -> TEN
                                             -> ELEVEN
                                             -> TWELVE
     ********************************************************************/

    // This will delete only directory eight
    // If we tried to delete directory FIVE with this call, the FSrmdir
    // function would return -1, since FIVE is non-empty
    if (FSrmdir(dirname5, FALSE))
        while (1);

    // This will delete directory NINE and all three of its sub-directories
    if (FSrmdir(dirname6, TRUE))
        while (1);

    // You can't initialize an array in PIC18 to just a backslash
    // Initialize it manually
    dirname7[0] = '\\';
    dirname7[1] = 0;
    // Change directory to the root dir
    if (FSchdir(dirname7))
        while (1);

#endif

#ifdef ALLOW_FILESEARCH
    // Set attributes
    attributes = ATTR_ARCHIVE | ATTR_READ_ONLY | ATTR_HIDDEN;

    // Functions "FindFirstpgm" & "FindNext" can be used to find files
    // and directories with required attributes in the current working directory.

    // Find the first TXT file with any (or none) of those attributes that
    // has a name beginning with the letters "FILE"
    // These functions are more useful for finding out which files are
    // in your current working directory
    if (FindFirstpgm("FILE*.TXT", attributes, &rec))
        while (1);

    // Keep finding files until we get FILE2.TXT
    while (rec.filename[4] != '2') {
        if (FindNext(&rec))
            while (1);
    }

    // Delete file 2.
    // NOTE : "FSremove" function deletes specific file not directory.
    //        To delete directories use "FSrmdir" function
    if (FSremove(rec.filename))
        while (1);
#endif

    /*********************************************************************
            The final contents of our card should look like this:
            \ -> FILE1.TXT
          -> ONE       -> TWO -> THREE -> FILE3.TXT
                                       -> FOUR      -> FIVE -> SIX
                                                            -> SEVEN

     *********************************************************************/


    while (1);
}

Error que aparece:
Código: [Seleccionar]
CLEAN SUCCESSFUL (total time: 67ms)
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory `C:/Microchip Solutions v2012-04-03/MDD File System-SD Card/PIC18F/SD.X'
make  -f nbproject/Makefile-default.mk dist/default/production/SD.X.production.hex
make[2]: Entering directory `C:/Microchip Solutions v2012-04-03/MDD File System-SD Card/PIC18F/SD.X'
"X:\Program Files (x86)\Microchip\mplabc18\v3.40\bin\mcc18.exe"  -p18F8722 -I"C:/Microchip Solutions v2012-04-03/Microchip/Include/MDD File System" -I"C:/Microchip Solutions v2012-04-03/Microchip/Include" -I"C:/Microchip Solutions v2012-04-03/MDD File System-SD Card/PIC18F" -I"C:/Microchip Solutions v2012-04-03/MDD File System-SD Card"  -I "X:\Program Files (x86)\Microchip\mplabc18\v3.40\bin"\\..\\h  -fo build/default/production/_ext/1472/Demonstration.o   ../Demonstration.c
"X:\Program Files (x86)\Microchip\mplabc18\v3.40\bin\mplink.exe"  "..\18f8722_g.lkr"  -p18f8722  -w    -z__MPLAB_BUILD=1  -u_CRUNTIME -l "X:\Program Files (x86)\Microchip\mplabc18\v3.40\bin"\\..\\lib  -o dist/default/production/SD.X.production.cof  build/default/production/_ext/1472/Demonstration.o  
MPLINK 4.40, Linker
Device Database Version 1.3
Copyright (c) 1998-2011 Microchip Technology Inc.
Error - could not find definition of symbol 'FSremove' in file './build/default/production/_ext/1472/Demonstration.o'.
Errors    : 1

make[2]: Leaving directory `C:/Microchip Solutions v2012-04-03/MDD File System-SD Card/PIC18F/SD.X'
make[1]: Leaving directory `C:/Microchip Solutions v2012-04-03/MDD File System-SD Card/PIC18F/SD.X'
make[2]: *** [dist/default/production/SD.X.production.hex] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 901ms)

Pareciese que no jala las funciones de la libreria "FSIO.h", que piensan??

Desconectado churrinfunflais

  • PIC12
  • **
  • Mensajes: 68
Re: Grabadora de sonido
« Respuesta #11 en: 12 de Junio de 2012, 16:10:29 »
Aquí les dejo el proyecto en el que estoy trabajando.

Cambie al compilador CX8 para ver si había alguna diferencia pero sigo sin lograr compilar... Saludos

Código: [Seleccionar]
CLEAN SUCCESSFUL (total time: 117ms)
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory `C:/Microchip Solutions v2012-04-03/MDD File System-SD Card/PIC18F/SD_Demo.X'
make  -f nbproject/Makefile-default.mk dist/default/production/SD_Demo.X.production.hex
make[2]: Entering directory `C:/Microchip Solutions v2012-04-03/MDD File System-SD Card/PIC18F/SD_Demo.X'
"C:\Program Files (x86)\Microchip\xc8\v1.00\bin\xc8.exe" --pass1  --chip=18F8722 -Q -G --asmlist  --double=24 --float=24 --emi=wordwrite --opt=all,+asm,-asmfile,+speed,-space,-debug,9 --addrqual=ignore --mode=pro -N31 --warn=0 --summary=default,-psect,-class,+mem,-hex,-file --runtime=default,+clear,+init,-keep,-no_startup,+osccal,-resetbits,-download,-stackcall,+config,+clib,+plib "--errformat=%%f:%%l: error: %%s" "--warnformat=%%f:%%l: warning: %%s" "--msgformat=%%f:%%l: advisory: %%s"  -obuild/default/production/main.p1  main.c
"C:\Program Files (x86)\Microchip\xc8\v1.00\bin\xc8.exe"  --chip=18F8722 -G --asmlist -mdist/default/production/SD_Demo.X.production.map  --double=24 --float=24 --emi=wordwrite --opt=all,+asm,-asmfile,+speed,-space,-debug,9 --addrqual=ignore --mode=pro -N31 --warn=0 --summary=default,-psect,-class,+mem,-hex,-file --runtime=default,+clear,+init,-keep,-no_startup,+osccal,-resetbits,-download,-stackcall,+config,+clib,+plib "--errformat=%%f:%%l: error: %%s" "--warnformat=%%f:%%l: warning: %%s" "--msgformat=%%f:%%l: advisory: %%s"   -odist/default/production/SD_Demo.X.production.cof  build/default/production/main.p1    
Microchip MPLAB XC8 C Compiler (Free Mode)  V1.00
Copyright (C) 2012 Microchip Technology Inc.
(1273) Omniscient Code Generation not available in Free mode (warning)
:: advisory: Employing 18F8722 errata work-arounds:
:: advisory:  * Corrupted fast interrupt shadow registers
main.c:167: warning: "RAM" is positioned at address 0x0 and has had its address taken; pointer comparisons may be invalid
:0: error: undefined symbols:
        _FSgetcwd(dist/default/production\SD_Demo.X.production.obj) _FSfclose(dist/default/production\SD_Demo.X.production.obj) _FSfwrite(dist/default/production\SD_Demo.X.production.obj) _FSremove(dist/default/production\SD_Demo.X.production.obj) _FindNext(dist/default/production\SD_Demo.X.production.obj) _FSrenamepgm(dist/default/production\SD_Demo.X.production.obj) _FSfeof(dist/default/production\SD_Demo.X.production.obj) _FSInit(dist/default/production\SD_Demo.X.production.obj) _FSfread(dist/default/production\SD_Demo.X.production.obj) _FSfseek(dist/default/production\SD_Demo.X.production.obj) _FSftell(dist/default/production\SD_Demo.X.production.obj) _FSchdir(dist/default/production\SD_Demo.X.production.obj) _FSmkdir(dist/default/production\SD_Demo.X.production.obj) _FSrmdir(dist/default/production\SD_Demo.X.production.obj) _FSfopenpgm(dist/default/production\SD_Demo.X.production.obj) _FindFirstpgm(dist/default/production\SD_Demo.X.production.obj) _MDD_SDSPI_MediaDetect(dist/default/production\SD_Demo.X.production.obj) _SetClockVars(dist/default/production\SD_Demo.X.production.obj)
make[2]: Leaving directory `C:/Microchip Solutions v2012-04-03/MDD File System-SD Card/PIC18F/SD_Demo.X'
make[1]: Leaving directory `C:/Microchip Solutions v2012-04-03/MDD File System-SD Card/PIC18F/SD_Demo.X'
(908) exit status = 1
make[2]: *** [dist/default/production/SD_Demo.X.production.hex] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 2s)

Desconectado churrinfunflais

  • PIC12
  • **
  • Mensajes: 68
Re: Grabadora de sonido
« Respuesta #12 en: 21 de Junio de 2012, 14:02:43 »
Hola!!!

Aquí les pongo el avance que tengo del proyecto, ya he logrado guardar los datos satisfactoriamente en la memoria sd pero tuve que cambiar de pic a un PIC18f8722 y eh tenido problemas configurando el USART,   Espero que alguien me apunte en la dirección correcta...

Código: [Seleccionar]
/** CONFIGURATION **************************************************/
#if defined(__18F8722)
    #pragma config OSC=HSPLL
    #pragma config IESO=OFF
    #pragma config PWRT=OFF
    #pragma config WDT=OFF
    #pragma config LVP=OFF
    #pragma config XINST=OFF
    #pragma config FCMEN=OFF
#endif

Código: [Seleccionar]
//Open The USART PORT
    Open1USART(USART_TX_INT_OFF & USART_RX_INT_OFF & USART_ASYNCH_MODE & USART_EIGHT_BIT & USART_CONT_RX & USART_BRGH_HIGH, 25);

Este es el main completo...
Código: [Seleccionar]
/** INCLUDES *******************************************************/
#include "MDD File System/FSIO.h"
#include "usart.h"

/** CONFIGURATION **************************************************/
#if defined(__18F8722)
    #pragma config OSC=HSPLL
    #pragma config IESO=OFF
    #pragma config PWRT=OFF
    #pragma config WDT=OFF
    #pragma config LVP=OFF
    #pragma config XINST=OFF
    #pragma config FCMEN=OFF
#endif

/** PRIVATE PROTOTYPES *********************************************/
WORD_VAL ReadMIC(void);
void PassOK(void);

/** VARIABLES ******************************************************/
char sendBuffer[];
char receiveBuffer[5];
volatile unsigned char BufferPass [64];
static BOOL BTControl;
INT8 Ptr=0;

/********************************************************************
 * Function:        void main(void)
 *
 * PreCondition:    None
 *
 * Input:           None
 *
 * Output:          None
 *
 * Side Effects:    None
 *
 * Overview:        Main program entry point.
 *
 * Note:            None
 *******************************************************************/
void main(void) {

    unsigned int* data;
    unsigned int i;
    FSFILE *logFile;
    BOOL initResults;
    WORD_VAL ADCResult;
    BYTE printData[6];

    //set the data pointer for the FSfwrite function
    data = &i;

    initResults = FSInit();

    //initialize the A/D
    mInitMIC();

    //Set up the LED as output
    mInitAllLEDs();

    //Set the push button input
    mInitSwitch2();

    //Open The USART PORT
    Open1USART(USART_TX_INT_OFF & USART_RX_INT_OFF & USART_ASYNCH_MODE & USART_EIGHT_BIT & USART_CONT_RX & USART_BRGH_HIGH, 25);

    //The log file is not open so let's make sure the pointer is NULLed out
    logFile = NULL;

    BTControl = FALSE;
    while (Busy1USART());
    putrs1USART("\fintroducir Pasword \r\n");

    while (1) {

        if (BTControl == TRUE) {
            if (initResults == TRUE) {

                //We don't want the USB and the MDD to try to write
                //to the file at the same time.  The simplest way to
                //block this is not to allow the demo application to
                //write to the file while it is connected to the USB
                //if(USBDeviceState < DEFAULT_STATE)
                //{
                if (sw2 == 0) {
                    if (logFile != NULL) {
                        // Get an ADC sample
                        ADCResult = ReadMIC();

                        sprintf((char*) &printData[0], "%d\r\n", ADCResult.Val);
                        FSfwrite((const void*) &printData[0], 1, sizeof (printData), logFile);

                    } else {
#if defined(__18CXX)
                        logFile = FSfopenpgm("log.csv", "w");
#else
                        logFile = FSfopen("log.csv", "w");
#endif
                    }

                    mLED_1_On();
                } else {
                    if (logFile != NULL) {
                        FSfclose(logFile);
                        logFile = NULL;
                    }
                    mLED_1_Off();
                }
            } else {
                if (MDD_SDSPI_MediaDetect() == TRUE) {
                    initResults = FSInit();
                }
            }
        } else {
            PassOK(); //Verificar contraseña
        }
    } //end while
#if !defined(__18CXX)
    return 0;
#endif
}

/******************************************************************************
 * Function:        WORD_VAL ReadMIC(void)
 *
 * PreCondition:    None
 *
 * Input:           None
 *
 * Output:          WORD_VAL - the 10-bit right justified MIC value
 *
 * Side Effects:    ADC buffer value updated
 *
 * Overview:        This function reads the MIC and leaves the value in the
 *                  ADC buffer register
 *
 * Note:            None
 *****************************************************************************/
WORD_VAL ReadMIC(void) {
    WORD_VAL w;

#if defined(__18CXX)
    mInitMIC();

    ADCON0bits.GO = 1; // Start AD conversion
    while (ADCON0bits.NOT_DONE); // Wait for conversion

    w.v[0] = ADRESL;
    w.v[1] = ADRESH;
#endif

    return w;
}//end ReadPOT

/********************************************************************
 * Function:        void PassOK(void)
 *
 * PreCondition:    None
 *
 * Input:           None
 *
 * Output:          None
 *
 * Side Effects:    None
 *
 * Overview:        This function grant acces to the serial control
 *
 * Note:
 *******************************************************************/
void PassOK(void) {
    while (!DataRdy1USART());

    memset(BufferPass, 0, sizeof (BufferPass));
    gets1USART(BufferPass, 4);

    if (BufferPass[Ptr] == '\r') {
        if (strcmppgm2ram(BufferPass, "1234") == 0) {
            while (Busy1USART());
            putrs1USART("Accsess Granted \r\n");
            BTControl = TRUE;
        } else {
            while (Busy1USART());
            putrs1USART("Accsess Denied \r\n");
            BTControl = FALSE;
        }
    }
}//End chek password

Saludos...

Desconectado churrinfunflais

  • PIC12
  • **
  • Mensajes: 68
Re: Grabadora de sonido
« Respuesta #13 en: 21 de Junio de 2012, 16:33:39 »
Bueno ... como siempre me falla la configuración pero ya esta funcionando con un Xtal de 24 MHz,,, aquí les dejo un pantallazo de de la info que guarda el micro....
Alguien sabe como echar a andar generador de sonido en el proteus???
me sale el error:
Código: [Seleccionar]
Internal Exception access violation in module 'WINMM.DLL'[74D5B8E3]
ahora solo me falta leer la SD abrir el archivo y transmitirlo a la pc...
« Última modificación: 21 de Junio de 2012, 17:25:34 por churrinfunflais »

Desconectado churrinfunflais

  • PIC12
  • **
  • Mensajes: 68
Re: Grabadora de sonido
« Respuesta #14 en: 22 de Junio de 2012, 13:27:08 »
Alguien ah implementado el audio recording de al appnote AN643 de microchip???? estoy un poco perdido porque el sourse code que trae es par reproducir y no para gravar, aunque trae el algoritmo para grabar... y se podría implementar con una SD???

AN643

Código: [Seleccionar]
The following is the sequence of events to record and
store speech data. A timer would be used to set the
sample rate. When the timer overflowed, an A/D
conversion would be started.
1. Start an A/D conversion when the timer overflows.
2. Read the sample and call the routine, ADPCMEncoder().
3. Store the result in the upper 4 bits of a temporary variable.
4. Start an A/D conversion when the timer overflows.
5. Read the sample and call the routine, ADPCMEncoder().
6. Store the result in the lower 4 bits of the temporary variable.
7. Write the temporary variable to the nonvolatile memory.
8. Go to step 1.

Saludos...
« Última modificación: 22 de Junio de 2012, 13:31:03 por churrinfunflais »


 

anything