Versão limpa em 04/09/2014. Telnet funcionando.
Dependencies: EthernetInterface mbed-rtos mbed NTPClient
Revision 29:fcfcb31a6362, committed 2015-04-28
- Comitter:
- rebonatto
- Date:
- Tue Apr 28 14:19:03 2015 +0000
- Parent:
- 28:463533ca610a
- Child:
- 30:9bf44d2785d5
- Commit message:
- Fun??es auxiliares para trabalhar com signed int;
Changed in this revision
--- a/Codes/Capture.cpp Fri Mar 27 21:09:39 2015 +0000 +++ b/Codes/Capture.cpp Tue Apr 28 14:19:03 2015 +0000 @@ -75,6 +75,14 @@ } } +void Capture::CopyBufferSigned(int channel, short int *dest) +{ + for(int i=0;i<NUMBER_OF_SAMPLES;i++) + { + dest[i] = GetValue(i,channel); + } +} + //DMA ISR signals the capture thread about the end of capture event extern "C" void DMA_IRQHandler(void) {
--- a/Codes/EventDetector.cpp Fri Mar 27 21:09:39 2015 +0000 +++ b/Codes/EventDetector.cpp Tue Apr 28 14:19:03 2015 +0000 @@ -11,6 +11,7 @@ #define MARCA 10 #define GERAFUGA 0 #define UMCICLO 16.666666667 + #define ZEROMV 1 CaptureMailbox EventDetector::m_EventMailbox; EventDetector EventDetector::m_Detector[NUMBER_OF_CHANNELS] = {0,1,2,3,4,5}; @@ -96,8 +97,27 @@ printf("\n"); } */ - if(rmsvalue > Settings::get_Limit(m_Channel)) + if(rmsvalue > Settings::get_Limit(m_Channel)) { + if ( ZEROMV ) // verifica se é para retirar o VM + { + short int buf[NUMBER_OF_SAMPLES]; + int i, newvm = 0; + Capture::CopyBufferSigned(m_Channel,buf); + + /* Retira o valorMedio de todas as amostras */ + for(i=0; i < NUMBER_OF_SAMPLES; i++){ + buf[i] -= (int) mv2; + newvm += buf[i]; + } + if ( m_EventCounter == Settings::get_EventLimit() ){ + newvm /= NUMBER_OF_SAMPLES; + printf("Novo valor medio %d\n", newvm); + } + + rmsvalue = SignalProcessor::CalculateRMSSigned(buf, m_Channel); + } + if(!m_OutletTriggered) { if(m_EventCounter < Settings::get_EventLimit()) @@ -311,7 +331,7 @@ // 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 Mar 27 21:09:39 2015 +0000 +++ b/Codes/SignalProcessor.cpp Tue Apr 28 14:19:03 2015 +0000 @@ -76,6 +76,28 @@ result = sqrt(result); return result; } + +float SignalProcessor::CalculateRMSSigned( short int *buffer,int nChannel) +{ + float result=0; + int nSample; + + for(nSample=0;nSample<NUMBER_OF_SAMPLES;nSample++) + { + + unsigned short int v = buffer[nSample]; + float val = (float)v; + // cada ponto + val -= Settings::get_Offset(nChannel); // diminui o offset + val /= Settings::get_Gain(nChannel); // divide pelo ganhp + val *= val; // eleva ao quadrado + result += val; // soma + } + result /= (float)NUMBER_OF_SAMPLES; // divide pelo numero de amostras (256) + result = sqrt(result); + return result; +} + void SignalProcessor::CalculateFFT(unsigned short int *buffer,float *sen,float *cos,float *vm,int sign, int ch) {
--- a/Headers/Capture.h Fri Mar 27 21:09:39 2015 +0000 +++ b/Headers/Capture.h Tue Apr 28 14:19:03 2015 +0000 @@ -39,6 +39,7 @@ static unsigned short int GetValue(int nsamples, int nchannel); static void CopyBuffer(int channel, unsigned short int *dest); + static void CopyBufferSigned(int channel, short int *dest); static void ISRHandler();
--- a/Headers/SignalProcessor.h Fri Mar 27 21:09:39 2015 +0000 +++ b/Headers/SignalProcessor.h Tue Apr 28 14:19:03 2015 +0000 @@ -24,6 +24,7 @@ //static void CalculateRMSBulk(float *result); static void CalculateRMSBulk(float *result, float *vm2, int *under, int *over); static float CalculateRMS(unsigned short int *buffer,int nChannel); + static float CalculateRMSSigned( short int *buffer,int nChannel); static void CalculateFFT(unsigned short int *buffer,float *sen,float *cos,float *vm,int sign, int ch); //static float DFT(float *data, float *seno, float *coss);
--- a/main.cpp Fri Mar 27 21:09:39 2015 +0000 +++ b/main.cpp Tue Apr 28 14:19:03 2015 +0000 @@ -133,7 +133,7 @@ int main() { PmedLog::WriteEntry(PMEDLOG_INITIALIZING); - printf("\r\nNova versao 45 ( 20150327.1 )...\r\n"); + printf("\r\nNova versao 48 ( 20150327.1 )...\r\n"); FILE *f; //Set Highest Priority //osThreadSetPriority(osThreadGetId(),osPriorityHigh); @@ -162,7 +162,7 @@ time_t tempo = time(NULL); if ((tempo+60) < 1420077600) set_time(1420077600); - ntpClient.setTime("192.168.103.101"); + // ntpClient.setTime("192.168.103.101"); DisplayRAMBanks();