Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Creating a steady PWM of 100 KHz using NI-9402 and cDAQ-9178

Solved!
Go to solution
Highlighted

Hello,

I've been trying to make a PWM with a steady frequency of 100 KHz. I can't make it works and I've been wondering if the problem comes from me and how I create my program or if the problem is hardware.

I am using a Ni-9264 mounted on a NI cDAQ-9178.
There is also a Ni-9401 which I can use.


I got 2 problems so far, either I got a non-steady frequency (going from 50 KHz to 200KHz depending on the sample rate) or -it seems- my USB bus is overloaded.

I am using a LeCroy HDO6004 to be sure my PWM is ok.

I tried different ways to create my PWM, you will find enclosed the VI. I'm sorry the VI is a bit messy. But you should be able, if you want to, see how I proceeded with the PWM.

Can you help me see where the problem lies?
Can I generate a steady PWM or I need to buy another NI device?
Do I need some real time device, something like cRIO with FPGA integrated?

Thank you,
Best regards,

Clément Horpin


0 Kudos
Message 1 of 26
(416 Views)

I haven't seen your VI but I guess NI 9401 can generate desired PWM signal.

Analog Output is not good way, counter is the best.

Number of Concurrent Tasks on a CompactDAQ Chassis Gen II

 

Most cDAQ chassis has onboard counter feature, 9401 can access to the circuit.

cDAQ Module Support for Accessing On-board Counters

Emboar
Certified LabVIEW Developer
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Message 2 of 26
(395 Views)

Thank you for your answer,
I'll try to make this work this afternoon then I'll come back to you Smiley Happy

Regards,

 

0 Kudos
Message 3 of 26
(388 Views)

I wanted to ask for some help but, I made some progress. Will be back later Smiley Very Happy

0 Kudos
Message 4 of 26
(373 Views)

 

 

I tried to use a counter for the PWM but I can't make it works..

So far, the only thing I got is an Impulsion going from 0V to 5V, and staying at 5V until I stop the VIs.

I tried to use Ni Max with the boardtest but I get the same result.
Any guess?

 

Here is the snippet from my VI

PWM_error.png

Capture2.PNG

Capture1.PNG

 

 

Cheer,

Clément

0 Kudos
Message 5 of 26
(365 Views)

It seems that your VI would work correctly...

Which pin did you check? If you use ctr0, "CTR0 OUT" should be observed.

The feature corresponds to pin19 (PFI3).

 

As additional information, you can use an example code located on below.

C:\Program Files (x86)\National Instruments\LabVIEW 2017\examples\DAQmx\Counter Output\Counter - Continuous Output.vi

Emboar
Certified LabVIEW Developer
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Message 6 of 26
(359 Views)

I'm using the Pin 19 with com 1. Today, I'll try to use different counters just in case..

I also tried the example "Counter - Continuous Output". I got the same reaction, meaning => An impulsion going from 0 to 5V.

May the problem come from the speed or something ? After the rising edge, there is not enough time to read the falling edge when there is the 2nd rising edge. And then, that is why I'm seeing a 0-5V signal.

Moreover, if I'm trying to make a PWM with low frequency (10Hz), I'm getting a sinus with an amplitude which depends of the duty cycle.

100% => 5V
50% => 2.5V

0% => 0V

 

Best regards,

Clément

p.s : on my snippet, I'm using "continuous samples" and not "finished samples" which is "échantillonnage finis" in French. I forgot to change when I was doing some test.

0 Kudos
Message 7 of 26
(343 Views)

Ok here it works !
The problem came from the oscilloscope. There was a bad sample configuration.. Sorry haha

Your solution was the good one from the start. Thanks!

Now I am taking the next step. I need to get 4 PWM working with the 4 counters.
I need PWM 1 and a PWM 2. PWM2 is delayed from PWM1.
PWM3 and PWM4 are the inversed of the 2 previous pwms.

I'll keep the topic open in case I'm encountering difficulties. I'll keep you in touch.

Thanks so far Emboar Smiley Happy

Cheers,
Clément

0 Kudos
Message 8 of 26
(336 Views)

That should be my last question..

I'd like to use the same clock for every counter. Is that possible ?
I'd like to synchronize all my PWM with the same counter.

0 Kudos
Message 9 of 26
(334 Views)

Im really released the problem has been resolved.

Do you want to synchronize all counter output?

 

The generation is based on master timebased clock.

http://www.ni.com/documentation/ja/ni-daqmx/latest/mxcncpts/clocks/

I think just using start trigger would be a solution. Why don't you try it?

Emboar
Certified LabVIEW Developer
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
0 Kudos
Message 10 of 26
(301 Views)