LabView Structures: Flat Sequence EN/ES 馃SPECIAL EDITION馃

Words
2225
Reading
10 min
3y
Listen to this post
~15 min

Life is a sequential process, events always occur in an order, to be parents you must first beget and before that there are many other events that must occur, for safety sometimes some events must occur first than others, for example if we stop a cab this should not go without first we get in the vehicle.

It is so logical that only to mention it can make you doubt on what things I am rambling, because now let's take that to the programming, when we write codes we know that they will be executed line by line, if we create a loop while the program will not go out of there while the condition that executes it is fulfilled ignoring the rest of the code.

But LabView is different in this sense, we have already demonstrated that two while loops can be executed simultaneously and depending on the application we want to develop this can become a problem because it does not respect the principle of sequence, that leads us to seek mechanisms that give us control of the order in which events are executed, so today we will see the Flat Sequence structure in a special edition of the father's day.


La vida es un proceso secuencial, los eventos siempre ocurren en un orden, para ser padres primero hay que engendrar y antes de eso hay muchos otros eventos que deben ocurrir, por seguridad a veces deben ocurrir unos eventos primeros que otros, por ejemplo si paramos un taxi este no debe irse sin que primero nos montemos en el veh铆culo.

Es tan l贸gico que solo mencionarlo puede hacerte dudar sobre qu茅 cosas estoy divagando, pues ahora llevemos eso a la programaci贸n, cuando escribimos c贸digos sabemos que se ejecutar谩n linea por linea, si creamos un bucle while el programa no saldr谩 de ah铆 mientras se cumpla la condici贸n que lo ejecuta ignorando el resto del c贸digo.

Pero LabView es distinto en este sentido, ya demostramos que dos bucles while se pueden ejecutar de forma simult谩nea y dependiendo de la aplicaci贸n que queramos desarrollar esto puede convertirse en un problema ya que no respeta el principio de secuencia, eso nos lleva a buscar los mecanismos que nos den el control de el orden en que se ejecutar谩n los eventos, por eso hoy veremos la estructura Flat Sequence en una edici贸n especial del dia del padre.


We want to celebrate Father's Day by giving away a machine that allows to dispense beers served to fathers who in a relaxed attitude enjoy a celebratory atmosphere.

The algorithm is simple, place the empty glass, wait for the father to request a beer, fill it with beer when there is a request, deliver it and repeat.

If we try to do this in Labview without further ado, the parent may end up receiving empty glasses, so we must first learn to control the flow of our program, for this we can establish that the actions are linked under conditions so that the second step does not meet the conditions to be executed until the first is complete or use the Flat Sequence structure.


Queremos celebrar el dia del padre obsequiando una m谩quina que permita despachar cervezas servidas a los padres que en una actitud relajada disfrutan de un ambiente de celebraci贸n.

El algoritmo es simple, colocar el vaso vac铆o, esperar que el padre solicite una cerveza, llenarlo de cerveza cuando exista la solicitud, entregarlo y repetir.

Si intentamos hacer esto en Labview sin m谩s puede que el padre termine recibiendo vasos vacios, por eso primero debemos aprender a controlar el flujo de nuestro programa, para ello podemos establecer que las acciones est茅n enlazadas bajo condiciones de manera que el segundo paso no cumpla las condiciones para ejecutarse hasta que el primero este completo o usar la estructura Flat Sequence.


This structure is presented as a film "reel", you can add as many frames as you want and the program will run in order from left to right. The steps of the algorithm are written in each frame in the order we want the execution of each step.


Esta estructura se presenta como un "rollo" de cine, se puede agregar la cantidad de cuadros que deseemos y el programa se ejecutar谩 de forma ordenada de izquierda a derecha. Los pasos del algoritmo se escriben en cada cuadro en el orden que deseamos la ejecuci贸n de cada paso.


With that I have already explained the Flat Sequence structure, as you can see it is very simple 馃槄. But let's design our example making the gift for parents that we have described.

First we are going to create a custom environment, for that we create custom controls and indicators that will give us the appearance of the cover image, by the way the subject that appears there I have hired him to act as a parent from pxhere.

Apart from our actor we have custom indicators in the form of text, this will change color as if made with LEDs, we have disc lights which we can adjust the speed of movement with the beautiful ferrari which is a slide control, we have two vertical slides that bring the empty glass up to the filling place, a modified level representation to represent our glass being filled, a horizontal slide to bring the full glass to the relaxed parent, a request button and a stop button.

The first thing we will do is to make our WELCOME... text have a fixed flashing using a while loop as we saw in previous articles.


Con eso ya te he explicado la estructura Flat Sequence, como ves es muy simple 馃槄. Pero vamos a dise帽ar nuestro ejemplo haciendo el regalo para los padres que hemos descrito.

Primero vamos a crear un ambiente personalizado, para ello creamos controles e indicadores personalizados que nos dar谩n la apariencia de la imagen de portada, por cierto el sujeto que aparece ah铆 lo he contratado para actuar como padre desde pxhere.

A parte de nuestro actor tenemos indicadores personalizados en forma de texto, este cambiar谩 de color como si estuviese hecho con LEDs, tenemos luces de disco las cuales podemos ajustar la velocidad de movimiento con el hermoso ferrari que es un control slide, tenemos dos slides verticales que hacen subir el vaso vac铆o hasta el lugar de llenado, una representaci贸n de nivel modificada para representar nuestro vaso en proceso de llenado, un slide horizontal para llevar el vaso lleno al padre relajado, un bot贸n de solicitud y un bot贸n de parada.

