LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Most efficient way to implement my own buffer

Thanks. I was actually on the right track then! Yay.

How does the Boolean Array to Digital.VI's sample rate option differ from that of the AI Sample Clock?

For instance, can I set the Boolean Array to Digita's rate to be 1000, and use the AI Sample clock at 15000?

I am asking this because instead of having to write 15 consecutive Trues in a boolean array for 1ms of true, it would be preferable if I can just do 1 single true and generate a waveform that would have HIGH for 15 AI samples.

Also, instead of having a buffer, can I instead just generate a 30 minute long waveform (our experiments typically run about that long) and have it start right as the AI starts?

 

I hope I am making myself clear.

0 Kudos
Message 21 of 29
(2,421 Views)

@RaymondLo wrote:

How does the Boolean Array to Digital.VI's sample rate option differ from that of the AI Sample Clock?

For instance, can I set the Boolean Array to Digita's rate to be 1000, and use the AI Sample clock at 15000?


The waveform dt (sample rate) is ignored when you write a waveform to a DAQmx channel. The channel's timing is used instead. I don't think there's any advantage to using a digital waveform instead of writing the boolean array directly.

 

You could use some clock other than the analog input acquisition clock, that would run at a slower rate. If you really want to be a perfectionist about this, set up a single digital channel to trigger both the analog acquisition and the digital outputs to start at exactly the same time. I think you can do this, but I'm not an expert in what the internal routing allows, particularly since it varies from device to device. Otherwise you can start them both in software at the same time, they won't be off by much if you start them together. You might want to run the digital input into an unused analog input, so you can see that signal on top of the other analog signals.

 

If you need a fixed-frequency square wave rather than a digital pattern, use a timer output instead.

 

I doubt that it would work to do a 30 minute buffer at 15000 samples per second, but I think you can write 20 seconds or so at a time and it will work so long as you provide the next chunk before you finish outputting the previous one. Test that out though and make sure you don't get an error.

Message 22 of 29
(2,409 Views)

Thanks. I started another VI so that I can play around with trying to sync the DO and the AI.

 

Am I doing this correctly? My makeshift software digital monitor doens't really work so I can't really tell what's going on.

 

If I simply started them both together in software at the same time, (by start I am guessing you mean calling "start.VI'), what kind of time difference can I expect? A few microseconds? As long as it's well under 1ms, I am fine.

0 Kudos
Message 23 of 29
(2,402 Views)

Did you mean to attach some code or an image?

 

I think you'd get a difference well under 1ms for starting one task immediately after the other, but I can't do any testing to confirm that.

Message 24 of 29
(2,398 Views)

Oops. I am sorry. Did indeed forget to attach the image. I really appreciate you guys taking the time to help me.

Screen Shot 2016-06-30 at 5.21.32 PM.png

0 Kudos
Message 25 of 29
(2,392 Views)

You want to use the Analog Input sample clock as the Source for the digital output sample clock. That's what synchronizes the two. If you create a DAQmx channel control you should be able to find the analog sample clock, although it may be abbreviated in a way that makes it difficult to identify.

You probably also want to start the digital task before the analog input task, rather than using the auto start.

 

I'm not sure what you're trying to accomplish by reading the digital waveform, and I don't know if reading an output works - maybe it does?

 

You already have an array of booleans, so there's no need to convert to a digital waveform, you can use the boolean array directly.

Message 26 of 29
(2,358 Views)

Thanks, I found the Sample Clock, now they seem to be acting together rate-wise. Does the sample rate for the DO sample clock just irrelevant then?

The main problem I still have though is how to write into the writing buffer for the digital output as we go along the experiment. Ideally, I should compute the digital waveform (or 2D boolean array) I want for the next  second and then write into the buffer before the next second starts, so then when the write VI is called, the buffer is not empty. Do I have to call the start VI after every time I feed new data into the buffer?

DAQ PIC2.png

 

0 Kudos
Message 27 of 29
(2,353 Views)

No, you should not have to start each time but you do need to keep the output buffer filled with the data prior to the hardware actullay using it. There are property nodes for the write task that will let you monitor the state of the output buffer and where the current pointer is within the buffer.

 

If you do not keep up the task will throw an error indicating it ran out of information.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 28 of 29
(2,350 Views)

@RaymondLo wrote:

Thanks, I found the Sample Clock, now they seem to be acting together rate-wise. Does the sample rate for the DO sample clock just irrelevant then?


Many of your questions are answered in the help. For example, the help for DAQmx Timing says "If you use an external source for the Sample Clock, set this input to the maximum expected rate of that clock."

0 Kudos
Message 29 of 29
(2,345 Views)