import time import pylab from PyHT6022.HTSDKScope import Oscilloscope if __name__ == "__main__": scope0 = Oscilloscope(scopeid=0) if not scope0.is_attached(): print("WARNING: Scope not found!") exit() scope0.set_voltage_division(1, 5) print(scope0.set_sampling_rate(26)) scope0.setup_dso_cal_level() pylab.ion() length = 1000 for i in range(1): data = scope0.read_data_from_scope(data_points=300) tIndex = data[3].value pylab.plot(data[2][:length], data[0][tIndex:tIndex + length]) # , 'r-') pylab.draw() time.sleep(100)
scope.set_voltage_division(1, 6) scope.set_sampling_rate(500) samplerate = 1000 * 1000 scope.set_sampling_rate(24) scope.setup_dso_cal_level() cal_level = scope.get_calibration_data() scope.set_dso_calibration(cal_level) data = [] total = 0 print "Reading data from scope!" for x in range(0, 10): print x data.append( scope.read_data_from_scope(1047550, raw_data=True)[scope_channel - 1]) total += len(data[x]) filename = "test.wav" print "Writing out data from scope to {}".format(filename) with open(filename, "wb") as wf: wf.write("RIFF") wf.write(pack("<L", 44 + total - 8)) wf.write("WAVE") wf.write("fmt \x10\x00\x00\x00\x01\x00\x01\x00") wf.write(pack("<L", samplerate)) wf.write(pack("<L", samplerate)) wf.write("\x01\x00\x08\x00") wf.write("data") wf.write(pack("<L", total)) raw = StringIO.StringIO()
scope.set_voltage_division(100, 200) scope.set_voltage_division(1, 6) scope.set_sampling_rate(500) samplerate = 1000 * 1000 scope.set_sampling_rate(24) scope.setup_dso_cal_level() cal_level = scope.get_calibration_data() scope.set_dso_calibration(cal_level) data = [] total = 0 print "Reading data from scope!" for x in range(0, 10): print x data.append(scope.read_data_from_scope(1047550, raw_data=True)[scope_channel-1]) total += len(data[x]) filename = "test.wav" print "Writing out data from scope to {}".format(filename) with open(filename, "wb") as wf: wf.write("RIFF") wf.write(pack("<L", 44 + total - 8)) wf.write("WAVE") wf.write("fmt \x10\x00\x00\x00\x01\x00\x01\x00") wf.write(pack("<L", samplerate)) wf.write(pack("<L", samplerate)) wf.write("\x01\x00\x08\x00") wf.write("data") wf.write(pack("<L", total)) raw = StringIO.StringIO()
import time import pylab from PyHT6022.HTSDKScope import Oscilloscope if __name__ == "__main__": scope0 = Oscilloscope(scopeid=0) if not scope0.is_attached(): print("WARNING: Scope not found!") exit() scope0.set_voltage_division(1, 5) print(scope0.set_sampling_rate(26)) scope0.setup_dso_cal_level() pylab.ion() length = 1000 for i in range(10): data = scope0.read_data_from_scope(data_points=3000) tIndex = data[3].value pylab.plot(data[2][:length], data[0][tIndex:tIndex + length]) # , 'r-') pylab.draw() time.sleep(1)
scope0 = Oscilloscope(scopeid=0) scope0, TScale, VScale1, VScale2 = SetScope(2, 2, 27) #TenXProbe=True #if(TenXProbe): # VScale1=VScale1*10 # VScale2=VScale2*10 numSampRead = 2000 numSampSave = 100 / 2 Ch1Trig = 0.01 Triggered = False print "Waiting for Trigger" while (Triggered == False): rawData = scope0.read_data_from_scope(data_points=numSampRead) ch1Data = np.asarray(rawData[0]) * VScale1 ch2Data = np.asarray(rawData[1]) * VScale2 timeData = np.asarray(rawData[2]) * TScale # conversion to microsec if (ch1Data.max() > Ch1Trig): Triggered = True ch1Max = np.argmax(ch1Data) if (ch1Max + numSampSave > numSampRead): ch1Max = numSampRead - numSampSave if (ch1Max - numSampSave < 0): ch1Max = numSampSave plt.plot(timeData[ch1Max - numSampSave:ch1Max + numSampSave], ch1Data[ch1Max - numSampSave:ch1Max + numSampSave], 'y-', timeData[ch1Max - numSampSave:ch1Max + numSampSave], ch2Data[ch1Max - numSampSave:ch1Max + numSampSave], 'b-') plt.xlabel("time[us]") plt.ylabel("Volt [V]")