Jump to content

How to achieve a fast PWM


Ernest Galbrun

Recommended Posts

Hello,

I am currently stuck with a problem : I am reconfiguring a test bench using labview. This bench sends various excitation signals to a target. These signals are presently generated through an analog output, and I am in charge of adding the possibility to do it through a PWM (pulse width modulation) output.

Now, I have implemented a standard example of PWM, and i works fine, except that it is far too slow. My signal is specified at 5000 Hz, and it takes around 80 ms to change the duty cycles.

Can anyone tell me if there is a solution, software or hardware, to improve the duty cycle modification rate ? (Since I dont use Labvew RT, I would be glad with a 1kHz rate.)

Here is the example I pasted from NI website :

dadc74b4233.jpg

Link to comment

QUOTE (Ernest Galbrun @ Dec 17 2008, 06:02 AM)

Now, I have implemented a standard example of PWM, and i works fine, except that it is far too slow. My signal is specified at 5000 Hz, and it takes around 80 ms to change the duty cycles.

Yes, the example code gives no clue how to change frequency and duty cycle without an interruption in the pulse train.

Here is how to do it. BTW, NI Tech Support was quite happy to sort this out for me - that is where the credit is due.

Mike

Link to comment

QUOTE (mross @ Dec 17 2008, 07:18 PM)

Yes, the example code gives no clue how to change frequency and duty cycle without an interruption in the pulse train.

Here is how to do it. BTW, NI Tech Support was quite happy to sort this out for me - that is where the credit is due.

Mike

Thank you for the tip !

However, this seems to rather confirm what I was affraid of, that the duty cycle can not be modified very fast (ie <1 ms). I will try to use this method though, and see how fast I can go. I will keep you informed. In the meantime if anyone know if there is some hardware solution to my problem, I would be glad to look in that direction too. I am looking for an analog/PWM or digital/PWM converter, but couldn't find it anywhere...

Link to comment

Hello,

iUSBDAQ- U120816 can output two 10bit PWM channels with frequency between 3kHZ - 333kHZ. Changing duty cycle takes about less than 8ms. There is another model iUSBDAQ - U1208LOG takes only 4ms to change duty cycle of PWM channels. Below is the link that you can take a look:

www.hytekautomation.com

Irene

Link to comment

QUOTE (Ernest Galbrun @ Dec 18 2008, 04:35 AM)

I ran that vi up to 10K HZ and never saw discontinuities. That is faster the the less than 1ms you mention. I have not tried to run it faster, but it will do more I am sure. I was using an DAQ board with AI capability up to 1.25MS/s. Perhaps your hardware is not up to the task. You did not share any information regarding the version of LV or the DAQ hardware involved. It is always a good idea to provide that information when asking for help.

Mike

QUOTE (Ernest Galbrun @ Dec 18 2008, 04:35 AM)

Thank you for the tip !

However, this seems to rather confirm what I was affraid of, that the duty cycle can not be modified very fast (
ie
<1 ms). I will try to use this method though, and see how fast I can go. I will keep you informed. In the meantime if anyone know if there is some hardware solution to my problem, I would be glad to look in that direction too. I am looking for an analog/PWM or digital/PWM converter, but couldn't find it anywhere...

You actually say "modify" the duty cycle faster than 1ms. I don't really understand that comment. If you were producing a frequency of 1KHz then changing it faster than 1ms would be shorter than the actual PWM cycle itself. When you change the duty cycle do you want to to stop in the middle of a cycle or what exactly?

If you need faster changes and can plan it out you can use my method and create an exact profile to follow. I wasn't resolving the time less that 1 second, but I am sure it could be done much more quickly than I did it. At some point you would need to use counters on a fast counter board or implenet a hardware solution as mentioned by another.

If you pre-program the steps and changes you may be able to avoid the limitations of windows because it is compiled and running on the DAQ board.

I can't conceive of a normal use of PWM that requires deterministic control of the pulse train. Perhaps if you explain why you think this is necessary we can figure out a way to produce what you need.

Link to comment

QUOTE (mross @ Dec 18 2008, 06:17 PM)

