LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Storing Data from Serial Connection

Solved!
Go to solution

Hello All,

 

I am fairly new to LabView, I am trying to store and anaylze values from a non-Labview hardware via an rs-232 connection.

 

I have two devices on COM1 and COM2 ports. COM2 sends a value which I would like to store in an array. COM 2 points will form a somewhat sine wave within a few seconds. I would like to compare these values live to generate: max and min peak values, peak to peak values, and mean (I know LabView has signal icons for this, I'm just not sure how to wire it up).

 

I have attached the vi.

 

Thank you for your time and help.

 

Kelvin R.

0 Kudos
Message 1 of 6
(2,549 Views)

Sounds like you need to put your read into a loop.  That way you continuously read.

 

What is the format that comes back?  Does the box you are reading from use the termination character?


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 2 of 6
(2,496 Views)

I am continuosly reading. I wrote to the meter a code function (the meter hast its own code for different functions) that displays the current reading (updated every ~<10ms). The problem I'm having is not being able to store these strings values (which I convert to numbers) to give me a peak to peak reading, or max and min values. I am using "array max and min" but it's always displaying the current reading on both boxes.

 

I believe I need to use a for loop along with shift registers, but I just don't know how to.

 

To answer your questions: 1) these string values are convert to integers, 2) no, termination character is not used.

 

Thanks.

0 Kudos
Message 3 of 6
(2,491 Views)

kore101 wrote:I believe I need to use a for loop along with shift registers, but I just don't know how to.

LabVIEW Basics
LabVIEW 101


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 4 of 6
(2,476 Views)

I am not 100% sure that that is the route I have to go. I have already tried checking out the information tutorials, but I cannot find anything that explains how to properly store values from a serial connection.

0 Kudos
Message 5 of 6
(2,471 Views)
Solution
Accepted by topic author kore101

The serial connection is irrelevant. What you need to learn is something as basic as a while loop and shift register. If you want to do a continuous write and read, then place a while loop around the VISA Writes and VISA Reads. Using the Run Continuous button is wrong. That is a special debug mode. The shift register can be something as simple as a Build Array where you append a new value each iteration.

 

Eliminate those case statements if you are always going to do something. You have configured the serial ports to terminate the read on a termination character so using the VISA Bytes at Serial Port is wrong. 

 

Before posting again, run the VI so that there is actual data in all controls and indicators. Go to Edit>Make Current Values Default, save the VI, and attach it.

 

 

Message 6 of 6
(2,462 Views)