Discussion:
Basic question about polling and saving data simultaneously
(too old to reply)
OscarJ
2008-06-09 14:10:10 UTC
Permalink
Hello, I'm new to programming in the LabVIEW environment. And my questions below is probably to be considered as super newbie, I've been studying the "LabVIEW Fundamentals PDF" included with the application for a week now but this "dataflow"-type of programming still makes me confused.

 

I would really like it if you people could give me comments on how to make the attached code more efficient.

 

The application I?m trying to build is to be used to acquire data from an event detector on a specific time interval, and save this data to a spreadsheet file on another time interval. Very basic procedure I?m sure, but this is my first try in building this kind of program :robothappy:

 

I saved the whole thing in an .LLB-file, I hope you all will be able to run it, or at least view the code. The top-level VI is the one called ?testVI.vi? and there is three VIs used as subVIs; ?initANAT?, ?pollANAT? and ?savetable?.



 

The pollANAT subVI leaves a 1D, 128 elements long array of ones and zeroes, where a value of one equals an event detected on the channel corresponding to that particular element. This array is to be added to another array that keeps track on the total number of events. When it?s time to save, the savetable subVI writes that array to the end of the spreadsheet file together with various other data such as absolute time and date, time in test, cycle number and so on (right now it only saves absolute time though). After this, the array is overwritten with all zeroes and ready to be used again.

 

When the user runs testVI he first points the path control to a file where he would like to store data, chooses the correct serial-hardware address and enters appropriate polling and saving time, he then executes the VI.

 

As the program look now, the first ting that happens is that initANAT clears the serial port, to insure that the first real polling receives correct data. Then the program enters two separate while-loops that executes two sequence structures wherein the program first waits the specified time via the ?Wait (ms)?-function. Next frame executes the main task (polling, or saves data to file) and after that it prepares for the next iteration of the while-loops.

 

OK, what do you all think of this layout? It feels like there should be a more efficient way to execute all these happenings in a more controlled way, for example I don?t know if it?s possible to abort the Wait (ms)-function if you?d like to end the program without waiting the maybe two hours you?ve set the save time input to be. And what happens if the savetable VI saves the total channel events array at the same time the polling sequence updates that array. Is there a fundamentally different way to do all this?

 

I would like to hear whatever feedback you may have on any aspect of this code!!


testVI.llb:
http://forums.ni.com/attachments/ni/140/30317/1/testVI.llb
muks
2008-08-05 07:40:09 UTC
Permalink
Can you post your vi for lv 8.0?
Albert Geven
2008-08-05 08:10:10 UTC
Permalink
Hi attached a version that shows a better timing and aborting on that, but this can be implemented better with even structures.The writing and reading of a global is done in one go and the data is locked for other processes at that time.So the last writer wins, but your data is never the result of a mix of data.This can better be handled by an action engine as described in the following thread.http://forums.ni.com/ni/board/message?board.id=170&message.id=328078&query.id=44779#M328078By the way, how do you stop your program?I guess you are using the Abort button that only is meant for stopping when you are in a loop due to a programming or IO error


oscarJ testVI.llb:
http://forums.ni.com/attachments/ni/140/31388/1/oscarJ testVI.llb
OscarJ
2008-08-12 08:10:12 UTC
Permalink
Hi! Thanks a whole lot for answering my question, I didn't realize there were any answers until just recently. The version you, (Albert Geven) posted is obviously better than mine :robotvery-happy: I've been trying to figure these action engines you've posted a link to out, they seem to be a good alternative, but they also seem to be over my labview programming-skills :smileysurprised: However this problem of mine has grown more complex than it was when I posted this back in the days (two months ago), maybe this better be solved with event structures like you said, I'm not sure how to go about it though...
Perhaps I should repost the current problem in the LabVIEW forums instead?
 
Thanks for the help anyhow!!!

Loading...