Discussion:
digital output to switch external hardware
(too old to reply)
BMEstudent
2008-08-04 19:40:06 UTC
Permalink
hello all
 
I am having trouble with error 200077 at a DAQ assistant.  I am trying to output a signal of boolean values (skinny blue wire) but will not "go through" the DAQ board. I see a chart on the front panel that is constantly being updated throughout running the signal processing when the DAQ assistant is not wired into the vi.  Initially I would just like to see that chart on an oscilloscope with relation to the original signal. Eventually, I want to trigger a mechanical ventilator with the signal.  i'll post the vi, just in case that is helpfl to anyone.
 
thanks in advance,
 
pmnMessage Edited by BMEstudent on 08-04-2008 02:29 PM


Version_8_4_2008_DAQoutput.vi:
http://forums.ni.com/attachments/ni/170/346447/1/Version_8_4_2008_DAQoutput.vi
mickeyw
2008-08-05 09:40:06 UTC
Permalink
Hi,
After replicating the problem, you are getting the error at the daq assistant 2 because you are only reading 1 number into the data input. This is because you have specified waveform timing as the source of number of samples and sampling rate. You need to specify some sampling and timing information for this input, as the least number of samples it can read in is 2.This can be done by either double-clicking the daq assistant 2 VI and unchecking "Use waveform timing" next to generation mode, or specifying 1 sample on demand.
As another point, on the daq assistant on the left hand side of your application, you have specified samples of 10K per second, but you are only actually reading 40 of them at a time. This number should be increased in order to keep up.
If you check out this&nbsp;<a href="http://digital.ni.com/public.nsf/allkb/FBCFE9C00758737686256F3E007F8E91?OpenDocument" target="_blank">KB</a>&nbsp;if should give you more information on that specific error code.
Regards,
Mike
BMEstudent
2008-08-05 14:10:05 UTC
Permalink
hi Mike
&nbsp;
I was just playing around with your suggestions and they helped greatly.
&nbsp;
As for your comments about the sampling rate and samples specified for the assistant on the left hand side, I still am confused.&nbsp; I thought that the assistant was taking forty samples AT 10kHz.&nbsp; in other words forty sample&nbsp;arrays every tenth of a millisecond.&nbsp; Is this incorrect? You seem to be saying that the two values do not match up but my understanding is that they have no affect on one another.
&nbsp;
Thank you for your help, in any case.
&nbsp;
PMNMessage Edited by BMEstudent on 08-05-2008 08:44 AM
mickeyw
2008-08-05 15:40:05 UTC
Permalink
From my understanding, you are under the impression that 40 samples at a frequency of 10K is equivilent to 400000 samples every second. In fact, to achieve this sampling rate you would need&nbsp;to take 4000 samples at 400KHz. This would give 400000 samples a second (as Hz is equal to number per second), with a buffer size of 4000. It is important to have the number of samples at 10-100 times less than the frequency in order for the computer to keep up with demand, due to the speed that the buffer fills up at.
&nbsp;
I hope this has cleared up the confusion for you, my apologies if my original explanation was a little vague. If i can be of any other assistance let me know.
&nbsp;
Regards,
BMEstudent
2008-08-05 16:10:05 UTC
Permalink
Mike,
&nbsp;
ok. &nbsp;That sounds clear, but after some prodding&nbsp; I am confused again.&nbsp; So I changed the buffer size ('samples' in the assistant) from 40 to 400 to get it in the range you suggested.&nbsp; The result is that the input signal (the signal produced&nbsp;from the wire coming directly&nbsp;from the assistant) displays ten times the amount of data points on the chart that I have displaying it. The iteration count still runs at the same speed of course.&nbsp; I guess I am having a little trouble grasping the buffer concept.&nbsp; Why does changing the buffer size alter the number of data points entering the system?
&nbsp;
pmnMessage Edited by BMEstudent on 08-05-2008 10:46 AM
Brooks_C
2008-08-05 22:40:05 UTC
Permalink
Hello PMN,
There are two numbers to consider here:&nbsp; Sample Rate and Samples to Read
Sample Rate:&nbsp; This number sets up the timing for your acquisition.&nbsp; If you&nbsp;choose 400 Hz the hardware will collect samples at 400 Hz for each of the specified analog input channels and put them into a buffer at the same rate.
Samples to Read:&nbsp; This is the number of samples you will remove from the above buffer each time you read samples.
In order to have a sustained acquisition you have to empty the buffer as fast as you fill it, otherwise your buffer will overflow.&nbsp; For example, if you acquire at a Sample Rate of 400 Hz and Samples to Read is 40 then you need to read at least 10 times a second to avoid an eventual buffer overflow.That?s a brief overview of what these values mean.&nbsp; For your specific question, you display ten times the amount of data because each loop iteration the DAQ Assistant returns 400 points rather than 40 points and the loop runs 10 times slower.&nbsp; Essentially you're not changing the buffer size, your explicitly changing the number of samples to read in each iteration.
I hope this helps, and have a great day!
BMEstudent
2008-08-06 13:40:09 UTC
Permalink
Ahhh.&nbsp; That is very clear and helpful.&nbsp; Thank you very much.&nbsp; Does that mean that the iteration speed is determined by the speed of the computer if no time delay is connected?&nbsp;&nbsp; Just a final question for conclusive purposes.
&nbsp;
ps, how do i give positive recognition to you two?&nbsp; would love to
&nbsp;
pmn
mickeyw
2008-08-06 14:40:06 UTC
Permalink
Your more than welcome, I'm glad we could be of service in some capacity and I wish you success with your application. I'm not sure on the recognition, you may have to post a certain number of times before being able to rate people.
&nbsp;
Regards,Message Edited by mickeyw on 08-06-2008 03:12 PM
Brooks_C
2008-08-07 19:40:06 UTC
Permalink
Hello pmn,

&nbsp;

The loop iteration speed is however long it takes for all of the VIs in the loop to run.&nbsp; If you have a DAQmx Read in a loop, that VI is "blocking" until the specified number of samples are available in the buffer.&nbsp; If you specify 100 samples that VI will wait until they are available and then allow execution to continue.&nbsp; If you specify -1 samples the DAQmx Read VI will pull all of the available samples and continue execution immediately.

&nbsp;

If you have additional analysis in series with the DAQmx Read the total loop iteration time will be the time to read + the analysis time.&nbsp; If you have a Wait (ms) VI in your loop it is a parallel process and the loop iteration will be the larger of the wait time and the code execution time.

&nbsp;

With a simple acquisition, a majority of the loop time will be determined by the sample rate and the samples to read.&nbsp; I.e. if you sample at 1 kHz and read 100 samples each iteration, your average loop time has to be 0.1 seconds to avoid overflowing the buffer.

&nbsp;

Cheers,

Continue reading on narkive:
Loading...