LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

State machine

Solved!
Go to solution

I didn't think about dynamically setting the timeout, thanks!

It works, sort of. I've encountered an odd bug in my program - after making the changes you proposed, the VI works like  a charm.

But only once.

If I hit 'Exit', then run the VI again, the second loop ("continously acquire) will only run once, then hang. Suddenly the new timeout value isn't being fed into the Wait on Notification...

 

And another, unrelated question - When I'll 'read' the values acquired, I'll only need the latest one read, and don't care about the history. So if I am going to use a queue, it will be quickly filled with unqueued elements. Can a queue be 'too full' (memory issues)? If I only need the latest value and don't care about the history, is it better to use notifiers or does it not matter?

 

Thanks again for all your assistance

Download All
0 Kudos
Message 11 of 20
(1,594 Views)

OK, I figured it out, stupid mistake - in the "Exit" state of the first loop, I use a property node to change the state of the boolean controller wired to the stop condition of the second while loop. However I forgot to turn it back to 'off' when the program restarts.

0 Kudos
Message 12 of 20
(1,576 Views)

@cl0ck wrote:

OK, I figured it out, stupid mistake - in the "Exit" state of the first loop, I use a property node to change the state of the boolean controller wired to the stop condition of the second while loop. However I forgot to turn it back to 'off' when the program restarts.


Instead of setting a control value to stop your second loop, why not make a command to do it?  I would change your notifier to be a queue with a data type of string.  From there you can easily pick up a "Stop" and stop your loop.  On a timeout, do the acquisition.  Your other commands can be "Start Acquire" and "Stop Acquire".


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
0 Kudos
Message 13 of 20
(1,566 Views)

ProducerConsumer_Modify_02.jpg

cl0ck,

Ok I got it working.Here is the Code.If you have more Question kindly post your Code again.

 

Certified LabVIEW Architect
Certified TestStand Architect
0 Kudos
Message 14 of 20
(1,546 Views)

I'm not sure I understand why, at this point, you're not using Producer/Consumer.  To me this would seem to make more sense to use to mimic data acquisition and still have UI.

Unless of course the only thing the slave loop does is acquire data.  Then... I guess nevermind.  I don't know, what do the professionals think about master/slave vs producer/consumer?

0 Kudos
Message 15 of 20
(1,541 Views)

@ohiofudu wrote:

ProducerConsumer_Modify_02.jpg


 


The problem with this code is when the command to stop is sent.  Here's the scenario I'm afraid of:

1. You read a TRUE from the Notifier.

2. A command is sent to stop acquisition (FALSE).

3. You into the case structure in the consumer loop and set the notification to a TRUE.

You just caused a problem.  That FALSE was never recieved since the TRUE overwrote it.  This is one of the reasons I do not have a consumer enqueue commands to itself.

 

Also, what happens if there is no notification and the Exit button is pressed?  The loop will not stop until it receives a command (likely 2).


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
0 Kudos
Message 16 of 20
(1,529 Views)

DailyDose wrote:  what do the professionals think about master/slave vs producer/consumer?

Rarely do I use Master/Slave.  Nearly everything I do needs every command sent to it.  Therefore I use Producer/Consumer with either queues or user events.


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
0 Kudos
Message 17 of 20
(1,526 Views)

crossrulz,

Talk is cheap.Let see your solution(Code).I was just playing with the original Code.

Certified LabVIEW Architect
Certified TestStand Architect
0 Kudos
Message 18 of 20
(1,508 Views)

@ohiofudu wrote:

crossrulz,

Talk is cheap.Let see your solution(Code).I was just playing with the original Code.


We're all on the same team, right?  Maybe you should rephrase your statement...

 

This is not a confrontation - it's a learning experience.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 19 of 20
(1,501 Views)

@ohiofudu wrote:

crossrulz,

Talk is cheap.Let see your solution(Code).I was just playing with the original Code.


No need to be hostile.  I was just pointing out some things to be careful of.  Just quickly made this from scratch with my 1 year old climbing all over me, so it is likely far from perfect.

 

I'm just using the timeout to allow for the acquisition to happen at a normal rate.  The top loop can send a Start, Stop, or Quit command at any time and the second loop will respond nearly instantly.

Also note that I destroy the queue in the "Quit" case of the consumer loop.  I hate stopping consumer loops by looking for the queue to be destroyed.  I always lose data that way.


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
0 Kudos
Message 20 of 20
(1,492 Views)