LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

RS232 communication with LabView

In the vi I attached earlier, I assigned the text file where I needed to save and selected 'end' in the set file position option. It still saves just a single value. Do I need to do any change in the vi back/front panel ?

 

Thank you,

 

vzv

0 Kudos
Message 11 of 43
(2,121 Views)

You problem is you are setting the file position AFTER write to the file.  You need to open, set position to end, write, and close.


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 12 of 43
(2,115 Views)

And don't use Run Continuously.  Use a while loop around the code that needs to continue to run, with a stop button control to stop the while loop.  Right now you are forced to use the abort button which is not a good idea.  It will leave your com port hanging open.

 

1.  Open the com port and the file before the loop.

2.  Read the com port and write to the file in the loop.. 

3.  Close the com port and the file after the loop.

Message 13 of 43
(2,110 Views)

I have modified my VI as per your suggestion. I still have only one data on my file. Can you have a look at the attached VI and let me know where I might have gone wrong.

 

Thank you,

 

vzv

0 Kudos
Message 14 of 43
(2,103 Views)

1.  You aren't saving the data.  Your Write to Text File should be inside of your loop where you read that data.  What you currently have for the Write to Text File should really be Create/Open/Replace File with the operation set to Open.

2.  When you set the file position, set the enum to "End" (and change it to a constant).


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 15 of 43
(2,097 Views)

@RavensFan wrote:

And don't use Run Continuously.  Use a while loop around the code that needs to continue to run, with a stop button control to stop the while loop.  Right now you are forced to use the abort button which is not a good idea.  It will leave your com port hanging open.

 

1.  Open the com port and the file before the loop.

2.  Read the com port and write to the file in the loop.. 

3.  Close the com port and the file after the loop.


Nothing more embarrassing than leaving your com port open.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 16 of 43
(2,088 Views)

I worked a little bit since I attached my last vi file on the grounds you suggested and I think its working like I intended it to. It is able to store multiple values in the text file. Can you have a look at this newly attached VI and the output file. Also how could I attach a time value to this data. The one in the text file shows a reading for every 5 sec. Is there a way I can incorporate this info with the data I obtain?

 

Thank you,

 

vzv

 

Download All
0 Kudos
Message 17 of 43
(2,085 Views)

Let me say this again.  SET THE FILE POSITION AFTER OPENING IT BUT BEFORE WRITING.  In other words, put the Set File Position outside of the while loop immediately after opening the file.  And be sure to wire your file reference through in the false case of the read case structure.


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
Message 18 of 43
(2,078 Views)

Hi Crossrulz

Thanks for your input. I have attached the VI modifying on your suggestion. It doesn't show any error. Can you see and tell me whether I did it right?

 

I am a novice with programming and this is my first. Kindly ignore any stupidity I do.

 

vzv

0 Kudos
Message 19 of 43
(2,067 Views)

vzv,

 

I see only one mistake, one which crossrulz already mentioned in an earlier post: You need to wire the file reference through the False case of the Read case structure.  If you run the program and set the Read button to False before hitting the Stop button, the file will not be closed. The reason is that the output tunnle has a small white dot at the center. This indicates that the tunnel is set to Use Default if Unwired. The Default value is no path or at least not the correct path for the file you have opened.  Generally the use of Use Default if Unwired is not a good idea unless you have a specific reason for doing so.

 

The other issue is cosmetic only. It is much easier to read, understand, and troubleshoot a program if the wires are as straight as is practical and definitely not hidden behind other objects.  See below for a nicer way to wire the file reference.

 

Straight wires.png

 

Lynn

Message 20 of 43
(2,059 Views)