Nicolás Camilo Guerrero Otálora
/
codigopicolo2
CODIGO PICOLO
/media/uploads/nicolas_guerrero/definimos_variables_globales.pdf
Revision 2:2e94085cdc90, committed 2018-05-30
- Comitter:
- nicolas_guerrero
- Date:
- Wed May 30 14:29:52 2018 +0000
- Parent:
- 1:629f060522ce
- Commit message:
- Programa Piccolo
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
stepmotor.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 629f060522ce -r 2e94085cdc90 main.cpp --- a/main.cpp Tue Apr 24 18:26:09 2018 +0000 +++ b/main.cpp Wed May 30 14:29:52 2018 +0000 @@ -134,7 +134,7 @@ motor_z.period_ms(periodo); motor_x.pulsewidth_us(750); motor_y.pulsewidth_us(750); - motor_z.pulsewidth_us(2000); + motor_z.pulsewidth_us(2650); char caracter; while(1) {
diff -r 629f060522ce -r 2e94085cdc90 stepmotor.cpp --- a/stepmotor.cpp Tue Apr 24 18:26:09 2018 +0000 +++ b/stepmotor.cpp Wed May 30 14:29:52 2018 +0000 @@ -11,23 +11,15 @@ #include "stepmotor.h" #include "mbed.h" - - - - - -stepmotor::stepmotor(PinName in1, PinName in2, PinName in3, PinName in4) : motor_out(in1,in2,in3,in4) { - - +stepmotor::stepmotor(PinName in1, PinName in2, PinName in3, PinName in4) : motor_out(in1,in2,in3,in4) +{ motor_out=0x0; nstep=0; motorSpeed=1100; } - - -void stepmotor::move() { - +void stepmotor::move() +{ switch(nstep) { case 0: motor_out = 0x1; break; // 0001 @@ -38,20 +30,17 @@ case 5: motor_out = 0xC; break; // 1100 case 6: motor_out = 0x8; break; // 1000 case 7: motor_out = 0x9; break; // 1001 - default: motor_out = 0x0; break; // 0000 } - wait_us(motorSpeed); - + wait_us(motorSpeed); } - -void stepmotor::set_speed(int speed){ +void stepmotor::set_speed(int speed) +{ motorSpeed=speed; //set motor speed us } uint32_t stepmotor::get_speed(){ return motorSpeed; // } - void stepmotor::step(uint32_t cuadrante, bool cw) { // funcion para mover el motor N pasos CW o CCW // num_steps número de paso que da el motor @@ -67,7 +56,5 @@ if (nstep<0) nstep=7; move(); count--; - } - } \ No newline at end of file