使用pyvisa从示波器获取数据

时间:2015-01-18 16:27:02

标签: visa

我试图通过TCP / IP从DSO_X 2024a读取波形数据,我需要特定数量的点。如何从范围获得浮点结果?

代码

import visa
rm = visa.ResourceManager()
Scope=rm.get_instrument(addrSRC)
print(Scope.ask("*IDN?"))
print(Scope.write(":SYSTem:PRESet"))
print(Scope.write(':WAVeform:POINts 5000'))
print(Scope.write(':WAVeform:SOURce CHANnel3'))

print(Scope.write(':WAVeform:FORMat WORD'))
print(Scope.ask(':WAVeform:FORMat?'))
data_bytes = Scope.query_ascii_values(':WAVeform:DATA?')

1 个答案:

答案 0 :(得分:1)

要检查它是否正常工作,我发现最好将波形格式更改为ASCII,然后使用普通" .ask()" :

import visa

rm = visa.ResourceManager()
myScope = rm.get_instrument(instAddress)
# example instAddress ='GPIB0::12::INSTR'
# you can find out the address using <rm.list_resources()>

print(myScope.ask("*IDN?"))
myScope.write("WGEN:FREQ 50000") #connect the wavegen to channel 1
myScope.write("WGEN:FUNC SIN")
myScope.write("WGEN:OUTP ON")
myScope.write("WGEN:VOLT 2")

myScope.write(":TIMebase:SCALe 3.0E-5")
myScope.write(":WAVeform:SOURce CHANnel1")
myScope.write(":WAVeform:FORMat ASCII")
myScope.write(":WAVeform:POINts 1000")

data = myScope.ask("WAV:DATA?")

print(data)

输出是这样的:

"#800026879 1.75879e-001,-2.88945e-001,-7.66332e-001..."