Now that we have learned how to use SubVI we are almost ready to face bigger and more complex projects, and I say almost ready because we still need to fine tune some details.
Thinking about it I think it is time to talk about the error cluster, this is a cluster that is available in LabView and has two important functions (in my opinion, maybe more).
The first one is to interact with the program and stop it if there is an error indicating the error code and a message describing the error, the second one is to direct the program flow.
In this article we are going to focus on the second one and for it we will create a simple SubVI with an error cluster and a TRUE signal.
Ahora que hemos aprendido a usar SubVI estamos casi listos para enfrentarnos a proyectos mas grandes y complejos, y digo casi listo porque aun nos falta afinar algunos detalles.
Pensando en ello creo que es tiempo de conversar sobre el cluster de error, este es un cluster que está disponible en LabView y tiene dos funciones importantes (a mi parecer, quizas sean mas).
La primera es interactuar con el programa y detenerlo si existe un error indicando el código de error y un mensaje que describa el mismo, la segunda es dirigir el flujo del programa.
En este artículo vamos a enfocarnos en la segunda y para ello crearemos un SubVI sencillo con un cluster de error y una señal TRUE.
As we can see it is a simple SubVI, we only have an input error cluster, an output one and a constant TRUE that we will use to "activate things" with our SubVI in an orderly way.
An error cluster has 3 types of data, Status which is a boolean data and is TRUE when an error occurs and FALSE when everything goes well, code which is a numeric data to encode the errors and source in which the source of the error is described.
Como podemos ver es un SubVI sencillo, solo tenemos un Cluster de error de entrada, uno de salida y una constante TRUE que usaremos para "activar cosas" con nuestro SubVI de forma ordenada.
Un cluster de error tiene 3 tipos de datos, Status que es un dato booleano y es TRUE cuando se produce un error y FALSE cuando todo marcha bien, code que es un dato numérico para codificar los errores y source en el cual se describe la fuente del error.
All these data are handled by the designer (us), that is to say, we must program the conditions that change the Status from FALSE to TRUE, the error code that must be shown and the descriptive message.
If we use SubVIs designed by someone else it will surely already come with the error connections built in so it is standard for SubVIs including Express. But this is material for the next article 😊.
Here we will focus on handling the program flow using Error Clustering. We already proved in the article LabView Structures: While Loop that in LabView the program flow is messy (unless we do something about it).
We know that some applications require a sequence of events, we already saw how to do it with LabView Structures: Flat Sequence but in larger programs and using SubVI it is necessary to try other more comfortable methods.
For this case we are going to launch a rocket to the moon with a pilot called HIVE (I don't know what's so interesting about the moon that all cryptocurrencies want to go there 😁). We will have 3 phases, verification of all instrumentation (LEDs on all good), engine warm-up and launch.
In the first phase we will light 12 LEDs, in pairs representing the verification of instruments, it is like the checklist that everything is operational and you can run the launch.
Todos esos datos los maneja el diseñador (nosotros), es decir, debemos programar las condiciones que cambian el Status de FALSE a TRUE, el código de error que se debe mostrar y el mensaje descriptivo.
Si usamos SubVI diseñados por alguien más seguramente ya vendrá con las conexiones de error integradas por lo que es algo estándar para los SubVI incluyendo los Express. Pero esto es material del siguiente artículo 😊.
Aquí nos enfocaremos en manejar el flujo del programa usando Cluster de error. Ya comprobamos en el artículo LabView Structures: While Loop que en LabView el flujo del programa es desordenado (a menos que hagamos algo al respecto).
Sabemos que algunas aplicaciones requieren una secuencia de eventos, ya vimos como hacerlo con LabView Structures: Flat Sequence pero en programas de mayor tamaño y uso de SubVI es necesario probar otros metodos mas comodos.
Para este caso vamos a lanzar un cohete a la luna con un piloto llamado HIVE (no se que hay de interesante en la luna que todas las criptomonedas quieren ir ahí 😁). Tendremos 3 fases, verificación de toda la instrumentacion (leds encendidos todo bien), calentamiento de motores y lanzamiento.
En la primera fase encenderemos 12 LEDs, en parejas que representan la verificación de instrumentos, es como el checklist de que todo esta operativo y se puede ejecutar el lanzamiento.
Ah yes, here we rely on Flat Sequence because we only need to turn on LEDs so the requirements make it suitable, our error SubVI (red cross) sends the TRUE signal that triggers the sequence of events, at the end the last frame sends a stop signal to the loop to start the next phase.
In the second phase we will rely on a Shift Register to warm up our engines, we will use the repetitions of the while loop taking advantage of the delay to set the time needed for the warm up.
Ah sí, aquí nos apoyamos con Flat Sequence porque solo necesitamos encender LED así que los requerimientos lo hacen adecuado, nuestro SubVI de error (equis roja) envía la señal TRUE que desencadena la secuencia de los eventos, al final el último frame envía una señal de parada al bucle para que inicie la siguiente fase.
En la segunda fase nos apoyaremos en un Shift Register para calentar nuestros motores, usaremos las repeticiones del bucle while aprovechando el retardo para establecer el tiempo necesario para el calentamiento.
If we reach the third phase, we just have to launch the spacecraft and take our friend HIVE straight to the moon, sounds simple, right?
Si llegamos a la tercera fase solo hay que despegar la nave y llevar a nuestro amigo HIVE directo a la luna, suena sencillo ¿verdad?
Now that we have configured our three phases, our diagrams will look like the one shown in the following image.
Ya tenemos configuradas nuestras tres fases, nuestros diagramas tendrían una apariencia como la que se muestra en la siguiente imagen.
Although the phases are programmed we should not try to run the program because as it is there is no guarantee that it will follow the sequence, it could try a takeoff without warming up engines or verify that the whole system is correct.
It is here where our error cluster serves to control the flow of the program, when we connect it to blocks or structures the flow starts from the first connection and runs them in the order they are connected until it reaches the last one.
Aunque las fases están programadas no deberíamos intentar correr el programa porque tal como está no hay garantía de que siga la secuencia, podría intentar un despegue sin calentar motores o verificar que todo el sistema esté correcto.
Es aquí donde nuestro cluster de error sirve para controlar el flujo del programa, cuando lo conectamos a bloques o estructuras el flujo parte desde la primera conexión y las va ejecutando en el orden que estén conectadas hasta llegar a la última.
I know some of my readers don't understand much about programming and blocks but enjoy the "visual art" of my articles, so I have taken extra time to design a custom control panel hoping that the design might be to the liking of my valued readers.
Se que algunos de mis lectores no comprenden mucho sobre la programación y los bloques pero disfrutan el "arte visual" de mis articulos, asi que me he tomado tiempo extra para diseñar un panel de control personalizado esperando que el diseño pueda ser del agrado de mis apreciados lectores.
Well, without further ado, let's send our friend HIVE to the moon. I thank you for visiting my blog and I hope that what is exposed in the article will be useful for you, I remain attentive to the comments section.
Bueno, sin mas que agregar enviemos a nuestro amigo HIVE a la luna. Agradezco por haber visitado mi blog y esperando que lo expuesto en el artículo te sea de utilidad quedo atento a la sección de comentarios.