oscilloscope – Reading Waveform from LeCroy 9310AL via RS232
I am currently trying to read the waveform from my LeCroy9300AL. I do manage to connect to the oscilloscope and retrieve data. But I struggle to interpret this data.
My current script is:
import serial
import matplotlib.pyplot as plt
import numpy as np
s = serial.Serial(port="/dev/ttyUSB0", baudrate=19200, bytesize=8, parity="N", timeout=60)
s.write(b"waveform_setup sp,100\r")
# Read echoed command
echo = s.read_until(b'\r')
s.write(b"C1:WaveForm? Dat1\r")
# Read echoed command
echo = s.read_until(b'\r')
print(echo)
waveform_data = s.read_until(b"\r")
print(waveform_data)
# get header length
raw_start = waveform_data.find(b"#")
raw = waveform_data[raw_start:]
# get data length
num_digits = int(raw[1] - 48)
length = int(raw[2:2+num_digits])
print(f"Waveform data length: {length} bytes")
waveform_bytes = raw[2+num_digits:2+num_digits+length]
# Extract the waveform bytes
waveform = np.frombuffer(waveform_bytes, dtype=">u2")
real_waveform = np.array(waveform[::2])
vertical_gain = 0.029999999329447746
vertical_offset = 0.0001220703125
real_waveform = vertical_gain * real_waveform - vertical_offset
plt.plot(real_waveform)
plt.title("LeCroy Waveform")
plt.xlabel("Sample")
plt.ylabel("Voltage (V)")
plt.show()
My current problem is that the waveform seems to be “blocky.” I attached an image which should be an sine wave. What confuses me is that these blocks aren’t perfectly square what I would expect when it is an problem of the ADC resolution.
I tried to match as much as possible all the information I was able to extract from the data descriptor (BigEndian, word size, etc.).
I would like to know if some of you encountered similar problems and could point me in the correct direction for troubleshooting.
Read more here: Source link

