2.007 PulleyInterface mbed code. Biomimetics robotics lab. Sangbae Kim. Ben Katz. For use with PulleyInterface.mlapp
Diff: main.cpp
- Revision:
- 10:ae139f40acc0
- Parent:
- 9:d8d2778bfbfd
- Child:
- 11:e563823d3c94
diff -r d8d2778bfbfd -r ae139f40acc0 main.cpp --- a/main.cpp Tue Feb 14 20:37:53 2017 +0000 +++ b/main.cpp Thu Feb 16 23:27:49 2017 +0000 @@ -16,7 +16,7 @@ Serial pc(USBTX, USBRX, 115200); DigitalOut green(LED2); -const int CPR = 900; // Encoder counts per revolution. Change to match your encoder +const int CPR = 900*4; // Encoder counts per revolution. Change to match your encoder. x4 for quadrature! const double VREF = 3; //Microcontroller reference voltage const float currentSensorOutputRatio = 0.185; // Volts/Amp. Divide Voltage by cSenseOutput to get current @@ -86,7 +86,7 @@ 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.07; + double filterRatio = 0.1; double currentFilterRatio = 0.035; float currentSensorOffset = 0; int i; for(i=1;i<301;i++){ currentSensorOffset += currentSense.read(); } @@ -99,10 +99,10 @@ while(1) { - currentSensorOffset = 0; i = 0; - 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; - +// currentSensorOffset = 0; i = 0; +// 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; + while(1) { green = true;