LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

real-time graph

Hello everyone,
 
I have a question concerning real-time graph. The vi I've attached generate a pulse train and acquire simutaneously a signal from an analog sensor. As you can see on the vi, I want to plot the signal from the sensor. However, I was wondering what would be the simplest way to plot the signal in real-time? 
 
With the DAQmx timing sub vi I'm using, I need to put the following inputs: sample rate and sample/channel. The sample/channel is calculated the following way: (number of pulses) / (frequency of the pulses) * (sample rate of the analog sensor). If I want to do a real-time graph, and my "sample/channel" is 1000 for example, do I need to use a while loop with 10 iterations max, and put into the DAQmx timing sub vi, 100 in "sample/channel"? Is this a simple solution?
 
Thanks a lot    
 
 
 
Marc
0 Kudos
Message 1 of 9
(10,080 Views)
 
0 Kudos
Message 2 of 9
(10,076 Views)
Hello,
 
I've made some tests with the method I talked previously. The only problem, is that the data plotted on the graph is real-time but it's erased at every loop. How do I store them in a sort of buffer, so all the data would be shown on the graph. Thanks
 
Marc
 
0 Kudos
Message 3 of 9
(10,075 Views)
That would be the job of a shift register. I have attached an example of how you would do this. I'm not sure what the best way to do this for a 1D array of waveforms is, but if you're only using a single channel then I don't think you particularly need multiple waveforms anyway.

Using Build Array in a While loop is actually a big no-no, and you should have the loop replace values in a pre-initialized array instead, but this should get you started.
0 Kudos
Message 4 of 9
(10,065 Views)

Hello,

 

I have some problem with the vi you gave me.

To check if it worked, I connected the output of my counter timer into the analog channel. I also change in the "DAQmx read" vi, the form of the data from a 1D DBL to a waveform. What happen is that, when I run the vi, the data on the graph is 0 all the time, even if I have a sample rate of 100 Hz while the frequency of the pulse from my counter is 1 Hz. Is it possible that the only data that the graph sees is the 0 from the initialized array?

Thanks

Marc

 

 

0 Kudos
Message 5 of 9
(10,032 Views)

Perhaps I was not clear: that VI will not work if you change the output of the DAQmx read to a wavform.

A waveform is really just a 1D array of data with a timestamp and a dT value (that is, the amount of time elapsed between data points).  If I am not mistaken, neither the timestamp nor the dT value is necessary in this particular case.  I suppose if you really wanted to, you could store an array of waveforms in the shift register and use Build Array to append a waveform to the array each time the loop executes, but that would be even messier than what's in there now.

Does the VI not behave properly if you leave the output as a 1D array of doubles?

0 Kudos
Message 6 of 9
(10,027 Views)

Hello,

 

Thanks a lot. It finally works. I just found what were the problems: 1) i didn't click on autoscale x and 2) waveform use seconds on the x-axis while 1D DBL used milliseconds.

What I did, is that when I used the waveform, I put the x axis from 0 to 10, without any autoscale. So when I changed to 1D DBL with still the x-axis from 0-10 and without autoscale, I wasn't seeing my pulse. I was seing only a part of my first pulse. Right now, I changed my axis and putted the autoscale x. Everything works fine now. I'm probably not the first one having being bug by so little (not to say stupid) things!!!  

Thanks again. It's really appreciated.

 Marc

0 Kudos
Message 7 of 9
(10,020 Views)

Hello everyone,

 

I have a question concerning real-time graph too. The VI (3 different versions)  i attached sends instructions through GPIB to a keithley 230 voltage source  that operates a circuit and then measures  the generated voltage with a NI6221. I have a couple of problems. One is that i can't get it to show the graph in realtimeand the other is that i want to use the card's on board counters to know when each measurement started and finished (since it takes some time to go through the loop and check and those few ms are crucial to my measurements. Unfortunately i can't find a way to do either of the.

 

Thanks a lot,

 

Kypros

0 Kudos
Message 8 of 9
(8,282 Views)

Hi kypros,

 

I'm slightly confused as to what exactly you are trying to display regarding the x-axis. Are you trying to display the time that each sample is taken? If so, it would probably be easier if you chose to do Analog Wfm 1Chan NSamp instead of Analog 1D DBL 1Chan NSamp. This will output a waveform data type, which will still include the 1D DBL array as well as timestamping information (t0 and dt).

 

I also see a few things in your code that could be improved. For example, why are you converting a 2D DBL array to Dynamic Data and then from Dynamic Data to a 1D DBL array? Also, why are you doing a For Loop with a constant value of 1 wired to the N terminal? Also, you may want to give some thought to using a State Machine architecture as opposed to a stacked sequence structure. It tends to be easier to read and follow.

 

Aaron P

National Instruments

Applications Engineer

http://www.ni.com/support

0 Kudos
Message 9 of 9
(8,224 Views)