07-07-2006 06:20 PM
07-09-2006 03:50 AM - edited 07-09-2006 03:50 AM
Hi H.,
I think your idea is to write to a Global Variable in the data-producer VI, and read it in the data-consumer VI(?)
One reason this might be less efficient than using Notifiers is if you want to graph every new value in the "consumer" - or make sure the value read in the consumer has changed at least once since the last loop.
> since each time the [consumer] loop timer runs the loop there will always be a value in the notifier...
> Would there be a performance difference between the two methods?
If you don't use the Notification "event" to synchronize the producer and consumer, then to be sure the consumer gets a new vaue, you've made the producer loop faster - every 5 ms - a waste of cpu-cycles. More often the situation is reversed, that is, there's a consumer that needs to see every single new value, and (without events) the consumer must loop faster than the producer (to catch every new value) - this is called polling and it wastes cpu-cycles.
Just about anytime one's tempted to make a loop execute "fast" to check on some value (or to make sure there's a fresh value,) there's an opportunity to improve performance through synchronization with events (including notifiers, queues, occurrances, semaphores, and rendezvous')
tbd
Message Edited by tbd on 07-09-2006 03:51 AM
07-10-2006 10:29 AM
tbd - In my case I'd be looking at having the producer act as the data acquisition and logging to file loop (hence the high speed) and the consumer as a calculation loop (e.g. PID calculation every 200 ms on the current value). So I think what you're saying is in this case there's no inherent performance difference in using a local (actually you said global) variable from a notifier. Do I understand correctly?
Thanks,
Hosehead
07-10-2006 02:39 PM
Hosehead,
I think for your application the best thing to use would be a local variable. Notifiers are really only usefull if the consumer will have to wait for data at any point. If data is always going to be available when the consumer needs it then there's no need for the extra complexity of a notifier.
Hope this helps,
Justin D.
Applications Engineering
National Instruments
07-10-2006 05:40 PM
07-12-2006 01:15 AM
Hi H.,
I must have misunderstand your original post, I though you were considering passing information from one VI to another - in which case you'd have to use a Global (not a Local). If I got it right after all, you may be interested in this link that talks about a "performance-hit" from writing to a Global in a "really tight loop".
Cheers.