Upravljanje unipolasnim motorom
Diff: umotor.cpp
- Revision:
- 1:9cd4fd37eee0
- Parent:
- 0:a3d5b06d790a
- Child:
- 2:b769f13c7523
--- a/umotor.cpp Sun Jan 29 23:53:10 2017 +0000 +++ b/umotor.cpp Mon Jan 30 00:22:04 2017 +0000 @@ -1,3 +1,18 @@ +/** Projektiranje ugradbenih računalnih sustava +* Interakcija sa linijom +* @author: mario_meh +* @code +#include "mbed.h" +#include "umotor.h" + +* int main() { +* Steper *bipolar = new Steper(); +* while(1) { +* bipolar->u_motor(); +* } +* } +* @endcode +*/ #include "mbed.h" #include "umotor.h" @@ -6,9 +21,11 @@ int koraka; int available = 1; static uint8_t step = 0; - +/** Unipolarni motor radi u half-step modu */ const uint8_t schrittfolge[] = {0b1001, 0b1010, 0b0110, 0b0101}; // Vollschritt zwei Phasen - +/** Konstruktor +* inicijalizacija je: Steper <naziv> = new Steper; +*/ Steper::Steper() : coil1(PTD2), coil2(PTD0), coil3(PTD5), coil4(PTA13), ledSec(PTB18), riseL(PTD6), fallL(PTD7), pbone(PTA5), pbtwo(PTA4) @@ -37,7 +54,7 @@ step = 0; } - +/** <timer_isr()> zove stepper_steo() */ void Steper::timer_isr() { static uint32_t g_tmr_cnt = 0; @@ -76,10 +93,10 @@ riseL = 1; fallL = 1; ledSec = 1; - + /** Imam flag za 2 tipkala */ pbone.fall(this, &Steper::pboneCallback); pbtwo.fall(this, &Steper::pbtwoCallback); - + /** Započni timer da bi mogao zvati prekid <timer_isr> */ t.start(); toggler.attach(this, &Steper::timer_isr, 0.001);