Autor klase: Josip Lupinski
Revision 0:a5f28c547fdb, committed 2017-02-06
- Comitter:
- feri
- Date:
- Mon Feb 06 16:21:59 2017 +0000
- Commit message:
- hmost;
Changed in this revision
Mot_inter.cpp | Show annotated file Show diff for this revision Revisions of this file |
Mot_inter.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r a5f28c547fdb Mot_inter.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Mot_inter.cpp Mon Feb 06 16:21:59 2017 +0000 @@ -0,0 +1,35 @@ +#include "Mot_inter.h" +#include "mbed.h" + +Mot_inter::Mot_inter(PinName pin1, PinName pin2, PinName tipka1, PinName tipka2):C(tipka1),D(tipka2) +{ + A = new PwmOut(pin1); + B = new PwmOut(pin2); + C.mode(PullUp); + D.mode(PullUp); + C.rise(this, &Mot_inter::pritisnuto); + D.rise(this, &Mot_inter::pritisnuto); +} + +void Mot_inter::naprijed() +{ + A->write(1); + B->write(0); +} + +void Mot_inter::natrag() +{ + A->write(0); + B->write(1); +} + +void Mot_inter::stop() +{ + A->write(0); + B->write(0); +} + +void Mot_inter::pritisnuto() +{ + stop(); +} \ No newline at end of file
diff -r 000000000000 -r a5f28c547fdb Mot_inter.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Mot_inter.h Mon Feb 06 16:21:59 2017 +0000 @@ -0,0 +1,43 @@ +#ifndef Mot_inter_H +#define Mot_inter_H + +#include "mbed.h" + +/** Jednostavna klasa za pokretanje motora spojenog na H-most, + * te prisilno zaustavljanje pomoću interrupt tipkala + * Autor klase: Josip Lupinski + */ + +class Mot_inter{ + public: + /** Konstruktor H-mosta + * @param A PWM signal za upravlajnje visokom stranom tranzistora H-mosta A + * @param B PWM signal za upravlajnje visokom stranom tranzistora H-mosta b + * @param C INTERRUPT signal za naglo zaustavljanje motora + * @param D INTERRUPT signal za naglo zaustavljanje motora + */ + Mot_inter(PinName A, PinName B, PinName C, PinName D); + + /** Naredba za pokretanje motora u jednom smjeru + */ + void naprijed(); + + /** Naredba za pokretanje motora u drugom smjeru + */ + void natrag(); + + /** Naredba za naglo zaustavljanje motora + */ + void stop(); + + private: + PwmOut *A, *B; //pointeri za Pwm Out objekte + InterruptIn C; + InterruptIn D; + + /** Naredba za naglo zaustavljanje motora kada se bilo koja tipka aktivira + */ + void pritisnuto(void); + +}; +#endif \ No newline at end of file