LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Do U have a simple and intelligent solution for this problem? Logical problem...

I must to do a cycle with this features:
- I have a random number, N(i), for 100, so I have a number between 0 and 100 generated every step of cycle;
- every number is pass to shift register of cycle;
- I have also a number X initialized at 50;
- I start with sum or subtract 1 from 50 in the first step (i=0) of cycle (for example I subtract 1: X(0)=50-1=49);
- I compare two subsequently number N(1) and N(0): if N(1)<N(0) I desire that the next step of cycle continue to subtract 1 from X(1), for example X(1)=49-1=48, instead, if N(1)>N(0) I want change the operation on X. Since the first is - the new operation is + (for example X(1)=49+1=50). Pratically I desire a SWITCH that if N(i)<N(i-1) don't change previous operation on X(i), if N(i)>N(i-1) change operation on X(i).
Can I do it?
0 Kudos
Message 1 of 15
(3,387 Views)
Yes.  You just need to have another shift register that is a boolean to store whether you are in a count up or count down cycle.
0 Kudos
Message 2 of 15
(3,378 Views)
 Please do... and post VI. Thanks.
0 Kudos
Message 3 of 15
(3,375 Views)
Try to check if this is what you need.
---

While evaluating my code please have in mind that I am a LV novice. Therefore sometimes my code might violate some coding rules that I have to learn about myself. But how else could I do that... 🙂

Chart zoom with "Mouse Over" effect
0 Kudos
Message 4 of 15
(3,361 Views)
Not very good... I hope excellent solution 😉
0 Kudos
Message 5 of 15
(3,353 Views)

What was wrong with the solution Giedrius gave you?

 

Why not try to work this out yourself and post a VI with any questions you might have if your attempt doesn't work right.

 

Is this homework?  Smiley Mad

0 Kudos
Message 6 of 15
(3,348 Views)
Absolutely no, please save it for previous version of LabView. I don't have LW9.
0 Kudos
Message 7 of 15
(3,344 Views)

What version do you have?
0 Kudos
Message 8 of 15
(3,342 Views)
LW8
0 Kudos
Message 9 of 15
(3,340 Views)

The only (possible; it depends on what exactly do you need) problem I see in my previous VI is that it is static. I mean, then you have the < as the outcome of the comparison, it substracts, and if you have > - it sums. This vi checks for the previous operation, maybe it is more correct according to what you need.

 

P.S. Both previous and this VI are coded using LV 8.6. What version do you need?

Message Edited by Giedrius.S on 02-20-2010 12:21 AM
Message Edited by Giedrius.S on 02-20-2010 12:25 AM
---

While evaluating my code please have in mind that I am a LV novice. Therefore sometimes my code might violate some coding rules that I have to learn about myself. But how else could I do that... 🙂

Chart zoom with "Mouse Over" effect
Download All
0 Kudos
Message 10 of 15
(3,337 Views)