I run Labview 8.6, with a multifunction DAQ PCI-6229, on windows XP.

QUOTE (mross @ Dec 18 2008, 06:17 PM)

You actually say "modify" the duty cycle faster than 1ms. I don't really understand that comment. If you were producing a frequency of 1KHz then changing it faster than 1ms would be shorter than the actual PWM cycle itself. When you change the duty cycle do you want to to stop in the middle of a cycle or what exactly?

If you need faster changes and can plan it out you can use my method and create an exact profile to follow. I wasn't resolving the time less that 1 second, but I am sure it could be done much more quickly than I did it. At some point you would need to use counters on a fast counter board or implenet a hardware solution as mentioned by another.

If you pre-program the steps and changes you may be able to avoid the limitations of windows because it is compiled and running on the DAQ board.

I can't conceive of a normal use of PWM that requires deterministic control of the pulse train. Perhaps if you explain why you think this is necessary we can figure out a way to produce what you need.

I haven't been very clear about my need. The PWM I am generating is set at 50 kHz. The waveform I want to imprint on this PWM is defined with a precision of 200 µs (5 kHz). Since I am using non-RT labview and don't plan on changing that, I had resigned on having a precision of 1 kHz. Maybe the use of the property node (that is the main difference in your vi comparing to the one I am using where I use Daqmx - write to set the duty cycle) is very fast, I will try it.

Link to comment

QUOTE (Neville D @ Dec 18 2008, 07:14 PM)

There are PWM chips out there (I can't remember the P/N) that will modify the duty cycle based on an analog input 0-5V. They are fairly easy to use, and make your software a whole lot simpler.

N.

Yes, in fact I was hoping for the existence of an integrated device using such a chip, but I will probably end up making the electronic circuit myself.

Link to comment

QUOTE (Ernest Galbrun @ Dec 18 2008, 10:57 AM)

Yes, in fact I was hoping for the existence of an integrated device using such a chip, but I will probably end up making the electronic circuit myself.

This should be fairly easy to do, since most NI boards provide a 5V line you can use for supply, and an Analog Out line you can use for control. If you need 10V supply, use another AO line with output set to 10V constant.

I have used a little board put together by some technicians at one of the places I worked in the past. Unfortunately don't remember any other details apart from the above.

N.

Link to comment

QUOTE (Ernest Galbrun @ Dec 18 2008, 01:05 PM)

I run Labview 8.6, with a multifunction DAQ PCI-6229, on windows XP.

I haven't been very clear about my need. The PWM I am generating is set at 50 kHz. The waveform I want to imprint on this PWM is defined with a precision of 200 µs (5 kHz). Since I am using non-RT labview and don't plan on changing that, I had resigned on having a precision of 1 kHz. Maybe the use of the property node (that is the main difference in your vi comparing to the one I am using where I use Daqmx - write to set the duty cycle) is very fast, I will try it.

I see, you didn't try the example before reviewing it.

The ni example code does not work as you want, and as I mentioned, but this enhancement fixes the problem. Don't ask me why it works because I couldn't figure out what they were talking about. I was even given code that didn't work right, so tech support finds this mysterious as well. I wish they would add a better PWM example that documents this method.

When you say "imprint" a waveform onto the PWM, that makes no sense to me. What it the real world result of this operation?

You want the 5000Hz waveform to be turned on and off according to a 50Hz PWM pattern? Why would you want to do such a thing.

Mike

Link to comment

QUOTE (mross @ Dec 18 2008, 08:39 PM)

I see, you didn't try the example before reviewing it.

The ni example code does not work as you want, and as I mentioned, but this enhancement fixes the problem. Don't ask me why it works because I couldn't figure out what they were talking about. I was even given code that didn't work right, so tech support finds this mysterious as well. I wish they would add a better PWM example that documents this method.

When you say "imprint" a waveform onto the PWM, that makes no sense to me. What it the real world result of this operation?

You want the 5000Hz waveform to be turned on and off according to a 50Hz PWM pattern? Why would you want to do such a thing.

Mike

I want the duty cycle of my counter signal (which ticks a 50 000 Hz) to change every 200µsec. Or every ms at the least.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.