From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
el 08-07-2020 05:47 PM
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!
¡Resuelto! Ir a solución.
el 08-07-2020 05:54 PM
Sí, en tu while Loop necesitas un shift register y en cada iteración sumar "0.01" a el numero.
el 08-07-2020 08:59 PM
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.
el 08-08-2020 12:26 PM
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.
el 08-08-2020 01:08 PM
Esta perfecto! Lo he puesto en práctica pero ahora lo quiero hacer que cuando llegue a 5, sea inverso.
Me podrías dar una idea?
08-08-2020 01:27 PM - editado 08-08-2020 01:30 PM
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!!
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.
el 08-08-2020 01:45 PM
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?
el 08-08-2020 01:51 PM
@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!)
el 08-08-2020 01:55 PM
@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!
el 08-08-2020 03:33 PM
OK, I will analyze it to introduce it to my general code, great answer, thank you very much!!!!