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: GSM_PUSHING_BOX_STATE_MACHINE MBed_Adafruit-GPS-Library SDFileSystem mbed
Fork of DCS by
Revision 14:97611177509b, committed 2015-04-14
- Comitter:
- bjcrofts
- Date:
- Tue Apr 14 04:05:59 2015 +0000
- Parent:
- 13:6fa5239902e8
- Child:
- 15:ff41fdee65e2
- Commit message:
- finished;
Changed in this revision
--- a/QAM.h Sun Apr 12 03:09:47 2015 +0000
+++ b/QAM.h Tue Apr 14 04:05:59 2015 +0000
@@ -3,46 +3,31 @@
#include "param.h"
-float firCoeffs[NUM_TAPS] = {-0.0144708808511496,-0.000385188817745075,-0.000390533183235675,-0.000394742906792089,-0.000399769196519628,-0.000403738202294335,-0.000408404623158276,-0.000412113149650395,-0.000416462833527476,-0.000419815012719482,-0.000423797959228978,-0.000426739337854087,-0.000430334330303594,-0.000432832690421492,-0.000436010304838419,-0.000438015762483701,-0.000440725998487324,-0.000442176271462813,-0.000444366451120004,-0.000445200741523877,-0.000446824764367193,-0.000446985068265349,-0.000448006554506719,-0.000447442784206942,-0.000447849219199270,-0.000446533842477948,-0.000446356250904501,-0.000444298930233344,-0.000443635712144896,-0.000440904172137380,-0.000439959781942889,-0.000436697184341028,-0.000435806956375018,-0.000432172615546733,-0.000431753345765173,-0.000427687598858029,-0.000428156810812652,-0.000422747252741829,-0.000424187630414963,-0.000407818792155013,-0.000395501352613792,-0.000405744503950700,-0.000392851507058367,-0.000390382687328383,-0.000381121528334916,-0.000376496114768088,-0.000367538945283741,-0.000361525919288397,-0.000352310773450881,-0.000345231412211433,-0.000335566815920174,-0.000327541463775560,-0.000317294849082828,-0.000308353744912893,-0.000297429505735636,-0.000287581380689517,-0.000275914761004970,-0.000265156646491960,-0.000252692261710763,-0.000241008558077738,-0.000227700089453720,-0.000215083331568167,-0.000200913782464340,-0.000187389392522164,-0.000172384694451466,-0.000158020178787410,-0.000142244665767066,-0.000127136823721230,-0.000110658475023229,-9.48790548136458e-05,-7.76831002440304e-05,-6.11819123150781e-05,-4.30660620622803e-05,-2.56168041232741e-05,-6.17332989349961e-06,1.25088872664492e-05,3.37927012878936e-05,5.35608705831692e-05,7.59589602239430e-05,9.15368291316554e-05,0.000115204777102917,0.000138069211971015,0.000159190880367532,0.000182373449206352,0.000205067466595210,0.000228860953939147,0.000252562953392044,0.000277043582173064,0.000301679014228284,0.000326937646605074,0.000352496019331738,0.000378568482119590,0.000405024475185201,0.000431919761467725,0.000459260045317933,0.000486996257677674,0.000515223422553390,0.000543812348041683,0.000572911638300866,0.000602328160312027,0.000632248178590089,0.000662431004457176,0.000693100970238447,0.000723983335774392,0.000755351502448320,0.000786905176937580,0.000818981905467808,0.000851254211738706,0.000884129083715379,0.000917225959710777,0.000951002817600966,0.000984976999461651,0.00101962720509619,0.00105433282442391,0.00108958012424409,0.00112464418634772,0.00115993840154260,0.00119539198931307,0.00123186816927046,0.00127036077901721,0.00130541180260479,0.00134335225448012,0.00138072879053652,0.00141863315366209,0.00145663029979914,0.00149499706458300,0.00153361610136926,0.00157251046039164,0.00161168223712593,0.00165107252541929,0.00169074663426727,0.00173062458634377,0.00177079136483371,0.00181115593295544,0.00185179221443832,0.00189260160550475,0.00193364149890840,0.00197481806389987,0.00201618182472885,0.00205765641294420,0.00209929421544075,0.00214104214683175,0.00218295189552009,0.00222499505616725,0.00226720655336976,0.00230957893654704,0.00235209893435240,0.00239478098228574,0.00243752682581544,0.00248040445148945,0.00252320826984942,0.00256614456884563,0.00260887923650444,0.00265189493075013,0.00269464123994112,0.00273811141960323,0.00278127146884799,0.00282487273216248,0.00286725582554936,0.00291011668741703,0.00295400852337480,0.00299631315283477,0.00303968228399754,0.00308228214271367,0.00312544335611165,0.00316800503060222,0.00321092060767114,0.00325335212983191,0.00329604768194258,0.00333833065815270,0.00338080571964383,0.00342287984676659,0.00346506666392088,0.00350683252327144,0.00354864820837975,0.00359002966433764,0.00363143184222281,0.00367240631021559,0.00371339474804699,0.00375396921299398,0.00379455066286027,0.00383471907116473,0.00387486722320318,0.00391457835212350,0.00395421450957656,0.00399336963891983,0.00403239345178008,0.00407090689986944,0.00410927413031459,0.00414714356884360,0.00418491195887327,0.00422220071777701,0.00425944291055203,0.00429609837010503,0.00433271517977119,0.00436816038563848,0.00440392829477787,0.00443863216787577,0.00447419332340360,0.00450790720060468,0.00454199779778719,0.00457557942718267,0.00460866745561361,0.00464128935709596,0.00467348005622625,0.00470521813258529,0.00473655480891466,0.00476738158613443,0.00479778554290533,0.00482760230079293,0.00485697947442532,0.00488572614267468,0.00491404812783003,0.00494172982871532,0.00496901245787740,0.00499565014615655,0.00502189761027694,0.00504747871309519,0.00507265469059348,0.00509712658822537,0.00512116774916649,0.00514446385204792,0.00516731571406126,0.00518939504399896,0.00521104829385877,0.00523192156106234,0.00525241391733289,0.00527210766449571,0.00529145309701562,0.00530992168933153,0.00532803731039166,0.00534513592720032,0.00536190019920468,0.00537753105163574,0.00539305759593844,0.00540779717266560,0.00542178330942988,0.00543520553037524,0.00544764194637537,0.00546016823500395,0.00547122210264206,0.00548202730715275,0.00549201155081391,0.00550147471949458,0.00551019050180912,0.00551821896806359,0.00552552472800016,0.00553208775818348,0.00553797790780664,0.00554313324391842,0.00554766040295363,0.00555146159604192,0.00555464252829552,0.00555708399042487,0.00555888703092933,0.00555992824956775,0.00556031381711364,0.00555992824956775,0.00555888703092933,0.00555708399042487,0.00555464252829552,0.00555146159604192,0.00554766040295363,0.00554313324391842,0.00553797790780664,0.00553208775818348,0.00552552472800016,0.00551821896806359,0.00551019050180912,0.00550147471949458,0.00549201155081391,0.00548202730715275,0.00547122210264206,0.00546016823500395,0.00544764194637537,0.00543520553037524,0.00542178330942988,0.00540779717266560,0.00539305759593844,0.00537753105163574,0.00536190019920468,0.00534513592720032,0.00532803731039166,0.00530992168933153,0.00529145309701562,0.00527210766449571,0.00525241391733289,0.00523192156106234,0.00521104829385877,0.00518939504399896,0.00516731571406126,0.00514446385204792,0.00512116774916649,0.00509712658822537,0.00507265469059348,0.00504747871309519,0.00502189761027694,0.00499565014615655,0.00496901245787740,0.00494172982871532,0.00491404812783003,0.00488572614267468,0.00485697947442532,0.00482760230079293,0.00479778554290533,0.00476738158613443,0.00473655480891466,0.00470521813258529,0.00467348005622625,0.00464128935709596,0.00460866745561361,0.00457557942718267,0.00454199779778719,0.00450790720060468,0.00447419332340360,0.00443863216787577,0.00440392829477787,0.00436816038563848,0.00433271517977119,0.00429609837010503,0.00425944291055203,0.00422220071777701,0.00418491195887327,0.00414714356884360,0.00410927413031459,0.00407090689986944,0.00403239345178008,0.00399336963891983,0.00395421450957656,0.00391457835212350,0.00387486722320318,0.00383471907116473,0.00379455066286027,0.00375396921299398,0.00371339474804699,0.00367240631021559,0.00363143184222281,0.00359002966433764,0.00354864820837975,0.00350683252327144,0.00346506666392088,0.00342287984676659,0.00338080571964383,0.00333833065815270,0.00329604768194258,0.00325335212983191,0.00321092060767114,0.00316800503060222,0.00312544335611165,0.00308228214271367,0.00303968228399754,0.00299631315283477,0.00295400852337480,0.00291011668741703,0.00286725582554936,0.00282487273216248,0.00278127146884799,0.00273811141960323,0.00269464123994112,0.00265189493075013,0.00260887923650444,0.00256614456884563,0.00252320826984942,0.00248040445148945,0.00243752682581544,0.00239478098228574,0.00235209893435240,0.00230957893654704,0.00226720655336976,0.00222499505616725,0.00218295189552009,0.00214104214683175,0.00209929421544075,0.00205765641294420,0.00201618182472885,0.00197481806389987,0.00193364149890840,0.00189260160550475,0.00185179221443832,0.00181115593295544,0.00177079136483371,0.00173062458634377,0.00169074663426727,0.00165107252541929,0.00161168223712593,0.00157251046039164,0.00153361610136926,0.00149499706458300,0.00145663029979914,0.00141863315366209,0.00138072879053652,0.00134335225448012,0.00130541180260479,0.00127036077901721,0.00123186816927046,0.00119539198931307,0.00115993840154260,0.00112464418634772,0.00108958012424409,0.00105433282442391,0.00101962720509619,0.000984976999461651,0.000951002817600966,0.000917225959710777,0.000884129083715379,0.000851254211738706,0.000818981905467808,0.000786905176937580,0.000755351502448320,0.000723983335774392,0.000693100970238447,0.000662431004457176,0.000632248178590089,0.000602328160312027,0.000572911638300866,0.000543812348041683,0.000515223422553390,0.000486996257677674,0.000459260045317933,0.000431919761467725,0.000405024475185201,0.000378568482119590,0.000352496019331738,0.000326937646605074,0.000301679014228284,0.000277043582173064,0.000252562953392044,0.000228860953939147,0.000205067466595210,0.000182373449206352,0.000159190880367532,0.000138069211971015,0.000115204777102917,9.15368291316554e-05,7.59589602239430e-05,5.35608705831692e-05,3.37927012878936e-05,1.25088872664492e-05,-6.17332989349961e-06,-2.56168041232741e-05,-4.30660620622803e-05,-6.11819123150781e-05,-7.76831002440304e-05,-9.48790548136458e-05,-0.000110658475023229,-0.000127136823721230,-0.000142244665767066,-0.000158020178787410,-0.000172384694451466,-0.000187389392522164,-0.000200913782464340,-0.000215083331568167,-0.000227700089453720,-0.000241008558077738,-0.000252692261710763,-0.000265156646491960,-0.000275914761004970,-0.000287581380689517,-0.000297429505735636,-0.000308353744912893,-0.000317294849082828,-0.000327541463775560,-0.000335566815920174,-0.000345231412211433,-0.000352310773450881,-0.000361525919288397,-0.000367538945283741,-0.000376496114768088,-0.000381121528334916,-0.000390382687328383,-0.000392851507058367,-0.000405744503950700,-0.000395501352613792,-0.000407818792155013,-0.000424187630414963,-0.000422747252741829,-0.000428156810812652,-0.000427687598858029,-0.000431753345765173,-0.000432172615546733,-0.000435806956375018,-0.000436697184341028,-0.000439959781942889,-0.000440904172137380,-0.000443635712144896,-0.000444298930233344,-0.000446356250904501,-0.000446533842477948,-0.000447849219199270,-0.000447442784206942,-0.000448006554506719,-0.000446985068265349,-0.000446824764367193,-0.000445200741523877,-0.000444366451120004,-0.000442176271462813,-0.000440725998487324,-0.000438015762483701,-0.000436010304838419,-0.000432832690421492,-0.000430334330303594,-0.000426739337854087,-0.000423797959228978,-0.000419815012719482,-0.000416462833527476,-0.000412113149650395,-0.000408404623158276,-0.000403738202294335,-0.000399769196519628,-0.000394742906792089,-0.000390533183235675,-0.000385188817745075,-0.0144708808511496};
+float LPF[FILTER_LENGTH] = {-0.0144708808511496,-0.000385188817745075,-0.000390533183235675,-0.000394742906792089,-0.000399769196519628,-0.000403738202294335,-0.000408404623158276,-0.000412113149650395,-0.000416462833527476,-0.000419815012719482,-0.000423797959228978,-0.000426739337854087,-0.000430334330303594,-0.000432832690421492,-0.000436010304838419,-0.000438015762483701,-0.000440725998487324,-0.000442176271462813,-0.000444366451120004,-0.000445200741523877,-0.000446824764367193,-0.000446985068265349,-0.000448006554506719,-0.000447442784206942,-0.000447849219199270,-0.000446533842477948,-0.000446356250904501,-0.000444298930233344,-0.000443635712144896,-0.000440904172137380,-0.000439959781942889,-0.000436697184341028,-0.000435806956375018,-0.000432172615546733,-0.000431753345765173,-0.000427687598858029,-0.000428156810812652,-0.000422747252741829,-0.000424187630414963,-0.000407818792155013,-0.000395501352613792,-0.000405744503950700,-0.000392851507058367,-0.000390382687328383,-0.000381121528334916,-0.000376496114768088,-0.000367538945283741,-0.000361525919288397,-0.000352310773450881,-0.000345231412211433,-0.000335566815920174,-0.000327541463775560,-0.000317294849082828,-0.000308353744912893,-0.000297429505735636,-0.000287581380689517,-0.000275914761004970,-0.000265156646491960,-0.000252692261710763,-0.000241008558077738,-0.000227700089453720,-0.000215083331568167,-0.000200913782464340,-0.000187389392522164,-0.000172384694451466,-0.000158020178787410,-0.000142244665767066,-0.000127136823721230,-0.000110658475023229,-9.48790548136458e-05,-7.76831002440304e-05,-6.11819123150781e-05,-4.30660620622803e-05,-2.56168041232741e-05,-6.17332989349961e-06,1.25088872664492e-05,3.37927012878936e-05,5.35608705831692e-05,7.59589602239430e-05,9.15368291316554e-05,0.000115204777102917,0.000138069211971015,0.000159190880367532,0.000182373449206352,0.000205067466595210,0.000228860953939147,0.000252562953392044,0.000277043582173064,0.000301679014228284,0.000326937646605074,0.000352496019331738,0.000378568482119590,0.000405024475185201,0.000431919761467725,0.000459260045317933,0.000486996257677674,0.000515223422553390,0.000543812348041683,0.000572911638300866,0.000602328160312027,0.000632248178590089,0.000662431004457176,0.000693100970238447,0.000723983335774392,0.000755351502448320,0.000786905176937580,0.000818981905467808,0.000851254211738706,0.000884129083715379,0.000917225959710777,0.000951002817600966,0.000984976999461651,0.00101962720509619,0.00105433282442391,0.00108958012424409,0.00112464418634772,0.00115993840154260,0.00119539198931307,0.00123186816927046,0.00127036077901721,0.00130541180260479,0.00134335225448012,0.00138072879053652,0.00141863315366209,0.00145663029979914,0.00149499706458300,0.00153361610136926,0.00157251046039164,0.00161168223712593,0.00165107252541929,0.00169074663426727,0.00173062458634377,0.00177079136483371,0.00181115593295544,0.00185179221443832,0.00189260160550475,0.00193364149890840,0.00197481806389987,0.00201618182472885,0.00205765641294420,0.00209929421544075,0.00214104214683175,0.00218295189552009,0.00222499505616725,0.00226720655336976,0.00230957893654704,0.00235209893435240,0.00239478098228574,0.00243752682581544,0.00248040445148945,0.00252320826984942,0.00256614456884563,0.00260887923650444,0.00265189493075013,0.00269464123994112,0.00273811141960323,0.00278127146884799,0.00282487273216248,0.00286725582554936,0.00291011668741703,0.00295400852337480,0.00299631315283477,0.00303968228399754,0.00308228214271367,0.00312544335611165,0.00316800503060222,0.00321092060767114,0.00325335212983191,0.00329604768194258,0.00333833065815270,0.00338080571964383,0.00342287984676659,0.00346506666392088,0.00350683252327144,0.00354864820837975,0.00359002966433764,0.00363143184222281,0.00367240631021559,0.00371339474804699,0.00375396921299398,0.00379455066286027,0.00383471907116473,0.00387486722320318,0.00391457835212350,0.00395421450957656,0.00399336963891983,0.00403239345178008,0.00407090689986944,0.00410927413031459,0.00414714356884360,0.00418491195887327,0.00422220071777701,0.00425944291055203,0.00429609837010503,0.00433271517977119,0.00436816038563848,0.00440392829477787,0.00443863216787577,0.00447419332340360,0.00450790720060468,0.00454199779778719,0.00457557942718267,0.00460866745561361,0.00464128935709596,0.00467348005622625,0.00470521813258529,0.00473655480891466,0.00476738158613443,0.00479778554290533,0.00482760230079293,0.00485697947442532,0.00488572614267468,0.00491404812783003,0.00494172982871532,0.00496901245787740,0.00499565014615655,0.00502189761027694,0.00504747871309519,0.00507265469059348,0.00509712658822537,0.00512116774916649,0.00514446385204792,0.00516731571406126,0.00518939504399896,0.00521104829385877,0.00523192156106234,0.00525241391733289,0.00527210766449571,0.00529145309701562,0.00530992168933153,0.00532803731039166,0.00534513592720032,0.00536190019920468,0.00537753105163574,0.00539305759593844,0.00540779717266560,0.00542178330942988,0.00543520553037524,0.00544764194637537,0.00546016823500395,0.00547122210264206,0.00548202730715275,0.00549201155081391,0.00550147471949458,0.00551019050180912,0.00551821896806359,0.00552552472800016,0.00553208775818348,0.00553797790780664,0.00554313324391842,0.00554766040295363,0.00555146159604192,0.00555464252829552,0.00555708399042487,0.00555888703092933,0.00555992824956775,0.00556031381711364,0.00555992824956775,0.00555888703092933,0.00555708399042487,0.00555464252829552,0.00555146159604192,0.00554766040295363,0.00554313324391842,0.00553797790780664,0.00553208775818348,0.00552552472800016,0.00551821896806359,0.00551019050180912,0.00550147471949458,0.00549201155081391,0.00548202730715275,0.00547122210264206,0.00546016823500395,0.00544764194637537,0.00543520553037524,0.00542178330942988,0.00540779717266560,0.00539305759593844,0.00537753105163574,0.00536190019920468,0.00534513592720032,0.00532803731039166,0.00530992168933153,0.00529145309701562,0.00527210766449571,0.00525241391733289,0.00523192156106234,0.00521104829385877,0.00518939504399896,0.00516731571406126,0.00514446385204792,0.00512116774916649,0.00509712658822537,0.00507265469059348,0.00504747871309519,0.00502189761027694,0.00499565014615655,0.00496901245787740,0.00494172982871532,0.00491404812783003,0.00488572614267468,0.00485697947442532,0.00482760230079293,0.00479778554290533,0.00476738158613443,0.00473655480891466,0.00470521813258529,0.00467348005622625,0.00464128935709596,0.00460866745561361,0.00457557942718267,0.00454199779778719,0.00450790720060468,0.00447419332340360,0.00443863216787577,0.00440392829477787,0.00436816038563848,0.00433271517977119,0.00429609837010503,0.00425944291055203,0.00422220071777701,0.00418491195887327,0.00414714356884360,0.00410927413031459,0.00407090689986944,0.00403239345178008,0.00399336963891983,0.00395421450957656,0.00391457835212350,0.00387486722320318,0.00383471907116473,0.00379455066286027,0.00375396921299398,0.00371339474804699,0.00367240631021559,0.00363143184222281,0.00359002966433764,0.00354864820837975,0.00350683252327144,0.00346506666392088,0.00342287984676659,0.00338080571964383,0.00333833065815270,0.00329604768194258,0.00325335212983191,0.00321092060767114,0.00316800503060222,0.00312544335611165,0.00308228214271367,0.00303968228399754,0.00299631315283477,0.00295400852337480,0.00291011668741703,0.00286725582554936,0.00282487273216248,0.00278127146884799,0.00273811141960323,0.00269464123994112,0.00265189493075013,0.00260887923650444,0.00256614456884563,0.00252320826984942,0.00248040445148945,0.00243752682581544,0.00239478098228574,0.00235209893435240,0.00230957893654704,0.00226720655336976,0.00222499505616725,0.00218295189552009,0.00214104214683175,0.00209929421544075,0.00205765641294420,0.00201618182472885,0.00197481806389987,0.00193364149890840,0.00189260160550475,0.00185179221443832,0.00181115593295544,0.00177079136483371,0.00173062458634377,0.00169074663426727,0.00165107252541929,0.00161168223712593,0.00157251046039164,0.00153361610136926,0.00149499706458300,0.00145663029979914,0.00141863315366209,0.00138072879053652,0.00134335225448012,0.00130541180260479,0.00127036077901721,0.00123186816927046,0.00119539198931307,0.00115993840154260,0.00112464418634772,0.00108958012424409,0.00105433282442391,0.00101962720509619,0.000984976999461651,0.000951002817600966,0.000917225959710777,0.000884129083715379,0.000851254211738706,0.000818981905467808,0.000786905176937580,0.000755351502448320,0.000723983335774392,0.000693100970238447,0.000662431004457176,0.000632248178590089,0.000602328160312027,0.000572911638300866,0.000543812348041683,0.000515223422553390,0.000486996257677674,0.000459260045317933,0.000431919761467725,0.000405024475185201,0.000378568482119590,0.000352496019331738,0.000326937646605074,0.000301679014228284,0.000277043582173064,0.000252562953392044,0.000228860953939147,0.000205067466595210,0.000182373449206352,0.000159190880367532,0.000138069211971015,0.000115204777102917,9.15368291316554e-05,7.59589602239430e-05,5.35608705831692e-05,3.37927012878936e-05,1.25088872664492e-05,-6.17332989349961e-06,-2.56168041232741e-05,-4.30660620622803e-05,-6.11819123150781e-05,-7.76831002440304e-05,-9.48790548136458e-05,-0.000110658475023229,-0.000127136823721230,-0.000142244665767066,-0.000158020178787410,-0.000172384694451466,-0.000187389392522164,-0.000200913782464340,-0.000215083331568167,-0.000227700089453720,-0.000241008558077738,-0.000252692261710763,-0.000265156646491960,-0.000275914761004970,-0.000287581380689517,-0.000297429505735636,-0.000308353744912893,-0.000317294849082828,-0.000327541463775560,-0.000335566815920174,-0.000345231412211433,-0.000352310773450881,-0.000361525919288397,-0.000367538945283741,-0.000376496114768088,-0.000381121528334916,-0.000390382687328383,-0.000392851507058367,-0.000405744503950700,-0.000395501352613792,-0.000407818792155013,-0.000424187630414963,-0.000422747252741829,-0.000428156810812652,-0.000427687598858029,-0.000431753345765173,-0.000432172615546733,-0.000435806956375018,-0.000436697184341028,-0.000439959781942889,-0.000440904172137380,-0.000443635712144896,-0.000444298930233344,-0.000446356250904501,-0.000446533842477948,-0.000447849219199270,-0.000447442784206942,-0.000448006554506719,-0.000446985068265349,-0.000446824764367193,-0.000445200741523877,-0.000444366451120004,-0.000442176271462813,-0.000440725998487324,-0.000438015762483701,-0.000436010304838419,-0.000432832690421492,-0.000430334330303594,-0.000426739337854087,-0.000423797959228978,-0.000419815012719482,-0.000416462833527476,-0.000412113149650395,-0.000408404623158276,-0.000403738202294335,-0.000399769196519628,-0.000394742906792089,-0.000390533183235675,-0.000385188817745075,-0.0144708808511496};
+
-void filter( float *in, Serial *pc)
-{
- float *taps = firCoeffs;
- int i, j;
- float out[2000] = {};
+float QAM(float *sI, float *sQ){
+
+ float total = 0.0;
+ float I = 0.0;
+ float Q = 0.0;
- for( i = NUM_TAPS; i < 2000; i++ )
- {
- out[ i ] = 0.0;
- for( j = 0; j < NUM_TAPS; j++ ){
- if(i-j >= 0){
- out[ i ] += in[ i - j ] * taps[ j ];
- }
-
+ for ( int i = 0; i < SAMPLE_LENGTH; i+=DEC_FACTOR){
+ I = 0.0;
+ Q = 0.0;
+ for (int j = 0; j < FILTER_LENGTH; j++){
+ if(i-j > 0 && i > 0 && j > 0){
+ I = I + (sI[ i - j] * LPF[ j ]);
+ Q = Q + (sQ[ i - j] * LPF[ j ]);
+ }
}
- }
+
+ total = total + (I*I + Q*Q);
- for( i = 0; i < 2000; i++ )
- {
- in[ i ] = out[i];
}
+
+ total = total/3000;
+
+ return total;
}
-
-float avg_QAM(float *sI, float *sQ, int length){
- int i = 0;
- float total = 0;
- int denom = length - 2*NUM_TAPS;
- for(i = NUM_TAPS; i < length - NUM_TAPS; i++){
- total = total + sqrt(sI[i]*sI[i] + sQ[i]*sQ[i]);
- }
- return total/denom;
-}
-
-float QAM(float *sI, float *sQ, Serial *pc){
-
- filter(sI, pc);
- filter(sQ, pc);
- return avg_QAM(sI, sQ, 2000);
-}
-
--- a/Sensor.cpp Sun Apr 12 03:09:47 2015 +0000
+++ b/Sensor.cpp Tue Apr 14 04:05:59 2015 +0000
@@ -11,12 +11,10 @@
DigitalOut led_red(LED_RED);
Serial pc(USBTX, USBRX);
Timer t;
-Timer z;
bool run = 0;
+bool fil = 0;
Serial gsm(D1,D0);
-char message[MAX_MSG_SIZE];//MSG_SIZE located at GSMLibrary.h
-char num[10];
/**************************************************
** SD FILE SYSTEM **
@@ -80,7 +78,7 @@
void create_sinWave(){
int i = 0;
- for(i = 0; i < sinRes; i++){
+ for(i = 0; i < SIN_LENGTH; i++){
sinWave[i] = 0.25 * sin(2.0*PI*i/sinRes) + 0.75;
}
}
@@ -112,18 +110,21 @@
float filteredLongRef = 0;
float filteredShortRef = 0;
+ fp = fopen("/sd/data.txt", "w");
+ if (fp != NULL){
+ fprintf(fp, "--------------- DCS ------------------");
+ }
+
+
void gsm_initialize();
sample_tick.attach(&tick, 0.0001);
t.start();
- z.start();
-
- int buffer = 0;
while(1){
- if(takeSample && z.read_ms()>1000){
+ if(takeSample){
dac0 = sinWave[sinIndex];
@@ -146,14 +147,14 @@
takeSample = false;
sinIndex++;
- if((sinIndex+1) > sinRes){
+ if((sinIndex+1) > SIN_LENGTH){
sinIndex = 0;
}
sampleIndex++;
if(sampleIndex+1 > SAMPLE_LENGTH){
- sampleIndex--;
+ fil = 1;
}
@@ -161,17 +162,22 @@
- if(t.read_ms()>1000){//sampleIndex+2 > SAMPLE_LENGTH){ //0.50 seconds
+ if(fil==1){
+ fil = 0;
run = 1;
- z.reset();
+
sampleIndex = 0;
gsm_tick();
- filteredLong = QAM(sLI, sLQ, &pc);
- filteredLongRef = QAM(sRefLI, sRefLQ, &pc);
- filteredShort = QAM(sSI, sSQ, &pc);
- filteredShortRef = QAM(sRefSI, sRefSQ, &pc);
+
+ filteredLong = 10*QAM(sLI, sLQ);
+ filteredLongRef = QAM(sRefLI, sRefLQ);
+ filteredShort = 25*QAM(sSI, sSQ);
+ filteredShortRef = QAM(sRefSI, sRefSQ);
+
+ gsm_tick();
+
}
c = myGPS.read();
@@ -186,67 +192,37 @@
led_red = !led_red;
run = 0;
-
pc.printf("%f, ", filteredLong);
pc.printf("%f, ", filteredLongRef);
pc.printf("%f, ", filteredShort);
pc.printf("%f\r\n", filteredShortRef);
pc.printf("%f, ", filteredLong/filteredLongRef);
pc.printf("%f\r\n", filteredShort/filteredShortRef);
- pc.printf("%d:%d:%d \r\n", myGPS.hour-6, myGPS.minute, myGPS.seconds);
+ pc.printf("%d:%d:%d \r\n", myGPS.hour+6, myGPS.minute, myGPS.seconds);
if (myGPS.fix) pc.printf("%5.2f%c, %5.2f%c\r\n", myGPS.latitude, myGPS.lat, myGPS.longitude, myGPS.lon);
else pc.printf("No GPS fix\r\n");
pc.printf("--------------------------------\r\n");
-
-
- fp = fopen("/sd/data.txt", "w");
+ fp = fopen("/sd/data.txt", "a");
if (fp != NULL){
fprintf(fp, "%f, ", filteredLong);
fprintf(fp, "%f, ", filteredLongRef);
fprintf(fp, "%f, ", filteredShort);
fprintf(fp, "%f\r\n", filteredShortRef);
- fprintf(fp, "%d:%d:%d\r\n", myGPS.hour, myGPS.minute, myGPS.seconds);
+ fprintf(fp, "%d:%d:%d\r\n", myGPS.hour+6, myGPS.minute, myGPS.seconds);
if (myGPS.fix) fprintf(fp, "%5.2f%c, %5.2f%c\r\n", myGPS.latitude, myGPS.lat, myGPS.longitude, myGPS.lon);
else fprintf(fp, "No_GPS_fix\r\n");
fclose(fp);
}
-
- snprintf(num,10,"%f, ",filteredLong);
- strcat(message, num);
- snprintf(num,10,"%f, ",filteredLongRef);
- strcat(message, num);
- snprintf(num,10,"%f, ",filteredShort);
- strcat(message, num);
- snprintf(num,10,"%f = ",filteredShortRef);
- strcat(message, num);
-
- snprintf(num,10,"%d:%d:%d = ", myGPS.hour, myGPS.minute, myGPS.seconds);
- strcat(message, num);
- if (myGPS.fix){
- snprintf(num,10,"%5.2f%c, %5.2f%c. ", myGPS.latitude, myGPS.lat, myGPS.longitude, myGPS.lon);
- strcat(message, num);
- }
- else strcat(message, "NO_GPS_FIX. ");
-
- //pc.printf("%s\r\n", message);
-
- if(gsm_ready()){
- gsm_send_sms(message);
- memset(message, 0, MAX_MSG_SIZE);
- buffer = 0;
- }else{
- buffer++; //if msgsize is 150, then 150 * 6 = 900 (max SMS length)
- if(buffer >= 6){ //Thus only allow 6 data points to be sent at once
- buffer = 0;
- memset(message, 0, MAX_MSG_SIZE);
- }
- }
-
- t.reset();
+
+ if(myGPS.fix)
+ gsm_send_data(filteredLong, filteredLongRef, filteredShort, filteredShortRef, myGPS.hour+6, myGPS.minute, myGPS.seconds, myGPS.latitude, myGPS.lat, myGPS.longitude, myGPS.lon);
+ else
+ gsm_send_data(filteredLong, filteredLongRef, filteredShort, filteredShortRef, 0, 0, 0, 0, 0, 0, 0);
+
}
}
--- a/param.h Sun Apr 12 03:09:47 2015 +0000 +++ b/param.h Tue Apr 14 04:05:59 2015 +0000 @@ -5,4 +5,5 @@ #define CARRIER_FREQ 220 #define TIME_CONST 0.0001 #define PI 3.14159265 -#define NUM_TAPS 513 \ No newline at end of file +#define FILTER_LENGTH 513 +#define DEC_FACTOR 2 \ No newline at end of file
