Daqarta for DOS Contents
DAC Frequency adjustment.
They allow the
Freq control to be restricted to discrete
steps that assure perfect continuous sine wave outputs in
Successive ENTERs at the upper control toggle between Off, Tone, and All while the title is Step Hz. Additional toggles change the title to Step N and move through Tone and All before wrapping back to Off.
The Tone modes only use Step operation for output component pages that have Start, Rise, and Fall set to zero, which is what you would need for creating continuous tones in RTime mode. The All modes apply to everything, including tone bursts.
The lower control sets the actual frequency step size in Hz for the Step Hz modes, or in fractions of a spectral line for the Step N modes.
When Step Hz is set to Off, the Freq item on each DAC page is adjustable in 1 Hz steps. For some purposes it may simply be convenient to have preset steps, such as when all component frequencies will be in multiples of a common step size. By setting Step Hz to All and the step size to 100, for example, you can quickly scroll Freq from 1000 to 1100 Hz without hitting every value in between or having to type in the direct value.
But the main advantage of the Step control is in generating continuous output tones using RTime mode. STIM3 produces a continuous tone by sending a sample from the output buffer to a DAC at each sample interval. When all the specified (Sustain) samples in the buffer are completed, it wraps back to the start and repeats. If the Sustain length doesn't hold an exact integer number of cycles of the desired tone, there will be a discontinuity at the wrap point where the output suddenly jumps back to the initial sample value.
For example, suppose the sample rate is 20000 Hz and you want to create a 100 Hz tone. One cycle of this takes 20000 / 100 or 200 samples, so the Sustain duration must be set to some multiple of 200. Of course, if this is to be a continuous pure tone, you must also set Start, Rise, and Fall to zero.
You could do this manually with Step Hz set Off, and it would work just fine. If you wanted to change to 110 Hz, you would find the calculations a bit less obvious, since one cycle takes 20000 / 110 = 181.81818 samples. To get an integer number of cycles, you would need to set Sustain to 2000 samples for exactly 11 cycles.
Even if you are a math whiz, this is cumbersome... and for some frequencies and sample rates it may not be possible to find a Sustain that will give the proper result with the size of buffer you have available.
Worse, scrolling the continuous tone frequency would be impossible, since for each Freq you need a new Sustain.
Step Hz mode set to Tone, all the math is done for you and the Sustain value is set automatically. This applies to any component page that might be used as a continuous tone (Start, Rise, and Fall = 0).
For example, if Step Hz = 10, then the Sustain value will be whatever will hold one cycle of a 10 Hz tone. If the sample rate is 20000 Hz, Sustain will be 20000 / 10 = 2000 samples. The Freq control for that page will now move only to values that are multiples of 10 Hz, so any one of these will thus give an exact integer number of cycles: 10 cycles for 100 Hz, 11 cycles for 110 Hz, 12 for 120 Hz, and so on.
But what if the sample rate is something like 19887 Hz? (This is the closest approximation to 20000 Hz that can be achieved with DEMO.ADC, or with certain laboratory-type boards when using the system timer instead of an on-board sample pacer.) Now to get 10 Hz resolution you would need 1988.7 samples, clearly a problem!
In this case Sustain would be automatically set to 1989 samples and the actual Freq values would be computed for best fit. If you tried to set 100 Hz, Freq would show 99.98 Hz and the true frequency would be 99.9849 Hz (assuming the pacer reference clock is perfectly accurate). In most applications, a small frequency error is much more tolerable than a discontinuity in a continuous tone.
You can usually get closer to the desired frequency by setting Step Hz to a smaller value. This will force a larger Sustain duration which holds more cycles of the tone, allowing better resolution. In the above case setting Step Hz to 2 would result in a Sustain of 9943 samples, and attempting to set Freq to 100 Hz would give 50 cycles at a true output frequency of 19887 * 50 / 9943 = 100.00503 Hz.
The minimum Step Hz value is limited by the available buffer size. For example, if the sample rate is 19887 Hz and the maximum available buffer size allows a total of 16384 samples for the current output and Pg Mode, the longest duration output would be 16384 / 19887 = 0.8239 seconds. The lowest integer frequency that will fit into this buffer will be 2 Hz, one cycle of which will take 0.5000 seconds or 19887 / 2 = 9943.5 samples. So Step Hz will not go below 2 in this case, and when it is set to 2 a Sustain value of 9943 will be set automatically where needed. Since we are using 9943 samples instead of 9943.5, the actual lowest frequency and Step Hz value is 2.0001 Hz.
Although small Step Hz values give finer frequency resolution, the resulting longer Sustain durations mean more time between trace updates (or longer averaging times) when Trigger Source is set to Stim. Each sweep is synchronized to the start of the stimulus buffer, so by utilizing more samples in the buffer it takes longer before it repeats. Thus, for faster operation, don't set Step Hz smaller than you actually need.
For continuous tones, however, you may not even need to have Trig active if you are only viewing or averaging the spectrum and not the waveform, so you could use any Step Hz value you wanted and still get fast operation.
Note that you must set Step Hz BEFORE you set the component Freq. Simply changing the Step Hz value alone does not change any Sustain settings or affect any Freq values, even if Tone mode is active. The Freq values only change when you actually go to adjust them, at which time they will be constrained by the current Step Hz setting. The Sustain value will likewise jump to the corresponding number of samples for continuous tone components.
Although Freq will thus affect Sustain, the opposite is not true: If you change the Sustain value after setting Freq, the existing frequency will be used for the new number of samples even if they no longer form an integer number of cycles.
Step Hz is set to Tone, you can produce up to four different tone components simultaneously on each DAC channel. They will all have the same Sustain value and each will have an integer number of cycles over those Sustain samples. (Remember to reduce the Level of each active component so that the sum is no more than 100% for either DAC channel.)
Rise and Fall value set its output will start and end at zero, so there is no problem with a discontinuity where the buffer repeats... any frequency will work. (You still have to limit the total Level to 100%.)
If you set Step Hz to All mode, then the burst components will have the exact same Step Hz frequency constraints and behavior as continuous tone components. This insures that if you set a burst to the same frequency as a background tone, they will add together to produce a single tone with cyclic amplitude changes.
You can add components in a single DAC channel with careful attention to the total Level, or you can put a burst on one DAC and a continuous tone on the other and control their relative levels with external attenuators for finer level control.
In either Tone or All modes, burst component Sustain must be set manually... there is no automatic action as for continuous tone components.
Note, however, that the timing between bursts will be controlled by the Sustain setting for the continuous tones. That's because the longest Sustain of any active component determines the actual number of samples in the buffer, and any shorter components are simply padded with zeroes. For this reason, don't set the total duration of any tone burst, including Start, Rise, Sustain, and Fall, to more than the Sustain value of the continuous component.
To get longer tone bursts or repeat cycles in this case, you need to increase the length of the continuous tone Sustain by setting the Step Hz value smaller, which will cause the automatic Sustain value to increase when you adjust the continuous tone Freq.
The minimum value for Step Hz is determined by the available buffer samples for the curent Pg Mode and active outputs. If only one DAC output is active and Pg Mode is set to All, then the full buffer size (specified via the B: parameter on the STIM3 line or INIT line of your DQA.CFG file, with 16 Kbytes default) is available and you will get the lowest minimum Step Hz value for the current sample rate... and the maximum Sustain samples.
Activating another DAC channel cuts the available buffer samples for any one output in half, and adding DigOut reduces them further.
Setting Pg Mode to Pair also cuts the available buffer samples in half, since they will be spread over two page phases for each output. Similarly, setting Pg Mode to Each gives you four page phases for each output, so each has only a quarter of the Pg Mode All setting.
In addition, the oversampling Factor interacts with the Step Hz minimum value and the resultant Sustain setting, because it changes the effective output sample rate. Using our prior example of a 19887 Hz sample rate and 16384 samples, setting Factor to 2 gives a 39774 Hz output sample rate. The longest output cycle would be 16384 / 39774 = 0.4119 seconds, which is too short for a 2 Hz cycle of 0.5000 seconds but will hold a 3 Hz cycle of 0.3333 seconds. The minimum Step Hz value will be thus be 3, which leads to a Sustain value of 39774 / 3 = 13258 samples.
The Step N modes allow component frequencies to fall EXACTLY on spectral lines of the FFT, so there are no "skirts" and you can read the response magnitude directly from the cursor readout of a single line.
The spectral line spacing is equal to the sample rate divided by the number of samples N in the FFT data sweep. Example: For N = 1024 samples at a 20 kHz sample rate, it would be 20000 / 1024 = 19.53 Hz.
The Step N line value always assumes that the number of samples is 1024, even if you are only using 512 or 256. (That way it doesn't jump around when you toggle the N-key.) You just have to remember to set Step N to multiples of 2 for N = 512 and to multiples of 4 for N = 256, if you only want tones that land exactly on spectral lines.
However, you CAN set Step N to get tones that land between the lines, with a resolution of 1/64 of a line at N1024. This is equivalent to 1/128 line at N 512 or 1/256 line at N 256.
The minimum Step N value is limited by the available buffer samples to 1024 / BufferSamples. The equivalent frequency step for this value is SampleRate / BufferSamples. The minimum Step N value is also limited such that this equivalent frequency must be at least 1 Hz. For example, with a sample rate of 8008 Hz and a buffer of 16384 samples, the equivalent frequency would be 8008 / 16384 = 0.48877 Hz, so the minimum Step N value would be increased to 9/64 or 0.1406 lines in order to meet the 1 Hz limit. Since one line = 8008 / 1024, this minimum would then be equivalent to 1.0997 Hz.
As with Step Hz, in Tone mode smaller Step N settings result in increased Sustain values for continuous tones, although again no changes take place until you change the corresponding Freq value. And just like with Step Hz, long Sustain durations result in more time between trace updates (or longer averaging times) when Trig is active and Trigger Source is set to Stim, so don't set Step N smaller than you actually need.
In Step N mode the maximum Freq value that may be set is limited to 8 times the sample rate or 65535 Hz, whichever is less. Note that if you set a high Freq value and then reduce the sample rate, this 8x limit will not be applied until you next attempt to change the Freq setting.
Of course, you will never actually need to set Freq higher than half the sample rate (the Nyquist frequency) anyway, since aliasing will fold the output to lower frequencies. But the 8x upper limit allows you to experiment with aliasing and watch it in action as you scroll the Freq value.
One of the major uses for Step N mode is in the analysis of intermodulation (IM) distortion, where you present two simultaneous tones and look for inharmonic distortion products. Since the product frequencies will appear at multiples of the sum and difference of the stimulus frequencies, Step N can assure that all of these fall exactly on spectral lines, as will all harmonic distortion products.
Questions? Comments? Contact us!We respond to ALL inquiries, typically within 24 hrs.
25 Years of Innovative Instrumentation
© Copyright 1999 - 2006 by Interstellar Research