ppannuto / python-saleae

Python library to control a Saleae Logic Analyzer
Apache License 2.0
125 stars 54 forks source link

Issues with Logic 8 #8

Closed echiou closed 8 years ago

echiou commented 9 years ago

When using a Logic 8 (both in demo mode and when one is plugged into the computer), self.set_sample_rate_by_minimum() asserts that self.sample_rates[0][0] >= self.sample_rates[-1][0], and it seems like the Logic 8 does the opposite (it returns it sorted lowest to highest). Is this intentional, or a bug somewhere (and thus we should check for which device we are using).

ppannuto commented 9 years ago

Hmm.. I'm not sure about this. @Marcus10110 is there an expected behavior here?

Marcus10110 commented 9 years ago

There is nothing in the software to guarantee that the sample rates are sorted, but in general, I would expect them to be sorted from analog slowest to analog fastest. (this implies digital fastest to digital slowest, but due to complex FPGA requirements, you will find frequent exceptions to this) It's possible that analog sample rates are always sorted from fastest to slowest.

Basically, for any given performance setting (which directly relates to USB throughput) the available sample rates try to offer a trade off between digital and analog sample rates. (i.e. trade analog bandwidth for digital bandwidth, and vice versa)

I would update set_sample_rate_by_minimum to scan all performance options, and every sample rate option. I would ignore sorting and check every option, while tracking the lowest analog & digital pair that satisfies the requirement.

if you would like to select exactly the slowest sample rate for a given requirement, the USB bit rate can be calculated like this:

ADC width = 12 bits for Logic 8, Pro 8 and Pro 16. ADC width = 8 bits for logic 4.

Bandwidth (bits per second) = (digital_sample_rate * digital_channel_count) + (analog_sample_rate * analog_channel_count * adc_width).

That's the exact USB bandwidth requirement for any sample rate combination. There is no additional overhead. The lower the bandwidth, the higher the reliability for long duration captures. (this really only affects the original Logic and Logic 4, and only on poor-performance host controllers)