p

NK_motor.cpp

Committer:
hamohamo
Date:
2021-08-22
Revision:
0:5f9d8f2ef93e

File content as of revision 0:5f9d8f2ef93e:

#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;
    }
}