Motor
Dependents: Nucleo_spi 2015_denziben_i2c_S2 Nucleo_Motor Nucleo_Motor ... more
Diff: Motor.cpp
- Revision:
- 4:56a1159c881c
- Parent:
- 3:dea2df71cb97
- Child:
- 5:3b639d84a95d
diff -r dea2df71cb97 -r 56a1159c881c Motor.cpp --- a/Motor.cpp Wed Sep 23 06:01:10 2015 +0000 +++ b/Motor.cpp Fri Oct 30 12:47:35 2015 +0000 @@ -5,6 +5,7 @@ Motor::Motor(const Motor& m): motor(m.Pin[0],m.Pin[1],m.Pin[2],m.Pin[3]),PwmPin(m.Pin[4]) { + bias=0.0; max=m.max; //this PwmPin.period_ms(20); @@ -27,17 +28,17 @@ void Motor::run(int i,float duty) { //static int state; - Duty = (float)duty*max; + Duty = (float)duty*max+bias; //printf("Duty %f \n",(float)duty); //if(state==i)return; - PwmPin = Duty*Duty; + PwmPin = Duty; if(state==i)return; motor=0; //wait_us(20); /*t.start(); t.reset(); while(t.read_us()>=20);*/ - wait_us(20); + wait_us(200); if(i==Front) motor=0x01|0x04; else if(i==Back) motor=0x02|0x08; else if(i==Stop) motor=0x01|0x08;