From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Start and Stop charting with single button

Hi guys,

 

I have only been learning LabView for a couple of weeks, and I seem to be having quite a basic problem here.

 

- I want to be able to start charting on button press, and also stop charting on button press (same button). (However, this principle carries across to any situation where a button must be pressed to activate something.) I have attached the VI that I am working with.

 

In my current setup, if you run the VI, nothing happens. But if you stop the VI, press the switch, then run it, it will chart. I believe this to be because the button is not within a while loop, so the program doesn't know to keep checking the button for status change? I know I can't wrap a while loop around the current block, because the while loop inside the case structure will never complete its iterations - so same problem.

Instead, I tried wrapping a while loop around just the button, then tunnelling across to the case structure... But in this instance, it doesn't seem to pass across the Boolean value to the case structure?

 

I also know I must need to somehow integrate the button with the 'stop' button on the loop but not sure how is the best way to do this? Because currently I have a separate button for Start / Stop and I want only 1 button. I tried wiring this directly to the loop stop switch, but then the loop would run automatically, and only stop on press.

 

I will also need to figure out a way to clear the current chart data 'on stop' but I haven't got to this yet.

 

Any thoughts are appreciated. Thanks

 

0 Kudos
Message 1 of 6
(4,121 Views)

Hi user,

 

I have only been learning LabView for a couple of weeks, and I seem to be having quite a basic problem here.

THINK DATAFLOW!

 

check.png

Everything inside a single loop:

- charting en-/disabled by a switching button

- stopping the loop by a latched button

- clearing the chart history when the loop stops

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(4,101 Views)

Thanks a lot for your quick response!

I have edited my VI, as per your suggestions... Well, as close as I can get... And you have solved some of problems.

 

However I now have a weird issue going on with the chart. It should be plotting every second, but the timestamp seems to be going up in 2's instead of by 1?  Can't figure out why. And also, if I press the stop button to clear the chart (which it does) nothing happens when I press start again, unless I stop running the VI and start again.

 

I have attached the updated VI. Thanks

0 Kudos
Message 3 of 6
(4,071 Views)

Hi user,

 

Can't figure out why.

It's because you mixed up rows and columns in your 2D array…

See attachment!

 

And also, if I press the stop button to clear the chart (which it does) nothing happens when I press start again, unless I stop running the VI and start again.

You need to stop both loops in your VI…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 6
(4,065 Views)

Don't set the waveform offset each time the loop iterates.  You are basically setting the initial time for your first data point to NOW, and pushing all the other datapoints into the future as the waveform chart grows.

 

Just set the offset once when the very first point is plotted.

 

Try combining all of your loops into one.  Having multiple stop buttons is not very user friendly.

 

I would recommend looking at the online LabVIEW tutorials
LabVIEW Introduction Course - Three Hours
LabVIEW Introduction Course - Six Hours

0 Kudos
Message 5 of 6
(4,062 Views)

Ok thank you for the updated version. This solves the problems mentioned.

 

It still has an effect that doesn't seem right though. The way the graph should scale is to always keep the start time on the left hand side, and just squash up the points on the right, until the buffer size is reached. I thought this is what I was achieving with Auto Scaling / Offset / Multiplier?  

 

So if I start charting at 14:36:33 I should always see this time on left, and current time on the right. At one point, this is what I was seeing but somewhere along the way this has been messed up.

 

On second look.. It looks like it is actually displaying it like this, but the time stamp along the bottom is just increasing periodically for some reason?

 

EDIT: 

When I right click > export data to excel - the time stamps are just completely wrong.. I think this must be what RavensFan is referring to! 

0 Kudos
Message 6 of 6
(4,035 Views)