07-19-2019 04:07 AM
Hi, I am having some trouble getting my waveform chart to plot data while the programme is running, the signal only appears once the code has stopped running. Can anyone advise on this? I've attached the code.
Solved! Go to Solution.
07-19-2019 04:14 AM
Hi ehalpin,
the chart gets new data with each iteration of the while loop.
But it doesn't make (absolutely NO) sense to clear the chart history in each iteration!
Did you read the caveats on the event structure? (I guess no: please do so…)
07-19-2019 04:27 AM
Hi thanks for a quick response!
If i don't include clearing the chart in each iteration, it does display the signal while the code is running but I then have no control over when it stops running.
07-19-2019 04:43 AM
Hi ehalpin,
If i don't include clearing the chart in each iteration, it does display the signal while the code is running
So that was your problem - it is solved now.
but I then have no control over when it stops running.
That doesn't make any sense: moving that property node out of the loop will not change the behaviour of the event case or while loop!
07-19-2019 04:57 AM
This is what's confusing me! Without the clearing inside the loop, the chart runs up to the thousands very quickly, when I only need it to run for t=100.
I have made a lot of codes like this but have never had this problem before.
07-19-2019 05:35 AM - edited 07-19-2019 05:36 AM
Hi ehalpin,
Without the clearing inside the loop, the chart runs up to the thousands very quickly, when I only need it to run for t=100.
Because you programmed it this way!
You create your own buffer array in the shift - and then send the whole buffer to the chart:
In the first iteration the buffer contains 1 row of data, the chart shows one row of data.
In the 2nd iteration the buffer contains 2 rows of data, the chart shows 1+2=3 rows of data.
After 10 iterations the chart already shows 55 rows…
As said before: everything works exactly as you programmed it!
Two options:
07-19-2019 05:45 AM
I see what you mean for where I've gone wrong, I just don't know how to fix it so that it does what I need. Do you have any advice for that?
07-19-2019 06:04 AM
07-19-2019 06:10 AM
You need to read up on the differences between a graph and a chart. GerdW already gave you the solution.
Two options:
- Use a graph instead of a chart.
- Wire the new data directly to the chart.
07-19-2019 06:20 AM
Sorry didn't notice that part of the message!
I've tried using a graph already and it doesn't work with the code. I've just wired the data straight to the chart but that also doesn't work.
I appreciate all the help but it won't work.