![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
servo visual
Realizamos mediante comunicacion serial, ingresando el comando para los servomotores:
COMANDO MOVER MOTOR
POS 1 | POS 2 | POS 3 | POS 4 | POS 5 |
< | #M | , | #°G | > |
- M -> indica el motor que se va a mover (00,01,02)
- °G -> indica los grados a mover del servomotor <,> -> inicio, separdor y fin de comando el inicio de comando no se almacena en el buffer
si el comando no tiene correctamente ingresado los simbolos ',' y '>', nos dara un error.
comando para el paso a paso:
COMANDO MOVER PASO A PASO
POS 1 | POS 2 | POS 3 | POS 4 | POS 5 |
< | #M | DIR | #PASOS | > |
- M -> indica el motor que se va a mover ( 03)
- PASOS -> indica los pasos a mover del motor paso a paso DIR -> indica la direccion en la que girara el motor (00-derecha, 01- izquierda) < > ->inicio, separdor y fin de comando
el inicio de comando no se almacena en el buffer.
En la visualizacion de la matriz se observara el numero del motor que se esta moviendo y su direccion indicada con una flecha
<- hacia la izquierda cuando el angulo de los servos sea mayor que 90, y el sentido del paso a paso sea este. ^ hacia arriba cuando el angulo de los servos sea 90 -> hacia la derecha cuando el angulo de los servos sea menor que 90, y el sentido del paso a paso sea este.
1- servomotor uno (00) 2-servomotor dos (01) 3-servomotor tres (02) 4- paso a paso (03)
main.cpp@0:65caec68ab34, 2017-04-24 (annotated)
- Committer:
- Paxtel
- Date:
- Mon Apr 24 22:40:04 2017 +0000
- Revision:
- 0:65caec68ab34
- Child:
- 1:908a41a33553
proyect
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Paxtel | 0:65caec68ab34 | 1 | #include "mbed.h" |
Paxtel | 0:65caec68ab34 | 2 | #include "max7219.h" //libreria |
Paxtel | 0:65caec68ab34 | 3 | |
Paxtel | 0:65caec68ab34 | 4 | |
Paxtel | 0:65caec68ab34 | 5 | |
Paxtel | 0:65caec68ab34 | 6 | unsigned char arrowup[]= {0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55}; //secuencia 1 |
Paxtel | 0:65caec68ab34 | 7 | unsigned char arrowleft[]= {0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa}; //secuencia 2 |
Paxtel | 0:65caec68ab34 | 8 | unsigned char arrowright[]= {0x01,0x03,0x07,0x0f,0x1f,0x3f,0x7f,0xff}; //secuencia 3 |
Paxtel | 0:65caec68ab34 | 9 | unsigned char motor1[]= {0x01,0x03,0x07,0x0f,0x1f,0x3f,0x7f,0xff}; //secuencia 4 |
Paxtel | 0:65caec68ab34 | 10 | unsigned char motor2[]= {0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55}; //secuencia 5 |
Paxtel | 0:65caec68ab34 | 11 | unsigned char motor3[]= {0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa}; //secuencia 6 |
Paxtel | 0:65caec68ab34 | 12 | unsigned char motor4[]= {0x01,0x03,0x07,0x0f,0x1f,0x3f,0x7f,0xff}; //secuencia 7 |
Paxtel | 0:65caec68ab34 | 13 | |
Paxtel | 0:65caec68ab34 | 14 | void Print_pantalla_tabla(unsigned char *pValor); //variable global |
Paxtel | 0:65caec68ab34 | 15 | void print_punto();//variable global |
Paxtel | 0:65caec68ab34 | 16 | |
Paxtel | 0:65caec68ab34 | 17 | |
Paxtel | 0:65caec68ab34 | 18 | |
Paxtel | 0:65caec68ab34 | 19 | |
Paxtel | 0:65caec68ab34 | 20 | |
Paxtel | 0:65caec68ab34 | 21 | Max7219 pantalla(PB_15, PB_14, PB_13, PB_12); //pines |
Paxtel | 0:65caec68ab34 | 22 | |
Paxtel | 0:65caec68ab34 | 23 | int main() |
Paxtel | 0:65caec68ab34 | 24 | { |
Paxtel | 0:65caec68ab34 | 25 | max7219_configuration_t cfg = { |
Paxtel | 0:65caec68ab34 | 26 | .device_number = 1, |
Paxtel | 0:65caec68ab34 | 27 | .decode_mode = 0, //configuracion del max7219 |
Paxtel | 0:65caec68ab34 | 28 | .intensity = Max7219::MAX7219_INTENSITY_5, |
Paxtel | 0:65caec68ab34 | 29 | .scan_limit = Max7219::MAX7219_SCAN_8 |
Paxtel | 0:65caec68ab34 | 30 | }; |
Paxtel | 0:65caec68ab34 | 31 | |
Paxtel | 0:65caec68ab34 | 32 | pantalla.init_device(cfg); |
Paxtel | 0:65caec68ab34 | 33 | pantalla.enable_device(1); |
Paxtel | 0:65caec68ab34 | 34 | pantalla.set_display_test(); //testeo de la matriz |
Paxtel | 0:65caec68ab34 | 35 | wait(1); |
Paxtel | 0:65caec68ab34 | 36 | pantalla.clear_display_test(); |
Paxtel | 0:65caec68ab34 | 37 | |
Paxtel | 0:65caec68ab34 | 38 | while(1){ |
Paxtel | 0:65caec68ab34 | 39 | Print_pantalla_tabla(led1); |
Paxtel | 0:65caec68ab34 | 40 | wait(1); |
Paxtel | 0:65caec68ab34 | 41 | Print_pantalla_tabla(led2); |
Paxtel | 0:65caec68ab34 | 42 | wait(1); //ciclo de visualizaciòn |
Paxtel | 0:65caec68ab34 | 43 | Print_pantalla_tabla(led3); |
Paxtel | 0:65caec68ab34 | 44 | wait(1); |
Paxtel | 0:65caec68ab34 | 45 | print_punto(); |
Paxtel | 0:65caec68ab34 | 46 | } |
Paxtel | 0:65caec68ab34 | 47 | |
Paxtel | 0:65caec68ab34 | 48 | } |
Paxtel | 0:65caec68ab34 | 49 | |
Paxtel | 0:65caec68ab34 | 50 | |
Paxtel | 0:65caec68ab34 | 51 | void Print_pantalla_tabla(unsigned char *pValor) |
Paxtel | 0:65caec68ab34 | 52 | { |
Paxtel | 0:65caec68ab34 | 53 | int i; //funcion de puntero, impresión de pantalla |
Paxtel | 0:65caec68ab34 | 54 | for (i =0;i<8;i++) |
Paxtel | 0:65caec68ab34 | 55 | pantalla.write_digit(1,i+1,pValor[i]); |
Paxtel | 0:65caec68ab34 | 56 | |
Paxtel | 0:65caec68ab34 | 57 | } |
Paxtel | 0:65caec68ab34 | 58 | |
Paxtel | 0:65caec68ab34 | 59 | |
Paxtel | 0:65caec68ab34 | 60 | void print_punto() |
Paxtel | 0:65caec68ab34 | 61 | { |
Paxtel | 0:65caec68ab34 | 62 | unsigned char personal[8]= {0x0,0x0,0,0,0,0,0,0}; |
Paxtel | 0:65caec68ab34 | 63 | unsigned char filas[8]= {1,3,7,0x0f,0x1f,0x3f,0x7f,0xff}; |
Paxtel | 0:65caec68ab34 | 64 | int i,j; |
Paxtel | 0:65caec68ab34 | 65 | |
Paxtel | 0:65caec68ab34 | 66 | for (i=0;i<8;i++) // secuencia de puntos |
Paxtel | 0:65caec68ab34 | 67 | personal[i]= 0; |
Paxtel | 0:65caec68ab34 | 68 | for (j=0;j<8;j++) |
Paxtel | 0:65caec68ab34 | 69 | for (i=0;i<8;i++){ |
Paxtel | 0:65caec68ab34 | 70 | personal[i]= filas[j]; |
Paxtel | 0:65caec68ab34 | 71 | Print_pantalla_tabla(personal); |
Paxtel | 0:65caec68ab34 | 72 | wait(0.2); |
Paxtel | 0:65caec68ab34 | 73 | |
Paxtel | 0:65caec68ab34 | 74 | |
Paxtel | 0:65caec68ab34 | 75 | } |
Paxtel | 0:65caec68ab34 | 76 | } |
Paxtel | 0:65caec68ab34 | 77 | |
Paxtel | 0:65caec68ab34 | 78 | |
Paxtel | 0:65caec68ab34 | 79 |