04-18-2013 09:19 AM
I think I need to do exactly what this guy wants:
http://forums.ni.com/t5/LabVIEW/Dynamic-Duty-Cycle-Change-for-PWM/m-p/2360002/highlight/true#M735803
Except I don't need sinosoidal waves, the pulse train is fine.
I need automation because I have to generate a pulse train that looks like the inputs 1,2,3,4 below:
so that the output gets generated in the osciloscope.
Basically, my question is how do you automate changing the duty cycle after, say, "x" milliseconds?
In case anybody is curious, I'm using Figure 8 from this data sheet
Solved! Go to Solution.
04-18-2013 09:39 AM
looking at the output ...there's capacitance on it. is that what you want or do you want a square wave instead?
04-18-2013 06:10 PM
I want to generate the square wave and feed it in as input to the motor.
That is the first step.
The next step will be to see if I actually get the output they have shown in Figure 8 on pg. 10 of the data sheet.
04-18-2013 06:47 PM
What device are you using? If your device supports it, you want to output a hardware-timed digital waveform. I don't believe there's an easy way to get a counter output to do what you want. You might be able to use one counter as a trigger or gate for the second one such that it would turn off the PWM generation after a specific amount of time, but digital waveform generation will be much easier and more flexible.
04-19-2013 12:19 PM
I am using the DAQ 6259.
Ideally I would like to generate a pulse train on hardware and be able to automate the switching ON/OFF of the pulse train.
04-19-2013 12:28 PM
invasion2121 wrote:
Ideally I would like to generate a pulse train on hardware and be able to automate the switching ON/OFF of the pulse train.
Please be more specific than "automate." What determines when you need to turn on and off the pulse train? There are lots of possibilities. If you need the pulse train to fire a fixed number of pulses and then stop, you can tell the counter output to generate that number of pulses. If you need to turn the PWM on and off regularly, but the on and off times stay mostly constant, then I think you could use two counter outputs - one as the PWM, the other as a gate (but you'd need to confirm that setup, I've never tried it). If you need to generate a number of pulses followed by an off time over and over where the number of pulse and off time varies, then as I suggested before a digital waveform is probably the best approach.
04-22-2013 05:45 PM
Hi Nathad -
If I understand correctly your response has 3 possibilities:
1. fixed # of pulses and stop
2. pulses are on and off regularly (i.e. constant period)
3. varying frequency and period pulse train
My goal is to put some measurements around the Figure 8's outputs (the wavey fast and slow decays). Currently the data sheet does not provide them so I have to measure them myself using an oscilloscope.
Using the Complete PWM example counter code I can dynamically update the frequency and duty cycle using the front panel controls.
Looking at your suggestions I believe ultimately #2 will be what is needed to get the motor behaving the way we want, however we may need to do testing with #3 in order to figure out what is needed for #2.
Is it possible to modify the Complete PWM Example code to change frequency and duty cycles after, say 10 seconds? What is the easiest way to do this?
04-22-2013 05:57 PM
How accurate do you need the timing to be? If you just want to adjust the signal after approximately 10s, then it's easy. Put in some timing code that counts 10s, and change the value when the timer expires. You could store a range of values in an array and index through them sequentially, or just increment/decrement the duty cycle and frequency each time the timer expires, depending on what you need. The simplest way to do this is the "Elapsed Time" function (I'm not usually a fan of Express VIs, but in this case it's easy).
There is no time scale in your Figure 8, and your original post said you need to change the duty cycle after some number of milliseconds. That's very different than changing it after some number of seconds, because to get accurate milliseconds you'll need hardware timing, whereas you can get approximate seconds in software.
04-22-2013 08:19 PM
Hi Nathand -
I went ahead and accepted your solution because I think what you are saying at a conceptual level is what I needed to hear.
To be honest, I do not know whether I need seconds or milliseconds as the Allegro 3901 data sheet does not give specifics. Unfortunately, I will have to experiment and figure this out.
Regarding your previous post about milliseconds you suggested I should do it in hardware. Is there any sample code that does this?
04-22-2013 11:35 PM
invasion2121 wrote:
Regarding your previous post about milliseconds you suggested I should do it in hardware. Is there any sample code that does this?
Search a bit, you should be able to find examples. A search for "gated pulse generation" returned this: https://decibel.ni.com/content/docs/DOC-11762 as the first result and I'm sure there's more further down the results.