I have a script that steps up frequencies over a range. The script works almost as expected, except I'm running into a strange issue with applying the configuration of Scope.Rate, and Scope.Samples.
On the first run of this loop, the Scope configuration is always set to whatever the default or previous configuration of the system was. For example:
If the Scope's base was set in the manual configuration
- 150 kHz sample
- 3 s
- 450 k samples
When I run the script below, the print will read:
"Base=3 Samples=450000 Rate=150000"
Upon the next loop and step up, the configuration will take effect and it will read:
"Base=1.5 Samples=150000 Rate=10000"
I am having trouble understanding why this is taking a loop cycle for my setting changes to take effect. I don't see any reason for it in the script, unless I am using the Scope.config() method incorrectly? Any tips here would be greatly appreciated. Thanks!
// Scope configvar sampleRate =100e3// Sample rate in Hz// Test variablesvar startFrequency =10;// Start frequency in Hzvar endFrequency =120;// Stop frequency in Hzvar stepFrequency =10;// Step frequency in Hzvar pulseTime_sec =1.5;// Pulse time in secfunction runAndCaptureeFrequencySweep(startFreq, endFreq, length_sec){
print("running with startFreq="+ frequency +" endFreq="+ endFreq +" length="+ length_sec +" sec");// Frequency sweepWavegen.Channel1.Mode.text ="Sweep"Wavegen.Channel1.Sweep.Frequency.Start.value = startFreq;Wavegen.Channel1.Sweep.Frequency.Stop.value = endFreq;Wavegen.Channel1.Sweep.Frequency.Time.value = length_sec;Wavegen.Channel1.Sweep.enable =true;// Capture the sweep with Scope// Enable Scope captureScope.Time.Mode.text ="Record";Scope.Time.Trigger="None";Scope.Channel1.fft =true;Scope.Time.Rate.value = sampleRate;Scope.Time.Samples.value = sampleRate * length_sec;Scope.config();
print("Base="+Scope.Time.Base.real+" Samples="+Scope.Time.Samples.real+" Rate="+Scope.Time.Rate.real);Scope.run();Wavegen.run();Scope.wait();// Stop Wavegen and ScopeWavegen.stop();}// Generate each stepped frequencyfor(var freq = startFrequency; freq <= stopFrequency; freq += stepFrequency){
generateAndCaptureTone(freq);
wait(0.5);}
Question
EZaro
// Function to generate and capture a tone
function generateAndCaptureTone(frequency) {
print("generating tone with freq=", frequency);
Wavegen.Channel1.Mode.text = "Simple";
Wavegen.Channel1.Simple.Type.text = "Sine";
Wavegen.Channel1.Simple.Frequency.value = frequency;
Wavegen.Channel1.Simple.Amplitude.value = 1.0;
// Enable Scope capture
Scope.config();
Scope.Time.Mode.text = "Record";
Scope.Time.Trigger = "None";
Scope.Time.Rate.value = sampleRate;
Scope.Time.Samples.value = sampleRate * pulseTime_sec;
Scope.Channel1.fft = true;
Scope.Time.enable = true;
Scope.config();
print("Base="+Scope.Time.Base.real+" Samples="+Scope.Time.Samples.real+ " Rate="+Scope.Time.Rate.real);
Wavegen.run();
Scope.run();
// Run Wavegen for specified time
Scope.wait();
I have a script that steps up frequencies over a range. The script works almost as expected, except I'm running into a strange issue with applying the configuration of Scope.Rate, and Scope.Samples.
On the first run of this loop, the Scope configuration is always set to whatever the default or previous configuration of the system was. For example:
If the Scope's base was set in the manual configuration
- 150 kHz sample
- 3 s
- 450 k samples
When I run the script below, the print will read:
"Base=3 Samples=450000 Rate=150000"
Upon the next loop and step up, the configuration will take effect and it will read:
"Base=1.5 Samples=150000 Rate=10000"
I am having trouble understanding why this is taking a loop cycle for my setting changes to take effect. I don't see any reason for it in the script, unless I am using the Scope.config() method incorrectly? Any tips here would be greatly appreciated. Thanks!
Link to comment
Share on other sites
1 answer to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now