LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW Case Structure Usage

I am attempting to write a VI that will collect data from an Arduino and print it onto an XY graph. The Arduino is collecting data from two sources to use as the x and y coordinates for the graph.  However, I want the VI to be repeatable in the sense that the data that the Arduino reads will go from 0-100 on the X-axis and then go back down to 0 or a negative value which is what I want the indicator to be to move on to the next case. Ideally I would like this to happen 3 times so I would have the initial start and two resets which would result in three graphs with varying y-values. 

 

I also am trying to save the data from the Arduino into a text/excel file and have it separated into three individual columns or three individual files. Is it possible to set up a single write to text file for the three sets of data or would it be possible to have one continuous write to text file and parse the data later?

 

I've also been attempting to create a default case, as I am using an Enumerator to allow for case selection, to designate that a new case has not been chosen as I would like to invalidate whatever Case has already been used. How would I go about that.

 

Sorry for all the questions. I have included the VI I have been working on and would love any input or advice. Thank you!

0 Kudos
Message 1 of 15
(488 Views)

Building an array with one element from a scalar is not useful.

If you want a case that is not one of the four enum values, create an enum with one more item, e.g. "do nothing".

If you have a popup in case 0, you cannot select a new item while the dialog is active. Catch 22.

Why not graph everything on one xy graph? You probably don't need the express VI, just accumulate the data in a shift register.

Do you really want wo write to three different files?

I doubt you need three visa reads.

Why do you write the entire growing string from scratch to the file. Wouldn't it make more sense to open the file once and just append the new data?

 

I recommend to do a few more of the simple tutorials.

0 Kudos
Message 2 of 15
(455 Views)

You love zig-zag wires.

I hate zig-zag wires.

0 Kudos
Message 3 of 15
(414 Views)

Since I don't have your instruments, here's a quick simulation how you could handle the xy graph data so each scan (up or down) has its own plot on the same graph. Maybe it can give you some ideas....

 

 

altenbach_0-1710785401213.png

 

Message 4 of 15
(379 Views)

This is almost exactly what I am looking for!!! With multiple plots, instead of shifting it up and down, could I overlay them on top of one another in the different colors that you have shown by removing the boolean up? Actually, how did you bound them to a single unit in the y-axis as I am noticing that each graph is bounded by 1 "NewtonMeters"?

 

I have included images of the XY graph with the data plotted. The idea with the multiple graphs was to be able to compare them as the same test would be ran multiple times and to see how similar the graphs are to one another.

0 Kudos
Message 5 of 15
(354 Views)

My simulation uses random numbers between zero and one offset by the state. You would graph your raw data instead.

0 Kudos
Message 6 of 15
(336 Views)

I adjusted the code and added a few questions. Thank you for all the help!

 

I've also included the Arduino code that I'm using to show how the microcontroller is reading the data.

Download All
0 Kudos
Message 7 of 15
(311 Views)

Sorry, I can't open your Vi at the moment. Always consider "save for previous", LabVIEW 2020 or ealier, before attaching.

 

Instead of showing the arduino docs, simply include a few typical message strings as received.

0 Kudos
Message 8 of 15
(302 Views)

1. No need for the wait in the VI since the communications from the Arduino will limit the loop rate.

2. The Scan From String can handle multiple outputs.  Set the format to "%f %f" and extend the node to have 2 outputs.

3. You really should not be constantly opening and closing the log file inside of the loop.  Open/Create the file before the loop and close it after the loop.  Inside the loop, you can just write the string coming straight from the VISA Read.  There is no need for the Feedback Node and Concatenate Strings.

4. What is controlling the potentiometer?  I'm failing to understand how your VI is to know which way the pot is moving.  Your additions on previous data and the current data really makes no sense to me.

 

Attached is how I would clean up what you have right now.  Hopefully this clears some things up.  It is saved in LabVIEW 2019 so Altenbach can tell me everything I did wrong.


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 9 of 15
(287 Views)

@crossrulz wrote:

Attached is how I would clean up what you have right now.  Hopefully this clears some things up.  It is saved in LabVIEW 2019 so Altenbach can tell me everything I did wrong.


You are a much better serial programmer than me so I would never dare to question your code. 😄

 


@crossrulz wrote:

4. What is controlling the potentiometer?  I'm failing to understand how your VI is to know which way the pot is moving.  Your additions on previous data and the current data really makes no sense to me.


We can of course use a feedback node to compare current to previous pot reading and determine the sign of the first derivative. Might need some soft filtering depending on noise. Is the pot a manual control? Does it have hard stops at 0 and 100? What should happen if the user does not turn the other way after reaching 100? What should happen if the user turns it the other way at 50 already? Is it controlled by some ramp from another instrument? Please explain in detail the entire experimental setup.

 

0 Kudos
Message 10 of 15
(279 Views)