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: 

Eje X con tiempo y fecha actual en un chart

Solved!
Go to solution

Buenas amigos, tengo la siguiente duda del VI adjuntado:

 

Con el chart "nivel de tanques" estoy ploteando cada 100 ms (Promedio de niveles (10 muestras) y Ploteo niveles y salida controlador). Los datos se obtienen cada 10 ms (Obtención de los niveles de los tanques). Debido a esta diferencia lo que hice fue un promedio de las 10 muestras en 100 ms y plotear eso. Sin embargo, la escala del tiempo, aunque tiene la fecha y hora correcta se pasa a una velocidad mayor a 1 segundo. Si graficara directamente en los datos dinámicos, es decir, donde obtengo los niveles de los datos si se plotea correctamente. Pongo entre paréntisis los comentarios que aparecen en el diagrama de bloques para que se logren ubicar (específicamente en los dos primeros whiles de arriba hacia abajo).

 

 

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

Hi friends, I have the following question of the VI attached:   With the "tank level" chart I am plotting every 100 ms (Average levels (10 samples) and Plot levels and controller output). The data is obtained every 10 ms (Obtaining the levels of the tanks). Due to this difference what I did was an average of the 10 samples in 100 ms and plot that. However, the time scale, although it has the correct date and time, is passed at a speed greater than 1 second. If I plot directly on the dynamic data, that is, where I get the levels of the data if plotted correctly. I put the comments that appear in the block diagram in order to locate them (specifically in the first two whiles from top to bottom).

0 Kudos
Message 2 of 6
(2,649 Views)
Solution
Accepted by topic author Juanma96

Hi Juan,

 

you also need to set the XScale.Multiplier when yu write to the chart with 10Hz rate instead of just 1Hz!

 

Charts only count the number of samples and use this counter for the x axis (unless you use waveforms and enable the timestamps of those waveforms)…

 

On your VI: do you really need so many loops with so many local variables?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 6
(2,619 Views)

Yes i try that, but I used 1k instead of 10k, but thats it, its solved. 

 

Answering to your question: it's depends. I need to get the data each 10 ms, plot each 100 ms, and save the data with a time given by the user. So, i think that i need at least 3 loops for that. Now, for example, i am using one loop fot getting the data and another one for the controller, both working each 10 ms. So in that case i could use just one loop! That will make my program better?

 

The other question is why so many local variables: Like i told you i get tha data each 10 ms, but i want to plot it each 100 ms. So i create a loop just for get the average of the 10 samples in 100 ms. The only way that i know to use the data on the loop of 10 ms in the one of 100 ms, is with local variables. I tryed with tunnes but something didn't work.

 

 

Thank you so much for your help and i will aprecciate any advice you can give to me!

 

 

0 Kudos
Message 4 of 6
(2,613 Views)

Hi Juan,

 

I need to get the data each 10 ms, plot each 100 ms

Set your DAQAssistent to read 10 samples with 100Hz samplerate and calculate the average of those 10 samples (per channel) for plotting. All within one loop, with basically just 2 functions…

Btw. I want to suggest to get rid of the DAQAssistent and use plain DAQmx functions.

 

The only way that i know to use the data on the loop of 10 ms in the one of 100 ms, is with local variables. I tryed with tunnes but something didn't work.

You could use queues to build a producer-consumer-scheme.

LabVIEW comes with example VIs and projects explaining such basic designs (like state machines and producer-consumer)!

Best regards,
GerdW


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

Set your DAQAssistent to read 10 samples with 100Hz samplerate and calculate the average of those 10 samples (per channel) for plotting. All within one loop, with basically just 2 functions…

 

It sounds good! But i can´t see the difference between that and what i am doing. I also will another loop to calculate the average of the samples acording to the time given by the user for save the data right?

0 Kudos
Message 6 of 6
(2,599 Views)