Discusiones sobre Productos NI

cancel
Showing results for 
Search instead for 
Did you mean: 

Aumentar gradualmente 0-5

Solved!
Go to solution
Highlighted

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
Message 1 of 12
(335 Views)
Highlighted

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

0 Kudos
Message 2 of 12
(332 Views)
Highlighted

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.


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 3 of 12
(291 Views)
Highlighted

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
Message 4 of 12
(257 Views)
Highlighted

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
Message 5 of 12
(253 Views)
Highlighted

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.

 

 


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 6 of 12
(249 Views)
Highlighted

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
Message 7 of 12
(234 Views)
Highlighted
Solution
Accepted by topic author 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

 


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 8 of 12
(229 Views)
Highlighted

@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!


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 9 of 12
(225 Views)
Highlighted

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

0 Kudos
Message 10 of 12
(190 Views)