Versão do protegemed que calcula o tempo em ms da fuga, calcula o numero de onverflow (valores muito baixo) e underflow (valores muito altos). Além disso, calcula um valor médio a partir dos valores capturados e não apenas pela fft.
Dependencies: EthernetInterface mbed-rtos mbed
Revision 2:86c3cb25577b, committed 2014-07-21
- Comitter:
- rebonatto
- Date:
- Mon Jul 21 00:58:34 2014 +0000
- Parent:
- 1:917ca6b5d9d9
- Commit message:
- Problemas com objeto para aquisi??o da rfid (serial)
Changed in this revision
--- a/Codes/Capture.cpp Fri Jul 18 20:24:45 2014 +0000 +++ b/Codes/Capture.cpp Mon Jul 21 00:58:34 2014 +0000 @@ -8,8 +8,11 @@ Semaphore Capture::m_CaptureSemaphore(1); //used to alert the capture thread about a ready capture int Capture::m_BufferIndex; -dmaLinkedListNode Capture::m_Nodes[2] __attribute__((section("AHBSRAM0"))); //this list holds the buffer configuration for the DMA peripheral -unsigned short int Capture::m_AdcBuffers[2][NUMBER_OF_SAMPLES][NUMBER_OF_CHANNELS] __attribute__((section("AHBSRAM0"))); + +//extern char LargeBuffer[1024]; + +__attribute((section("AHBSRAM1"),aligned)) dmaLinkedListNode Capture::m_Nodes[2];// __attribute__((section("AHBSRAM0"))); //this list holds the buffer configuration for the DMA peripheral +__attribute((section("AHBSRAM1"),aligned)) unsigned short int Capture::m_AdcBuffers[2][NUMBER_OF_SAMPLES][NUMBER_OF_CHANNELS];// __attribute__((section("AHBSRAM0"))); //Serial rfid_serial(p28,p27); //This function prepares the capture buffers and starts the DMA peripheral @@ -36,6 +39,7 @@ //This function initializes the ADC and DMA peripherals void Capture::Initialize() { + //printf("0x%lx\n", LargeBuffer); init_adc(Settings::get_FreqBase()*NUMBER_OF_SAMPLES*NUMBER_OF_CHANNELS); select_channels(ADC_CH_0|ADC_CH_1|ADC_CH_2|ADC_CH_3|ADC_CH_4|ADC_CH_5); LPC_ADC->ADCR |= ADC_MODE_BURST;
--- a/Codes/EventDetector.cpp Fri Jul 18 20:24:45 2014 +0000 +++ b/Codes/EventDetector.cpp Mon Jul 21 00:58:34 2014 +0000 @@ -271,7 +271,7 @@ } } - printf("Passou algum troço\n"); + if (type == 1 || type == 2 || type == 4) // Calula FFT s nos eventos de fuga, acompanhamento de fuga (diferencial) e liga SignalProcessor::CalculateFFT(buf,seno,coss,&mv,1, m_Channel); /* @@ -284,14 +284,14 @@ //event->Setup(rfid,type,outlet_number,mv,rmsvalue,Settings::get_Gain(m_Channel),Settings::get_Offset(m_Channel),seno,coss); - printf("Passou FFT\n"); + event->Setup(rfid,type,outlet_number,mv,mv2, rmsvalue,under, over, Settings::get_Gain(m_Channel),Settings::get_Offset(m_Channel),duration, seno,coss); //printf("\n\nDuration: %d\n\n", duration); ShowValues(event); //and finally place the object in the mailbox queue. - GetMailbox().put(event); + //GetMailbox().put(event); //printf("Deu put no evento no mailBox\n"); }
--- a/Codes/SignalProcessor.cpp Fri Jul 18 20:24:45 2014 +0000 +++ b/Codes/SignalProcessor.cpp Mon Jul 21 00:58:34 2014 +0000 @@ -11,6 +11,7 @@ #include <string.h> #include "SignalProcessor.h" +#include "limites.h" #define SWAP(a,b) tempr=(a);(a)=(b);(b)=tempr #define PI 3.14159265358979323846F @@ -99,9 +100,9 @@ for(i=0; i<Settings::get_Samples();i++) value[i]= (float) ( (buffer[i] - Settings::get_Offset(ch)) / Settings::get_Gain(ch) ); */ - printf("Antes ComplexFFT\n"); + float* fft = ComplexFFT(buffer,1, ch); //deve desalocar memoria do ptr retornado - printf("Passou ComplexFFT\n"); + /* Mapa do vetor fft. @@ -122,11 +123,12 @@ sen[i-1] = fft[i*2+1]; } + /* for(int i=0;i<Settings::get_MaxHarmonics();i++) { printf("[%dHz]\tsen %.4f\tcos %.4f\n", (i+1)*60, sen[i], cos[i]); } - + */ free(fft); //printf("[3] %d %d %d %d\n", buffer[0], buffer[100], buffer[200], buffer[255]); } @@ -153,6 +155,10 @@ vector=(float*)malloc(2*Settings::get_Samples()*sizeof(float)); memset(vector,0,2*Settings::get_Samples()*sizeof(float)); printf("DEpois malloc\n"); + + + DisplayRAMBanks(); + //put the real array in a complex array //the complex part is filled with 0's //the remaining vector with no data is filled with 0's
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Functions/limites.c Mon Jul 21 00:58:34 2014 +0000 @@ -0,0 +1,33 @@ +/* + * limites.c + * + * Created on: 20/07/2014 + * Author: rebonatto + */ + +#include "limites.h" + + +// These external symbols are maintained by the linker to indicate the +// location of various regions in the device's memory. They will be used by +// DisplayRAMBanks() to dump the size of each RAM bank to stdout. +extern unsigned int Image$$RW_IRAM1$$Base; +extern unsigned int Image$$RW_IRAM1$$ZI$$Limit; +extern unsigned int Image$$RW_IRAM2$$Base; +extern unsigned int Image$$RW_IRAM2$$ZI$$Limit; +extern unsigned int Image$$RW_IRAM3$$Base; +extern unsigned int Image$$RW_IRAM3$$ZI$$Limit; + + +// Displays the size of static allocations for each RAM bank as indicated by +// ARM linker to stdout. +void DisplayRAMBanks(void) +{ + printf("Static RAM bank allocations\r\n"); + printf(" Main RAM = %u\r\n", (unsigned int)&Image$$RW_IRAM1$$ZI$$Limit - + (unsigned int)&Image$$RW_IRAM1$$Base); + printf(" RAM0 = %u\r\n", (unsigned int)&Image$$RW_IRAM2$$ZI$$Limit - + (unsigned int)&Image$$RW_IRAM2$$Base); + printf(" RAM1 = %u\r\n", (unsigned int)&Image$$RW_IRAM3$$ZI$$Limit - + (unsigned int)&Image$$RW_IRAM3$$Base); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Functions/limites.h Mon Jul 21 00:58:34 2014 +0000 @@ -0,0 +1,23 @@ +/* + * limites.h + * + * Created on: 20/07/2014 + * Author: rebonatto + */ + +#ifndef LIMITES_H_ +#define LIMITES_H_ + +#include <stdio.h> + +#ifdef __cplusplus +extern "C" { +#endif + +extern void DisplayRAMBanks(void); + +#ifdef __cplusplus +}; +#endif + +#endif /* LIMITES_H_ */ \ No newline at end of file
--- a/main.cpp Fri Jul 18 20:24:45 2014 +0000 +++ b/main.cpp Mon Jul 21 00:58:34 2014 +0000 @@ -16,13 +16,14 @@ #include "Settings.h" #include "Capture.h" #include "Http_post.h" -#include "CommTCP.h" +//#include "CommTCP.h" #include "SignalProcessor.h" #include "EventDetector.h" +#include "limites.h" -#include "TelnetServer.h" +//#include "TelnetServer.h" - +//__attribute((section("AHBSRAM0"),aligned)) char LargeBuffer[1024]; EthernetInterface eth; void thread1(void const *args) @@ -129,6 +130,8 @@ //Start HTTP POST service Thread http_post(HttpPost::HttpPost_Thread); + DisplayRAMBanks(); + //Start TCP daemon service //Thread TcpService(CommTCP::CommTCP_Thread); @@ -148,7 +151,10 @@ printf("SEN%d = %f, COS%d = %f\n",i,sen[i],i,cos[i]); } */ - printf("Nova versao [6]\n\n"); + printf("Nova versao [8]\n\n"); + + //printf("0x%lx\n", LargeBuffer); + //Jump to the capture routine(will run on this thread) thread1(NULL);