LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Generating single random number with a boolean signal on a RT Target

Solved!
Go to solution

Thank you so much Bob and Gregory!

 

I did fix my code to work how i want. I think I understood the nature of what's happening.

I guess the logic should be AND("current signal", NOT("previous signal")) in terms of MS excel logic function.

This logic will give me,

 

CurrentPreviousOutput 
TRUETRUEFALSE
TRUEFALSETRUE
FALSETRUEFALSE
FALSEFALSEFALSE

 

So when I ran the VI continuously (and before and after I switched "experiment on" to ON),

the previous code that I had would provide input signal to the case structure something like,

FFFTTTTTTTTTTT....

so the "random number" was generating number continuosly according to the number of Ts there.

But if I set the above logic based on the sequence of current and previous signal, the same input,

FFFTTTTTTTTTTT....

would only trigger when F becomes T.

 

Makes perfect sense.

 

But I do wanna know how to do this with WHILE loop now. Guess it's more about technical understanding now.

SoI tried with the while loop as it is attached in the VI with the understanding that I have.

But I'm not getting the right results here. What am I missing now?

0 Kudos
Message 11 of 14
(1,130 Views)

Hi geek,

 

when you want a VI to iterate for several times you should use a loop…

 

Why did nobody suggest the BooleanCrossing function before?

check.png

 

SoI tried with the while loop as it is attached in the VI with the understanding that I have. But I'm not getting the right results here. What am I missing now?

Basically you missed to THINK DATAFLOW!

When you want to read the current state of a button inside a loop you should actually read the button inside the loop!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 12 of 14
(1,127 Views)

 

But I do wanna know how to do this with WHILE loop now. Guess it's more about technical understanding now.

SoI tried with the while loop as it is attached in the VI with the understanding that I have.

But I'm not getting the right results here. What am I missing now?


Bob and I both uploaded examples using while loops, were you able to take a look at those?

0 Kudos
Message 13 of 14
(1,120 Views)

GerdW,

 

     Because Geek is a beginner, doesn't understand Data Flow, doesn't know how to use Shift Registers, doesn't know about using Do Once or Feedback for "local memory", we were attempting to teach him (or her) these concepts so that he/she could write their own Boolean Crossing function (or understand the one that comes with LabVIEW).

 

     There's still a way to go ...

 

Bob Schor

0 Kudos
Message 14 of 14
(1,112 Views)