Blog cajón desastre (CBTis 44 / TecNM Teziutlán) https://github.com/maigke ( tiene muy poca aportación)
sábado, 21 de octubre de 2017
GHDL, UMHDL y Quartus en Fedora 25 y 26
jueves, 26 de diciembre de 2013
Compilando en GCC una funcion creada en XFuzzy en Manjaro Linux
En la imagen se muestra como esta implementado un sistema difuso y su monitorización.
Para generar un fuente a partir del sistema, dar clic en Synthesis -> To C, ahora elige la carpeta donde se van a almacenar los archivos generados que tendrán el mismo nombre del sistema, por ejemplo, para este caso el sistema se denomina example.xfl y los archivos generados se llaman example.c y example.h
Dentro del archivo example.h se encuentra la función que se puede llamar desde lenguaje , esta funcion incluye el nombre del sistema difuso diseñado en XFuzzy seguido de las palabras "Inference Engine", en este caso:
Esta función tiene igual número de parámetros que entradas y salidas tiene el sistema
El código fuente se muestra en la imagen anterior, revise que la salida del sistema se almacena en la variable sal, la cual inicialmente se le asigna un valor de 0.0 por ser una variable de tipo double. notese que se usa paso por referencia.
Para compilar el programa (http://stackoverflow.com/questions/8999975/strange-behaviour-of-gcc-and-math-h) se usan algunos parámetros como son Wall y lm pque sirven para imprimir todas las advertencias que se generan (-Wall) durante la compilación del programa y -lm para el uso de la libreria math.h
En la imagen se aprecian las líneas para compilar el programa mostrado y la forma en que se ejecuta, es importante el orden de los archivos a compilar.
Para este caso se podrá notar la salida del sistema cuando las variables val1=val2 = 50.0 y val3 = 0.4 da el compilador de C un resultado de salida de 0.15 y en la imagen siguiente se muestra la salida del sistema difuso definido en XFuzzy cuando las entradas son 50.0, 50.0, 0.4
Esta portabilidad hace interesante a la herramienta, ya que es posible en cierta medida, colocar este código generado en un sistema embebido como lo es un microcontrolador.
hasta el momento les puedo comentar que en avr-gcc funciona muy bien pero con Pinguino PIC no se puede compilar a causa de que SDCC no permite el paso de estructuras como argumentos de funciones. Esto tambien lo probé al tratar de compilar en SDCC puro con el IDE PIKLAB
A fin de confirmarles el uso de la libreria generada por Xfuzzy en AVR-GCC se usa como IDE el code-blocks en su versión 12.11
y programando un ATmega32u4 (vea los siguientes links http://iemontiel.blogspot.mx/2013/05/mexican-arduino-usb-en-fedora-18.html y http://iemontiel.blogspot.mx/2013/12/teensyduino-en-manjaro.html) con cristal de 16MHz integrado en la tarjeta, es posible su compilación y el empleo de EASYDFU (como supervaca) para enviar la información al microcontrolador.
Vea que es interesante el hecho de que solamente se ocupó el 17.30% del total de la memoria del microcontrolador en cuestión.
domingo, 15 de diciembre de 2013
Configurar Codeblocks en Manjaro para programar AVR
La primera parte es muy sencilla ya que solo hay que seguir un asistente, el problema es que cuando se pretende compilar el nuevo codigo, envia un error
/usr/lib/libm.so: file not recognized: File format not recognized
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings
Esto es a causa de que el IDE no está correctamente configurado para funcionar con el AVR GCC, por lo tanto solo hay que redireccionarlo, tal y como se indica en esta entrada de AVR Freaks
http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=99954&view=next
De acuerdo a lo que ahi se indica debemos ir al menu settings, luego al menu Compiler..
Seleccionar el compilador "GNU AVR GCC Compiler"
Ir a la pestaña "Search directories" y en la sub-pestaña "Linker"
cambia la ruta por
/usr/lib/avr/lib/
que actualmente dice /usr/lib
ahora ir a la sub-pestaña "Compiler" y editar la entrada para que diga lo siguiente:
/usr/lib/avr/include/avr
Entonces, ahora si al compilar tendremos el siguiente resultado :)
martes, 8 de enero de 2013
Participación en WEEF2012
Libro de Abstracts: http://www.weef2012.edu.ar/archivos/papers/WEEF2012.pdf
Tuve a bien participar en el World Engineering Education Forum (WEFF) 2012 “Educación de ingeniería para el desarrollo sostenible y la inclusión social”, con la publicación del trabajo “Kit de prácticas OSH para la programación básica del microcontrolador PIC18F2550 con SDCC y PIKLAB en GNU/Linux” en Co-autoría con la M.S.C. Mariana Lobato Baéz y el M.C. Jorge Rivera Flores, en el cual se propone el uso de las herramientas libres para la enseñanza de microcontroladores.
Agradezco los comentarios de los revisiones, quienes comentaron:
"En este trabajo se recupera el valor de la “guía didáctica”. Los autores la proponen como material didáctico integrado a la realización de prácticas experimentales con elementos físicos (circuito pre-ensamblado o Kit de prueba) y a la aplicación del concepto de Open Source Hardware en un curso de Microcontroladores. Como resultado los autores exponen que esta estrategia integradora aparece cómo más favorable que el empleo de clases y simulación para el desarrollo de competencias específicas.
Esta experiencia concreta puede resultar de interés para los docentes en carreras de ingeniería ya que estaría mostrando que la simulación por sí sola no garantiza el aprendizaje de ciertas habilidades. Resalta la aplicación de Software Libre y sus beneficios en caso de no disponer de los recursos económicos necesarios para adquirir un software comercial."
Del mismo modo, agradezco el apoyo del Instituto Tecnológico Superior de Teziutlán, que es donde actualmente laboro.
miércoles, 21 de diciembre de 2011
Tercer Rally Mecatrónico -- Sumobots
miércoles, 14 de diciembre de 2011
Tercer Rally Mecatrónico -- Mecanismos Móviles
PIC18F2250 y timer 1 una propuesta para configurarlo.
http://www.itsteziutlan.edu.mx/index.php?option=com_content&view=article&id=715:propuesta-para-la-programacion-basica-del-temporizador-1-del-microcontrolador-pic18f2550-con-el-compilador-sdcc&catid=27:artlos&Itemid=288
http://www.itsteziutlan.edu.mx/index.php?option=com_content&view=article&id=714:propuesta-para-la-configuracion-basica-del-temporizador-1-del-microcontrolador-pic18f2550&catid=27:artlos&Itemid=288
lunes, 31 de enero de 2011
Algo que escribí
Echenle un ojito y espero sus comentarios
LINK
http://www.itsteziutlan.edu.mx/index.php?option=com_content&view=article&id=597:herramientas-libres-para-la-programacion-de-microcontroladores-pic&catid=27:artlos&Itemid=288
domingo, 14 de marzo de 2010
Lecturas para Fisica 2 Ing Industrial
http://www.filefactory.com/file/b0a6088/n/lecturas.zip
El video de abajo te muestra como descargar este archivo y el mismo procedimiento es para las descargas de los avances programáticos.
bajarInformacionBlog
Cargado por maigke. - Descubre más videos de ciencia y hi tech.
miércoles, 27 de enero de 2010
Dosificación de Materias
Matemáticas Discretas
Análisis de Circuitos Eléctricos
Gracias!
Avances Programaticos TEC2010A
********************************************************************************************
Buen día, después de no tener mis datos, por fin pondre unos links para que descarguen los avances programaticos, las fecha tentativas para practicas, los criterios de evaluación y las fechas para examenes extra ordinarios, saludos a todos
Analisis de Circuitos Electricos A Alternativo
Analisis de Circuitos Eléctricos Alternativo -- B
Nuevos Links
Matemáticas Discretas B
Matemáticas Discretas A
Física 2 Semiescolarizado
Electricidad y Electrónica Industrial Semiescolarizado
sábado, 12 de diciembre de 2009
Semana Académica 2009 invierno Mecatronica
Esta vez me toco ser jurado y no me fue posible tomar tantas fotos como hubiese querido, pero aqui están algunas
AFASA
MEMCD
lunes, 26 de octubre de 2009
Mas de Tlacotli
Hola de nuevo, pues el dia de hoy estuve trabajando con el Tlacotli un rato, aunque solo un poco, estuve buscando la forma de como interactuán las fuerzas en los engranajes del codo, que son los que por el momento me están dando problemas.
sábado, 17 de octubre de 2009
stands-Quehacer Académico 2007
domingo, 20 de septiembre de 2009
Tlacotli aun mas pruebas
Tlacotli primeras pruebas
Pruebas con GAMBAS y el Puerto Serie desde SSH
La respuesta del micro que esta conectado al puerto serial, responde al caracter enviado colocando en el textArea correspondiente S_1 + o S_1 - segun sea el caso de avance o retroceso en la posicion del servomotor, pero bueno ahora colocaremos el video y algunas notas que postee en el Foro de PIC Linux
Bueno aqui estan ya las correcciones
http://www.filefactory.com/file/a0a2a6h/n/mmm-testserial_0_0_5_orig_tar_gz
y bueno un video de como funciona ya este programa
Para grabar el escritorio use gtk-RecordMyDesktop y para los acercamientos use un efecto de Compiz Fusion
para convertir los videos a .AVI que genera el gtk-RecordMyDesktop use la consola con el mencoder, muy bueno, muy rápido y sencillo, el comando usado fue
mike@mike:~$ mencoder testRS232viaSSh.ogv -o testRS232viaSSh.avi -oac mp3lame -ovc lavc
Saludos!!
sábado, 12 de septiembre de 2009
Pruebas casi finales, aun falta ensamblar!!
El código, se ha quedado como se muestra, solo que hemos hecho un pequeño trucaje al servo que mostre en fotos anteriores, puesto que se transporto el potenciometro del servo que lleva interno, a una parte externa, de estar forma se hizo, debido a que el mecanismo de gusano sinfin + corona, exigia dos cosas:
- El servo pudiera dar vueltas completas y varías, debido a la relacion que hay entre los engranajes
- El posicionamiento del eje deberia ser exacto, con respecto a la horizontal que forma con la base.
Lamentablemente, la corona que va con el gusano sin fin, al estar hecha de aluminio, y soportar una gran fuerza, pues, los dientes sufrieron los estragos, desgastandose, me comenta, Ruben, que sería mejor que dichos engranes fueran hechos de bronce, espero que consigamos una pieza pronto
El codigo fuente, hasta el momento, es el que presente en post anteriores, y el programa lo deje trabajando un buen de horas solo conectado con la tarjeta de control de servomotores y funciona de forma muy adecuada, detalles aun hay muchos, sin embargo, prodria decir, ¡Ya casí esta listo!
Falta el video donde se ve como se mueve el servo con el slider del GUI desarrollado, en este momento esta de subida.
Codigo Fuente para control de servos por RS232 Gambas
Re: GAMBAS Almenos es basic- Puerto Serie - PIC16F628A
maigke el Lun 7 Sep 2009 - 19:39
- Código:
' Gambas class file
'Variables Globales
PUBLIC flag1 AS Boolean = FALSE
PUBLIC flag2 AS Boolean = FALSE
PUBLIC fTermine AS Boolean = FALSE ' bandera para indicar que ya acabo de mover un servo
'Variables para posicionamiento
PUBLIC S1Pos1 AS Integer PUBLIC S2Pos1 AS Integer PUBLIC S3Pos1 AS Integer PUBLIC S4Pos1 AS Integer
PUBLIC S5Pos1 AS Integer
PUBLIC S1Pos2 AS Integer PUBLIC S2Pos2 AS Integer PUBLIC S3Pos2 AS Integer PUBLIC S4Pos2 AS Integer
PUBLIC S5Pos2 AS Integer
'Variables para HOME
PUBLIC s1 AS Integer PUBLIC s2 AS Integer PUBLIC s3 AS Integer PUBLIC s4 AS Integer PUBLIC s5 AS Integer
PUBLIC vini1 AS Integer PUBLIC vfin1 AS Integer PUBLIC vini2 AS Integer PUBLIC vfin2 AS Integer PUBLIC vini3 AS Integer
PUBLIC vfin3 AS Integer PUBLIC vini4 AS Integer PUBLIC vfin4 AS Integer PUBLIC vini5 AS Integer PUBLIC vfin5 AS Integer
PUBLIC tempo AS Integer
PUBLIC SUB Form_Close()
IF ttyUSB.Status = Net.Active THEN CLOSE ttyUSB
END
'***************************Seccion para la comunicacion del puerto serial
'Esta parte es bastante modificable
PUBLIC SUB Check_Status()
ChkDSR.Value = ttyUSB.DSR
ChkDTR.Value = ttyUSB.DTR
ChkCTS.Value = ttyUSB.CTS
ChkRTS.Value = ttyUSB.RTS
ChkDCD.Value = ttyUSB.DCD
ChkRNG.Value = ttyUSB.RNG
END
PUBLIC SUB Form_Open()
cmdVelocidad.Index = cmdVelocidad.Find("115200") 'Lo que sigue no es valido separa las lineas indicadas por ';'
vini1 = 0; vfin1 = 0; vini2 = 0; vfin2 = 0; vini3 = 0; vfin3 = 0; vini4 = 0; vfin4 = 0; vini5 = 0; vfin5 = 0; sldS1.Value = 250
sldS2.Value = 250; sldS3.Value = 250; sldS4.Value = 250; sldS5.Value = 250
END
PUBLIC SUB Button1_Click()
ME.Close
END
PUBLIC SUB cmdAbreCierra_Click()
IF ttyUSB.Status = Net.Active THEN
CLOSE ttyUSB
cmdAbreCierra.Text = "Abre"
ELSE
'Linea de parametros
ttyUSB.PortName = txtPortText.Text
ttyUSB.Speed = cmdVelocidad.Text
ttyUSB.Parity = cmbParidad.Index
ttyUSB.DataBits = cmbDataBits.Text
ttyUSB.FlowControl = cmbControlFlujo.Index
ttyUSB.StopBits = cmbBitParo.Text
ttyUSB.Open()
Check_Status()
TextArea1.Text = "Puerto Abierto : " & ttyUSB.PortName & " Ajustes : " &
ttyUSB.Speed & " , " & ttyUSB.Parity & " , " & ttyUSB.DataBits & " , " &
ttyUSB.StopBits & " , " & Chr(13) & Chr(10)
cmdAbreCierra.Text = "Cierra"
ENDIF
END
'Funcion para leer puerto serial RS232
PUBLIC SUB ttyUSB_Read()
DIM s AS String
IF TabStrip1.Text = "Configuracion" THEN
READ #ttyUSB, s, Lof(ttyUSB)
TextArea1.Text = TextArea1.Text & s
ELSE IF TabStrip1.Text = "Servo 1" THEN
READ #ttyUSB, s, Lof(ttyUSB)
TextArea2.Text = TextArea2.Text & s
ELSE IF TabStrip1.text = "Servo 2" THEN
READ #ttyUSB, s, Lof(ttyUSB)
TextArea3.Text = TextArea3.Text & s
ELSE IF TabStrip1.Text = "Servo 3" THEN
READ #ttyUSB, s, Lof(ttyUSB)
TextArea4.Text = TextArea4.text & s
ELSE IF TabStrip1.Text = "Servo 4" THEN
READ #ttyusb, s, Lof(ttyUSB)
TextArea5.Text = TextArea5.text & s
ELSE IF TabStrip1.Text = "Servo 5" THEN
READ #ttyUSB, s, Lof(ttyUSB)
TextArea6.Text = TextArea6.Text & s
ENDIF
END
PUBLIC SUB ttyUSB_RNGChange(ival AS Boolean)
ChkRNG.Value = ival
END
PUBLIC SUB ttyUSB_DTRChange(ival AS Boolean)
ChkDTR.Value = ival
END
PUBLIC SUB ttyUSB_DSRChange(ival AS Boolean)
ChkDSR.Value = ival
END
PUBLIC SUB ttyUSB_CTSChange(ival AS Boolean)
ChkCTS.Value = ival
END
PUBLIC SUB ttyUSB_DCDChange(ival AS Boolean)
ChkDCD.Value = ival
END
PUBLIC SUB ttyUSB_RTSChange(ival AS Boolean)
ChkRTS.Value = ival
END
PUBLIC SUB ChkDTR_Click()
ttyUSB.DTR = ChkDTR.Value
Check_Status
END
PUBLIC SUB ChkRTS_Click()
ttyUSB.RTS = ChkRTS.Value
Check_Status
END
PUBLIC SUB cmbControlFlujo_Click()
ttyUSB.FlowControl = cmbControlFlujo.Index
END- Esta parte es la que envia los datos a los
seisservos upps, ¿de cuál fumé? si son solo 5 - Código:
'************************************************************************************************
PUBLIC SUB cmdAtras_Click()
IF ttyUSB.Status = Net.Inactive THEN
Message("Primero abre el Puerto")
ELSE
PRINT #ttyUSB, "a"
ToolButton2.Background = &FF0000&
ToolButton2.Text = "A"
WAIT 0.3 'Este retardo es para el parpadeo, entre colores, pero no tiene mucho caso
ToolButton2.BackColor = &00FF00&
ToolButton2.Text = ""
ENDIF
END
PUBLIC SUB cmdAdelante_Click()
IF ttyUSB.Status = Net.Inactive THEN
Message("Primero abre el puerto")
ELSE
PRINT #ttyUSB, "11"
ToolButton1.Background = &FF0000&
ToolButton1.Text = "1"
WAIT 0.3
ToolButton1.Background = &00FF00&
ToolButton1.text = ""
ENDIF
END
'**************************************************************************
'Control del primer servo
'Para el envio de datos, fue probada la tarjeta con varios valores
'en el tiempo medido por osciloscopio, cuando la tarjeta es reiniciada
'con escala de 0.5ms por division, el tiempo en alto esta establecido a 1500ms
'tomado este valor como referencia, el slider y el spinbox, tienen el valor de
'250 de forma inicial, ya fueron medidos los tiempos de forma repetida, para
'verificar la presición del numero de datos enviados a la tarjeta.
PUBLIC SUB spnboxS1_Change()
DIM maximo AS Integer
DIM i AS Integer
sldS1.Value = spnboxS1.Value
vfin1 = spnboxS1.Value
tempo = 0
tempo = Abs(vfin1 - vini1)
'TextArea2.Text = "Vini1=" & vini1 & " Vfin1= " & vfin1 & " ciclo= " & tempo
'wait 1
IF (vfin1 - vini1) < 0 THEN
IF ttyUSB.Status = Net.Active THEN
maximo = tempo
FOR i = 1 TO maximo
PRINT #ttyUSB, "AAA"
ToolButton2.Background = &FF0000&
ToolButton2.Text = "A"
WAIT 0.1 'Este retardo es importante, ya que la tarjeta no responde muy rápido
ToolButton2.BackColor = &00FF00&
ToolButton2.Text = ""
NEXT
maximo = 0
ELSE
ENDIF
ELSE
IF ttyUSB.Status = Net.Active THEN
maximo = tempo
FOR i = 1 TO maximo
PRINT #ttyUSB, "111"
ToolButton1.Background = &FF0000&
ToolButton1.Text = "1"
WAIT 0.1
ToolButton1.Background = &00FF00&
ToolButton1.text = ""
NEXT
maximo = 0
ELSE
ENDIF
ENDIF
vini1 = vfin1
tempo = 0
fTermine = TRUE
END
'**********************************************************************************
PUBLIC SUB sldS1_Change()
DIM maximo AS Integer
DIM i AS Integer
spnboxS1.Value = sldS1.Value
vfin1 = spnboxS1.Value
tempo = 0
tempo = Abs(vfin1 - vini1)
'TextArea2.Text = "Vini1=" & vini1 & " Vfin1= " & vfin1 & " ciclo= " & tempo
'WAIT 1
IF (vfin1 - vini1) < 0 THEN
IF ttyUSB.Status = Net.Active THEN
maximo = tempo
FOR i = 1 TO maximo
PRINT #ttyUSB, "A"
ToolButton2.Background = &FF0000&
ToolButton2.Text = "A"
WAIT 0.1
ToolButton2.BackColor = &00FF00&
ToolButton2.Text = ""
NEXT
maximo = 0
ELSE
ENDIF
ELSE
IF ttyUSB.Status = Net.Active THEN
maximo = tempo
FOR i = 1 TO maximo
PRINT #ttyUSB, "1"
ToolButton1.Background = &FF0000&
ToolButton1.Text = "1"
WAIT 0.1
ToolButton1.Background = &00FF00&
ToolButton1.text = ""
NEXT
maximo = 0
ELSE
ENDIF
ENDIF
vini1 = vfin1
tempo = 0
fTermine = TRUE
END
'***********************************************************************************
'Control del segundo servo
PUBLIC SUB spnboxS2_Change()
DIM maximo AS Integer
DIM i AS Integer
sldS2.Value = spnboxS2.Value
vfin2 = spnboxS2.Value
tempo = 0
tempo = Abs(vfin2 - vini2)
'Usese solo en caso de que olvide el cable de comicacion como a mi me paso :(
'TextArea3.Text = "Vini2=" & vini2 & " Vfin2= " & vfin2 & " ciclo= " & tempo
' WAIT 1
IF (vfin2 - vini2) < 0 THEN
IF ttyUSB.Status = Net.Active THEN
maximo = tempo
FOR i = 1 TO maximo
PRINT #ttyUSB, "B"
ToolButton3.Background = &FF0000&
ToolButton3.Text = "B"
WAIT 0.1 'Este retardo es importante, ya que la tarjeta no responde muy rápido
ToolButton4.BackColor = &00FF00&
ToolButton4.Text = ""
NEXT
maximo = 0
ELSE
ENDIF
ELSE
IF ttyUSB.Status = Net.Active THEN
maximo = tempo
FOR i = 1 TO maximo
PRINT #ttyUSB, "2"
ToolButton1.Background = &FF0000&
ToolButton1.Text = "2"
WAIT 0.1
ToolButton1.Background = &00FF00&
ToolButton1.text = ""
NEXT
maximo = 0
ELSE
ENDIF
ENDIF
vini2 = vfin2
tempo = 0
END
'**********************************************************************************
PUBLIC SUB sldS2_Change()
DIM maximo AS Integer
DIM i AS Integer
spnboxS2.Value = sldS2.Value
vfin2 = spnboxS2.Value
tempo = 0
tempo = Abs(vfin2 - vini2)
IF (vfin2 - vini2) < 0 THEN
IF ttyUSB.Status = Net.Active THEN
maximo = tempo
FOR i = 1 TO maximo
PRINT #ttyUSB, "B"
ToolButton2.Background = &FF0000&
ToolButton2.Text = "B"
WAIT 0.1
ToolButton2.BackColor = &00FF00&
ToolButton2.Text = ""
NEXT
maximo = 0
ELSE
ENDIF
ELSE
IF ttyUSB.Status = Net.Active THEN
maximo = tempo
FOR i = 1 TO maximo
PRINT #ttyUSB, "1"
ToolButton2.Background = &FF0000&
ToolButton2.Text = "1"
WAIT 0.1
ToolButton2.Background = &00FF00&
ToolButton2.text = ""
NEXT
maximo = 0
ELSE
ENDIF
ENDIF
vini2 = vfin2
tempo = 0
fTermine = TRUE
END
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
'Control del tercer servo
PUBLIC SUB spnboxS3_Change()
DIM maximo AS Integer
DIM i AS Integer
sldS3.value = spnboxS3.Value
vfin3 = spnboxS3.Value
tempo = 0
tempo = Abs(vfin3 - vini3)
IF (vfin3 - vini3) < 0 THEN
IF ttyUSB.Status = Net.Active THEN
maximo = tempo
FOR i = 1 TO maximo
PRINT #ttyUSB, "C"
ToolButton5.BackColor = &FF0000&
ToolButton5.Text = "C"
WAIT 0.1
ToolButton5.BackColor = &00FF00&
ToolButton5.Text = ""
NEXT
maximo = 0
ELSE
END IF
ELSE
IF ttyUSB.Status = Net.Active THEN
maximo = tempo
FOR i = 1 TO maximo
PRINT #ttyUSB, "3"
ToolButton6.BackColor = &FF0000&
ToolButton6.Text = "3"
WAIT 0.1
ToolButton6.BackColor = &00FF00&
ToolButton6.Text = ""
NEXT
maximo = 0
ENDIF
END IF
vini3 = vfin3
tempo = 0
fTermine = TRUE
END
PUBLIC SUB sldS3_Change()
DIM maximo AS Integer
DIM i AS Integer
spnboxS3.value = sldS3.Value
vfin3 = sldS3.Value
tempo = 0
tempo = Abs(vfin3 - vini3)
IF (vfin3 - vini3) < 0 THEN
IF ttyUSB.Status = Net.Active THEN
maximo = tempo
FOR i = 1 TO maximo
PRINT #ttyUSB, "C"
ToolButton5.BackColor = &FF0000&
ToolButton5.Text = "C"
WAIT 0.1
ToolButton5.BackColor = &00FF00&
ToolButton5.Text = ""
NEXT
maximo = 0
ELSE
END IF
ELSE
IF ttyUSB.Status = Net.Active THEN
maximo = tempo
FOR i = 1 TO maximo
PRINT #ttyUSB, "3"
ToolButton6.BackColor = &FF0000&
ToolButton6.Text = "3"
WAIT 0.1
ToolButton6.BackColor = &00FF00&
ToolButton6.Text = ""
NEXT
maximo = 0
ENDIF
END IF
vini3 = vfin3
tempo = 0
fTermine = TRUE
END
'***********************************************************************************************************
'Control del 4to servo
PUBLIC SUB spnboxS4_Change()
DIM maximo AS Integer
DIM i AS Integer
sldS4.value = spnboxS4.Value
vfin4 = spnboxS4.Value
tempo = 0
tempo = Abs(vfin4 - vini4)
IF (vfin4 - vini4) < 0 THEN
IF ttyUSB.Status = Net.Active THEN
maximo = tempo
FOR i = 1 TO maximo
PRINT #ttyUSB, "D"
ToolButton7.BackColor = &FF0000&
ToolButton7.Text = "D"
WAIT 0.1
ToolButton7.BackColor = &00FF00&
ToolButton7.Text = ""
NEXT
maximo = 0
ELSE
END IF
ELSE
IF ttyUSB.Status = Net.Active THEN
maximo = tempo
FOR i = 1 TO maximo
PRINT #ttyUSB, "4"
ToolButton8.BackColor = &FF0000&
ToolButton8.Text = "4"
WAIT 0.1
ToolButton8.BackColor = &00FF00&
ToolButton8.Text = ""
NEXT
maximo = 0
ENDIF
END IF
vini4 = vfin4
tempo = 0
fTermine = TRUE
END
PUBLIC SUB sldS4_Change()
DIM maximo AS Integer
DIM i AS Integer
spnboxS4.value = sldS4.Value
vfin4 = sldS4.Value
tempo = 0
tempo = Abs(vfin4 - vini4)
IF (vfin4 - vini4) < 0 THEN
IF ttyUSB.Status = Net.Active THEN
maximo = tempo
FOR i = 1 TO maximo
PRINT #ttyUSB, "D"
ToolButton7.BackColor = &FF0000&
ToolButton7.Text = "D"
WAIT 0.1
ToolButton7.BackColor = &00FF00&
ToolButton7.Text = ""
NEXT
maximo = 0
ELSE
END IF
ELSE
IF ttyUSB.Status = Net.Active THEN
maximo = tempo
FOR i = 1 TO maximo
PRINT #ttyUSB, "4"
ToolButton8.BackColor = &FF0000&
ToolButton8.Text = "4"
WAIT 0.1
ToolButton8.BackColor = &00FF00&
ToolButton8.Text = ""
NEXT
maximo = 0
ENDIF
END IF
vini4 = vfin4
tempo = 0
fTermine = TRUE
END
'***********************************************************************************************************
'control Servo 5
PUBLIC SUB spnboxS5_Change()
DIM maximo AS Integer
DIM i AS Integer
sldS5.value = spnboxS5.Value
vfin5 = spnboxS5.Value
tempo = 0
tempo = Abs(vfin5 - vini5)
IF (vfin5 - vini5) < 0 THEN
IF ttyUSB.Status = Net.Active THEN
maximo = tempo
FOR i = 1 TO maximo
PRINT #ttyUSB, "E"
ToolButton9.BackColor = &FF0000&
ToolButton9.Text = "E"
WAIT 0.1
ToolButton9.BackColor = &00FF00&
ToolButton9.Text = ""
NEXT
maximo = 0
ELSE
END IF
ELSE
IF ttyUSB.Status = Net.Active THEN
maximo = tempo
FOR i = 1 TO maximo
PRINT #ttyUSB, "5"
ToolButton10.BackColor = &FF0000&
ToolButton10.Text = "5"
WAIT 0.1
ToolButton10.BackColor = &00FF00&
ToolButton10.Text = ""
NEXT
maximo = 0
ENDIF
END IF
vini5 = vfin5
tempo = 0
fTermine = TRUE
END
PUBLIC SUB sldS5_Change()
DIM maximo AS Integer
DIM i AS Integer
spnboxS5.value = sldS5.Value
vfin5 = sldS5.Value
tempo = 0
tempo = Abs(vfin5 - vini5)
IF (vfin5 - vini5) < 0 THEN
IF ttyUSB.Status = Net.Active THEN
maximo = tempo
FOR i = 1 TO maximo
PRINT #ttyUSB, "E"
ToolButton9.BackColor = &FF0000&
ToolButton9.Text = "E"
WAIT 0.1
ToolButton9.BackColor = &00FF00&
ToolButton9.Text = ""
NEXT
maximo = 0
ELSE
END IF
ELSE
IF ttyUSB.Status = Net.Active THEN
maximo = tempo
FOR i = 1 TO maximo
PRINT #ttyUSB, "5"
ToolButton10.BackColor = &FF0000&
ToolButton10.Text = "5"
WAIT 0.1
ToolButton10.BackColor = &00FF00&
ToolButton10.Text = ""
NEXT
maximo = 0
ENDIF
END IF
vini5 = vfin5
tempo = 0
fTermine = TRUE
END
'***********************************************************************************************************- La última parte del código borra los textareas y manda a posicionar al servo, aqui hay una parte importante con un ciclo while - wend, y tiene mucho que ver la bandera que puse en cada seccion de movimiento de servos, ya que sin esta bandera no se saldría de dicho ciclo.
- Código:
'Area de borrados de textAreas, cada text area solo contendra la info necesaria para su propio servo
PUBLIC SUB cmdBorrar_Click()
TextArea2.Text = ""
END
PUBLIC SUB Button2_Click()
TextArea3.Text = ""
END
PUBLIC SUB Button3_Click()
TextArea4.Text = ""
END
PUBLIC SUB Button4_Click()
TextArea5.Text = ""
END
PUBLIC SUB Button5_Click()
TextArea6.Text = ""
END
'Rutina de grabar las posiciones de los servos
PUBLIC SUB cmdGrabar_Click()
IF flag1 = FALSE AND flag2 = FALSE THEN
cmdGrabar.Text = "Grabar"
S1Pos1 = spnboxS1.Value
S2Pos1 = spnboxS2.Value
S3Pos1 = spnboxS3.Value
S4Pos1 = spnboxS4.Value
S5Pos1 = spnboxS5.Value
flag1 = TRUE
ELSE IF flag1 = TRUE AND flag2 = FALSE THEN
S1Pos2 = spnboxS1.Value
S2Pos2 = spnboxS2.Value
S3Pos2 = spnboxS3.Value
S4Pos2 = spnboxS4.Value
S5Pos2 = spnboxS5.Value
flag2 = TRUE
ELSE
Message.Error("Solo dos posiciones")
cmdGrabar.Text = "Borra"
S1Pos1 = 0
S1Pos2 = 0
S2Pos1 = 0
S2Pos2 = 0
S3Pos1 = 0
S3Pos2 = 0
S4Pos1 = 0
S4Pos2 = 0
S5Pos1 = 0
S5Pos2 = 0
flag1 = FALSE
flag2 = FALSE
END IF
END
PUBLIC SUB cmdHome_Click()
s1 = spnboxS1.Value
s2 = spnboxS2.Value
s3 = spnboxS3.Value
s4 = spnboxS4.Value
s5 = spnboxS5.Value
TextArea1.text = "Home ha sido selecionado con las siguientes
posiciones " & s1 & " " & s2 & " " & s3 & " "
& s4 & " " & s5
'TabStrip1.Action =
END
PUBLIC SUB ToolButton11_Click()
'Ir a home
'Colocamos una bandera que se llama fTermine que nos indica si un ciclo de envio de datos ya termino
' ahora preguntamos si los valores del spinbox y del valor dado como home son iguales
' esto pasa si un eje no lo mueves desde un inicio, en caso de ser cierto, pues entonces
' no hace nada, ya que si no se pone el if por alguna razon entra en un bucle infinito
' si los valores actuales del spinbox y de la pos de home no son iguales,
' mandamos a modificar ahora el valor del spinbox, enviando los correspondientes
' a través del puerto serial
fTermine = FALSE
IF (spnboxS1.Value <> s1) THEN
spnboxS1.Value = s1
WHILE fTermine = FALSE
WEND
END IF
fTermine = FALSE
IF (spnboxS2.Value <> s2) THEN
spnboxS2.Value = s2
WHILE fTermine = FALSE
WEND
END IF
fTermine = FALSE
IF (spnboxS3.Value <> s3) THEN
spnboxS3.Value = s3
WHILE fTermine = FALSE
WEND
END IF
fTermine = FALSE
IF (spnboxS4.Value <> s4) THEN
spnboxS4.Value = s4
WHILE fTermine = FALSE
WEND
END IF
fTermine = FALSE
IF (spnboxS5.Value <> s5) THEN
spnboxS5.Value = s5
WHILE fTermine = FALSE
WEND
END IF
'Ir a la posicion 1
'Ir a la posicion 2
'Regresar a home
END








