Data AcQuisition And Real-Time AnalysisScope - Spectrum - Spectrogram - Signal Generator
Software for Windows
Science with your Sound Card!
Contact us about
Random Pulse or Burst Timing
This application note discusses techniques for creating pulses or tone bursts that are of random duration, and/or have random intervals between them.
This is the simplest method to obtain random timing. Select a Noise source, typically White, as the Wave type. Exit back to its Stream dialog and click on the Smooth TC button that replaces the former Tone Freq button. In the Random Timing dialog that opens, click on the Step radio button, then set the Step Size to the minimum desired on or off duration. This will give a wave with steps of random heights and this width. (Rarely, you might see multiples of this width when two or more adjacent steps are so close in height that they look the same at the current display magnification.)
With Bias set to 0, the output will spend about half the time in each of the high and low states. If you set Bias above zero, then the output will spend more of the time in the high state. If you set Bias to negative values, the output will spend more time in the low state.
The random pulses thus created can be used directly, or they can be used to modulate another stream. For example, you can set a later stream to create a Sine wave, and set its AM on with the AM Source set to the random pulse stream. With 100% AM Depth, this will produce tone bursts of random duration. The minimum burst duration and the minimum gap between bursts will be the value of the Step size you set for the random pulse stream. The maximum durations are indeterminate; the longer a duration, the less often it arises.
These random tone bursts can be adjusted to make a fairly good approximation of Morse code.
Of course, you don't have to modulate a sine wave; with the Wave type set to White you will have random bursts of noise, for example. Or you can modulate a Play file of music or speech to simulate poor radio reception that is "breaking up".
One thing you may notice, particularly if you are modulating a sine wave, is that there will frequently be clicks at the onset and offset of the signal. The abrupt transitions of the modulator cause spectral splatter which you hear as clicking. (View this splatter by toggling to the Spectrum display mode with ALT+S.) You can greatly reduce this by adding some smoothing to the random pulses. In the Timing dialog, set Smooth TC to a value about one-tenth of the step size as a good starting point, and experiment from there.
The smoothing thus produced is helpful, but not really ideal. And you don't really have control over the maximum durations. For complete control over both of these, you can go to a more sophisticated method of random timing using Burst modulation.
Burst Timing Modulation
The Daqarta Generator allows you to create tone bursts with independent control over the minimum and maximum on and off durations, plus control over the burst rise and fall times.
RndBurst.GEN is an example setup that produces random bursts of white noise. The bursts vary over the range of 1 to 10 seconds in duration, with a lag between bursts that also varies over a 1 to 10 second range. In this setup, these random durations are continuous variables over their ranges, but they can easily be quantized to use only discrete time steps.
Set up White noise sources on two different streams. These will act as random number generators for the on and off durations. Set their Timing modes to Spec, not Step like the prior method. Set Quant to 0 and Smooth TC to minimum. The Burst interval modulators will read these sources only once at the start of an interval, ignoring all the other values during the interval. If the sources used Step timing and the step size was longer than an interval, the same value might be read again at the start of the next interval.
Set a third stream to the desired output waveform, such as Sine for tone bursts or White for noise bursts. If you just want DC pulses, set the Sine Tone Freq to zero and Phase to 90 degrees. Click on the Burst button in the Stream dialog to open the Burst dialog, and toggle Burst On.
Click on the High button to bring up its modulator dialog. Toggle Mod On and set the High duration to the average of the desired minimum and maximum intervals. To set the bursts to range from 1 to 10 seconds long, set High to 5.5 seconds.
High = (Max + Min) / 2
The Mod Depth control determines how far the duration can vary above and below that base value. To get a 1 to 10 second range, it should vary +/- 4.5 seconds from the base of 5.5, so set Depth to 4.5 / 5.5 = 81.8181%.
Depth = 100% * (Max - Min) / High
The Mod Source should be set to the stream that will provide the random values for burst High duration. Its Level control must be set to 100% and its DC Offset to 0 for this example, to apply a symmetrical full-range modulation swing prior to being reduced by the Mod Depth control.
Exit the High modulation dialog and repeat the above procedure for Lag to set the range for the duration of the silent period between bursts. You will of course set its Mod Source to the other of the two White noise streams.
Exit the Lag modulation dialog and set the desired Rise and Fall times, if any. Typically, these will be fixed values based upon the nature of the signal and the needs of the experiment. In the above example, 10 msec is probably a good minimum value, but this could be larger if you need especially smooth transitions.
Now set Burst Cycle to 0. It won't actually go to zero if you have non-zero unmodulated Rise or Fall times, but it will go to a minimum value. That allows the modulators to adjust the High and Lag durations as needed, without any limiting to a defined Cycle time.
TIP: When setting up random timing it can be difficult to tell just by listening that you are getting the desired maximum and minimum High and Lag durations. You can temporarily set each Mod Source to use the dedicated Sine modulation source instead of a random stream. Note that there is only one such source, shared by all stages of the burst cycle. Set it to a very slow frequency, to give a period about 10 times longer than the maximum duration.
Sometimes it is helpful to temporarily increase or decrease the High and Lag values to make it easier to verify what's happening. For example, you might want to decrease the above 1-10 second range to 1-10 milliseconds so you can see complete intervals directly on the waveform display. Conversely, if your goal is 1-10 msec you might want to increase to 1-10 seconds to listen to individual bursts.
The preceding discussion assumes you want a continuous distribution of random intervals. If you want only discrete values, such as only integer seconds, you can do that with the Quant control in the Random Timing dialog. You set this to one less than the total number of steps you want over the interval range. For 1-10 seconds in 1 second steps, set Quant to 9.
The preceding discussion also assumes you want independent control of both the burst duration and the silence duration. If you want a constant burst with variable silence, turn off both Lag and High modulation, and use Burst Cycle modulation instead. The example below discusses this approach with Play files, but it works equally well for any wave type.
Random Play Timing
You can use the Burst Timing Modulation approach to play a selected sound at random times. Example applications might be simulating a dog barking or bird calling.
Set the Wave type to Play, and load a wave file that includes the desired sound. Use the Play From and Play To controls to isolate just the desired portion, such as single bark or chirp. Make sure Burst Single is set instead of Burst Repeat. Go back to the Stream dialog and enter the Play Rate dialog that will now appear there instead of Tone Freq. Set Reset Phase On Burst.
In the Burst dialog set Lag to zero and High to the same duration as the selected sound. You may need to add some Rise and Fall time to the sound if the selected portion doesn't start and end with silence. In that case, you can reduce High and make the sum of Rise, High, and Fall equal to the selected portion. Some experimentation may be required.
The random delay between sound bursts will come from modulating the Burst Cycle time. Decide what minimum silence interval you want, and add that to the sum of Rise, High, and Fall to get the minimum Cycle time. Do the same with the maximum desired silence interval to get the maximum Cycle time. Set Cycle to the average of these two values. Set the Depth to the difference divided by the average, as before.
Distribution of Values
With White sources as randomizers you will get a uniform distribution of intervals over the specified range. You can use Gaussian sources to concentrate intervals near the mean value (5.5 seconds in the prior example). Decreasing the standard deviation will increase the concentration near the mean, and vice-versa.
If you want a custom distribution that can be completely arbitrary, you can create an text file containing the desired distribution of values. This can then be loaded directly as a Arb file, or you can first use the Convert Text File to .DAT option in the File menu. Use values between -32768 and +32767, repeating values multiple times to increase their representation in the distribution. In other words, this file will not hold a graph of the distribution curve, but an actual collection of values showing that distribution.
Use this Arb file as the Wave Type of an intermediate stream, with its Tone Freq set to zero. Turn on its Phase Modulation and set the modulation source to use a White stream. Set the modulator Depth to 100%, which will cause the White stream to randomly select values from the Arb file. Now use this stream of values as the modulator for the Burst interval. If you want to select values from only a certain portion of the file, reduce the Depth to restrict the range, and adjust the Tone Phase to set the center of the desired portion.
See also Random Selection of Arb Values
Questions? Comments? Contact us!We respond to ALL inquiries, typically within 24 hrs.
Over 35 Years of Innovative Instrumentation
© Copyright 2007 - 2021 by Interstellar Research
All rights reserved