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 locate_by_hello_enc by
Diff: locate.h
- Revision:
- 1:10cc86cabdce
- Parent:
- 0:f12d257b587e
- Child:
- 2:4b2594dd86be
--- a/locate.h	Thu Sep 01 05:13:31 2016 +0000
+++ b/locate.h	Thu Sep 01 08:53:14 2016 +0000
@@ -30,7 +30,7 @@
 Serial pc(SERIAL_TX, SERIAL_RX);
 TIM_Encoder_InitTypeDef encoder1, encoder2;
 TIM_HandleTypeDef  timer1,  timer2;
-DigitalOut enc_v(PB_10);
+DigitalOut enc_v(PC_7);
 
 uint16_t count1=0,  count2=0;
 int8_t dir1, dir2;
@@ -72,7 +72,7 @@
     count2=__HAL_TIM_GET_COUNTER(&timer2);
     dir2 = __HAL_TIM_IS_TIM_COUNTING_DOWN(&timer2);   
     
-    r = convert_enc_count(count1, dir1);
+    r = -convert_enc_count(count1, dir1);
     l = convert_enc_count(count2, dir2);
         
     theta = (r - l) * ROUND;
@@ -83,8 +83,8 @@
 
     pr = r;
     pl = l;
-    pc.printf("count1:%d%s  count2:%d%s\r\n", count1, dir1==0 ? "+":"-",count2, dir2==0 ? "+":"-");
-    pc.printf("right:%d     left:%d", r, l);
+    //pc.printf("count1:%d%s  count2:%d%s\r\n", count1, dir1==0 ? "+":"-",count2, dir2==0 ? "+":"-");
+    pc.printf("right:%d     left:%d    ", r, l);
 }
 
 short coordinateX()
    