LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

CLAD Exam

Thank you both very much for answering my questions. My next question is not quite related with CLAD, it's a design question that has been with me for over a year and I couldn't figure it out, couldn't get much help from NI tech support either.

In my program, data is from an RS-232 port, this is a rather slow process, it takes over one second to get one set of data in, we can not do anything to the feeding rate, the only thing we can do is to wait until it's available. On my front panel, I need to display some charts which update every second, I want to keep the update time strict. What I'm using is parallel while loops and local variables are used to pass data between loops. In general, the programs work ok, some times the one-second update loops run late. I'm reading the design patten article from NI website. It mentioned using master/slave design pattern with notifiers. I tried it, with master sending data and slave accept data. If the master is running faster, then the slave can keep the one-second update rate and just throw away the undisplayed data points in between. But if the master is running slower than one second, the slave will wait for the data and keeps the same update rate as the master one. I tried to have time out, it will add zeros to the the series that's not whatI want to see, it will make the charts messy. What I want is if there is no new value, just use the old value.

Even though I read from the articles saying the master/slave structure is just for this kind of application, I have never figured out how I can make it work. Please give me some advice/comment. I hope I have made myself clear enough.

Best regards,

Guangde

0 Kudos
Message 11 of 16
(1,282 Views)

You're kind of stuck there.  If you need to update a value once per second, but the source of the data can't give it to you that fast, then what?  What do you want the graph to show every second if the new data point has been received yet?

You could put a timeout on the queue so that it guarantees to return and finish the loop within the second.  But if it times out, you have nothing but the default data (which is why the zeroes.).  You could maintain the last received value in a shift register, and in a case structure, if the queue times out, plot the last data point again instead of a zero.

0 Kudos
Message 12 of 16
(1,276 Views)

If you use a waveform data type chart, you can leave the array (in the WF) for the slow data source empty and just plot what dat you have. The Chart will plot the info you gave and connect the dots bewteen updates for each plot.

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 13 of 16
(1,268 Views)
I agree with Ravens Fan. You must decide what you want to do if the data is not available from the source on time. The software cannot create the data nor can it force the source to speed up. LV is pretty good, but there are a few things that it cannot do!

If you detect the timeouts and put NaN (Not a Number) into your data stream rather than the default zero, the point will not show up on the plot. This may be better than have the plot suddenly jump to zero then back to the next valid data point. If the data will be used for calculations as well as display, you will need to evaluate the effects of the NaN values in the data.

Lynn
0 Kudos
Message 14 of 16
(1,265 Views)
If you want a simple "sample and hold" with a fixed update rate, I'd suggest keeping the last valid value in a shift register (as Ravens Fan suggested) and use the selector function. Wire the timeout of the notifier/queue to the selector, the last valid value to the true terminal (true = timeout) and the noti/queue output to the false terminal.

Hope this helps,
Daniel

0 Kudos
Message 15 of 16
(1,245 Views)
I'll thank everyone here who provides advices to help me. I tried the time out and shift register way and it works very well. I'll try to implement it in my program, but I'm not very sure what kind of benefit I'll get over the change. I'm thinking save some overhead is one of them, even though I don't know how much it will save and it will be hard to tell in the future. Please advise me what are the other benefits and what kind of caution I should take to make the change.
 
Best regards,
 
Guangde
0 Kudos
Message 16 of 16
(1,232 Views)