Initial commit: merge nuescan, pymso, pybbd202, and pypewpewhops into scanengine-3
- Merged four separate hardware control projects into unified platform - Created unified requirements.txt with all dependencies - Added comprehensive .gitignore - Added project overview README Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,115 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Test script for transfer_fastframe() method.
|
||||
|
||||
Tests bulk FastFrame transfer with 1MHz square wave on CH1.
|
||||
Signal: 1MHz square wave, +125mV to -125mV
|
||||
"""
|
||||
|
||||
import time
|
||||
from tektronix_base import TektronixOscilloscopeBase
|
||||
|
||||
|
||||
def main():
|
||||
scope_ip = "192.168.10.105"
|
||||
num_frames = 1000
|
||||
|
||||
print(f"Connecting to {scope_ip}...")
|
||||
scope = TektronixOscilloscopeBase(resource_name=scope_ip, timeout=30.0)
|
||||
|
||||
try:
|
||||
scope.connect()
|
||||
print(f"Connected: {scope.identify()}\n")
|
||||
|
||||
# Configure CH1
|
||||
print("Configuring CH1...")
|
||||
scope.set_channel_scale(1, 0.1) # 100mV/div
|
||||
scope.set_channel_offset(1, 0.0)
|
||||
scope.set_channel_coupling(1, 'DC')
|
||||
scope.set_channel_termination(1, 50)
|
||||
|
||||
# Configure horizontal
|
||||
print("Configuring horizontal...")
|
||||
scope.set_record_length(5000)
|
||||
scope.set_time_scale(80e-9) # 80ns/div
|
||||
|
||||
# Configure trigger
|
||||
print("Configuring trigger...")
|
||||
scope.set_trigger_source('CH1')
|
||||
scope.set_trigger_level(1, 0.05) # 50mV
|
||||
scope.set_trigger_slope('RISE')
|
||||
scope.set_trigger_mode('NORMAL')
|
||||
|
||||
# Configure FastFrame
|
||||
print(f"Configuring FastFrame ({num_frames} frames)...")
|
||||
scope.set_fastframe_state(True)
|
||||
scope.set_fastframe_count(num_frames)
|
||||
|
||||
# Verify settings
|
||||
ff_count = scope.get_fastframe_count()
|
||||
record_len = scope.get_record_length()
|
||||
print(f" Frames: {ff_count}, Record length: {record_len}")
|
||||
|
||||
# Configure data transfer
|
||||
print("Configuring data transfer...")
|
||||
scope.set_data_encoding('RIBinary')
|
||||
scope.set_data_source('CH1')
|
||||
|
||||
# Acquire
|
||||
print("\nAcquiring FastFrame data...")
|
||||
scope.write("ACQuire:STATE RUN")
|
||||
time.sleep(2) # Wait for triggers
|
||||
scope.write("ACQuire:STATE STOP")
|
||||
time.sleep(0.5)
|
||||
print(" Acquisition complete")
|
||||
|
||||
# Transfer all frames using the new method
|
||||
print(f"\nTransferring {ff_count} frames using transfer_fastframe()...")
|
||||
start_time = time.time()
|
||||
|
||||
waveforms = scope.transfer_fastframe(parse=True, byte_count=1, signed=True)
|
||||
|
||||
end_time = time.time()
|
||||
total_time = end_time - start_time
|
||||
|
||||
# Results
|
||||
print(f"\n=== Transfer Complete ===")
|
||||
print(f"Frames received: {len(waveforms)}")
|
||||
print(f"Points per frame: {len(waveforms[0])}")
|
||||
print(f"Total samples: {sum(len(wf) for wf in waveforms)}")
|
||||
print(f"Transfer time: {total_time:.3f}s")
|
||||
print(f"Frame rate: {len(waveforms) / total_time:.1f} frames/s")
|
||||
print(f"Sample rate: {sum(len(wf) for wf in waveforms) / total_time / 1e6:.2f} MS/s")
|
||||
|
||||
# Waveform statistics
|
||||
print(f"\n=== Waveform Statistics ===")
|
||||
print(f"Frame 1: min={min(waveforms[0])}, max={max(waveforms[0])}, avg={sum(waveforms[0])/len(waveforms[0]):.1f}")
|
||||
print(f"Frame {len(waveforms)//2}: min={min(waveforms[len(waveforms)//2])}, max={max(waveforms[len(waveforms)//2])}")
|
||||
print(f"Frame {len(waveforms)}: min={min(waveforms[-1])}, max={max(waveforms[-1])}")
|
||||
|
||||
# Check for square wave
|
||||
first_frame = waveforms[0]
|
||||
positive = sum(1 for v in first_frame if v > 0)
|
||||
negative = sum(1 for v in first_frame if v < 0)
|
||||
print(f"\nSquare wave check (frame 1): {positive} positive, {negative} negative samples")
|
||||
print(f"Duty cycle estimate: {positive / len(first_frame) * 100:.1f}%")
|
||||
|
||||
print("\n=== Success! ===")
|
||||
|
||||
except Exception as e:
|
||||
print(f"\nError: {type(e).__name__}: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
finally:
|
||||
if scope.is_connected:
|
||||
try:
|
||||
scope.set_fastframe_state(False)
|
||||
print("\nFastFrame disabled")
|
||||
except:
|
||||
pass
|
||||
scope.disconnect()
|
||||
print("Disconnected")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user