03-13-2015 03:40 PM - edited 03-13-2015 03:46 PM
Hi all,
So I have a .VI that I have gotten to communicate with my machine, which I've attached. I've tried to strip it down as much as possible just to understand the concept. It essentially just takes a VISA Resource name, uses that open VISA, then it uses the same VISA Resource to write a command that fetches data from my machine (xall?), and then reads in 500 bytes and prints that out. So that works, and that's good.
I'm trying to use the producer/consumer model to do basically exactly what this guy is doing. I have an LCR meter, I want to press a button that starts my measurement, I want it to sample many times a second, save the data to a text or .csv file, and then stop when I press the stop button. So, it will be taking data indefinitely potentially.
I'd like the data to be in a format something like:
Time C R
0 5.0 4.3
...etc.
I've read the P/C model link above, but my LabView knowledge is still weak. Currently, my plan is to take the read/write part of my attached VI, make that a sub-VI, and then put that in the pink box in the VI from the producer/consumer page above that is labeled "produce data to be placed in the queue":
What's stopping me from doing this is that I can't seem to get the read/write part to work properly as a standalone sub-VI.
Is this the right way of going about this?
Thank you!
Solved! Go to Solution.
03-13-2015 04:15 PM
Alright, instead I tried just working the write/read module into the code from the producer/consumer model in the link above. Here is a picture of the block diagram, and I've attached the file (LoopRW.vi):
I have it write and read in the producer loop, and put the output from the read into the enqueue. Then, it dequeues it in the consumer loop, where I have it output it to a string so I can read it in the front panel, and then write it to a text file. The first problem is that, after hitting stop in my program, the text file has no data in it.
Also, it is probably indicative of the problem, but during measurement, if I pull out the capacitor and replace it with another one, the string value doesn't change.
What am I doing wrong?
thanks!
03-13-2015 04:45 PM
03-13-2015 04:46 PM
03-13-2015 04:47 PM
I am questioning if you are actually getting data from your instrument. Or your instrument isn't actually taking new measurements and is just sending you the last reading it did make.
As far as the File IO, I recommend you learn to use the functions in the File IO palette. You need to create your file before your loop, write to a text file inside, and then close after the loop. I do not thing the Comment input on the express VI will do what you want it to.
03-13-2015 05:02 PM
Hi Mike, thanks for the response.
I'm a little new at this, what do you mean by signal input? Do you mean the part that says "signals" below "write to measurement file" in my picture?
I realized I was actually routing my output string to "comments" of "write to measurement file"... But routing it to "signals" instead doesn't work because signals expects a "dynamic data", apparently.
03-13-2015 05:11 PM
03-16-2015 09:27 AM - edited 03-16-2015 09:30 AM
Hi crossrulz, sorry for the delay in response.
You were right, I wasn't really getting data from my instrument. The meter was on "triggered" mode, so it was basically just returning the last value I had measured, which perfectly explains why I was getting the value for one capacitor even if I switched them. Though I guess that means I was getting data, just no new data.
For future reference, would it be better to have it run continuously, or trigger and measure?
Yeah, you're definitely right about the express VI, the comment field is just for...adding comments. And it really seems like this is the wrong VI to use anyway, like you also said.
thanks!
03-16-2015 10:06 AM
optoelectro wrote:
For future reference, would it be better to have it run continuously, or trigger and measure?
There is nothing wrong with letting it trigger as long as you actually send it the trigger and then wait for the data to become available.
03-16-2015 02:44 PM
Thanks, I got it working, just using the regular Write to spreadsheet file VI!