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.
Revision 0:081a0007e5b3, committed 2014-12-01
- Comitter:
- kikoaac
- Date:
- Mon Dec 01 08:25:22 2014 +0000
- Commit message:
- test QEI;
Changed in this revision
diff -r 000000000000 -r 081a0007e5b3 QEI.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QEI.lib Mon Dec 01 08:25:22 2014 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/farbodjam/code/QEI/#fc0482177a6d
diff -r 000000000000 -r 081a0007e5b3 main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Mon Dec 01 08:25:22 2014 +0000
@@ -0,0 +1,60 @@
+#include "mbed.h"
+#include "QEI.h"
+#define ROTATE_PER_REVOLUTIONS 48
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+DigitalOut led3(LED3);
+DigitalOut led4(LED4);
+Ticker timer1;
+Ticker timer2;
+Serial pc(USBTX, USBRX); // tx, rx pc hyper terminal
+QEI wheel1(D1,D0,NC, ROTATE_PER_REVOLUTIONS, QEI::X4_ENCODING);
+int buf,cfd,predata,pulse1,pulse2;
+
+void disp() {
+ /*lcd.locate(0,0);
+ lcd.printf("ec1:%03d ec2:%03d\n", pulse1,pulse2);
+ lcd.locate(0,1);
+ lcd.printf("cfd:%03d\n", cfd); */
+ printf("encoder1: %02d\n\r", pulse1);
+ printf("encoder2: %02d\n\r", pulse2);
+ printf("cfd:%03d\n\r", cfd);
+ led2=!led2; //check
+ }
+void encoder() {
+ pulse1 = wheel1.getPulses()/4;
+ //pulse2 = wheel2.getPulses()/4;
+ led4=!led4; //check
+}
+ int main()
+ {
+ timer1.attach_us(&disp, 50000); //100ms
+ timer2.attach_us(&encoder,10); //10ms
+ printf("Opt Feder X1");
+ while(1)
+ {
+ led3=!led3;//check
+ if(pc.readable()) {
+ buf = pc.getc();
+ if(buf == 127)
+ { //to aboid freeze issue at 127 not fixed.
+ buf =pc.getc();
+ }
+ cfd = buf;
+ if(buf != predata)
+ {
+ if(buf >= 3)
+ {
+ led1 = 1;
+ }
+ else{
+ led1 =0;
+ }
+ //cfd = buf;
+ predata = buf;
+
+ }//if(x1 != predata)
+
+ }//if(device.readable())
+ }
+ }
\ No newline at end of file
diff -r 000000000000 -r 081a0007e5b3 mbed-src.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-src.lib Mon Dec 01 08:25:22 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed-src/#cc1c4962551c