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.
pwm.cpp@4:48d390356fba, 2018-02-22 (annotated)
- Committer:
- Weranest
- Date:
- Thu Feb 22 17:01:00 2018 +0000
- Revision:
- 4:48d390356fba
- Parent:
- 3:c9df852ad9ac
Tech Demo version
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Weranest | 0:62e51b80d738 | 1 | //this defines motor setup and movement |
Weranest | 0:62e51b80d738 | 2 | #include "mbed.h" |
Weranest | 0:62e51b80d738 | 3 | #include "C12832.h" |
Weranest | 1:12f18cede014 | 4 | #include "pins.h" |
Weranest | 1:12f18cede014 | 5 | #include "pwm.h" |
Weranest | 3:c9df852ad9ac | 6 | #include "constants.cpp" |
Weranest | 0:62e51b80d738 | 7 | //will have to determine real pulsewidths by testing with encoder |
Weranest | 3:c9df852ad9ac | 8 | |
Weranest | 0:62e51b80d738 | 9 | //currently the setup uses unipolar mode, hence the need for direction |
Weranest | 0:62e51b80d738 | 10 | |
Weranest | 0:62e51b80d738 | 11 | |
Weranest | 3:c9df852ad9ac | 12 | |
Weranest | 0:62e51b80d738 | 13 | void motorSetup(){ |
Weranest | 0:62e51b80d738 | 14 | motorRight.period_ms(MOTOR_PERIOD); |
Weranest | 0:62e51b80d738 | 15 | motorLeft.period_ms(MOTOR_PERIOD); |
Weranest | 1:12f18cede014 | 16 | motorDirLeft.write(0); |
Weranest | 1:12f18cede014 | 17 | motorDirRight.write(0); |
Weranest | 1:12f18cede014 | 18 | motorModeLeft.write(0); //1 =bipolar, 0 = unipolar |
Weranest | 3:c9df852ad9ac | 19 | motorModeRight.write(0); |
Weranest | 3:c9df852ad9ac | 20 | driveBoard.write(1); //enables the buggy to drive |
Weranest | 3:c9df852ad9ac | 21 | } |
Weranest | 3:c9df852ad9ac | 22 | |
Weranest | 3:c9df852ad9ac | 23 | |
Weranest | 4:48d390356fba | 24 | void buggyPWM(float pwmLeft, float pwmRight){ //drives forward |
Weranest | 4:48d390356fba | 25 | motorRight.write(pwmRight); |
Weranest | 4:48d390356fba | 26 | motorLeft.write(pwmLeft); |
Weranest | 3:c9df852ad9ac | 27 | } |
Weranest | 3:c9df852ad9ac | 28 | |
Weranest | 3:c9df852ad9ac | 29 |