p
Diff: NK_motor.cpp
- Revision:
- 0:5f9d8f2ef93e
diff -r 000000000000 -r 5f9d8f2ef93e NK_motor.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/NK_motor.cpp Sun Aug 22 13:01:50 2021 +0000 @@ -0,0 +1,33 @@ +#include "NK_motor.hpp" + +Nk_motor::Nk_motor(PinName plus,PinName minus,int period){ + Plus = new PwmOut(plus); + Minus = new PwmOut(minus); + Plus->period_us(period); + Minus->period_us(period); + /**Minus=0.0; + *Plus=0.0;*/ +} +Nk_motor::~Nk_motor(){ +} +void Nk_motor::SetLimit(double max,double min){ + Max = max; + Min = min; +} +void Nk_motor::pwmout(double pwm){ + if(pwm>=Max){ + Pwm=Max; + } + else if(pwm<=Min){ + Pwm=Min; + } + else{ + Pwm=pwm; + } + if(Pwm<0.0){ + *Minus=Pwm*-1; + } + else { + *Plus=Pwm; + } +}