Programabilno vođenje DC motora

Committer:
Josip
Date:
Sun Feb 14 20:26:18 2016 +0000
Revision:
0:111d0d8f408d
Programabilno vo?enje DC Motora_prva verzija

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Josip 0:111d0d8f408d 1 #include "DCMotor_seminarski.h"
Josip 0:111d0d8f408d 2 #include "mbed.h"
Josip 0:111d0d8f408d 3
Josip 0:111d0d8f408d 4 Motor::Motor(PinName naprijed, PinName nazad): _naprijed(naprijed), _nazad(nazad){
Josip 0:111d0d8f408d 5 _naprijed=0;
Josip 0:111d0d8f408d 6 _nazad=0;
Josip 0:111d0d8f408d 7 }
Josip 0:111d0d8f408d 8 void Motor::naprijedbrzo(){
Josip 0:111d0d8f408d 9 _nazad.period(0.010);
Josip 0:111d0d8f408d 10 _nazad=0.0;
Josip 0:111d0d8f408d 11 for(float p=0.0f; p<1.0f; p+=0.5f){
Josip 0:111d0d8f408d 12 _naprijed=p;
Josip 0:111d0d8f408d 13 wait(2);
Josip 0:111d0d8f408d 14 }
Josip 0:111d0d8f408d 15 _nazad=0.0;
Josip 0:111d0d8f408d 16 _naprijed=0.0;
Josip 0:111d0d8f408d 17 }
Josip 0:111d0d8f408d 18 void Motor::naprijedsporo(){
Josip 0:111d0d8f408d 19 _nazad.period(0.010);
Josip 0:111d0d8f408d 20 _nazad=0.0;
Josip 0:111d0d8f408d 21 for(float p=0.0f; p<0.5f; p+=0.25f){
Josip 0:111d0d8f408d 22 _naprijed=p;
Josip 0:111d0d8f408d 23 wait(2);
Josip 0:111d0d8f408d 24 }
Josip 0:111d0d8f408d 25 _nazad=0.0;
Josip 0:111d0d8f408d 26 _naprijed=0.0;
Josip 0:111d0d8f408d 27 }
Josip 0:111d0d8f408d 28
Josip 0:111d0d8f408d 29 void Motor::nazadbrzo(){
Josip 0:111d0d8f408d 30 _naprijed.period(0.010);
Josip 0:111d0d8f408d 31 _naprijed=0.0;
Josip 0:111d0d8f408d 32 for(float p=0.0f; p<1.0f; p+=0.5f){
Josip 0:111d0d8f408d 33 _nazad=p;
Josip 0:111d0d8f408d 34 wait(2);
Josip 0:111d0d8f408d 35 }
Josip 0:111d0d8f408d 36 _nazad=0.0;
Josip 0:111d0d8f408d 37 _naprijed=0.0;
Josip 0:111d0d8f408d 38 }
Josip 0:111d0d8f408d 39 void Motor::nazadsporo(){
Josip 0:111d0d8f408d 40 _naprijed.period(0.01);
Josip 0:111d0d8f408d 41 _naprijed=0.0;
Josip 0:111d0d8f408d 42 for(float p=0.0f; p<0.5f; p+=0.25f){
Josip 0:111d0d8f408d 43 _nazad=p;
Josip 0:111d0d8f408d 44 wait(2);
Josip 0:111d0d8f408d 45 }
Josip 0:111d0d8f408d 46 _nazad=0.0;
Josip 0:111d0d8f408d 47 _naprijed=0.0;
Josip 0:111d0d8f408d 48 }
Josip 0:111d0d8f408d 49 void Motor::naprijedrampa(){
Josip 0:111d0d8f408d 50 _nazad.period(0.010);
Josip 0:111d0d8f408d 51 _nazad=0.0;
Josip 0:111d0d8f408d 52 for(float p=0.0f; p<1.0f; p+=0.33f){
Josip 0:111d0d8f408d 53 _naprijed=p;
Josip 0:111d0d8f408d 54 wait(1);
Josip 0:111d0d8f408d 55 }
Josip 0:111d0d8f408d 56 _nazad=0.0;
Josip 0:111d0d8f408d 57 _naprijed=0.0;
Josip 0:111d0d8f408d 58 }
Josip 0:111d0d8f408d 59 void Motor::stop(){
Josip 0:111d0d8f408d 60 _nazad=0.0;
Josip 0:111d0d8f408d 61 _naprijed=0.0;
Josip 0:111d0d8f408d 62 wait(2);
Josip 0:111d0d8f408d 63 }