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: pot/pot.cpp
- Revision:
- 22:c18f04d1dc49
- Parent:
- 20:8063c82bbb35
- Child:
- 23:5238b046119b
--- a/pot/pot.cpp Wed Nov 16 23:48:46 2016 +0000
+++ b/pot/pot.cpp Fri Nov 18 02:47:59 2016 +0000
@@ -10,7 +10,7 @@
void Pot::update(){
angular_velocity = (get_angle() - angle)/ UPDATE_TIME;
- angle=get_angle();
+ angle=get_angle_pulse();
velocity = (get_position() - position) / UPDATE_TIME;
position=get_position();
}
@@ -25,6 +25,12 @@
return a;
}
+float Pot::get_angle_pulse(){
+ float b = (float) 360/ (float)1024;
+ float a = ((float)encoder->getPulses()*b);
+ return a;
+}
+
float Pot::get_position(){
float a = (-1)*encoder->getPulses()*CM_PER_PULSE;
return a;