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.
Fork of motor_calibration by
Revision 0:1045216da12e, committed 2018-10-22
- Comitter:
- kweisbeek
- Date:
- Mon Oct 22 11:11:15 2018 +0000
- Child:
- 1:53bb5928adcf
- Commit message:
- V1
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
| mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Mon Oct 22 11:11:15 2018 +0000
@@ -0,0 +1,42 @@
+#include "mbed.h"
+
+
+//initial allocations
+DigitalOut dirpin(D4);
+PwmOut pwmpin(D5);
+QEI Encoder(D12,D13,NC,64,QEI::X4_ENCODING);
+
+//volatiles
+volatile counts_prev=0;
+
+//functions
+int counts(){
+ int counts=Encoder.getPulses(); //MAAK NOG AF MET PREVIOUS COUNTS ONTHOUDEN.
+ return counts
+
+
+int main(){
+ pwmpin.period_us(60);
+
+ //parameters
+ int caltime=30; //calibration time until condition has been met, caltime=(time/0.1)
+ float speed=0.50f;
+ int dir=0
+
+ //move towards end
+ for (m=1;2;m++){
+ dirpin.write(dir);
+ pwmpin = speed;
+ int n=1
+ //when motor counts do not change anymore, change direction
+ while(n<(caltime+1)){
+ for (n=1;caltime;n++){
+ if (counts()!=counts_prev){
+ n=0;}
+ else {}
+ wait(0.1);}
+ dir=dir+1;}
+
+
+
+
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Oct 22 11:11:15 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/e95d10626187 \ No newline at end of file
