![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Signa-bot code for project BioRobotics, at University of Twente.
Dependencies: mbed QEI MODSERIAL FastPWM ttmath Math
Motor_tryout.cpp@4:bd21569250c7, 2019-09-30 (annotated)
- Committer:
- Feike
- Date:
- Mon Sep 30 11:36:51 2019 +0000
- Revision:
- 4:bd21569250c7
- Child:
- 5:fea5544804c1
- Child:
- 7:e119b12e5e7f
Robot-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 | } |
Feike | 4:bd21569250c7 | 19 | } |