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.
Diff: src/motor.cpp
- Revision:
- 49:3aaa790800ad
- Parent:
- 45:0db0fc9f77b1
- Child:
- 50:510ce69c2a10
diff -r 8f0e007bd305 -r 3aaa790800ad src/motor.cpp
--- a/src/motor.cpp Sun Dec 01 22:19:48 2013 +0000
+++ b/src/motor.cpp Sun Dec 01 23:43:58 2013 +0000
@@ -20,6 +20,10 @@
t.attach(this, &Motor::Control, freq);
}
+void Motor::calibAngle(float ang){
+ encoder.calibPulse((int)ang*1200/6.283);
+}
+
void Motor::stop(){
t.detach();
pwmOut.write(0);
@@ -31,6 +35,10 @@
encoder.reset();
}
+float Motor::getAngle(){
+ return encoder.getPulses()/1200.0*6.283;
+}
+
void Motor::Control(){
float preAngle=angle; // Storing the angle in the previous time step
angle = encoder.getPulses()/1200.0*6.283; // Updating new motor angle
