![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Tests the motor by having the speed follow a sine wave.
Dependencies: mbed
Revision 0:113570912de7, committed 2014-10-06
- Comitter:
- jmar11
- Date:
- Mon Oct 06 14:56:56 2014 +0000
- Commit message:
- Tested the motor driver
Changed in this revision
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
motor_test.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 113570912de7 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Oct 06 14:56:56 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/552587b429a1 \ No newline at end of file
diff -r 000000000000 -r 113570912de7 motor_test.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/motor_test.cpp Mon Oct 06 14:56:56 2014 +0000 @@ -0,0 +1,25 @@ +#include "mbed.h" + +PwmOut speed = PTE21; //speed +DigitalOut direct = PTE20; //direction + +int main() { + float t = 0; + float val; + + while(1){ + val = sin(t)/4; //motor speed follows a sine wave + t += 0.00314f; + + if(val < 0){ //when val is negative switch direction + direct = 1; + speed = val * -1f; + } + else{ + direct = 0; + speed = val; + } + + wait_us(2500); + } +} \ No newline at end of file