Lo primero que haremos ser谩 que nuestro texto WELCOME... tenga una intermitencia fija usando un while loop como lo vimos en art铆culos anteriores.


Now we want HAPPY FATHERS DAY also to be intermittent but each word separately in a sequential way, for this we can use the same pattern of the while loop with the shift registers but this time we will use a Flat Sequence to establish the order of execution, it is important to note that the delay is inside the frames needing one per frame and not only one per while loop, this is so to establish the delay between a sequence and another.


Ahora queremos que HAPPY FATHERS DAY tambi茅n sea intermitente pero cada palabra por separado de forma secuencial, para ello podemos usar el mismo patr贸n del while loop con los shift registers pero esta vez usaremos un Flat Sequence para establecer el orden de ejecuci贸n, es importante notar que el delay est谩 dentro de los frames necesitando uno por frame y no uno solo por while loop, esto es as铆 para establecer el retardo entre una secuencia y otra.


We have 6 spheres of lights with adjustable speeds, we have made an attractive control so that our friend can adjust the speed of the spheres to his liking and even play with the knob while enjoying his beer.

Again we use a while loop but this time we make the repetition time variable, as the value of our slide increases the execution time decreases, the way I can think of to do it is using the value of our knob as denominator that divides a constant, for this we must make the minimum value to be 1 instead of zero since we don't want to have a zero in the denominator.


Tenemos 6 esferas de luces con velocidades regulables, hemos hecho un control atractivo para que nuestro amigo pueda ajustar la velocidad de las esferas a su gusto e incluso jugar con la perilla mientras disfruta su cerveza.

De nuevo usamos un while loop pero en esta ocasi贸n hacemos que el tiempo de repetici贸n sea variable, a medida que aumenta el valor de nuestro slide disminuye el tiempo de ejecuci贸n, la forma que se me ocurre para hacerlo es usando el valor de nuestra perilla como denominador que divide una constante, para ello debemos hacer que el valor m铆nimo sea 1 en lugar de cero ya que no queremos tener un cero en el denominador.


Now let's take a look at how our environment looks like and test the speed control for the lights at once.


Ahora demos un vistazo a como queda nuestro entorno y de una vez probamos el control de velocidad para las luces.


Now we are going to design our beer dispatcher, it is assumed that in the initial condition there is already an empty glass waiting to be served, a button sends the service request signal and the process starts, this button is not latching, that is, it only sends the condition true when it is pressed and false when it stops being pressed, therefore our friend must press for more than a second for a safe signal.

We have to enclose everything in a while loop because we want that the process can be repeated every time we want, the push button is inside this while loop but outside the flat sequence however it has influence on all the frames, in total we have 3 frames, one to fill the glass, another to deliver the glass and another to place a new glass.

To create the first frame we use the push button signal (TRUE/FALSE) in a CASE structure that will return (1/0), then inside the frame we create a while loop that receives this data through a shift register and compares if it is equal to zero, the result is sent to a selector and when it is zero the level of the glass is taken to zero and a stop is sent to the while loop, only when this stop occurs it goes to the next frame, when it is one it goes through an incrementer and with a delay it continues increasing until it reaches a value of ten (full glass), this condition also stops the while loop to go to the next frame.


Ahora vamos a dise帽ar nuestro despachador de cervezas, se supone que en la condici贸n inicial ya hay un vaso vac铆o esperando ser servido, un pulsador env铆a la se帽al de solicitud de servicio y el proceso inicia, este pulsador no es de enganche, es decir, solo env铆a la condici贸n verdadero cuando es pulsado y falso cuando deja de ser pulsado, por lo tanto nuestro amigo deber谩 pulsar por m谩s de un segundo para una se帽al segura.

Tenemos que encerrar todo en un while loop porque queremos que el proceso se pueda repetir cada vez que se desee, el pulsador esta dentro de ese while loop pero fuera del flat sequence sin embargo tiene influencia sobre todos los cuadros, en total tenemos 3 cuadros, uno para llenar el vaso, otro para entregar el vaso y otro para colocar un nuevo vaso.

Para crear el primer frame usamos la se帽al del pulsador (TRUE/FALSE) en una estructura CASE que devolver谩 (1/0), luego dentro del cuadro creamos un while loop que recibe este dato mediante un shift register y compara si es igual a cero, el resultado se env铆a a un selector y cuando es cero el nivel del vaso se lleva a cero y se env铆a un stop al while loop, solo cuando ocurre ese stop pasa al siguiente cuadro, cuando es uno se pasa por un incrementador y con un retardo se sigue incrementando hasta que alcanza un valor de diez (vaso lleno), esa condici贸n tambi茅n detiene el while loop para que pase al siguiente cuadro.


Since all the indicators have the same numerical range we can copy the same table into the next one and just replace the indicator with the corresponding one, that way we will have our complete flat sequence.


Ya que todos los indicadores tienen el mismo rango num茅rico podemos copiar el mismo cuadro en el siguiente y solo reemplazar el indicador por el que corresponda, de esa forma tendremos nuestro flat sequence completo.


The stop button has become common to all while loops that have a manual stop, our complete structure would look as follows:


El bot贸n de stop se ha hecho com煤n a todos los while loop que poseen parada manual, nuestra estructura completa se ver铆a de la siguiente forma:


With this we have our design ready, now to continue enjoying father's day and remember not to abuse the service button 馃榿馃樀.


Con esto ya tenemos nuestro dise帽o listo, ahora a seguir disfrutando del dia del padre y recuerda no abusar del bot贸n de servicio 馃榿馃樀








LabView Structures: Flat Sequence EN/ES 馃SPECIAL EDITION馃 | Ecency