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.
Revision 8:6ae3c3cd7f55, committed 2017-02-14
- Comitter:
- abraham1
- Date:
- Tue Feb 14 20:36:07 2017 +0000
- Parent:
- 7:1726c40ad774
- Child:
- 9:d8d2778bfbfd
- Commit message:
- Field width enlarged. power of 10 problem corrected!!!
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Feb 10 00:04:57 2017 +0000 +++ b/main.cpp Tue Feb 14 20:36:07 2017 +0000 @@ -86,8 +86,8 @@ double publishFrequency = 0.05; /* seconds. rate to publish to matlab */ double samplesPerPublish = (int)(publishFrequency/updatePeriod); /*this improves time response of filter and maintains smoothness*/ int publishCounter = 1; - double filterRatio = 0.045; - double currentFilterRatio = 0.03; + double filterRatio = 0.07; + double currentFilterRatio = 0.035; float currentSensorOffset = 0; int i; for(i=1;i<301;i++){ currentSensorOffset += currentSense.read(); } currentSensorOffset = currentSensorOffset*VREF/300; @@ -128,6 +128,10 @@ while(1) { + // currentSensorOffset = 0; i = 0; TODO: this is not working +// for(i=1;i<201;i++){ currentSensorOffset += currentSense.read(); } //TODO: watch out this could take some time, but this should make things better! +// currentSensorOffset = currentSensorOffset*VREF/300; + green = false; wait(updatePeriod); start = end; @@ -153,8 +157,8 @@ } } if(publishCounter == samplesPerPublish) { - printf("%+8f,%+8f,%+8f,%+8f\n", currentSensed/currentSensorOutputRatio, pwm.read(), velocity, ((double)(end-absoluteStart)/CLOCKS_PER_SEC)); - publishCounter = 1; + printf("%+9.5f,%+8.4f,%+9.5f,%+8.2f\n", currentSensed/currentSensorOutputRatio, pwm.read(), velocity, ((double)(end-absoluteStart)/CLOCKS_PER_SEC)); + publishCounter = 1; // good for 1000 seconds. and room to grow one power of 10 on all other inputs. } publishCounter++;