Jump to content

EZaro

Members
  • Posts

    1
  • Joined

  • Last visited

EZaro's Achievements

Newbie

Newbie (1/4)

0

Reputation

  1. // 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! // Scope config var sampleRate = 100e3 // Sample rate in Hz // Test variables var startFrequency = 10; // Start frequency in Hz var endFrequency = 120; // Stop frequency in Hz var stepFrequency = 10; // Step frequency in Hz var pulseTime_sec = 1.5; // Pulse time in sec function runAndCaptureeFrequencySweep(startFreq, endFreq, length_sec){ print("running with startFreq=" + frequency + " endFreq=" + endFreq + " length="+ length_sec + " sec"); // Frequency sweep Wavegen.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 capture Scope.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 Scope Wavegen.stop(); } // Generate each stepped frequency for(var freq = startFrequency; freq <= stopFrequency; freq += stepFrequency) { generateAndCaptureTone(freq); wait(0.5); }
×
×
  • Create New...