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.
Dependencies: mbed-dev-f303 FastPWM3
Diff: PositionSensor/PositionSensor.cpp
- Revision:
- 11:c83b18d41e54
- Parent:
- 10:370851e6e132
- Child:
- 12:c473a25f54f7
--- a/PositionSensor/PositionSensor.cpp Thu May 12 05:02:52 2016 +0000
+++ b/PositionSensor/PositionSensor.cpp Sun May 22 00:14:59 2016 +0000
@@ -15,7 +15,15 @@
cs->write(1);
MechOffset = 0;
}
+
+int PositionSensorSPI::GetRawPosition(){
+ cs->write(0);
+ int response = spi->write(0)>>4;
+ cs->write(1);
+ return response;
+ }
+
float PositionSensorSPI::GetMechPosition(){
cs->write(0);
int response = spi->write(0)>>4;
@@ -28,8 +36,8 @@
}
old_counts = response;
MechPosition = (6.28318530718f * ((float) response+(_CPR*rotations)))/ (float)_CPR;
- return MechPosition - MechOffset;
-
+ //return MechPosition - MechOffset;
+ return MechPosition;
}
float PositionSensorSPI::GetElecPosition(){
@@ -143,7 +151,7 @@
float dir = -2.0f*(float)(((TIM3->CR1)>>4)&1)+1.0f; // +/- 1
float meas = dir*90000000.0f*(6.28318530718f/(float)_CPR)/rawPeriod;
-
+ out = meas;
if(meas == vel_old){
out = .95f*out_old;
}