Script voor aansturen motoren
Dependencies: Encoder HIDScope MODSERIAL mbed-dsp mbed
Diff: main.cpp
- Revision:
- 6:f260176f704b
- Parent:
- 5:e4b9cc904928
- Child:
- 7:697293226e5e
--- a/main.cpp Wed Oct 22 14:08:43 2014 +0000 +++ b/main.cpp Thu Oct 23 10:26:25 2014 +0000 @@ -2,7 +2,7 @@ #include "encoder.h" #include "HIDScope.h" -#define TSAMP 0.01 +#define TSAMP 0.005 #define K_P (0.1) #define K_I (0.03 *TSAMP) #define K_D (0.001 /TSAMP) @@ -38,23 +38,26 @@ //motor 25D Encoder motor1(PTD3,PTD5); //wit, geel - PwmOut pwm_motor1(M2_PWM); // PTC8, blauw, /*PwmOut to motor driver*/ + PwmOut pwm_motor1(M2_PWM); // pwm_motor1.period_us(75); //10kHz PWM frequency - DigitalOut motordir1(M2_DIR); //PTC9, groen + DigitalOut motordir1(M2_DIR); //motor2 37D Encoder motor2(PTD2, PTD0); //wit, geel - PwmOut pwm_motor2(M1_PWM); //PTA5, blauw + PwmOut pwm_motor2(M1_PWM); pwm_motor2.period_us(75); - DigitalOut motordir2(M1_DIR); //PTA4, groen + DigitalOut motordir2(M1_DIR); - char c ='0'; + //char c ='0'; while(1) { + wait(13); pwm_motor1.write(1); - motordir1.write(1); + + + wait(0.01); - scope.set(0, motor1.getposition()); + scope.set(0, motor1.getPosition()); scope.set(1, motor2.getPosition()); scope.send(); /*do { @@ -69,7 +72,6 @@ motordir1.write(0); wait(3); - }*/ + }*/ + } } - -