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.
Dependents: locomotion_pid_action_refactor_EMG
Revision 4:2af658a4e54b, committed 2017-10-26
- Comitter:
- tvlogman
- Date:
- Thu Oct 26 14:02:01 2017 +0000
- Parent:
- 3:71a7dd98fb2c
- Commit message:
- changed so it has a seperate fetchMotorPosition function
Changed in this revision
| errorFetch.cpp | Show annotated file Show diff for this revision Revisions of this file |
| errorFetch.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 71a7dd98fb2c -r 2af658a4e54b errorFetch.cpp
--- a/errorFetch.cpp Sun Oct 22 08:01:40 2017 +0000
+++ b/errorFetch.cpp Thu Oct 26 14:02:01 2017 +0000
@@ -7,11 +7,13 @@
errorFetch::errorFetch(float N, float Ts):gearRatio(N), Ts(Ts), e_pos(0), e_int(0), e_der(0), e_prev(0){
}
+
+double errorFetch::fetchMotorPosition(int counts){
+ double motorPosition = 2*3.14*(counts/(gearRatio*64.0f));
+ return motorPosition;
+ }
-void errorFetch::fetchError(int counts, float ref){
- // Calculating motor position based on encoder counts
- double motorPosition = 2*3.14*(counts/(gearRatio*64.0f));
-
+void errorFetch::fetchError(double motorPosition, double ref){
// Computing position error
e_pos = ref - motorPosition;
diff -r 71a7dd98fb2c -r 2af658a4e54b errorFetch.h
--- a/errorFetch.h Sun Oct 22 08:01:40 2017 +0000
+++ b/errorFetch.h Thu Oct 26 14:02:01 2017 +0000
@@ -12,7 +12,8 @@
volatile float e_der;
volatile float e_prev;
- void fetchError(int counts, float ref); // Gets reference position on specified pin
+ double fetchMotorPosition(int counts);
+ void fetchError(double motorPosition, double ref); // Gets reference position on specified pin
private:
const float gearRatio;