Hi all,
Using a tango device server to get information from an oscilloscope by the network I can get the waveform when I use ASCII format. Calling:
+:WAVeform:SOURce CHANnel1;:WAVeform:FORMat ascii;:WAVeform:DATA?+
I get an string:
+8E-03,4E-03,1E-03,1E-03,1E-03,0.0E+00,1E-03,3E-03,8E-03,1.2E-02,1.1E-02,6E-03,2E-03,3E-03,7E-03,...+
This contains the 40000 points of the plot:
!https://www.cells.es/Members/sblanch/Ellipsis/Visa-instruments/waveform-data/at_download!
But when I try the same but in binary format:
+:WAVeform:SOURce CHANnel1;:WAVeform:FORMat word;:WAVeform:DATA?+
The answer doesn't contain all the waveform:
+'#580004\xe4\xfd\xe1\xfd,\xfe\xaa\xfe\xf3\xfe\xbf\xfeI...+
Not 80004 elements follows the header. Worst than that the number of words varies between a few tenths to a thousand, but never the complete waveform.
I have tried to use the +[start\[,size]]+ parameters of the command and try to read more often parts of the waveform, but the signal is triggered more often than what I can check it.
How can I get the complete waveform, like I have with ascii format?
Using a tango device server to get information from an oscilloscope by the network I can get the waveform when I use ASCII format. Calling:
+:WAVeform:SOURce CHANnel1;:WAVeform:FORMat ascii;:WAVeform:DATA?+
I get an string:
+8E-03,4E-03,1E-03,1E-03,1E-03,0.0E+00,1E-03,3E-03,8E-03,1.2E-02,1.1E-02,6E-03,2E-03,3E-03,7E-03,...+
This contains the 40000 points of the plot:
!https://www.cells.es/Members/sblanch/Ellipsis/Visa-instruments/waveform-data/at_download!
But when I try the same but in binary format:
+:WAVeform:SOURce CHANnel1;:WAVeform:FORMat word;:WAVeform:DATA?+
The answer doesn't contain all the waveform:
+'#580004\xe4\xfd\xe1\xfd,\xfe\xaa\xfe\xf3\xfe\xbf\xfeI...+
Not 80004 elements follows the header. Worst than that the number of words varies between a few tenths to a thousand, but never the complete waveform.
I have tried to use the +[start\[,size]]+ parameters of the command and try to read more often parts of the waveform, but the signal is triggered more often than what I can check it.
How can I get the complete waveform, like I have with ascii format?
Well, to day I can only get noise from the scope signalling, and with the way it works, the ASCII format I get data similar to the scope:
!https://www.cells.es/Members/sblanch/Ellipsis/Visa-instruments/scodisr0201_WfFormat_ascii/at_download!
The code to get it is simple. I am formatting the output trace as:
DEBUG sr02/di/sco-01 In sr02/di/sco-01::ask_for_values() query= :WAVeform:SOURce CHANnel1;:WAVeform:DATA?
DEBUG sr02/di/sco-01 In sr02/di/sco-01::ask_for_values() answer= "\[ 0.005 0.009 0.011 0.008 0.003 0.001 0.003 0.005 0.004 0. -0.001 -0.001 -0.001 -0.002 -0.001 0. 0.001 0. -0.003 -0.006 -0.005 -0.001 0.006 0.01 0.01 0.006 0.001 0. 0.004 0.009 0.011 0.009 0.005 0.001 0.001 0.002 0.002 0.001 0. 0. -0.001 -0.001 0.002 0.007 0.011 0.011 0.006 0. -0.003 0. 0.003 0.004 0.004 0.003 0.002 0.002 0.003 0.006 0.006 0.004 -0.001 -0.004 -0.002 0.005 0.009 0.007 0.003 0.001 0.004 0.008 0.009 0.007 0.006 0.006 0.007 0.008 0.008 0.009 0.011 0.011 0.012 0.014 0.018 0.018 0.012 0.003 -0.003 -0.001 0.005 0.008 0.007 0.004 0.004 0.005 0.005 0.004 0.004 0.006 0.007 0.004]... +39902)"
*DEBUG sr02/di/sco-01 In sr02/di/sco-01::read_ChannelN() waveform= "\[ 0.003 0.007 0.007 ..., 0.009 0.005 -0.001]"*
This is what has been already check and compared with a real oscilloscope signal. But when try to get this data using binary this doesn't works this good.
Reading the data using BYTE or WORD formats, the date is being processed this way:
if not _waveform[0] == '#':
raise AttributeError,"Wrong data receiver from channel %d"%chNum
nBytesLengthBlock = int(_waveform[1])
nBytesWaveBlock = int(_waveform\[2:nBytesLengthBlock+2])
waveBytes = _waveform\[nBytesLengthBlock+2:nBytesWaveBlock]
if WaveformDataFormat == 'BYTE':
format = 'B'#unsigned char, 1byte
divisor = 1
elif WaveformDataFormat == 'WORD':
format = 'H'#unsigned short, 2byte
divisor = 2
else:
raise AttributeError,"Cannot decodify data receiver from channel %d"%chNum
nCompletBytes = len(waveBytes)-(len(waveBytes)%divisor)
if not len(waveBytes)%4 == 0:
print("nIncompleteBytes = %d"%(len(waveBytes)%divisor))
if not WaveformDataFormat == 'LONG':
#expand the input when each float is codified in less than 4 bytes
h = struct.unpack(format*(nCompletBytes/divisor),waveBytes\[:nCompletBytes])
i = struct.pack('I'*len(h),*h\[:len(h)])
else:
i = waveBytes
f = struct.unpack('f'*(len(i)/4),i\[:len(i)])
With this code, what I am trying is to "expand" the byte/word data to be possible to unpack it in floats. But the signals doesn't look equivalent (with precision differences):
In the case of the BYTE format:
!https://www.cells.es/Members/sblanch/Ellipsis/Visa-instruments/scodisr0201_WfFormat_byte/at_download!
With the output trace:
DEBUG sr02/di/sco-01 In sr02/di/sco-01::ask() query=:WAVeform:SOURce CHANnel1;:WAVeform:DATA?
DEBUG sr02/di/sco-01 In sr02/di/sco-01::ask() answer= '#540002\x00\x00\x00\xff\xff\xff\x00\x00\x00\x00\x01\x01\x00\x00\x00\x01\x01\x00\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\x00\x01\x01\x01\x00\xff\xff\x00\x01\x01\x00\x00\x00\x00\xff\xff\x00\x00\x00\xff\xfe\xfe\xff\x00\x00\xff\xff\xff\x00\xff\xff\xff\x00\x00\x00\x00\x01\x01\x00\x00\xff\xff\x00\x00\x00\x00\x00\xff\xff\xff\xff\x00\x00\x00\x00'...(+39909)
*DEBUG sr02/di/sco-01 In sr02/di/sco-01::read_ChannelN() waveform= "'(0.0, 0.0, 0.0, 3.5733110840282835e-43, 3.5733110840282835e-43, 3.5733110840282835e-43, 0.0, 0.0, 0.'...(+578754)"*
In case of the WORD format:
!https://www.cells.es/Members/sblanch/Ellipsis/Visa-instruments/scodisr0201_WfFormat_word/at_download!
With the output trace:
DEBUG sr02/di/sco-01 In sr02/di/sco-01::ask() query=:WAVeform:SOURce CHANnel1;:WAVeform:DATA?
DEBUG sr02/di/sco-01 In sr02/di/sco-01::ask() answer= '#580004\x1e\xfc(\xfc\xb2\xfc\x11\xfd*\xfd_\xfd\xd8\xfd7\xfe\x13\xfe\x9e\xfd{\xfd\xfc\xfd\xb0\xfe\xdf\xfeg\xfe\xdf\xfd\xd8\xfd'\xfe+\xfe\xbd\xfd\x7f\xfd\x12\xfe4\xff\xe5\xffr\xff-\xfe\x05\xfd\xb0\xfc&\xfd\xde\xfdA\xfe\x17\xfe\xa3\xfdg\xfd\xac\xfd0\xfei\xfe\x1e\xfe\xa9\xfd\x93\xfd\xf9\xfdy\xfe\xa2\xfeb\xfe\xf1\xfdy\xfd\x05"...(+79911)
*DEBUG sr02/di/sco-01 In sr02/di/sco-01::read_ChannelN() waveform= "'(9.0442605484452343e-41, 9.0456618469095592e-41, 9.0649997657172416e-41, 9.0783121011283274e-41, 9.0'...(+955613)"*
My questions now are:
*a)* Is this conversion/expansion correct?
I think I am doing something wrong because BYTE/WORD are too different than ASCII formats. At least those binary formats are not soo different, but the WORD have some "glitch"s that neither I understand.
*b)* Now it looks that I am getting the 40000 points for the plot. Would be possible that previous data read that looks shorter, where because some '\x00' or termination characters becomes in the stream? I am not sure about that, but by now I didn't see them again using str.__repr__()
Thanks