Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

Why does Pulse Width Modulation not work as intended with NI 9474?

Hi,

I am having some trouble implementing Pulse Width Modulation (PWM) with my cRIO. After some trouble I decided to make the following experiment today: I used the PWM example from the Example Finder to set the according FPGA VI to generate a 50% duty cycle PWM signal and did this for a set of PWM period lengths. I then measured the output using a standard handheld Voltmeter in DC mode. Hence, the voltmeter should read, what a motor that is connected to PWM port would "see". The supply voltage to the NI 9474 was 20V at all times.

For example, I set the PWM period length to 40,000 ticks for a 1kHz PWM signal with a 20,000 ticks PWM duty cycle length. However, instead of reading 10V output voltage, the Voltmeter gave me a reading of 17V. Varying the PWM period length gave the results as in the following graph:





This indicated to me that the digital output module 9474 which is supposed to have a switching speed of less than 1us, does in fact have some trouble keeping up with the speeds at much lower speeds. Hooking an oscilloscope up with the 9474 prooved, that the output of the PWM signal was every thing but a square wave (to be exact: a noisy square wave).

I attach a VI documentation of the FPGA VI I used. Any hints on why the PWM does not work as intended would be greatly appreciated.
0 Kudos
Message 1 of 7
(7,071 Views)
Hi Jonemo,

Unfortunatly the attached documentation regarding the Example VI that you are using seems to be corrupted and i can't open it; can you confirm that the example VI that you are using is "PWM Out, Simple - cRIO.lvproj"?

In order to tackle this I'd like to know more about the output that you are seeing: the "
noisy square wave" measured on an oscilloscope. If you make the period length to 40,000 ticks for a 1kHz PWM signal with a 20,000 ticks duty cycle length, do you see a noisy version of the correct wave, or do you see something quite different? If it is different and you can measure the characteristics of the pulse train, what is the period and duty cycle of the output signal in seconds?

Regards,

Ian Colman
Applications Engineer
National Instruments UK & Ireland
0 Kudos
Message 2 of 7
(6,987 Views)
Ian,

here's a link to the VI documentation again, it's a modified version of whats in the examples which I stripped down to locate the error: http://jonemo.de/stuff/vidocumentation.pdf

I will have another look at the output I get and will make a photo of the oscilloscope output. I remember, that it shows a square wave with the right period length. However, instead of only switching between 20V and 0 there is a transient which ultimately leads to the wrong average voltage that my voltmeter sees. I have no own circuitry apart from a short single core wire to connect the Rio module with the oscilloscope.

Jonas
0 Kudos
Message 3 of 7
(6,980 Views)
Hi Jonas,

That sounds good, if you could post a picture of the reading or a detailed description of the waveform that would be great.

Best Regards,

Ian
0 Kudos
Message 4 of 7
(6,934 Views)
Yea I agree, with the screenshot or description it would be easier to see what's going on.

0 Kudos
Message 5 of 7
(6,859 Views)
Ok, one of my colleagues solved the problem for me now. But I explain what was going on anyways.

This is a photo of the oscilloscope screen showing the DO running at 1kHz (Period Length: 40,000 ticks, duty length: 20,000ticks).


You can see, that the Voltage does not drop to zero immediately. this problem is getting even worse when putting the frequency up to over 10kHz:



Hence the average of the signal is nowhere near the 10V you would expect from a 50% duty cycel PWM.

The solution is to put a resistor between the channel output and COM, i sketched this below (sorry for the bad quality).


I don't really understand why it is necessary to put a resistor there, I cannot see why the Rio module should not include this extra piece of circuitry.

0 Kudos
Message 6 of 7
(6,855 Views)

Hi Jonemo,

I think this KnowledgeBase, Troubleshooting Digital Output and Pulse Generation on the NI 9472/9474, will explain the behavior for you better.

Bassett

Message 7 of 7
(6,849 Views)