Showing results for 
Search instead for 
Did you mean: 

while loops

Hi, I am currently working on a project which monitors the energy use of a polymer extrusion process.  I'm also monitoring the pressure as well, and will eventually incorporate several thermocouples into the barrel.   I'm doing this using LabVIEW 7.1, reading an out of date LV text book for guidance.  Please somebody have alook at what I have attached - ( I hope it is readable) it is a quick and dirty attempt at writing a program, I know, and would be thankful for any tips on cleaning it up.  Or maybe it is fine the way it is?  But I need to write this to a spreadsheet file, and put a time stamp on it.  I'm having a bit of difficulty figuring this out, and would appreciate any thoughts. 
0 Kudos
Message 1 of 4
Basic comments:
  • A pretty good start, especially if you're new to LabVIEW.
  • Wiring should be relatively straight if possible, and set up to go left-to-right, top-to-bottom. In your case you have wires going back on themselves, making it difficult to read the code. A good example is right where your while loop termination terminal is. I couldn't figure out what was going on there.
  • I don't know if this is true in LabVIEW 7.1, but in LabVIEW 8.2 the "Merge Signals" is expandable. In a couple of cases you can use a 3-input "Merge Signals" rather than merging twice.
  • It's not clear what criteria you're using to stop the while loop. You've wired the result of a merge of two signals. ??? Have no idea what that's supposed to mean. You probably want a front-panel boolean control that the user presses to stop the monitoring.
  • You don't have a filename wired to the "Write to Spreadsheet" file so it will ask you for the name of a file each time you write data to it. Also, you need to wire the input to specify whether you want to append data to the file (which you probably do).
As for the timestamp question, are you referring to the name of the file being written to have a timestamp, or for the datapoints to have a timestamp? 'Cause the readings have timestamps. If you just want the filename to have a timestamp, then you need to generate the name of the file yourself. There's a Get Date/Time string you can use for this purpose.

If you want more resources for learning LabVIEW, a good place to start is in the Developer Zone.

Message Edited by smercurio_fc on 04-04-2007 12:57 PM

0 Kudos
Message 2 of 4

I've cleaned up a bit your VI and I have some advice to tell you. First of all always include a Wait function on your while loops or another timing function to avoid your program to  make your processor to work at 100%.

Also, always try to make your data flow from left to right, and try to wire a way you can see clearly which is the data source and which is the data sink, so you can read easily the block diagram.

Whenever you use an Express VI and you need to display the output (in Dinamic Data Type) in a numeric or boolean indicator, use the Convert from DDT VI instead of letting LabVIEW do the casting.

About the Spreadsheet file, what do you exactly need to store on it?

I've attached an screenshot of the cleaned-up block diagram, and the VI. The VI is stored in LV 8.2, I wonder if somebody can covert it to 7.1 for you to see it.

Hope this helps


Robst - CLD

Using LabVIEW since version 7.0

Download All
0 Kudos
Message 3 of 4
Hi, me again, thanks for the help, I've put into use much of what you's have advised. The JPEG was a massive help, but i cant find that icon beside the 'Write to SS' icon? What I want to do is write all this data, and the thermocouples to an excel file, so I assume times will be a part and parcel of this transfer? When I have previously attempted to write data, a pop-up window appears, and when I select the file, nothing appears to happen. Any thoughts? Like how do I wire a filename to the 'Write to SS' file, but I'll try and figure out how to wire the input to append data to the file.

As for a boolean stop button, before I just used the abort button. I have'nt yet thought about including something to stop the loop automatically. I don't think its necessary because not much can go wrong that will require the operation to stop. I don't think so at this stage anyhow. So I think a boolean stop button should do the trick for now. I will eventually run a pump alongside it feeding CO2 into the extrusion barrel ( energy efficiency benefits) and I may need some form of triggering in the future.

Has anyone ever used a Hioki meter with labview before? I'm getting wrong power readings from it, but the Voltage and Current phases are correct. So I intend to use the phase relationship equations to come up with a figure for the power. The problem lies in that I need 6 outputs from the meter, for each phase, but there are only 4 channel outputs, as far as I am aware? Big trouble as the average current and voltages read from the meter will give the average power ( which I'm using at the moment) which isn't exactly the true power.

I hope you follow what I mean, as I'm having trouble following it, but there is always an answer for something and I just thought I'd put it out there in hope.

0 Kudos
Message 4 of 4