E

Dependencies:   mbed

Committer:
fabeltranm
Date:
Tue Mar 20 23:49:10 2018 +0000
Revision:
0:2890f9a09e85
Child:
1:5dfedc044f7a
Ok

Who changed what in which revision?

UserRevisionLine numberNew contents of line
fabeltranm 0:2890f9a09e85 1 #include "mbed.h"
fabeltranm 0:2890f9a09e85 2 #include "stepmotor.h"
fabeltranm 0:2890f9a09e85 3
fabeltranm 0:2890f9a09e85 4 stepmotor smotor1(D9,D10,D11,D12);
fabeltranm 0:2890f9a09e85 5 Serial pc(USBTX,USBRX);
fabeltranm 0:2890f9a09e85 6 int main() {
fabeltranm 0:2890f9a09e85 7 uint32_t speed=1500;
fabeltranm 0:2890f9a09e85 8 uint8_t cw=1;
fabeltranm 0:2890f9a09e85 9 while(1)
fabeltranm 0:2890f9a09e85 10 {
fabeltranm 0:2890f9a09e85 11 smotor1.set_speed(speed);
fabeltranm 0:2890f9a09e85 12
fabeltranm 0:2890f9a09e85 13
fabeltranm 0:2890f9a09e85 14 pc.printf("velocidad del motor: %i, %f rpm, CW=%d \n",smotor1.get_speed(), (60/((smotor1.get_speed()*4.096)/1000)),cw);
fabeltranm 0:2890f9a09e85 15
fabeltranm 0:2890f9a09e85 16 smotor1.step(4096,cw);
fabeltranm 0:2890f9a09e85 17
fabeltranm 0:2890f9a09e85 18 cw=~cw &(0x01);
fabeltranm 0:2890f9a09e85 19 speed=speed+200;
fabeltranm 0:2890f9a09e85 20 if (speed > 10000)speed =1500;
fabeltranm 0:2890f9a09e85 21 wait(1);
fabeltranm 0:2890f9a09e85 22 }
fabeltranm 0:2890f9a09e85 23 }