Motor component testing

Dependencies:   Encoder HIDScope mbed

Committer:
phgbartels
Date:
Thu Oct 23 09:09:24 2014 +0000
Revision:
0:2240263f7068
Motor component testing

Who changed what in which revision?

UserRevisionLine numberNew 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
phgbartels 0:2240263f7068 8 Encoder motor1(PTD3,PTD1, true);
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
phgbartels 0:2240263f7068 13 float PWM = 0.2; /// (1000/200);
phgbartels 0:2240263f7068 14 //HIDScope scope(3);
phgbartels 0:2240263f7068 15
phgbartels 0:2240263f7068 16 int main() {
phgbartels 0:2240263f7068 17 //pwm_motor1.period_us(100);
phgbartels 0:2240263f7068 18 //pwm_motor1.write(PWM);
phgbartels 0:2240263f7068 19 LED = 0;
phgbartels 0:2240263f7068 20 motordir1 = 1;
phgbartels 0:2240263f7068 21 while(true) {
phgbartels 0:2240263f7068 22 //wait(3);
phgbartels 0:2240263f7068 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 }