LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

GPIB data into text file

I have a simple data retrieval program and I am having difficulty in logging all the data into a text file. It does work but I only get one string of data. 

It is set to loop and retrieve data a set number of times at a set rate but the resultant read buffer and file only show one string?

Any ideas where i am going wrong?

Should the file be a different type? I would prefer t use an excel file but not sure on the data conversion.

 

Regards

 

0 Kudos
Message 1 of 20
(1,336 Views)

Hi Compolitus,

 


@Compolitus wrote:

I have a simple data retrieval program and I am having difficulty in logging all the data into a text file. It does work but I only get one string of data. 

It is set to loop and retrieve data a set number of times at a set rate but the resultant read buffer and file only show one string?

Any ideas where i am going wrong?


So there is a problem in your VI when it overwrites the text file instead of appending new data at the end.

As you decided not to attach your VI you need to debug on your own!

(Suggestion: append the new data at the end of the file instead of overwriting the file again and again.)

 

Next try:

There is a problem in your VI when it only keeps one string in the loop, but does not build an array of strings.

As you decided not to attach your VI you need to debug on your own!

(Suggestion: build an array of strings in the loop instead of keeping the last string.)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 20
(1,334 Views)

Without seeing your code we can only guess what you have done wrong.

 

I am guessing you are only saving the first or last measurement.

 

Why not save every measurement right after you take them?

 

If writing to disk is causing too long of a delay then use a producer/consumer architecture.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 3 of 20
(1,319 Views)

 

Hi GerdW

 

Wow that was a quick response, Thank you.

 

I have attached screenshots

 

Data read 2.PNG

 

Data read 1.PNG

Basically an initial wait time and then a selected number of data strings collected at set intervals. Above all works fine but the results in the file are always just one string.

Basically what I need next is a trigger from a "greater than zero" GPIB reading to start the initial wait time (1000ms) and then read in set number of strings (Numeric 2) at the selected repeat rate (milliseconds to wait) time. The results to be stored in the named text or preferably, Excel file.

it sounds easy enough but I am a complete novice here!

 

regards

 

Trevor

0 Kudos
Message 4 of 20
(1,314 Views)

Oh where do I begin....

 

  1. You are opening and closing your VISA session on every loop iteration
    1. Open your VISA session 
    2. Enter your acquisition loop
    3. Acquire and save data until done
    4. Exit acquisition loop
    5. Close your Visa session
  2. You are overwriting your data file on every loop iteration
    1. Open your data file
    2. Enter your acquisition loop
    3. Acquire and save data until done
    4. Exit acquisition loop
    5. Close your data file

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 5 of 20
(1,283 Views)

Hi RTSLVU

 

Thanks for that.

 

Any chance of a block diagram to make it easier for me?

 

If not, I will try to sort it myself. Ive got this far!

 

regards and thank you

 

Trevor

 

 

 

0 Kudos
Message 6 of 20
(1,277 Views)

Hi Trevor,

 

when you would attach a VI instead of a plain image we would be able to edit your VI.

As you attached only an image you need to edit the VI on your own - which is a good training for you! 😄

(Did I already mention in my first message you forgot to "attach your VI"?)

 

Examine the example VIs, which come with LabVIEW. None of them is opening an closing files or VISA references with each iteration of a loop…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 20
(1,255 Views)

Hi RTSLVU

 

I tried but still only get one reading stored!!

 

I  have attached the VI file

 

Any chance of putting the controls in the right place for me

 

Sorry to ask but would be grateful for any help.

 

Trevor

 

0 Kudos
Message 8 of 20
(1,208 Views)

Hi GerdW

 

I have attached the file in my last post.

 

regards

 

Trevor

0 Kudos
Message 9 of 20
(1,200 Views)

Hi Trevor,

 


@Compolitus wrote:

I have attached the file in my last post.


Yes, I noticed. Unfortunately I cannot open your VI right now (see my signature line).

Maybe you could attach a version downconverted to LV2017?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 20
(1,197 Views)