Discusiones sobre Productos NI

cancelar
Mostrando los resultados de 
Buscar en lugar de 
Quiere decir: 

Aumentar gradualmente 0-5

¡Resuelto!
Ir a solución

Que tal a todos, me gustaría generar un código donde al presionar un botón de arranque, se active un ciclo donde haya como un "contador" de 0-5 con dos digitos... sería algo como:

INICIO

     0,0.01,0.02,0.03,0.04,0.05,0.06,0.07,0.08,0.09,0.10,... y así hasta llegar a 5

 

AGRADECERÉ MUCHO SU RESPUESTA!

0 kudos
Mensaje 1 de 12
3.078 Vistas

Sí, en tu while Loop necesitas un shift register y en cada iteración sumar "0.01" a el numero.

=======
My Channel: https://www.youtube.com/@LV_Lab

0 kudos
Mensaje 2 de 12
3.075 Vistas

Since you can calculate the number of iterations needed before the loop starts, a FOR loop is more appropriate than a WHILE loop. You don't even need a shift register. Just multiple [i] with 0.01.

0 kudos
Mensaje 3 de 12
3.034 Vistas

Ok, but in a for loop I would need to make it very long, with the shift register it works for me perfectly. Your answer has given me more ideas, thank you very much.

0 kudos
Mensaje 4 de 12
3.000 Vistas

Esta perfecto! Lo he puesto en práctica pero ahora lo quiero hacer que cuando llegue a 5, sea inverso. 

DavidOrtega_0-1596907656194.png

Me podrías dar una idea?

 

0 kudos
Mensaje 5 de 12
2.996 Vistas

Have you actually tested your VI?

 

 

You cannot do equal comparisons with DBLs. There is a very high chance that your loop will never stop. The value 0.1 cannot be represented in DBL (you would need an infinite amount of mantissa bits!), so continually adding such a value is not guaranteed to be exactly 5.0, ever (the closest you get is 4.99999999999993783).

 

The following code will NEVER stop, but go on to infinity (given enough time) because the value is never exactly five!!

 

altenbach_0-1596910940654.png

 

That's why I said you need to count iteration, because you can calculate exactly how many iterations are needed!

 

Also, exclusive OR is probably not the correct boolean operation. (Try a plain OR). Look at the truth table! Your VI will not stop if both conditions are true.

 

 

0 kudos
Mensaje 6 de 12
2.992 Vistas

I have been reviewing your method and it sure does not stop. With the for loop, is it possible to counter up and then down? I mean from 0 to 5 (+0.01) and from 5 to 0 (-0.01).

What do you think?

0 kudos
Mensaje 7 de 12
2.977 Vistas
Solución
Aceptado por DavidOrtega

@DavidOrtega wrote:

Esta perfecto! Lo he puesto en práctica pero ahora lo quiero hacer que cuando llegue a 5, sea inverso. 


Try something like the following:

(Make sure you fully understand the reason for each part of the code!)

 

altenbach_0-1596912590752.png

 

0 kudos
Mensaje 8 de 12
2.972 Vistas

@DavidOrtega wrote:

I have been reviewing your method and it sure does not stop. With the for loop, is it possible to counter up and then down? I mean from 0 to 5 (+0.01) and from 5 to 0 (-0.01).

What do you think?


See my example right above. If you want exactly one up and one down trace, you can again calculate from first principles how many iterations you need, then use a FOR loop with the correct N, based on y-max, dy, and number of desired periods. Simple math!

0 kudos
Mensaje 9 de 12
2.968 Vistas

OK, I will analyze it to introduce it to my general code, great answer, thank you very much!!!!

0 kudos
Mensaje 10 de 12
2.933 Vistas