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: Encoder HIDScope mbed
Fork of Motor_component_testing by
main.cpp@2:b7d757570748, 2014-10-23 (annotated)
- Committer:
 - BArendshorst
 - Date:
 - Thu Oct 23 09:47:12 2014 +0000
 - Revision:
 - 2:b7d757570748
 - Parent:
 - 1:0471de635f87
 
Ondergrens goede pinnen no scope;
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| phgbartels | 0:2240263f7068 | 1 | #include "mbed.h" | 
| phgbartels | 0:2240263f7068 | 2 | #include "encoder.h" | 
| phgbartels | 0:2240263f7068 | 3 | //#include "HIDScope.h" | 
| phgbartels | 0:2240263f7068 | 4 | #include "PwmOut.h" | 
| phgbartels | 0:2240263f7068 | 5 | #define M1_PWM PTA5 | 
| phgbartels | 0:2240263f7068 | 6 | #define M1_DIR PTA4 | 
| phgbartels | 0:2240263f7068 | 7 | |
| BArendshorst | 1:0471de635f87 | 8 | Encoder motor1(PTD3,PTD1); | 
| phgbartels | 0:2240263f7068 | 9 | PwmOut pwm_motor1(M1_PWM); | 
| phgbartels | 0:2240263f7068 | 10 | DigitalOut motordir1(M1_DIR); | 
| phgbartels | 0:2240263f7068 | 11 | DigitalOut LED(LED_GREEN); | 
| phgbartels | 0:2240263f7068 | 12 | |
| BArendshorst | 2:b7d757570748 | 13 | float PWM = 0.51; /// (1000/200); | 
| phgbartels | 0:2240263f7068 | 14 | //HIDScope scope(3); | 
| phgbartels | 0:2240263f7068 | 15 | |
| phgbartels | 0:2240263f7068 | 16 | int main() { | 
| BArendshorst | 1:0471de635f87 | 17 | pwm_motor1.period_us(100); | 
| BArendshorst | 1:0471de635f87 | 18 | pwm_motor1.write(PWM); | 
| phgbartels | 0:2240263f7068 | 19 | LED = 0; | 
| BArendshorst | 1:0471de635f87 | 20 | motordir1 = 0; | 
| phgbartels | 0:2240263f7068 | 21 | while(true) { | 
| phgbartels | 0:2240263f7068 | 22 | //wait(3); | 
| BArendshorst | 1:0471de635f87 | 23 | //pwm_motor1.write(0.4); | 
| phgbartels | 0:2240263f7068 | 24 | LED = 1; | 
| phgbartels | 0:2240263f7068 | 25 | //wait(1); | 
| phgbartels | 0:2240263f7068 | 26 | //PWM = PWM + 0.05; | 
| phgbartels | 0:2240263f7068 | 27 | |
| phgbartels | 0:2240263f7068 | 28 | //pwm_motor1.pulsewidth_us(50); | 
| phgbartels | 0:2240263f7068 | 29 | |
| phgbartels | 0:2240263f7068 | 30 | //scope.set(0, motor1.getPosition()); | 
| phgbartels | 0:2240263f7068 | 31 | //scope.set(1, DigitalIn(PTD3)); | 
| phgbartels | 0:2240263f7068 | 32 | //scope.set(2, DigitalIn(PTD1)); | 
| phgbartels | 0:2240263f7068 | 33 | //scope.send(); | 
| phgbartels | 0:2240263f7068 | 34 | //wait(0.01); | 
| phgbartels | 0:2240263f7068 | 35 | |
| phgbartels | 0:2240263f7068 | 36 | /* | 
| phgbartels | 0:2240263f7068 | 37 | while (PWM > 0) { | 
| phgbartels | 0:2240263f7068 | 38 | PWM = PWM - 0.005; | 
| phgbartels | 0:2240263f7068 | 39 | motordir1 = 0; | 
| phgbartels | 0:2240263f7068 | 40 | pwm_motor1.write(PWM); | 
| phgbartels | 0:2240263f7068 | 41 | scope.set(0, motor1.getPosition()); | 
| phgbartels | 0:2240263f7068 | 42 | scope.set(1, DigitalIn(PTD3)); | 
| phgbartels | 0:2240263f7068 | 43 | scope.set(2, DigitalIn(PTD1)); | 
| phgbartels | 0:2240263f7068 | 44 | scope.set(3, pwm_motor1); | 
| phgbartels | 0:2240263f7068 | 45 | scope.send(); | 
| phgbartels | 0:2240263f7068 | 46 | wait(0.005); | 
| phgbartels | 0:2240263f7068 | 47 | } | 
| phgbartels | 0:2240263f7068 | 48 | while (PWM < 1) { | 
| phgbartels | 0:2240263f7068 | 49 | PWM = PWM + 0.005; | 
| phgbartels | 0:2240263f7068 | 50 | motordir1 = 0; | 
| phgbartels | 0:2240263f7068 | 51 | pwm_motor1.write(PWM); | 
| phgbartels | 0:2240263f7068 | 52 | scope.set(0, motor1.getPosition()); | 
| phgbartels | 0:2240263f7068 | 53 | scope.set(1, DigitalIn(PTD3)); | 
| phgbartels | 0:2240263f7068 | 54 | scope.set(2, DigitalIn(PTD1)); | 
| phgbartels | 0:2240263f7068 | 55 | scope.set(3, pwm_motor1); | 
| phgbartels | 0:2240263f7068 | 56 | scope.send(); | 
| phgbartels | 0:2240263f7068 | 57 | wait(0.005); | 
| phgbartels | 0:2240263f7068 | 58 | }*/ | 
| phgbartels | 0:2240263f7068 | 59 | } | 
| phgbartels | 0:2240263f7068 | 60 | } | 
