hirromu takaki
/
106_MD_practice
動いた
Diff: main.cpp
- Revision:
- 0:2762f6b27c5f
- Child:
- 1:81190825251c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Jan 25 09:13:29 2020 +0000 @@ -0,0 +1,33 @@ +#include "mbed.h" +#include "haseMD.h" +#include "lpf.h" + +HaseMD md[4] = { HaseMD(PA_6),HaseMD(PA_7), HaseMD(PA_9),HaseMD(PB_10) }; +//DigitalIn DS[3] = { DigitalIn(PC_12), DigitalIn(PC_10), DigitalIn(PD_2) }; +Timer tim; +Serial pc(USBTX,USBRX,115200); +lpf mdlpf(1.0/300,0.005); +//DigitalIn fallut(PB_6); +//DigitalIn otw(PC_7); + +int main() +{ + tim.start(); + double pwm = 0.0,put; + + while (true) { + + pwm = sin(tim/3.0); + for(int i=0; i < 4; i++) + { + md[i].setSpeed(pwm); + + } + mdlpf.path_value(pwm); +// pwm += ((pwm < 0.1) - (pwm > 0.9)) * 0.1; +// put = 0.5 + pwm / 2.0; + put = pwm * 0.9 / 2 + 0.5; + pc.printf("%f \n\r",put); + } +} +