12-03-2012 07:32 AM - edited 12-03-2012 07:37 AM
Hi everyone,
Attached is a vi I have been working on (using simulated DAQ cards; so data are sine waves)... When I press 'STOP' I get "Error 1" warnings; something to with de-queue inputs? Any suggestions?
Thanks,
Jack
12-03-2012 07:58 AM
Well, your stopping your loops when you get an error on your queues. You are getting an error (invalid reference) in your consumer loops when you destroy the queue right after the producer loop. This is expected based on your code. You might want to catch error code 1 and clear it.
12-03-2012 02:56 PM
12-03-2012 03:11 PM
@jcannon wrote:
Ok... Makea senses... How might you stop both consumer loops to avoid errors?
Thanks,
Jack
I've actually seen examples where they wire the error to the conditional terminal and jump out that way. They then swallow the error so you don't see it. I guess you can read the value of the stop button and wire that to the conditional terminal also. You can also make the consumer loops into state machines and have separate queues and have the producer issue shutdown states to each consumer. (Useful because it is scalable. Complicated if you don't need scalability.)
12-04-2012 07:27 AM
Well, for your DAQ loop, you already have a STOP in the enum. Why not just exit when you get that command? Also, don't release the queue to send data to the DAQ loop until after the DAQ loop is complete. The top loop can just exit on the error. That's not nearly as big of a deal.
12-10-2012 09:07 PM
Hi crossrulz,
I have been working on this for almost a week and I am still unable to get this to work... I always get the error message no matter what I do OR some but not all loops stop (which leaves a loop hanging)...
Any chance you could post a basic example of what you mean? I must be doing something wrong... The attached is my latest attempt...
Regards,
Jack
12-10-2012 09:42 PM
Move the Release Queue functions to after the respective consumer loops.
12-12-2012 06:20 PM - edited 12-12-2012 06:20 PM
Thanks RavensFan... That worked...
However, I have used a notifier to stop all the loops, rather than a queue (as I only need one notifier, rather that a queue between each loop)... I assume that is ok and appropriate coding practice...
I now have another problem.. In my UE Command Loop I would like to add ALL user commands that will be used in the vi, such as menu commands for read, idle and stop, plus other boolean comments that might, for example, change the x axis scale on wavefort charts... Currently, the way I have this set-up makes the chart flicker...
It it possible to have ALL user commends send in the one queue so that the number of wires can be reduced? Attached is my current code.
Thanks,
Jack
12-12-2012 07:11 PM
Why did you change from using queues to notifiers?
Now you have several loops that execute based on a notifier. With queues, the loops will wait until something is in the queue which effectively throttles the loop. Now that you are using "Get Notifier Status" those same loops are running as fast as they can. That is probably why thinks look like they flicker. You aren't yielding any real time to the CPU to take care of display updates.
Go back to using queues. At least put wait statements in your loops if you insist on continuing the way you are now. It scares me when someone is improving their code, then suddenly decides to change the way they are doing something for no apparent reason.
12-12-2012 07:14 PM - edited 12-12-2012 07:16 PM
You're getting flicker because in your Data Display loop, the only case that writes valid data to the graph is the RUN case. Your writing default data to the graph otherwise. Just saw Ravensfan reply so maybe I'm all wet on that.
I'd also recommend taking all your DAQ setup code and putting it into a subVI.