![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Robot tryout
Dependencies: mbed QEI biquadFilter MODSERIAL FastPWM ttmath Math
Motor_tryout.cpp@5:fea5544804c1, 2019-09-30 (annotated)
- Committer:
- viviien
- Date:
- Mon Sep 30 11:43:11 2019 +0000
- Revision:
- 5:fea5544804c1
- Parent:
- 4:bd21569250c7
- Child:
- 6:4dbd0d12e0f7
COmmit tryout
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Feike | 4:bd21569250c7 | 1 | #include "mbed.h" |
Feike | 4:bd21569250c7 | 2 | #include "MODSERIAL.h" |
Feike | 4:bd21569250c7 | 3 | |
Feike | 4:bd21569250c7 | 4 | DigitalOut motor1_pwm(D3); |
Feike | 4:bd21569250c7 | 5 | MODSERIAL pc(USBTX, USBRX); |
Feike | 4:bd21569250c7 | 6 | int main(void) |
Feike | 4:bd21569250c7 | 7 | { |
Feike | 4:bd21569250c7 | 8 | int frequency_pwm = 10000; //10 kHz PWM |
Feike | 4:bd21569250c7 | 9 | PwmOut motor1_pwm(D3); |
Feike | 4:bd21569250c7 | 10 | motor1_pwm.period(1.0/frequency_pwm); // T=1/f |
Feike | 4:bd21569250c7 | 11 | while(true) |
Feike | 4:bd21569250c7 | 12 | { |
Feike | 4:bd21569250c7 | 13 | for(int pct = 0 ; pct <= 100 ; pct = pct +10) |
Feike | 4:bd21569250c7 | 14 | { |
Feike | 4:bd21569250c7 | 15 | motor1_pwm.write(pct/100.0); // write Duty Cycle |
Feike | 4:bd21569250c7 | 16 | wait(0.1); |
Feike | 4:bd21569250c7 | 17 | } |
Feike | 4:bd21569250c7 | 18 | } |
viviien | 5:fea5544804c1 | 19 | } |
viviien | 5:fea5544804c1 | 20 | // Comment |