Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

PWM measurement pattern for continuous samples over higher frequencies (100kHz) with SemiPeriod(HighTime / LowTime)

Solved!
Go to solution

Hi Folks,

 

I have a challenge which I like to discuss with you and hope to get some ideas and maybe a solution.

 

I have a National Instruments multifunction data acquisition (DAQ) devices NI-PCIe-6353 this means X-Series!

 

I'd like to generate and measure Pulse-width modulation  signals.

 

DRIVER:

 

 

 

OUTPUT:

Freq: 0.1Hz - 1MHz

Duty:    1%  - 99%

 

change parameter on the fly

 

(This works fine and is implemented)

 

INPUT:

Freq: 0.1Hz - 40kHz

Duty:    1%  - 99%

Method of measurement:  Semi-Period / ContinuousSamples / AsyncCallback 

 

Here I have problems I am running only on a Intel(R) Core(TM) 2 Duo CPU E8500 @ 3,16GHz.

And I want to run 2 PWM_IN and 2 PWM_OUT

 

 

Low frequency work fine!

 

0.1Hz - 20kHz

 

its a Callback loop with

 

myCounterReader_1.BeginMemoryOptimizedReadMultiSampleDouble(2, myCallback_1, myPWM_IN_1, myPWM_IN_1_Data);

Data = myCounterReader_1.EndMemoryOptimizedReadMultiSampleDouble(ar, out myPWM_IN_1_Data_actualNumberOfSamplesRead);

Higher frequency don't work fine!

 

20kHz - 40kHz

 

I get exception Status Code -200279:

 

Attempted to read samples that are no longer available. The requested sample was previously available, but has since been overwritten.

 

Increasing the buffer size, reading the data more frequently, or specifying a fixed number of samples to read instead of reading all available samples might correct the problem.

 

Property: NationalInstruments.DAQmx.DaqStream.ReadRelativeToRequested Value:

NationalInstruments.DAQmx.ReadRelativeTo.CurrentReadPosition

 

Property: NationalInstruments.DAQmx.DaqStream.ReadOffsetRequested Value: 0 

 

Task Name: NI1_PWM_IN_ctr0

 

Status Code: -200279

 

40kHz means period = 25us = 12,5us HighTime and 12,5us LowTime by 50% DutyCycle

 

this means each 25us i get a reading of 2 samples the HighTime and the LowTime

 

I load my Task from Max so here is the configuration(sorry its german):

 

MAXPWM_IN.PNG

 

1. Can someboby explain me what the MemoryOptimized means?

2. Zu lesende Werte means the buffer size 10 is not a lot but increasing the buffer size to lets say 10.000 want help over

    a longer time! 

3. Reading the data more frequently is not possible because the data are live as it is 

4. Specifying a fixed number of samples I have der number is 2 HighTime and LowTime

5. I did not start and stop task! Is it better to start and stop the task everytime so that I always have a new buffer perhaps?

 

Hope someone has an idea for!

 

By 

 

Steven

 

 

 

 

0 Kudos
Message 1 of 3
(4,723 Views)
Solution
Accepted by Sensor-Wiedemann

Software reading with 50 us period - bad idea, you will skip pulses. Try to use DAQmx Read property Overwrite, set it to "overwrite unread samples" - it will overwrite pulses without error.

0 Kudos
Message 2 of 3
(4,641 Views)

Hi Alexander,

 

thanks for your reply I believe this will work!

 

myPWM_IN_1.Stream.ReadOverwriteMode = NationalInstruments.DAQmx.ReadOverwriteMode.OverwriteUnreadSamples;

Thanks a lot and have a nice day.

 

God bless you!

 

 

0 Kudos
Message 3 of 3
(4,627 Views)