Seeking clipping detection example for MSO46B #490
-
|
Hello, I am using an MSO46B with
I am reading I am experiencing an issue on step 4. Using the CHx:CLIPPING? query returns 0 even when the waveform data is obviously saturated. I am able to get a more reliable result by configuring a measurement on CHx, (e.g. Peak-to-Peak) and monitoring ESR and EVMSG for measurement warnings and errors related to clipping. However, this too is cumbersome as I have not found a way to associate those errors with a specific channel. Is it possible to provide a simple example of how to detect and rescale to achieve maximum usage of the vertical scale? def get_data(self, burst_num_cycles: int):
n = 0
self.scope.inst.commands.acquire.stopafter.write("SEQuence")
while True:
self.scope.inst.commands.acquire.state.write("RUN")
self.scope.inst.poll_query(
number_of_polls=100,
query="TRIGger:STATE?",
wanted_val="READY",
sleep_time=0.001,
)
self.fun.inst.write(f"INV:BURSTCYCles {int(burst_num_cycles)}")
self.scope.inst.commands.opc.query()
self.scope.inst.poll_query(
number_of_polls=100,
query="TRIGger:STATE?",
wanted_val="SAVE",
sleep_time=0.001,
)
with self.scope.hsi.access_data(AcqWaitOn.AnyAcq):
needs_rescale = False
ch2_scale = float(self.scope.inst.query("CH2:SCAle?"))
vpkpk2 = float(self.scope.inst.query("MEASUrement:MEAS1:VALue?"))
esr = int(self.scope.inst.commands.esr.query())
if esr:
evmsg = self.scope.inst.commands.evmsg.query()
import ipdb; ipdb.set_trace()
print(f"vpkpk2: {vpkpk2}")
print(f"clipping?: {self.scope.inst.commands.ch[2].clipping.query()}")
print(f"clipping?: {self.scope.inst.query('CH2:CLIPping?')}")
if int(self.scope.inst.query("CH2:CLIPping?")) == 1:
print("CH2 is clipping")
self.scope.inst.write(f"CH2:SCAle {ch2_scale * 2}")
needs_rescale = True
if vpkpk2 < ch2_scale:
self.scope.inst.write(f"CH2:SCAle {ch2_scale / 2}")
needs_rescale = True
ipkpk = float(self.scope.inst.query("MEASUrement:MEAS3:VALue?"))
print(f"ipkpk: {ipkpk}")
print(f"clipping?: {self.scope.inst.commands.ch[4].clipping.query()}")
print(f"clipping?: {self.scope.inst.query('CH4:CLIPping?')}")
ch4_scale = float(self.scope.inst.query("CH4:SCAle?"))
if int(self.scope.inst.query("CH4:CLIPping?")) == 1:
print("CH4 is clipping")
self.scope.inst.write(f"CH4:SCAle {ch4_scale * 2}")
needs_rescale = True
if ipkpk < ch4_scale:
self.scope.inst.write(f"CH4:SCAle {ch4_scale / 2}")
needs_rescale = True
if needs_rescale:
n += 1
print(f"Scope rescaled {n} times, acquiring once more...")
self.scope.inst.write("ACQuire:STATE STOP")
self.scope.inst.query("*OPC?") # fence after scale changes
continue
ch1 = self.scope.hsi.get_data("ch1")
ch2 = self.scope.hsi.get_data("ch2")
ch3 = self.scope.hsi.get_data("ch3")
ch4 = self.scope.hsi.get_data("ch4")
assert (
len(ch1.normalized_vertical_values)
== len(ch2.normalized_vertical_values)
== len(ch3.normalized_vertical_values)
== len(ch4.normalized_vertical_values)
), "Channel data lengths do not match"
return {
"vin": ch1.normalized_vertical_values,
"vcap": ch2.normalized_vertical_values,
"icvr": ch4.normalized_vertical_values,
"time_vec": ch1.normalized_horizontal_values,
}Kind regards, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
Here is an example of the behavior I am observing: CH2 is clearly clipping but CH2:CLIPPING? returns 0: |
Beta Was this translation helpful? Give feedback.
-
|
I have found that it is possible to query whether or not a particular measurement has warnings or errors with the following procedure:
|
Beta Was this translation helpful? Give feedback.

I have found that it is possible to query whether or not a particular measurement has warnings or errors with the following procedure:
*ESR?to clear the ESR registerMEASUrement:MEAS3:VALue?*ESR?to check whether or not there is an error associated with query 2.EVENT?to get the exact error code.