Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: SDFileSystem dspmodified mbed
Revision 7:3d5fd645c11d, committed 2015-03-03
- Comitter:
- jaspreetsingh
- Date:
- Tue Mar 03 07:07:01 2015 +0000
- Parent:
- 6:87c4ae320c7c
- Child:
- 8:12b4c521c033
- Commit message:
- Updated code FTPGET_Merged code with TC value correction
Changed in this revision
| merged_code.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/merged_code.cpp Mon Mar 02 12:42:24 2015 +0000
+++ b/merged_code.cpp Tue Mar 03 07:07:01 2015 +0000
@@ -184,11 +184,12 @@
{
Timer t;
int j=0;
+ ADC0_CFG2=ADC0_CFG2||0x10;
t.start();
while(j<10) {
if((int)(t.read()*50*freq*1000)%100 == 0) {
DC_Detect_data[j] = DC_Detect.read_u16();
- Temp_data[j] = TC2.read_u16();
+ Temp_data[j] = TC1.read_u16();
++j;
}
}
@@ -387,10 +388,10 @@
GetFileDir();
sprintf(filenameAC,"%sAC.txt",filename);
sprintf(pathAC,"%sAC.txt",filepath);
- pc.printf("\r\nFilename-AC\t%s", pathAC);
+ //pc.printf("\r\nFilename-AC\t%s", pathAC);
FILE *fp = fopen(pathAC, "w");
if(fp == NULL) {
- pc.printf("Could not open file for write\n\r");
+ //pc.printf("Could not open file for write\n\r");
//reset_mod();
} else {
//pc.printf("attempting to save file\n\r");
@@ -402,7 +403,7 @@
}
sprintf(filenameDC,"%sDC.txt",filename);
sprintf(pathDC,"%sDC.txt",filepath);
- pc.printf("\r\nFilename-DC\t%s", pathDC);
+ //pc.printf("\r\nFilename-DC\t%s", pathDC);
fp = fopen(pathDC, "w");
if(fp == NULL) {
//pc.printf("Could not open file for write\n\r");
@@ -415,7 +416,7 @@
fclose(fp);
}
sprintf(pathDCdetect,"%sData.txt",hour_dir);
- pc.printf("\r\nFilename-TC\t%s", pathDCdetect);
+ //pc.printf("\r\nFilename-TC\t%s", pathDCdetect);
fp = fopen(pathDCdetect, "w");
if(fp == NULL) {
//pc.printf("Could not open file for write\n\r");
@@ -435,23 +436,13 @@
}
avg_dc_detect=avg_dc_detect/10;
avg_temp=avg_temp/10;
- pc.printf("\r\nfftstart");
+ //pc.printf("\r\nfftstart");
//pc.printf("\r\nfftstage1");
sprintf(filenamefft,"%sft.txt",filename);
- sprintf(ftp_timestamp,"%s",filename);
sprintf(pathfft,"%sft.txt",filepath);
- pc.printf("\r\nFilename-FFT\t%s", pathfft);
- fp = fopen(pathfft, "w");
- if(fp == NULL) {
- //pc.printf("Could not open file for write\n\r");
- //reset_mod();
- } else {
- fprintf(fp, "\r\n%s",time_stamp);
- fprintf(fp, "\r\n DCD %d\n\rTC %d",avg_dc_detect,avg_temp);
- fclose(fp);
- }
+ //pc.printf("\r\nFilename-FFT\t%s", pathfft);
ftptimestamp(); //For Timestamp.txt filename
@@ -459,29 +450,77 @@
int fft_start_index[4]= {0,760,1520,2280};
int fft_points_count[4]= {4,120,240,360};
int fft_maximas_required[4]= {1,20,8,8};
+ float AC_rms_value=0;
+ float AC_mean_value=0;
+ float DC_rms_value=0;
+ float DC_mean_value=0;
+
//AC fft
for(int i=0; i<fft_points; i++) {
fft_array[i]=int(ACdata[i]);
+ AC_mean_value=AC_mean_value+fft_array[i];
//pc.printf("%d %d %d\r\n", i, i+int(fft_points), fft_array[i]);
fft_array[(i+int(fft_points))]=0;
}
+ AC_mean_value=AC_mean_value/fft_points;
+ for(int i=0; i<fft_points; i++) {
+ AC_rms_value=AC_rms_value+((AC_mean_value-fft_array[i])*(AC_mean_value-fft_array[i])/10000);
+ //pc.printf("%d %d %d\r\n", i, i+int(fft_points), fft_array[i]);
+ //fft_array[(i+int(fft_points))]=0;
+ }
+
+ fp = fopen(pathfft, "w");
+ if(fp == NULL) {
+ //pc.printf("Could not open file for write\n\r");
+ //reset_mod();
+ }
+ else {
+ fprintf(fp, "\r\n%s",time_stamp);
+ fprintf(fp, "\r\nDCD %d",avg_dc_detect);
+ fprintf(fp, "\r\nTC %d",avg_temp);
+ fprintf(fp, "\r\nAC-RMS %.0f",AC_rms_value);
+ fclose(fp);
+ }
fft(fft_points,0,1,1);
- pc.printf("\r\nfftdone");
+ //pc.printf("\r\nfftdone");
prepare_fft_array(fft_start_index,fft_points_count,fft_maximas_required,fft_segments,0);
//DC fft
for(int i=0; i<fft_points; i++) {
fft_array[i]=int(DCdata[i]);
+ DC_mean_value=DC_mean_value+fft_array[i];
//pc.printf("%d %d %d\r\n", i, i+int(fft_points), fft_array[i]);
fft_array[(i+int(fft_points))]=0;
}
+ DC_mean_value=DC_mean_value/fft_points;
+ for(int i=0; i<fft_points; i++) {
+ DC_rms_value=DC_rms_value+((DC_mean_value-fft_array[i])*(DC_mean_value-fft_array[i])/10000);
+ //pc.printf("%d %d %d\r\n", i, i+int(fft_points), fft_array[i]);
+ //fft_array[(i+int(fft_points))]=0;
+ }
+ fp = fopen(pathfft, "a");
+ if(fp == NULL) {
+ //pc.printf("Could not open file for write\n\r");
+ //reset_mod();
+ }
+ else {
+
+ fprintf(fp, "\r\nDC-RMS %.0f",DC_rms_value);
+ fclose(fp);
+ }
+
fft(fft_points,0,1,1);
- pc.printf("\r\nfftdone");
prepare_fft_array(fft_start_index,fft_points_count,fft_maximas_required,fft_segments,1);
- pc.printf("\r\nstorage done\r\n");
+
+
+
+ //pc.printf("\r\nfftdone");
+
+ //pc.printf("\r\nstorage done\r\n");
//osSignalSet(tid6, 0x1);
// }
}
+
//--------------------------------------------------------------------------------------------------//
// GSM Initialization //
//--------------------------------------------------------------------------------------------------//