04-09-2014 05:42 PM
To summarize my problem, I'm trying to create a period and voltage controlled sequence of pulses , but as I decrease my duty cycle, the distance between each pulse starts to become irregular. Specifically:
I want to have three pulses, each of a specified positive amplitude, 80 microseconds long, with 23 ms in between each. After those three pulses, I'd like to have a negative pulse of 3* that amplitude, followed again by 23 ms. This cycle should repeat 260 times.
I tried to first create the positive pulses by using the Simulate Signal VI, setting it to a square wave with a frequency of 43.327556, an offset of 0.5 and amplitude of 0.5. With the duty cycle as the default 50%, the signal seems to be normal (constant frequency and duration of each pulse is equal; I'm measuring it using an oscilloscope). However, when setting the duty cycle to .3466%, the times between each pulse varies and some pulses are longer than others. I wrote the data to a measurement file directly from the Simulate Signal VI to make sure it wasn't just an oscilloscope problem, but it looked like the write to measurement file didn't sample enough points for me to measure this accurately. Even decreasing the duty cycle to just 10%, I see the issue arise already.
So my question is, am I doing something wrong here? Is there some kind of Labview lag with trying to do a duty cycle that small? And are there any alternatives to the way I have this set up? I was thinking about trying to use a pulse train instead, but I'm not very familiar with that and as far as I know, you can't control the amplitude of pulses.
Any help is appreciated! Thank you very much.
Solved! Go to Solution.
04-09-2014 08:21 PM
My guess is that you are limited by the sampling rate. If the difference between the on time of two signals is less than the sampling period (1/sampling frequency), you will not be able to generate the signals you want.
Please tell us the sampling rate you are using and the settings which work and those which do not. If your data file is not too large, please post that so we can see some data. Posting your VI may help also. Please make the settings default before saving the VI.
Lynn
04-10-2014 02:08 PM
Hi Lynn,
Thanks very much for the help. I think you're right that the sampling rate is the issue, but I'm still not sure at what setting I need the sampling rate to get the signal to be consistent.
I've attached the VI I'm using to troubleshoot this (It's very simple, just the simulate signal VI attached to a DAQ assistant).
If I use the below settings...
Signal Type: Square wave
Frequency: 43.327556 Hz
Phase: 0 deg
Amplitude: 0.5
Offset: 0.5
Duty cycle: 50%
Timing:
Samples per second: 2000
Number of samples: 200 (Automatic)
Run as fast as possible
...The signal seems consistent.
However if I use the above settings and change the duty cycle to 0.3466%, the signal isn't consistent. After your suggestion, I calculated what I think the sampling rate needs to be to get the complete signal: for an 80 us pulse, that would give a period of 160 us and a frequency of 6250 Hz, so the sampling rate should be 12500 Hz at least. Does that seem right? I set the sampling rate to be 20,000 Hz just to be safe, and the consistency is definitely improved, but still not always accurate. For example, I'm usually getting 23 ms between each pulse now, but the pulses aren't always the same size.
To give a more detailed description of what I'm getting:
At 2,000 samples,
I measured one triangle wave (another sampling rate issue I'm guessing?) of duration of 80 us, some square waves of 120 us (with the flat top being 40 us), and one of 160 us (with the flat top being 80 us). (I'm not sure of the correct terminology, but by flat top I mean the part of the signal that is constant after ramp on and before ramp off).
At 20,000 samples,
I measured a square wave of 60 us (with the flat top being 40 us) and mostly square waves of 120 us (with the flat top being 80 us).
I tried writing into a measurement file again, with the sampling rate at 20,000 but it's still not giving me enough points...Am I calculating this sampling rate correctly?
Some further questions I have now are:
-Shouldn't increasing the number of samples in the timing always increase the resolution of our signal? I tested both the default number of samples of 2000 that would go with a samples per second of 20,000 and also changed the number of samples to be 20,000, but the default number seemed to be closer to what I want, and a more consistent signal.
-When I say "closer to what I want", I mean an ideal pulse of 80 us. I know it's impossible to get an ideal pulse through hardware, but am I right in thinking that an ideal pulse in Labview will translate to a non-ideal pulse with a total duration of 120 us and a flat-top duration of 40 us? That would mean it's high for 80 us on average.
I tried just randomly increasing the frequency of the timing as well (eg. 30,000), but that still didn't solve the issue as far as I could tell.
Thanks again for your help,
Renee
04-10-2014 02:29 PM
Actually I did some more calculations and realized I need something more on the order of magnitude of 3 million for the sample rate to get enough samples for this to actually work (my calculations must have been wrong before).
Thank you so much for your help!