LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using the producer/consumer model with GPIB/VISA

Solved!
Go to solution

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!

0 Kudos
Message 1 of 10
(3,842 Views)

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):

 

RWloop.PNG

 

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!

0 Kudos
Message 2 of 10
(3,830 Views)
The first problem is that you aren't sending any data to the file. That's what the signal input is for.

Mike...

Ps: it might help for you to start with a better model. Check the link in my signature. Look for a post about the producer consumer pattern.

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 3 of 10
(3,816 Views)
Divide and conquer is s great tactic...

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 4 of 10
(3,813 Views)
Solution
Accepted by optoelectro

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 10
(3,808 Views)

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.

0 Kudos
Message 6 of 10
(3,799 Views)
On the express VI there is a big terminal labeled Signals with nothing wired to it. For what you are trying to do use the plain file wrote node. That will at least show something getting written to a file.

There are several online tutorials from NI you should probably start with them before going any further.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 7 of 10
(3,792 Views)

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!

0 Kudos
Message 8 of 10
(3,731 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 9 of 10
(3,721 Views)

Thanks, I got it working, just using the regular Write to spreadsheet file VI!

0 Kudos
Message 10 of 10
(3,702 Views)