05-30-2014 05:58 AM
Hi everyone,
I have written the attached code which will eventually be a part of a bigger program. The program is intended to log some test value, in this case just the date and time to a csv file when a button is pressed (log in WHITE, loop1). Loop2 is intended to read a test value from a line in the first csv file and then add an extra test value to the end of that line when the serial number matches and then saves that line to a new csv file. This all works well but loop2 seems to pause a few times before continuing when either of the log button is pressed. I tried putting the code in 1 while loop with no success. Can anybody see what I am doing wrong?
05-30-2014 06:44 AM
The Write To Spreadsheet File.vi is not reentrant. This means that only one call to it can run at a time. So if you are logging data in loop 1, loop 2 must wait until the first call to the Write To Spreadsheet File is complete before it can use the function.
05-30-2014 07:32 AM
Suggestion: Do not use the Read from Spreadsheet VI inside a while loop at that rate. When you open the VI you may see the file is opened and closed everythime when you excute the VI, which is not a good practice. Instead try to use the the open file and then Read from Text file and Write to Text file primitives to perform read/write operation.
Good luck!
05-31-2014 01:53 PM
@Maiz wrote:
Can anybody see what I am doing wrong?
In addition to waht has been said already, your code is extremely convoluted.
Can you explain your setup and what the program is supposed to do? I am sure it could be done with 20% of the current code.
06-02-2014 07:03 AM
Hello altenbach,
This is my very first attempt at writting a real program. It took me ages to work out how to read a row from a csv file and then add a value to the end of that row. I was quite proud of this until now 😞 . As you can guess I am very new to this and the main problem I have with Labview is finding the right functional block to use.
The main purpose of the program will be to log a number of motor stator weights before and after varnish. When the stator is weighed after varnish the program will need to find the log data that was recorded against a serial number before varnish and then add the varnished weight to the end of that line.
I will take on what you said and have a go at simplifying the code. Are you able to help me with some sample code?
Best regards,
Maiz
06-02-2014 02:20 PM
Maiz wrote:I will take on what you said and have a go at simplifying the code. Are you able to help me with some sample code?
Sure. See how far you get and post back if you gets stuck.
You simply need to gain a little bit more experience (we've all been there ;)), that that's most easily achieved by actual programming. Also look at the design templates and example programs that ship with LabVIEW.