From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, 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: 

Need Help separating waveform graph rate and logging rate

Solved!
Go to solution

I've created 10 channels for transducer and flowmeter inputs using a simulated PXIe-6361. I want to display the reading on a waveform graph. I also want to add the option to start data logging whenever the user chooses at a selected rate. I can't seem to keep the waveform graph sample rate and the logging data rate separate. When I try to split the task into two separate loops, the program doesn't work as intended. I've looked at the examples and browsed the forums and it got me pretty far but now I'm stuck!

 

The main issues are:

1) I want to be able to display and change rate of the data that shows in the waveform graph.

2) I want an option (button) to enable data logging (TDMS) at a user selected rate whenever they choose.

 

Any help is appreciated!

0 Kudos
Message 1 of 4
(1,765 Views)
Solution
Accepted by topic author osharifi

Hi osharifi,

 

the first I saw after opening the block diagram is this code:

Why are there 2 different terminals, both labelled "Logging"? (Would you create code in a text-based language with two variables named exactly the same?)

Why is there a local variable "Logging" right next to the terminal of its control? Why don't you use more wire?

Why do you need 4 different LED indicators to show the logging state???

 

After that I started to scroll around and realized: the block diagram is huge! And it's peppered with local variables: ever heard of "THINK DATAFLOW!"?

 


@osharifi wrote:

I can't seem to keep the waveform graph sample rate and the logging data rate separate. When I try to split the task into two separate loops, the program doesn't work as intended.


You cannot do, what you are trying to do in your VI:

- splitting the DAQmx task reference to be used in two parallel loops, both reading from that task

- additionally trying to change the sample rate of this single DAQmx task in both loops…

A DAQmx task is (kind of) a shared resource, you cannot operate on that resource in parallel!!!

 

The simple solution is to create a proper producer-consumer scheme:

  • one producer containing the DAQmx part, reading the data into a queue and a notifier
  • one consumer displaying the data from your queue
  • another consumer reading the data from notifier and saving to file at an arbitrary rate…

(Even simpler (+quick&dirty) would be to display the data in the producer loop in a graph and read from a local variable of that graph in your file saving loop…)

Best regards,
GerdW


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

Thanks, GerdW!

 

I used the four LEDs to show logging state on all tabs. Moving the one LED on top of the tab control created some weird black lines around the LED which didn't look good. 

 

I'm not too familiar with the Producer-Consumer architecture so I have one question: Will the Producer and Consumer each have sample clocks in them?

0 Kudos
Message 3 of 4
(1,717 Views)
Solution
Accepted by topic author osharifi

FYI the weird black lines that you see mean the control or indicator is floating (not connected to the tab control or what every you are floating over). Secondly if you run the application the black line will go away and no one will be able to see that this is a floating control or initiator.

Tim
GHSP
0 Kudos
Message 4 of 4
(1,706 Views)