final nnnn

Dependencies:   mbed

Este proyecto es un Piccolo en el cual se envía comandos para la realización de un dibujo en especifico. El programa va a controlar servos y motores paso a paso teniendo libertad de movimiento en los ejes X,Y,Z; En el programa se utiliza Comunicacion Serial (TX,RX) y para leer el dato fue necesario concatenarlo debido a que recibe 8 Bits pero tenemos que recibir 4 paquetes de 8 Bits para llegar a 32 Bits y poder asi leerlo.

Se estan implementando algunas librerias para su ejecucion como la #include "memory.h" que es de memoria, #include memory_array_h, tambien definimos la memoria #define mm_size 10 de tipo Type Uint32_t, la libreria de operaciones #include "math.h" y la libreria para los motores #include "stepmotor.h".

Para su ejecucion se crearon variables de ejecucion:

CM_DRAWING 0XFF: Se ejecuta siempre y cuando exista datos validos para leer de memoria y nos muestra por medio de un mensaje que se esta ejecutando el dibujo

CM_SAVING 0XFE: Inicia el comando de guardar

CM_VERTEX2D 0XFD: Se encarga de dar las coordenadas a los servomotores en X,Y.

CM_DRAW 0XFC: Se encarga de mover nuestro motor en Z

CM_NODRAW 0XFB: Su funcion es volver a la posicion inicial el motor en el eje Z

CM_MOTOR 0XF9: Se encarga de mover los motores paso a paso para llegar a la ubicacion asignada ingresando el Numero de cuadrantes y su sentido de giro.

Committer:
ANTONIO_VARGAS
Date:
Thu Apr 26 01:48:40 2018 +0000
Revision:
2:14fcd29abee0
Parent:
0:0119b611fc51
explicacion programa piccolo

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ANTONIO_VARGAS 0:0119b611fc51 1 #include "mbed.h"
ANTONIO_VARGAS 0:0119b611fc51 2 #include "memory.h"
ANTONIO_VARGAS 0:0119b611fc51 3
ANTONIO_VARGAS 0:0119b611fc51 4 int mem_head = 0;
ANTONIO_VARGAS 0:0119b611fc51 5 int mem_tail = 0;
ANTONIO_VARGAS 0:0119b611fc51 6 uint8_t full = 0;
ANTONIO_VARGAS 0:0119b611fc51 7
ANTONIO_VARGAS 0:0119b611fc51 8 MEM_TYPE buffer[MEM_SIZE];
ANTONIO_VARGAS 0:0119b611fc51 9
ANTONIO_VARGAS 0:0119b611fc51 10 void tail_reset()
ANTONIO_VARGAS 0:0119b611fc51 11 {
ANTONIO_VARGAS 0:0119b611fc51 12 mem_tail=0;
ANTONIO_VARGAS 0:0119b611fc51 13 }
ANTONIO_VARGAS 0:0119b611fc51 14
ANTONIO_VARGAS 0:0119b611fc51 15 void mem_free()
ANTONIO_VARGAS 0:0119b611fc51 16 {
ANTONIO_VARGAS 0:0119b611fc51 17 mem_head=0;
ANTONIO_VARGAS 0:0119b611fc51 18 full=0;
ANTONIO_VARGAS 0:0119b611fc51 19 }
ANTONIO_VARGAS 0:0119b611fc51 20
ANTONIO_VARGAS 0:0119b611fc51 21
ANTONIO_VARGAS 0:0119b611fc51 22 uint8_t mem_put(MEM_TYPE data)
ANTONIO_VARGAS 0:0119b611fc51 23 {
ANTONIO_VARGAS 0:0119b611fc51 24
ANTONIO_VARGAS 0:0119b611fc51 25 if (full)
ANTONIO_VARGAS 0:0119b611fc51 26 return 1;
ANTONIO_VARGAS 0:0119b611fc51 27 buffer[mem_head] = data;
ANTONIO_VARGAS 0:0119b611fc51 28 mem_head += 1;
ANTONIO_VARGAS 0:0119b611fc51 29 if (mem_head == MEM_SIZE)
ANTONIO_VARGAS 0:0119b611fc51 30 full =1;
ANTONIO_VARGAS 0:0119b611fc51 31 return 0;
ANTONIO_VARGAS 0:0119b611fc51 32 }
ANTONIO_VARGAS 0:0119b611fc51 33
ANTONIO_VARGAS 0:0119b611fc51 34 uint8_t mem_get(MEM_TYPE* data)
ANTONIO_VARGAS 0:0119b611fc51 35 {
ANTONIO_VARGAS 0:0119b611fc51 36 if (mem_head == 0)
ANTONIO_VARGAS 0:0119b611fc51 37 return 1;
ANTONIO_VARGAS 0:0119b611fc51 38 if (mem_head == mem_tail)
ANTONIO_VARGAS 0:0119b611fc51 39 return 1;
ANTONIO_VARGAS 0:0119b611fc51 40
ANTONIO_VARGAS 0:0119b611fc51 41
ANTONIO_VARGAS 0:0119b611fc51 42 *data = buffer[mem_tail];
ANTONIO_VARGAS 0:0119b611fc51 43 mem_tail += 1;
ANTONIO_VARGAS 0:0119b611fc51 44
ANTONIO_VARGAS 0:0119b611fc51 45 return 0;
ANTONIO_VARGAS 0:0119b611fc51 46 }