PICCOLO CNC

INTEGRANTES: CARLOS SOTELO

Es un robot constituido por tres ejes de rotación, que por medio de un puerto serial se envían datos de desplazamiento por coordenadas X,Y,Z dando valores a los grados de cada servomotor. transmitidos por cable serial, al puerto físico de entrada de la tarjeta F446RE, fabricado para realizar dibujos 2D y 3D a pequeña escala.

Estos aparatos emplean el CNC o 'control numérico por ordenador', un método que hace que grandes robots corten metales, plástico o manejan botes de pintura en las fábricas, como los que hemos visto cientos de veces en documentales y vídeos de Internet.

Así que tal vez es más fácil pensar en Piccolo simplemente como en un mini robot programable capaz de dibujar. Este pequeño y entrañable robotito es el trabajo de un equipo de varios ingenieros y programadores del Diatom Studio.

Entre las cosas que Piccolo puede hacer están dibujar con lápices, rotuladores y bolígrafos convencionales, trazar líneas y curvas en diseños en miniatura o combinarse con otros Piccolos para dibujar un mural. También tiene ciertas habilidades que le permiten dibujar con pinceles sobre objetos tridimensionales.

materiales:

3 Micro Servo SG90

8 Tornillos de cabeza plana M3 de 10 mm

3 Tornillos de cabeza plana M3 de 16 mm

2 Tornillos M3 de 10 mm

4 Tornillos M3 de 22 mm

17 Tuercas de bajo perfil M3

1 Llave hexagonal de 2.5 mm

1 Llave hexagonal de 2 mm

1 Cable USB microB

1 Tarjeta Nucleo STM32F446re

Piezas de MDF: entre 2,75 y 3,10 mm

Partes acrílicas: entre 2,90 y 3,20 mm

NUCLEO F446re:

/media/uploads/jeanmojica05/f8224049-01.jpg

servomotor: SG90

/media/uploads/jeanmojica05/htb1rak6nxxxxxxpxxxxq6xxfxxx9.jpg

CODIGO PROPUESTO :

  1. include "mbed.h"
  2. include "stepmotor.h"
  3. include "draw.h"
  4. define CM_EJECUTAR 0xff
  5. define CM_GUARDAR 0xfe
  6. define CM_VERTEX2D 0xfd
  7. define CM_DRAW 0xfc
  8. define CM_NODRAW 0xfb
  9. define CM_STOP 0xfa
  10. define CM_END 0xf0
  11. define CM_CUADRANTE 0xf9
  12. define MEM_SIZE 5000
  13. define MEM_TYPE uint32_t

int mem_head = 0; int mem_tail = 0; uint32_t full = 0;

MEM_TYPE buffer[MEM_SIZE]; Serial command(USBTX, USBRX); stepmotor smotor1(D9,D10,D11,D12);

void mem_free() { mem_head=0; mem_tail=0; full=0; }

void cuadrante() { uint32_t speed=1500; uint8_t cw; int mover; smotor1.set_speed(speed); if ( mover != 0 ) { if(cw == 1) {smotor1.step(1633*mover,cw);} if(cw == 0) {smotor1.step(1633*mover,cw);}

} }

uint32_t mem_put(MEM_TYPE data) { if (full) return 1; buffer[mem_head] = data; mem_head += 1; if (mem_head == MEM_SIZE) full =1; return 0; } uint32_t mem_get(MEM_TYPE* data) { if (mem_head == 0) return 1; if (mem_head == mem_tail) return 1;

  • data = buffer[mem_tail]; mem_tail += 1;

return 0; }

void ejecutar(){ command.printf("se esta ejecutando el dibujo..."); if(full==0){ command.printf("memoria vacia"); } else{ for(int i=1;i<=mem_tail;i++) { command.printf("%x\n",buffer[i]); } } ubicar acà el codigo } void guardar(){ uint32_t dato; uint8_t val; command.printf("_SE INICIA COMANDO GUARDAR... SELECCIONE: (fd- vertex2d) (fc- draw)(fb - nodraw)(fa - menu principal)(f9 - cuadrante)_ "); ubicar acà el codigo mem_free(); val = command.getc(); while( val != CM_STOP) {

switch (val){

case CM_CUADRANTE: dato=val<<8; command.printf("_SELECCIONE DIRECCION: 1- ADELANTE 0- ATRAS"); val=command.getc(); dato=(dato+val)<<8; mem_put(dato); command.printf("NUMERO DE CUADRANTES QUE SE DESEA MOVER"); val=command.getc(); dato=(dato+val)<<8; mem_put(dato); command.printf("CIERRE LINEA DE DATOS... "); val=command.getc(); dato=(dato+val); mem_put(dato);

break; case CM_VERTEX2D: dato=val<<8; command.printf("_SUMINISTRE POSICION 1... "); val=command.getc(); dato=(dato+val)<<8; mem_put(dato); command.printf("_SUMINISTRE POSICION 2... "); val=command.getc(); dato=(dato+val)<<8; mem_put(dato); command.printf("_CIERRE LINEA DE DATOS... "); val=command.getc(); dato=(dato+val); mem_put(dato);

break;

case CM_DRAW: dato=val<<8; val=command.getc(); dato=(dato+val); mem_put(dato); break;

case CM_NODRAW: dato=val<<8; val=command.getc(); dato=(dato+val); mem_put(dato); break;

default: command.printf("valor erroneo");break ; } command.printf("_SELECCIONE: (fd- vertex2d) (fc- draw)(fb - nodraw)(fa - menu principal)(f9 - cuadrante)"); val=command.getc(); mem_put(dato); } } void init_serial() { command.baud(9600); } void read_cc(){ command.printf("MENU PRINCIPAL (ff f0 - ejecutar) (fe f0 - guardar)_ "); char read_cc = command.getc(); char end = command.getc(); switch (read_cc) { case CM_EJECUTAR: ejecutar(); break; case CM_GUARDAR: guardar(); break; default: command.printf("error de comando");break ; } }

int main() { init_servo(); init_serial(); home(); while(1) { read_cc(); } }


Please log in to post comments.