06-24-2013 11:03 AM
Is it possible to generate a PWM signal at a certain duty cycle with the NI 9264 16 channel analog output module??
Thanks,
Robert
Solved! Go to Solution.
06-25-2013 10:17 AM
Hi Robert,
You might take a look at this example to see if it does what you are looking for, or if you can modify it to do what you want. I hope this helps.
06-25-2013 01:37 PM
Hi,
Just to condense this to one forum topic with all the relevant information, especially for those also interested in Pulse Width Modulation using an analog device, I have copied over TechnicRC's post discussing his application:
@TechnicRC wrote:
Good afternoon,
I have an experiment in the works that I was hoping you folks could assist me with! I am attempting to derive the transfer function of a motor/propeller using the frequency response method. I have already created a VI that reads all of the outputs of the sensors on the test stand (propeller RPM, Force, and Torque) using the NI 9205 module (attached VI). However now I am attempting to provide the input to the speed controller (takes a 50Hz PWM signal) by using the frequency response sinusoidal input
u(t) = A sin (2*pi*freq*time)
I am confused as to how I go from this frequency response input to a PWM input at different duty cycles for the ESC (speed controller) using an NI 9264 AO module? Can anyone provide any assistance or point me in the right direction?
My attempt of beginning this input VI can be seen in the attached file (FR.vi) I am creating this sinusoidal input but am not too sure where to go from here..
Your help is much appreciated,
Robert
Attachements provided by TechnicRC can be found here.
Another good example worth looking at for PWM using an analog output can be found here, has detailed steps on how the VI is actually setup to output the desired signal.
-Jake B.
06-25-2013 02:22 PM - edited 06-25-2013 02:23 PM
Both examples provided by you folks turned out to be very helpful, thank you! I have been doing more reading into the topic of frequency response and have decided to implement a Swept Sine frequency response test with a PWM signal as my input into the system. I have found a couple excellent Swept Sine vi's and was hoping to implement the one I attached with the PWM vi. I am a little confused though with regards to one aspect. I will be sweeping frequencies from 1-10Hz in my frequency reponse test but my PWM signal needs to be sent at 50Hz for it to control the motor. How do I go from my frequency response input to my PWM output? I am quite confused about this but I will keep looking into it
Thank you,
Robert
06-26-2013 02:19 PM
Hi Robert,
I am not sure I fully understand what you are trying to do. What is your end goal? Are you trying to make the output of your Swept Signal VI the input of your PWM vi?
I would be happy to help, but I need you to explain exaclty what you desire to do.
06-26-2013 02:53 PM
Hello Thomas,
Yes I am trying to make the output of my Swept Signal VI as the input of my PWM vi. I am basically running a frequency response test on my motor/propeller (measuring torque and thrust) and then trying to derive the transfser function of this motor/prop combo. The motor is controlled via an ESC which takes a regular PWM signal. If you need any more information let me know.
Thanks,
Robert
06-27-2013 08:18 PM
Hi Robert,
From what it sounds like, you may not want to input a sine wave for your function. Based on your explanation of your goal, it sounds like you need to simply input a function that varies linearly from 0 to 1 into the duty cycle parameter of the PWM vi you already have. Does that make sense? That would allow you to analyze the motor's response as the duty cycle varies in a consistent manner. Also, it would not make sense to have your duty cycle be negative, as would be the case during half of the period of your sine function. Let me know if this makes sense, or if I am misunderstanding your goal.
06-28-2013 02:10 PM
Hello Thomas,
Thank you for your response but I actually do not want the duty cycle to vary in a consistent manner, instead I would like to vary it with the swept sine wave frequency. Neverthless I have figured out how to do this but now I have an issue with the while loop. It is executing way too slow ( should be running every 20ms, 50Hz for a duration of 2 seconds ) but it is running way slower. I believe that the DAQmx write block is delaying the entire loop. Shouldn't it be able to execute faster?
Thanks,
Robert
06-28-2013 03:46 PM
I found that changing the sample clock rate and samples input on the DAQmx timing has sped up my program considerably but am still unsure as to what these values should be to guarantee a 50Hz refresh rate of the while loop. Any ideas? For now I have the sample clock rate set to 2000 and the samples to 50 with faster results
Robert
07-01-2013 12:35 PM
Hi Robert,
Changing the Rate and Samples inputs will ensure that there are samples to write, but wil not necessarily ensure that the loop executes at consistent 20ms intervals. In fact, there is no way to ensure that it will write at 50Hz exactly without getting and RT system. What rate does it appear to write at now? The Wait.vi that you have in the loop should be the primary contributor to th execution rate of the loop, from what I can see in your program right now. Is the current rate unsatisfactory?