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: FastPWM HIDScope MODSERIAL QEI Matrix biquadFilter controller errorFetch mbed motorConfig refGen MatrixMath inverseKinematics
Fork of Minor_test_serial by
Revision 12:0462757e1ed2, committed 2017-09-21
- Comitter:
- tvlogman
- Date:
- Thu Sep 21 08:35:44 2017 +0000
- Parent:
- 11:d1692be2de30
- Child:
- 13:83e3672b24ee
- Commit message:
- Now counts revolutions as well.;
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Sep 21 08:20:49 2017 +0000
+++ b/main.cpp Thu Sep 21 08:35:44 2017 +0000
@@ -3,23 +3,25 @@
#include "HIDScope.h"
#include "QEI.h"
-QEI Encoder(D12,D13,NC,32);
+QEI Encoder(D12,D13,NC,64, QEI::X4_ENCODING);
MODSERIAL pc(USBTX, USBRX);
Ticker encoderTicker;
volatile int counts = 0;
-
+volatile float revs = 0.00;
void readEncoder(){
counts = Encoder.getPulses();
- pc.printf("%i pulses", counts);
+ revs = counts/64.0f;
+ pc.printf("%i pulses \r\n", counts);
+ pc.printf("%f revolutions \r\n", revs);
}
int main()
{
pc.baud(115200);
- encoderTicker.attach(readEncoder, 0.5);
+ encoderTicker.attach(readEncoder, 1.0);
pc.printf("Encoder ticker attached and baudrate set");
}
