09-06-2013 11:30 AM
Hello all!
Now what I'm trying to do is to do a syncronization. A series of signal keeps coming, and a counter keeps records of the number.
And I also have a DAQ to output voltages. Now I want that every time the counter changes, a change of the output of the DAQ
could be triggered. A syncronization problem! I'd ask help about implementing this. To use a notifier or occurance? and how?
Anybody got any idea?
Thanks!
Chao
Solved! Go to Solution.
09-07-2013 03:09 AM
Actually I would use a user event.
There is a producer-consumer design pattern (that you can access through the New menu selection) that shows how it could work.
Mike...
09-09-2013 03:05 AM
Hi Mike sorry I'm not quite sure what you meant. Where can I find the producer-consumer design pattern?
In the functions palette I found some VIs related to user event like creat, generate user event, which one
or ones I can use?
Thanks.
Chao
09-09-2013 05:31 AM
The VIs you found would be used, but when you select New from the file menu one of the options is to open one of several design pattern templates.,
When you select New, a dialog box opens where you can select what you want to open. In the hierarchical menu on the left, expand the "VI" section and the section under it titled "From Template". Continue drilling down by expanding "Frameworks" and finally "Design Patterns".
Inside that last section you will find a template called "Producer/Consumer Design Pattern (Events)". Select it and then click OK.
This pattern uses an event (in this case a value change event on a button) to do something (cause a value to be put into a queue). This basic idea would be expanded by first flipping it "upside down" and then using a user-defined event to pass state-change information between loops.
In this scenario, the bottom loop (which is where your DAQ logic would be) becomes the producer loop while the top loop (the one with the event structure in it) serves as the consumer loop.
Basically, the counter in your code would generate a user-defined event whenever the counter value changes. The event would pass this state-change information to the consumer loop (instead of a queue).
I make this change because one of the issue that you have to address with using queues and notifiers to perform synchronization is that only one consumer will see any given notification or queue item. This is the way they are designed to work and it can be a very helpful trait, but if you have more than one consumer needing to be notified of a state change, this is also a problem.
By contrast, an event will be seen at the same time by all the consumers that are registered to receive it. Likewise, an event can pass as little or as much data as you like.
Mike...
09-09-2013 06:36 AM
Thank you very much for the explanation, and I've found this VI!
Actually I figured out a simpler way do the syncronization by using just
case structures with different choices. But I'm sure this VI and your way
are useful, and probably I will use it later.
Thanks again!
Chao