Signal Conditioning

cancel
Showing results for 
Search instead for 
Did you mean: 

NI-9263 : Get signal generation progression

Hello,

 

I've a NI-9263 module to generate output signal.

 

I would like to know if there is some kind of progress value ?

 

I've tried EveryNSamplesWritten event but I've this message :

 

"NationalInstruments.DAQmx.DaqException : 'Requested Every N Samples Event Interval is not supported for the given Data Transfer Mechanism and buffer size.
To keep DMA or USB Bulk as the Data Transfer Mechanism, modify the buffer size and/or the Every N Samples Event Interval so the buffer size is an even multiple of the Every N Samples Event Interval. To keep the same Every N Samples Event Interval and buffer size, change the Data Transfer Mechanism to Interrupts if supported."

 

Thx.

0 Kudos
Message 1 of 4
(171 Views)

Hello Flow75,

 

Before being able to help you, there are a few questions that I have:

  • Which softwares and drivers are you using for your signal generation ?
  • What it your OS and what are the references of your other hardware devices (especially the cDAQ device) ?
  • What do you mean by a "kind of progress value" ? Does it mean that you want to generate a slowly evolving signal ? An evolving generation rate ? Or does it mean something else ?
  • What is the context and the goals of this signal generation ?

By giving us more details, it's going to be easier for us to help you ! 😉

0 Kudos
Message 2 of 4
(82 Views)

Hello,

 

I'm developping a c# software with the Daqmx framework on win 11

 

For the hardware, We use a NI cDAQ-9174 with the NI-9263 output module.

 

I've send my signal array with the sampling frequency to the buffer but I want to be able to display the signal progression like with a progress bar.

 

 

0 Kudos
Message 3 of 4
(66 Views)

Hello Flow75,

 

You're encountering an exception related to the EveryNSamplesWritten event because the Data Transfer Mechanism (DMA, USB Bulk, or Interrupts) imposes constraints on the buffer size and the sample interval.

 

 

You have here two different options to solve this issue:

 

  • If you don't necessarily need to use EveryNSamplesWritten, the best approach is probably to send the samples in chunks (chunkSize) at regular intervals. This would allow you to manually update your progress bar.

To do this, you can take inspiration from the small code snippet structure below.

 

while (written < totalSamples)
{ int remaining = totalSamples - written;
int currentChunk = Math.Min(chunkSize, remaining);
double[] buffer = new double[currentChunk];
Array.Copy(signal, written, buffer, 0, currentChunk);
writer.WriteMultiSample(false, buffer);
written += currentChunk;
Console.WriteLine($"Progression : {written * 100 / totalSamples}%");
Thread.Sleep(100); // <-- Simulate the regular interval }

 

However, while this method provides a practical workaround, it is not true hard real-time. Still, it’s often sufficient for generating simple analog signals.

If you’re working with a high sampling rate, you’ll also need to adjust both chunkSize and Thread.Sleep() to avoid underfeeding the device.

 

 

  • If you absolutely want to use EveryNSamplesWritten, you’ll need to make sure the buffer size is an exact multiple of N.

However, be aware that not all modules and configurations support this approach (which is what your error message is indicating), so in many cases it's better to rely on your own progress logic, like in the first method using chunkSize.

0 Kudos
Message 4 of 4
(6 Views)