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 13:83e3672b24ee, committed 2017-09-21
- Comitter:
- tvlogman
- Date:
- Thu Sep 21 09:29:19 2017 +0000
- Parent:
- 12:0462757e1ed2
- Child:
- 14:664870b5d153
- Commit message:
- Motor works
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:35:44 2017 +0000
+++ b/main.cpp Thu Sep 21 09:29:19 2017 +0000
@@ -6,6 +6,10 @@
QEI Encoder(D12,D13,NC,64, QEI::X4_ENCODING);
MODSERIAL pc(USBTX, USBRX);
+DigitalOut motor1_direction(D4);
+PwmOut motor1_pwm(D5);
+float pwmPeriod = 1.0/5000.0;
+
Ticker encoderTicker;
volatile int counts = 0;
volatile float revs = 0.00;
@@ -17,12 +21,25 @@
pc.printf("%f revolutions \r\n", revs);
}
+int frequency_pwm = 10000; //10kHz PWM
+
int main()
{
+ motor1_direction = true;
+ motor1_pwm.period(pwmPeriod);//T=1/f
+
pc.baud(115200);
encoderTicker.attach(readEncoder, 1.0);
pc.printf("Encoder ticker attached and baudrate set");
+
+
+ while(true){
+ for(int i = 0 ; i<=30 ; i= i+10)
+ {
+ motor1_pwm.write(i/100.0);//write Duty Cycle
+ }
+ }
}
