LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

logging rate independant of sampling rate plus other issues

Solved!
Go to solution

Hi there

 

I have just gotten a new NI compact DAQ and am currently trying to get LabVIEW to read from multiple channels on it.

 

In short I have a thermocouple input and a current input on my cDAQ and what I would like to do is read from multiple channels on each module. However what I would like is for the user display to be updated in real time from these readings, while I only want to log (or write to file) all the values at a rate of once per second.

 

at the moment I can either do both at 1 second (which makes the UI look clunky and slow) or I can do both very fast which makes the UI nice, but the log file massive.

 

 

Also I have questions regarding accessing the DAQ channels and whether I need a producer consumer loop if I am only wishing to log every second.

 

First the DAQ:

 

To access my channels I have used the NI DAQmx Create virtual channel VI and wired the required things. Now this works, but I wonder now, how I might modify this to apply certain scales to each of the channels individually. I have 5 pressure sensors with slightly different min and max outputs (calibration data). I thought I could do this by specifying a project task, but it gives errors saying I have duplicate channels or something. Basically each channel needs its own custom scale.

 

Producer/Consumer

 

Do I need to bother with a producer consumer? I thought it a pretty nice way to lay things out, especially with a queue, but really if I am logging once per second, the queue is never really going to have more than 1 thing in it. Besides I end up with an array of pressure measurements and an array of temperature measurements against time and the queue wants a string input. So it doesn work anyway.

 

Is it possible to put a slower loop inside a fast loop to do the logging?

 

Thanks

 

Alex

 

 

0 Kudos
Message 1 of 22
(4,054 Views)

Hi Alex,

 

I've had a read through your post and hopefully I should be able to clear up a few things.

 

Firstly, it is generally good prcatise to use a producer consumer loop if you want to free up the data acquisition task.

 

Secondly, are you using the DAQ Assistant or are you using lower level DAQmx functions? Both otions should allow you to configure your task to read multiple samples from the hardware at once. This can be configured from inisde the DAQ Assistant Dialogue window or by changing the 'samples to read' value of the DAQmx Read function if you are using lower level functions.

 

You must set the data type that you wish the queue to hold by wiring a constant of your intended datatype into the Obtain Queue.vi 'element data type' input.

 

For adding custom scaling to individual DAQ channels it may be easier to apply this afterwards in your consumer loop on a channel by channel basis.

 

If you want to try and implement some of these ideas I would be happy to have a look over the code and see if there are any further suggestions I can make.

 

Best regards,

 

Chris

National Instruments - Tech Support
Message 2 of 22
(4,024 Views)

I am using the lower level DAQmx things

 

I assum that having the virtual channel created and the task start VI's outside the loop is correct? and the read DAQmx VI inside my loop. Seems to work so I assume its right.

 

What I am having problems with is data types I think, and passing data from the producer to the consumer.

 

 

I have two DAQmx virtual channels, one for pressure and one for temperature. These are running side by side. The temerature data is then linked to the front panel via some temperature indicators, the pressure data is linked via similar indicator, but also the last two pressure data streams are subtracted from one another and displayed on a chart. This all works as imagined so far. However the temperature data can be read as a single sample per channel as a DBL, whereas if i want the time information for the chart, I must read the pressure data as single sample per channel 1D waveform (DBL). Thats still fine though as the numeric indicators can handle being fed a waveform. At the moment this loop repeats every 10ms to give the front panel a decent update rate.

 

What I then want to do is somehow bundle all that up (the Pressure wave forms and the temperature numbers) and pass them into a consumer loop where I can perform data logging operations.What I want is to be able to specify the data logging rate here. ie once per second.

 

So i have the producer loop going like the clappers to give me a nice fluid front panel, but I only want to log data say every second. Eventually this will be built up with event structures.

 

 

What I am having trouble with is a) passing the data to the consumer loop and b) timing.

 

for a) I tried to use a queue. I bundled all the data into a cluster and wired it to the enqueue.... I made the queue limit one as well because I only want the data that is present at this instant, I dont need to keep a buffer. But the only way I can wire to the enqueue is if the data type is set to void?... which i dont understand.

 

ill post my VI in due course, but its a bit of a mess right now!

0 Kudos
Message 3 of 22
(4,020 Views)

Hi Alex,

 

You should create a constant from your bundle wire. Wire the constant into the input of Obtain Queue function. This should allow you to pass the cluster of data in. From here you should be able to configure the run times of each loop.

 

If you are sure that you don't want to buffer data then setting the queue size to 1 should be fine. Just remember that you will only get the most recent values at the point of the logging loop iterating.

 

let me know how it goes, it would be interesting to see your code.

 

Regards,

 

Chris

National Instruments - Tech Support
Message 4 of 22
(4,018 Views)

I think usually you'd want to sample at a fast rate and have the queue buffer it up and let the software log it in its own time. But here we basically want a continuous stream of data on the computer screen so we can watch it, but only plucking data to log from it every second.

 

So for the queue I create a queue constant and wire it in? I was right clicking and creating a constant but it just gave an empty purple box

0 Kudos
Message 5 of 22
(4,011 Views)

Is that from clicking on your cluster data type?

 

CG

National Instruments - Tech Support
0 Kudos
Message 6 of 22
(4,009 Views)

oh i see, so I bundle up my stuff into a cluster then make a constant from that cluster and wire that to my queue?

0 Kudos
Message 7 of 22
(3,998 Views)

Exactly! Has that worked?

 

CG

National Instruments - Tech Support
Message 8 of 22
(3,995 Views)

yep that appears to have worked.... will try now to do the block diagram for writing that data to a file.

 

 

Would you recommend going with the Excel VI or the TDMS route?

 

What I have at moment is 10 1d wave forms...... but what I want the log file to look like is:

 

Name

Date

Time

 

Data

 

Time stamp            Ch1     ch2  ch 3     ch4 ......... Ch10

 

 

Thanks for your help so far!

0 Kudos
Message 9 of 22
(3,991 Views)

Hi Alex,

 

You should be fine to use the Write to spreadsheet VI as you wont be writing huge amounts of data. I believe the formatting should work Ok with the write to spreadsheet VI but there is a 'transpose' input on the VI if you need to flip the data. I will be posting my own version of the write to spreadsheet VI on the community later in the week. I have broken out the opening and closing of the file from the loop so that the writing can be done more efficiently. I will post the link on here if you're interested.

 

CG

National Instruments - Tech Support
Message 10 of 22
(3,988 Views)