Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

NI-9203 Multiple PWM Signal Outputs with 25kHz Frequency

Hello everyone,

I am trying to get 4 PWM output signals with a 25 kHz frequency from the NI-9203 using the FPGA-based CompactRIO NI-9045.

 

I was able to get an accurate PWM signal, but the moment I add other PWM signal generation loops for the 3 other outputs or blocks to read from analog pins or write to the digital output pins, the PWM signal always gives 50% for the duty cycle and different frequencies that never change.

 

The equivalent of 25 kHz is 1600 ticks (internal clock 40 MHz).

 

I tried putting them in different SubVIs and running all of them in a while loop (and without that), but it was no use.

The only loops that use a clock-related function (Loop Timer) are the PWM SubVIs (the attached screenshot refers to the PWM code).

 

Does anyone know more about this? How can I fix it?

0 Kudos
Message 1 of 3
(111 Views)

What module did you use to output the PWM?

In FPGA, you must duplicate (copy and paste) the subVI to duplicate the functionality for different I/O.

See Pulse Width Modulation (PWM) IP Core for LabVIEW FPGA for an example.

-------------------------------------------------------
Applications Engineer | TME Systems
https://tmesystems.net/
0 Kudos
Message 2 of 3
(80 Views)

I used the NI-9403 module.
When duplicating the PWM code, it stops working efficiently and gives wrong duty cycles and frequencies.



The rest of the code is basically for reading and mapping sensors data and receiving a system output reference. I created a subVI out of each block and linked them to controls/indicators.


I have checked the site you shared before, but it seemed it would take some time to adapt it to what I need, and that won't necessarily work. I am tight on time as I have to meet my deadline, so I need something that will surely work or get me too close to making things work.

I tried putting each one of them in an independent while loop; it didn't work, and the same for when I put them together with the PWM code shown in the screenshot in a while loop.

The PWM code by itself, as shown in the screenshot, works perfectly without any other codes trying to run in parallel or with other PWM codes to control other components.

However, I tried implementing the same PWM code in the real-time module and the rest in an FPGA.vi (I integrated its compiled file into the RT.vi so that we can read sensors data in RT). ==> Reading and displaying data was working, but the PWM wasn't giving any signal.

I also tried the loop, changing the while loop into a timed loop with a 40 us period and a 1 MHz clock, but that did not work either.

It is a mess trying different things.

I also tried working with this one: https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000015CPCSA2&l=en-CA. Well, it was actually the first step to reach the PWM generator above.

Thank you for your support!

0 Kudos
Message 3 of 3
(70 Views)