Jose Eduardo Laruta Espejo / motoresDC

Dependents:   maple_motores maple_heading_pid maple_chotobot_rf_motores motores ... more

Committer:
tabris2015
Date:
Fri Jun 10 22:14:35 2016 +0000
Revision:
1:5715aefb07ca
Parent:
0:b1e9ffb92a0a
Child:
2:b5d41b0442a7
pines maple;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tabris2015 0:b1e9ffb92a0a 1 /** motoresDC class
tabris2015 0:b1e9ffb92a0a 2 * libreria para controlar un driver dual de motores DC
tabris2015 0:b1e9ffb92a0a 3 * funciona con drivers como el L293D o el L298N
tabris2015 0:b1e9ffb92a0a 4 * se necesitan 6 pines del microcontrolador
tabris2015 0:b1e9ffb92a0a 5 * uno para la velocidad (PWM) y 2 para el sentido (digital)
tabris2015 1:5715aefb07ca 6 * esta librería esta basada en la libreria RedBot de Sparkfun
tabris2015 0:b1e9ffb92a0a 7 */
tabris2015 0:b1e9ffb92a0a 8 #ifndef MBED_MOTORESDC_H
tabris2015 0:b1e9ffb92a0a 9 #define MBED_MOTORESDC_H
tabris2015 0:b1e9ffb92a0a 10
tabris2015 0:b1e9ffb92a0a 11 #include "mbed.h"
tabris2015 0:b1e9ffb92a0a 12
tabris2015 0:b1e9ffb92a0a 13 class MotoresDC
tabris2015 0:b1e9ffb92a0a 14 {
tabris2015 0:b1e9ffb92a0a 15 public:
tabris2015 0:b1e9ffb92a0a 16 /**inicia la clase con los pines del driver**/
tabris2015 0:b1e9ffb92a0a 17 MotoresDC(PinName MI_vel, PinName MI_s1, PinName MI_s2,
tabris2015 0:b1e9ffb92a0a 18 PinName MD_vel, PinName MD_s1, PinName MD_s2);
tabris2015 0:b1e9ffb92a0a 19 // metodos publicos //
tabris2015 0:b1e9ffb92a0a 20 /* funcion para conducir ambos motores en la misma direccion */
tabris2015 0:b1e9ffb92a0a 21 void conducir(float velocidad);
tabris2015 0:b1e9ffb92a0a 22 void conducir(float velocidad, int duracion);
tabris2015 0:b1e9ffb92a0a 23 /* funcion para conducir motores en sentido contrario */
tabris2015 0:b1e9ffb92a0a 24 void pivotar(float velocidad);
tabris2015 0:b1e9ffb92a0a 25 void pivotar(float velocidad, int duracion);
tabris2015 0:b1e9ffb92a0a 26
tabris2015 0:b1e9ffb92a0a 27 /* funciones para conducir motores independientemente */
tabris2015 0:b1e9ffb92a0a 28 void motorIzq(float velocidad);
tabris2015 0:b1e9ffb92a0a 29 void motorDer(float velocidad);
tabris2015 0:b1e9ffb92a0a 30 /* funciones para conducir motores independientemente con duracion */
tabris2015 0:b1e9ffb92a0a 31 void motorIzq(float velocidad, int duracion);
tabris2015 0:b1e9ffb92a0a 32 void motorDer(float velocidad, int duracion);
tabris2015 0:b1e9ffb92a0a 33 /* funciones para detener los motores */
tabris2015 0:b1e9ffb92a0a 34 void detener(void);
tabris2015 0:b1e9ffb92a0a 35 void frenar(void);
tabris2015 0:b1e9ffb92a0a 36
tabris2015 0:b1e9ffb92a0a 37 void detenerIzq(void);
tabris2015 0:b1e9ffb92a0a 38 void detenerDer(void);
tabris2015 0:b1e9ffb92a0a 39 void frenarIzq(void);
tabris2015 0:b1e9ffb92a0a 40 void frenarDer(void);
tabris2015 0:b1e9ffb92a0a 41 /* --------------- */
tabris2015 0:b1e9ffb92a0a 42 // metodos y atributos privados //
tabris2015 0:b1e9ffb92a0a 43 private:
tabris2015 0:b1e9ffb92a0a 44 /* velocidad izquierda */
tabris2015 0:b1e9ffb92a0a 45 PwmOut _MI_vel;
tabris2015 0:b1e9ffb92a0a 46 /* sentido de giro */
tabris2015 0:b1e9ffb92a0a 47 DigitalOut _MI_s1; // motor izq
tabris2015 0:b1e9ffb92a0a 48 DigitalOut _MI_s2;
tabris2015 0:b1e9ffb92a0a 49 /* velocidad derecha */
tabris2015 0:b1e9ffb92a0a 50 PwmOut _MD_vel;
tabris2015 0:b1e9ffb92a0a 51 /* sentido de giro */
tabris2015 0:b1e9ffb92a0a 52 DigitalOut _MD_s1;
tabris2015 0:b1e9ffb92a0a 53 DigitalOut _MD_s2;
tabris2015 0:b1e9ffb92a0a 54
tabris2015 0:b1e9ffb92a0a 55 /* funciones */
tabris2015 0:b1e9ffb92a0a 56 void _izqAdelante(float velocidad);
tabris2015 0:b1e9ffb92a0a 57 void _izqAtras(float velocidad);
tabris2015 0:b1e9ffb92a0a 58 void _derAdelante(float velocidad);
tabris2015 0:b1e9ffb92a0a 59 void _derAtras(float velocidad);
tabris2015 0:b1e9ffb92a0a 60
tabris2015 0:b1e9ffb92a0a 61 };
tabris2015 0:b1e9ffb92a0a 62 #endif