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.
Fork of DSP_200kHz by
Revision 87:80c9169acb85, committed 2018-06-27
- Comitter:
- baxterja
- Date:
- Wed Jun 27 19:23:32 2018 +0000
- Parent:
- 86:b3520f4453cf
- Commit message:
- Changed frequencies for different probe number. I also ordered frequencies from smallest to largest (I don't know if this is a good idea or not)
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Jun 22 18:13:46 2018 +0000 +++ b/main.cpp Wed Jun 27 19:23:32 2018 +0000 @@ -10,7 +10,23 @@ #include "dsp.h" #include "print_data.h" -#define PROBE_NUMBER 5 +#define PROBE_NUMBER 6 + +#if PROBE_NUMBER == 1 + #define PRE_COMPUTE_LENGTH 528 +#elif PROBE_NUMBER == 2 + #define PRE_COMPUTE_LENGTH 368 +#elif PROBE_NUMBER == 3 + #define PRE_COMPUTE_LENGTH 288 +#elif PROBE_NUMBER == 4 + #define PRE_COMPUTE_LENGTH 232 +#elif PROBE_NUMBER == 5 + #define PRE_COMPUTE_LENGTH 200 +#elif PROBE_NUMBER == 6 + #define PRE_COMPUTE_LENGTH 176 +#endif + +/* #if PROBE_NUMBER == 1 #define PRE_COMPUTE_LENGTH 232 #elif PROBE_NUMBER == 2 @@ -24,14 +40,23 @@ #elif PROBE_NUMBER == 6 #define PRE_COMPUTE_LENGTH 528 #endif -//#define probe_number 1 //Probe number -const int probe_number = PROBE_NUMBER; -//const int PCL_LUT[] = {232,528,176,320,208}; //Pre-compute-length for the different probe numbers +6/27/18 switched the frequency and final LPF +LPF now has a pass band of 40 instead of 60 and a stop band of 70 instead of 120. +This allows for more frequency in the desired range. //190Hz 528 //312Hz 320 //431Hz 232 //481Hz 208 //568Hz 176 +*/ +//#define probe_number 1 //Probe number +const int probe_number = PROBE_NUMBER; +//190Hz 528 +//272Hz 368 +//347Hz 288 +//431Hz 232 +//500Hz 200 +//568Hz 176 #define PRINT_BUFFER_LENGTH 10000 #define GATHER_STATISTICS 1 @@ -139,10 +164,12 @@ //Fs = 1562.5 Fpass = 100, FStop = 195.6, null at 200 Hz float Coeffs_1563[32] = {-0.00296990567211633, 0.00784631357544163, 0.00955642274001412, 0.0105078670942049, 0.00746432577935901, -0.000715888274492355, -0.0127656342089486, -0.0248578255670040, -0.0313597093257934, -0.0264804428976321, -0.00639056527392095, 0.0289495639622991, 0.0749846381319702, 0.123239880157668, 0.163403327438059, 0.186215627611441, 0.186215627611441, 0.163403327438059, 0.123239880157668, 0.0749846381319702, 0.0289495639622991, -0.00639056527392095, -0.0264804428976321, -0.0313597093257934, -0.0248578255670040, -0.0127656342089486, -0.000715888274492355, 0.00746432577935901, 0.0105078670942049, 0.00955642274001412, 0.00784631357544163, -0.00296990567211633}; //Fs = 781.25, Fpass = 60, Fstop = 120, -50 Db - float Coeffs_782[32] = {-0.00423132648651131, -0.00413085595827858, -0.00212955364173648, 0.00345345707266939, 0.0105870277845968, 0.0147191914630408, 0.0108878516242339, -0.00283458314983071, -0.0224398052018669, -0.0377493805765767, -0.0358474685211045, -0.00721456868509791, 0.0483564412276129, 0.119338204671425, 0.185468453617916, 0.225354002914126, 0.225354002914126, 0.185468453617916, 0.119338204671425, 0.0483564412276129, -0.00721456868509791, -0.0358474685211045, -0.0377493805765767, -0.0224398052018669, -0.00283458314983071, 0.0108878516242339, 0.0147191914630408, 0.0105870277845968, 0.00345345707266939, -0.00212955364173648, -0.00413085595827858, -0.00423132648651131}; + //float Coeffs_782[32] = {-0.00423132648651131, -0.00413085595827858, -0.00212955364173648, 0.00345345707266939, 0.0105870277845968, 0.0147191914630408, 0.0108878516242339, -0.00283458314983071, -0.0224398052018669, -0.0377493805765767, -0.0358474685211045, -0.00721456868509791, 0.0483564412276129, 0.119338204671425, 0.185468453617916, 0.225354002914126, 0.225354002914126, 0.185468453617916, 0.119338204671425, 0.0483564412276129, -0.00721456868509791, -0.0358474685211045, -0.0377493805765767, -0.0224398052018669, -0.00283458314983071, 0.0108878516242339, 0.0147191914630408, 0.0105870277845968, 0.00345345707266939, -0.00212955364173648, -0.00413085595827858, -0.00423132648651131}; + //Fs = 781.25, Fpass = 40, Fstop = 70, -80 Db Wstop = 1000 + float Coeffs_782[64] = {9.75137900147270e-06, 0.000242116460111013, 0.000587759650222984, 0.00121948229641138, 0.00218692996477935, 0.00352877877192510, 0.00522776253657456, 0.00719094075913147, 0.00923733657506023, 0.0110994562722364, 0.0124427726825193, 0.0129046836285611, 0.0121508175170645, 0.00994240690006920, 0.00620512977988183, 0.00108717079481820, -0.00500601108796552, -0.0114117467388055, -0.0172511672001640, -0.0215122218794239, -0.0231679949423431, -0.0213174230933399, -0.0153286015860647, -0.00496376773300694, 0.00953605359350501, 0.0274232655747699, 0.0474831945783405, 0.0681394765484662, 0.0876167028664372, 0.104139083136827, 0.116139722609181, 0.122451402975443, 0.122451402975443, 0.116139722609181, 0.104139083136827, 0.0876167028664372, 0.0681394765484662, 0.0474831945783405, 0.0274232655747699, 0.00953605359350501, -0.00496376773300694, -0.0153286015860647, -0.0213174230933399, -0.0231679949423431, -0.0215122218794239, -0.0172511672001640, -0.0114117467388055, -0.00500601108796552, 0.00108717079481820, 0.00620512977988183, 0.00994240690006920, 0.0121508175170645, 0.0129046836285611, 0.0124427726825193, 0.0110994562722364, 0.00923733657506023, 0.00719094075913147, 0.00522776253657456, 0.00352877877192510, 0.00218692996477935, 0.00121948229641138, 0.000587759650222984, 0.000242116460111013, 9.75137900147270e-06}; - float Coeffs[20] = {0.0328368433284673, 0.0237706090075265, 0.0309894695180997, 0.0385253568846695, 0.0459996974310349, 0.0530165318016261, 0.0591943866845610, 0.0641755708098907, 0.0676960677594849, 0.0694621149975389, 0.0694621149975389, 0.0676960677594849, 0.0641755708098907, 0.0591943866845610, 0.0530165318016261, 0.0459996974310349, 0.0385253568846695, 0.0309894695180997, 0.0237706090075265, 0.0328368433284673}; - float Coeffs2[20] = {-0.00506451294187997, -0.00824932319607346, -0.00986370066237912, -0.00518913235010027, 0.00950858650162284, 0.0357083149022659, 0.0711557142019980, 0.109659494661247, 0.142586101123340, 0.161603335553589, 0.161603335553589, 0.142586101123340, 0.109659494661247, 0.0711557142019980, 0.0357083149022659, 0.00950858650162284, -0.00518913235010027, -0.00986370066237912, -0.00824932319607346, -0.00506451294187997}; + //float Coeffs[20] = {0.0328368433284673, 0.0237706090075265, 0.0309894695180997, 0.0385253568846695, 0.0459996974310349, 0.0530165318016261, 0.0591943866845610, 0.0641755708098907, 0.0676960677594849, 0.0694621149975389, 0.0694621149975389, 0.0676960677594849, 0.0641755708098907, 0.0591943866845610, 0.0530165318016261, 0.0459996974310349, 0.0385253568846695, 0.0309894695180997, 0.0237706090075265, 0.0328368433284673}; + //float Coeffs2[20] = {-0.00506451294187997, -0.00824932319607346, -0.00986370066237912, -0.00518913235010027, 0.00950858650162284, 0.0357083149022659, 0.0711557142019980, 0.109659494661247, 0.142586101123340, 0.161603335553589, 0.161603335553589, 0.142586101123340, 0.109659494661247, 0.0711557142019980, 0.0357083149022659, 0.00950858650162284, -0.00518913235010027, -0.00986370066237912, -0.00824932319607346, -0.00506451294187997}; //note I allocate space for 4 adc inputs, but usually I only use 2 for(int i = 0; i < 8; i++) @@ -154,7 +181,7 @@ //f: the filter after current filter. //block_size: block size of each filter command should be an integer multiple of DECIMATION //Flag noting rather or not to demodulate, and if so what frequency to demodulate at - filters f4 = filters(4, 8, NULL, 8, 32, Coeffs_782,DEMOD_No_Demod); + filters f4 = filters(4, 8, NULL, 8, 64, Coeffs_782,DEMOD_No_Demod); filters f3 = filters(4, 2, &f4, 4, 32, Coeffs_1563,DEMOD_No_Demod); filters f2 = filters(4, 8, &f3, 8, 64, Coeffs_12500,DEMOD_No_Demod); filters f1 = filters(2, 8, &f2, 64, 64, Coeffs_100k,DEMOD_200HZ); @@ -194,6 +221,7 @@ { while(pc.readable())//if there is a Keyboard input { + read_in_character = pc.getc(); if (read_in_character == 'R')//start printing { timer.reset();