Ernest Galbrun Posted December 18, 2008 Report Share Posted December 18, 2008 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 : Quote Link to comment
mross Posted December 18, 2008 Report Share Posted December 18, 2008 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 Quote Link to comment
Ernest Galbrun Posted December 19, 2008 Author Report Share Posted December 19, 2008 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... Quote Link to comment
AnalogKid2DigitalMan Posted December 19, 2008 Report Share Posted December 19, 2008 One way to generate PWM is to use an comparator chip and feed it 2 analog inputs. The first input is a triangle wave, the other is a variable DC level that adjusts the duty cycle. Quote Link to comment
Irene_he Posted December 19, 2008 Report Share Posted December 19, 2008 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 Quote Link to comment
ned Posted December 19, 2008 Report Share Posted December 19, 2008 QUOTE (Ernest Galbrun @ Dec 18 2008, 04:35 AM) 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 can't really do anything in Windows faster than 1ms predictably. The NI FPGA products are definitely capable of what you're trying to do, but they're not cheap. I don't think this is exactly what you need but I've seen http://www.omega.com/ppt/pptsc.asp?ref=PCM4&Nav=temp10' rel='nofollow' target="_blank">this module from Omega for converting an analog (4-20mA) signal to a pulsed output for use with a solid-state relay. Quote Link to comment
mross Posted December 19, 2008 Report Share Posted December 19, 2008 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... 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. Quote Link to comment
Ernest Galbrun Posted December 19, 2008 Author Report Share Posted December 19, 2008 QUOTE (mross @ Dec 18 2008, 06:17 PM) 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. 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. Quote Link to comment
Neville D Posted December 19, 2008 Report Share Posted December 19, 2008 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. Quote Link to comment
Ernest Galbrun Posted December 19, 2008 Author Report Share Posted December 19, 2008 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. Quote Link to comment
Neville D Posted December 19, 2008 Report Share Posted December 19, 2008 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. Quote Link to comment
mross Posted December 19, 2008 Report Share Posted December 19, 2008 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 Quote Link to comment
Ernest Galbrun Posted December 19, 2008 Author Report Share Posted December 19, 2008 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. Quote Link to comment
mross Posted December 19, 2008 Report Share Posted December 19, 2008 QUOTE (Ernest Galbrun @ Dec 18 2008, 02:47 PM) 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. To change in what way and for what purpose? Quote Link to comment
Ernest Galbrun Posted December 19, 2008 Author Report Share Posted December 19, 2008 QUOTE (mross @ Dec 18 2008, 08:49 PM) To change in what way and for what purpose? I want to generate custom signals (sine, triangle, etc.) with a frequency varying from 10 to 200 Hz. Quote Link to comment
Irene_he Posted December 20, 2008 Report Share Posted December 20, 2008 QUOTE (Ernest Galbrun @ Dec 18 2008, 04:10 PM) I want to generate custom signals (sine, triangle, etc.) with a frequency varying from 10 to 200 Hz. I guess you want to turn PWM output into custom signals such as sine etc, then why not use a hardware based PWM output? iUSBDAQ-U120816 uses PWM outputs that exist on microcontroller itself. And this application note tells a very easy way to turn PWM into analog output with few resistors and capacitors. http://ww1.microchip.com/downloads/en/AppNotes/00538c.pdf Irene Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.