11-18-2008 06:23 AM
Hi,
I'm getting data from a precision thermometer and want to save it in a 2d array. The problem is that the thermometer has a sample rate of approx. 1Hz. This means that I have for each of my 12 channels only one value each 12 seconds. So I'm getting data every single second for a different channel. In the mean while the value is 0. Therefore, my 2d array looks something like in the attachment.
Is there a way to delete all the zeros? I've tried using a for loop in combination with the search 1d array function but I couldn't really figure out how to convert it back into a 2d array. Any suggestions?
Thanks,
David
11-18-2008 07:18 AM - edited 11-18-2008 07:18 AM
Hi David,
to use a loop sounds great, but don´t delete in it. Sort out the values you need. I think it should also be possible to do it while record the data. You can store an index for every channel and write the new value by channel and index into an initialized array.
Mike
11-18-2008 07:40 AM
11-18-2008 08:06 AM
Hi Mike, hi Wiebe, thanks for the quick response.
@ Mike: I don't really know what you mean. How am i supposed to store all the indices and then delete the values later? And even if, there is still the problem with converting it back into a 2d array.
@ Wiebe: What you described is excactly what i did. The only problem with that solution though is that you cannot wire a 2d array through a shift register and then try to use the search 1d array function. Since I'm only able to search a 1d array I have to use another way to get the zeros out. I was able to so with a for loop. But then I had the problem to convert it back into a 2d array.
Is there maybe a way to directly search in a 2d array?
Thanks,
David
11-18-2008 08:24 AM
11-18-2008 08:40 AM
11-18-2008 08:56 AM
Yeah, just give a pic of your block diagram, at least of the loop in question; someone might be able to clean it up for you. You can just copy your block diagram, or just parts of it (be sure the wires are highlighted too) and paste it in MSpaint, or some other simple paint program. Or, hit the Print Screen button on your keyboard to copy what you see on your screen, then open up a paint program to paste the image.
But yes, it seems that the way you have constructed your loop(s) is your problem. So, am I correct in saying that you have 12 channels recording temperature, and once every second a channel records its temp, but the others output zero since you're only recording one at a time? How did you set up the task? I mean, there should be no reason why you couldn't record all simultaneously, unless you've created separate tasks for each channel? I am not sure what hardware you have, but I am assuming you can create new NI-DAQmx tasks. If that's the case, then open up the Measurement and Automation Explorer, right-click on Data Neighbourhood, and select 'Create new...', and select NI-DAQmx Task. Go through the options... input temperature, etc. Now add all 12 channels in the same task. Set the acquisition rate and then numer of samples, and set the mode; all of these options can be specified using property nodes in the program too. Going to your block diagram, you can place a Task Constant, and select the task you just created in it, and use the other Measurement I/O VIs to read from your hardware. I have explained all this because I ran into problems before when I neglected to put multiple channels in the same task; there were conflicts because Labview will not allow two or more input, or two+ output tasks to run at the same time (although an input and output task can run side-by-side).
I hope that helps, and again, send out a pic of your block diagram so someone can perhaps help simplify the task.
Cheers,
Dan
11-18-2008 08:57 AM
Here is the VI.
I'm using instrument drivers for the precision thermometer so I kind of have to take the data how I get it. I tried already first deleting the zeros in the 1d array and then building a 2d array but since the values are slightly shifted each time I won't have the channels in the right order anymore.
11-18-2008 09:06 AM
Hey Dan,
that's correct. I have 12 channels and each second I get the value of one of these channels. Unfortunately, I am physically restricted by the sample rate of approx. 1Hz. Since the thermometer is a high precision thermometer there is no way of increasing the sample rate. The thermometer is connected through the seriell port of my computer. Hence, I have to take the data how I get it. The only solution I see is to delete these 11 zeros I get every second since I cannot change the way of how I get my data.
11-18-2008 09:27 AM
Hi David112,
can you show the DDM1000_DAQ.vi? I think you should delete the zeros there.
Mike