pklaus / ds1054z

Python package for the Rigol DS1054Z Oscilloscope
https://ds1054z.readthedocs.org/
176 stars 40 forks source link

get_waveform_samples does not fetch the complete internal memory in RAW mode #5

Closed LongHairedHacker closed 7 years ago

LongHairedHacker commented 7 years ago

I've just noticed that get_waveform_samples("CHAN1", "RAW") always returns 1200 samples, from my DS1054z, regardless of the state of the scope or the configured memory depth.

After enabling logging reading through the debug output I realized that the points field in the waveform preamble is always set to 1200 for me, whereas memory_depth_curr_waveform returns the correct memory depth for all scenarios I've tested so far.

Here is a small piece of code to reproduce this:

#!/usr/bin/env python3

import logging
from ds1054z import DS1054Z

def main():
    logging.basicConfig(level=logging.DEBUG)

    scope = DS1054Z('192.168.0.23')
    print("Connected to: ", scope.idn)

    samples = scope.get_waveform_samples("CHAN1", "RAW")
    print(len(samples))

    print(scope.memory_depth_curr_waveform)

if __name__ == '__main__':
    main()

The output while the scope is stopped, with only one channel active and the memory depth set to 12M manually is:

DEBUG:pyds1054z.ds1054z:sending: b'*IDN?'
DEBUG:pyds1054z.ds1054z:received: b'RIGOL TECHNOLOGIES,DS1054Z,XXXXXXXXXXXXXXX,00.04.02.SP4\n'
DEBUG:pyds1054z.ds1054z:sending: b'*IDN?'
DEBUG:pyds1054z.ds1054z:received: b'RIGOL TECHNOLOGIES,DS1054Z,XXXXXXXXXXXXXXX,00.04.02.SP4\n'
Connected to:  RIGOL TECHNOLOGIES,DS1054Z,XXXXXXXXXXXXXXX,00.04.02.SP4
DEBUG:pyds1054z.ds1054z:sending: b':TRIGger:STATus?'
DEBUG:pyds1054z.ds1054z:received: b'STOP\n'
DEBUG:pyds1054z.ds1054z:sending: b':TRIGger:STATus?'
DEBUG:pyds1054z.ds1054z:received: b'STOP\n'
DEBUG:pyds1054z.ds1054z:sending: b':WAVeform:SOURce CHAN1'
DEBUG:pyds1054z.ds1054z:sending: b':WAVeform:FORMat BYTE'
DEBUG:pyds1054z.ds1054z:sending: b':WAVeform:MODE RAW'
DEBUG:pyds1054z.ds1054z:sending: b':WAVeform:PREamble?'
DEBUG:pyds1054z.ds1054z:received: b'0,2,1200,1,1.000000e-09,-6.000000e-03,0,2.074219e-01,-78,122\n'
DEBUG:pyds1054z.ds1054z:sending: b':WAVeform:STARt 1'
DEBUG:pyds1054z.ds1054z:sending: b':WAVeform:STOP 1200'
DEBUG:pyds1054z.ds1054z:sending: b':WAVeform:DATA?'
DEBUG:pyds1054z.ds1054z:received a long answer: 23 39 30 30 30 30 30 31 32 30 ... 70 71 71 71 71 71 70 70 71 0A
DEBUG:pyds1054z.ds1054z:sending: b':WAVeform:PREamble?'
DEBUG:pyds1054z.ds1054z:received: b'0,2,1200,1,1.000000e-09,-6.000000e-03,0,2.074219e-01,-78,122\n'
1200
DEBUG:pyds1054z.ds1054z:sending: b':WAVeform:MODE?'
DEBUG:pyds1054z.ds1054z:received: b'RAW\n'
DEBUG:pyds1054z.ds1054z:sending: b':TRIGger:STATus?'
DEBUG:pyds1054z.ds1054z:received: b'STOP\n'
DEBUG:pyds1054z.ds1054z:sending: b':ACQuire:MDEPth?'
DEBUG:pyds1054z.ds1054z:received: b'12000000\n'
12000000

(I've removed the output for info as it contained only timing information.)

I'd like to know if anybody can reproduce this, or if this is a problem specific to my setup. If I can find the time next week, I'll try to reproduce it on my other DS1054z.

Meanwhile I've been able to get get_waveform_samples working for me, by using the memory_depth_curr_waveform instead of the points value from the waveform preamble to determine how many sample should be fetched from the scope. In theory this should not break anything else, as the modified line is in _get_waveform_bytes_internal.

I can also provide a pull request with my fix.

LongHairedHacker commented 7 years ago

D'oh I've just discovered my approach fails as well, if the memory depth is set to 'AUTO'.

LongHairedHacker commented 7 years ago

Turns out updating to the latest firmware (00.04.04.03.02) seems to fix all of the oddities I encountered.

pklaus commented 7 years ago

Thanks for your bug report. I'm glad that the latest firmware version works again as it should. I took the opportunity to power up my device again and work on this Python package. I will close this issue for now. Please reopen if you encounter a related problem or open a new one.