Programabilno vođenje DC motora
Diff: DCMotor_seminarski.cpp
- Revision:
- 0:111d0d8f408d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DCMotor_seminarski.cpp Sun Feb 14 20:26:18 2016 +0000 @@ -0,0 +1,63 @@ +#include "DCMotor_seminarski.h" +#include "mbed.h" + +Motor::Motor(PinName naprijed, PinName nazad): _naprijed(naprijed), _nazad(nazad){ + _naprijed=0; + _nazad=0; + } + void Motor::naprijedbrzo(){ + _nazad.period(0.010); + _nazad=0.0; + for(float p=0.0f; p<1.0f; p+=0.5f){ + _naprijed=p; + wait(2); + } + _nazad=0.0; + _naprijed=0.0; + } + void Motor::naprijedsporo(){ + _nazad.period(0.010); + _nazad=0.0; + for(float p=0.0f; p<0.5f; p+=0.25f){ + _naprijed=p; + wait(2); + } + _nazad=0.0; + _naprijed=0.0; + } + + void Motor::nazadbrzo(){ + _naprijed.period(0.010); + _naprijed=0.0; + for(float p=0.0f; p<1.0f; p+=0.5f){ + _nazad=p; + wait(2); + } + _nazad=0.0; + _naprijed=0.0; + } + void Motor::nazadsporo(){ + _naprijed.period(0.01); + _naprijed=0.0; + for(float p=0.0f; p<0.5f; p+=0.25f){ + _nazad=p; + wait(2); + } + _nazad=0.0; + _naprijed=0.0; + } + void Motor::naprijedrampa(){ + _nazad.period(0.010); + _nazad=0.0; + for(float p=0.0f; p<1.0f; p+=0.33f){ + _naprijed=p; + wait(1); + } + _nazad=0.0; + _naprijed=0.0; + } + void Motor::stop(){ + _nazad=0.0; + _naprijed=0.0; + wait(2); + }