The Daily CLAD

Community Browser
cancel
Showing results for 
Search instead for 
Did you mean: 

Re: The Dataflow Paradigm #7

SercoSteveB
Active Participant

The following VI is executed; exactly 2 seconds later the user performs a left mouse click on the 'Stop' control.  Assuming an initial value for the 'Stop' control of FALSE and a 'latched when pressed' mechanical action; what is the value of Numeric Value Out following activation of the 'Stop' button?

 

Daily CLAD #17 Dataflow #7.png

 

a) 11

b) 15

c) 21

d) Undefined

Comments
SercoSteveB
Active Participant

Answer: D

The While loop will iterate indefinitely.  The default value of the 'Stop' control (FALSE) is read at the start of execution and passed to the standard input tunnel of the While Loop.  Once the While loop has all required inputs the value of the standard input tunnel is read (along with that of the shift register) and begins to execute.

Once the value of the standard input tunnel has been read (on the first iteration) it is not read again; therefore a boolean FALSE is passed to the Conditional Terminal of the While loop throughout execution.  As the Conditional terminal is set to STOP on TRUE, the While loop never completes.

Frabto
Member

Tricky qsn

GSXR100038
Active Participant

Hi,

I need to know whay happen if the button Stop is inside the While loop the numeric Value Out is 20 but I don't understand why. Because normally the while loop execute (2000/500 = 4) in this case the  

numeric Value Out is 15. Can you explain Why? Thanks for your answer.

crossrulz
Knight of NI

GSXR100045 wrote:


                       

Hi,

I need to know whay happen if the button Stop is inside the While loop the numeric Value Out is 20 but I don't understand why. Because normally the while loop execute (2000/500 = 4) in this case the  

numeric Value Out is 15. Can you explain Why? Thanks for your answer.


                   

It is sort of a race condition.  At exactly the 2second mark, the loop has iterated 4 times.  But it hasn't stopped yet.  On the fifth iteration, the button will be read as TRUE.  So at the completion of the 5th iteration, you have a value of 15 (5+0+1+2+3+4).  You would get 20 if you were even slightly late for the 2 second mark.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
GSXR100038
Active Participant

Hi

Ok, I understand it's a race condition but in the question is "exactly 2 seconds later the user performs a left mouse click on the 'Stop' control" and the reponse is 15, 20 or both ?  

ps3fer
Member

download the examples please

faisalm88
Member

Clever question!

GSXR100038
Active Participant

Sorry for my question is not very clear, thank you crossrulz for you explanation.

ashwinilele
Member

D

Stop button doesn't change to TRUE  while WHILE loop is in running condition.  It occurs race condition . I think so.

eleshrudra
Member

D

R.Elesh
Andreas.Bernau
Member

D

M.P.Bharghavi
Member

Ans: D

undefined

ersmt444
Member

Image broken