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.

Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

I save 2 voltage mesurments for eachc cicle of execution

Solved!
Go to solution

I m using USB-6008 for doing some test and I have some problem.

PROBLEM 1

When I tried to save some data that i adquired with the DAQ, it saves 3 values, the namber of the iteration, and 2 values of diferent voltages for each iteration of the bucle that I have used (I tried while and timed while), I have that problem when I tried to use a timed loop with a signal generation with diferents times of execution, but In this case I don't know where I have failed. Also I have another problem.

PROBLEM 2

When I tried to execute a program where I try to generate a signal, and at the same time to read it with an analogi terminal, sometimes the generator sends ha signal but the analog port waits many seconds befor start to read.

How I could solve my problem? Thanks in advance!

 

 

Download All
0 Kudos
Message 1 of 9
(3,295 Views)

Hi,

 

Problem 1:

Since you are programing in Windows, Timed Loop has no effect, instead, use the normal While loop.

Second, why read 1 sample only ? Why not more samples ? You are sampling at 1 kHz, then , why not reading e.g. 100 samples ?

Third, it is not a good idea to use Express VIs, but any way, even using Express VIs you must not write to the text file in each iteration of the loop. You should acquire samples, and then, after some time (or when finished), save those samples to the text file.

Attached VI which saves data to Excel after you have finished reading. You have to change the Channel Settings for your app.

Change the VI as you want but you got the idea..

 

Problem 2:

We can not know without seeing the code. Anyway, try the example I attach called "AI and AO". You then modify it as you want.. but just shows an example.

 

 

Download All
0 Kudos
Message 2 of 9
(3,230 Views)

CataM wrote: you must not write to the text file in each iteration of the loop. You should acquire samples, and then, after some time (or when finished), save those samples to the text file.

Or use a Producer/Consumer, which just moves the writing to the file into a parallel loop.  This way the writing to the file will not affect the timing of the acquisition.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 9
(3,225 Views)

First of all I aprecciate the help.

I have tried to follow your advice and put the subVi of write to file out of the while loop, but it still read 2 values for every iteration, and I think is because the configuration of the device because, if I say that is a 1 chanel multiple samples it gives my and the next error:

Possible reason(s):

"Read cannot be performed because this version of DAQmx Read only returns data from a single channel, and there are multiple channels in the task.

Use the multichannel version of DAQmx Read.

Number of Channels in Task: 2
Number of Channels in Data: 1"

 

I think it's is for my hardware, when i configure the instrument as an 1 sample (on demand) in 1 chanel, at mesurament and automation, when i try tu use with this configuration at labview allways says that the number of chanels in task are 2 and chanels in data is 1, for this reaons every iteration read 2 chanels, due the task, but i don't know how i an configure the DAQ for a 1 chanel 1 sample in continuos mode of read.

I have read bools where are the code and examples but it don't work for my DAQ (6008). I think I would become crazy XD.

Thanks in advance.!!

 

0 Kudos
Message 4 of 9
(3,192 Views)

Should I buy a beter DAQlike 6001?

Thanks!

0 Kudos
Message 5 of 9
(3,190 Views)
Solution
Accepted by topic author RafaelExposito

I have tried to follow your advice and put the subVi of write to file out of the while loop, but it still read 2 values for every iteration, and I think is because the configuration of the device


Yes, we know that will happen if you have your DAQmx Read.vi configured to read 1 sample every iteration (1 sample from each channel).

 

[...] if I say that is a 1 chanel multiple samples it gives my and the next error:

Possible reason(s):

"Read cannot be performed because this version of DAQmx Read only returns data from a single channel, and there are multiple channels in the task.
[...]

 


That is because you have implemented the code exactly as I have showed you with 1 Channel N Samp but you still let the DAQmx Create Virtual Channel reading from 2 channels. That is why I have said that gives you the idea but what I have showed you is NOT what you want, you need to change my code to perform what you want, so, you need to change DAQmx Read to N Channels, N Samp.

 


I think it's is for my hardware


No, it is not.

 


 


but i don't know how i an configure the DAQ for a 1 chanel 1 sample in continuos mode of read.

See picture attached.

If the physical channel is "Dev1/ai0, Dev1/ai3, Dev1/a5", you are reading channel 0,3 and 5.

 

Should I buy a beter DAQlike 6001?

No.

0 Kudos
Message 6 of 9
(3,188 Views)

Dear CataM

I have just chequed your program. it's wonderful and also I think I have found where lie the problem. To solve it i just eliminate the task and the configuration of the Daqread.vi, and it's work. I think that when i configure it whit the mesurament and automation explorer it genearte some problems. When I eliminate the Task, the DAQ read as I want...but i still don't know how i could generate a task who it would work with your configuration.

I apreciate your help,

Sincerly yours.

0 Kudos
Message 7 of 9
(3,175 Views)

 


[...] but i still don't know how i could generate a task who it would work with your configuration.

I do not understand that. What do you mean by generating a "task" which would work with my configuration ?

You just have to adapt the VIs shown for your application...

Message 8 of 9
(3,165 Views)

I am so sorry. I am new in these world. I thought that you need to create some task to work with labview annd DAQ but it don't need it. You only has to use the DAQmx subVI to configure and use your DAQ. Tey are "diferent" concepts as far I know, but conected.

Also I have proved the file that you give to me, awsome. I have change the parameters and its works.

Merci for help. I will try to read more about task.

Than you very much!

0 Kudos
Message 9 of 9
(3,159 Views)