Closed VitaliChar closed 1 year ago
Looking at get_samples
:
Returns list of samples read in one sampling period.
The number of sampled values depends on the delay between serial reads. (...)
Are you sure you even have samples in the buffer when not waiting at all? The example also checks that get_data
has valid values before passing it into get_samples
. Please print the get_data
values to see what you are parsing.
Yes, that's right. But if I need to get the maximum number of samples per second, I set the minimum delay between reads: in the PC version, the maximum number of samples = 100,000 is a delay of 0.00001 seconds. If I set delay in my script = 0.00001 the result is as described above.
Result printing get_data
:
def get_data(self):
"""Return readings of one sampling period"""
sampling_data = self.ser.read(self.ser.in_waiting)
print(f"{sampling_data=}")
return sampling_data
sampling_data=b'' 1 -1.0382233070880205 sampling_data=b'\r\x03\x00\xff\x11\x03\x04\xff\x0c\x03\x08\xff\x11\x03\x0c\xff\x0c\x03\x10\xff\x0e\x03\x14\xff\r\x03\x18\xff\t\x03\x1c\xff\n\x03 \xff\x08\x03$\xff\x08\x03(\xff\x08\x03,\xff\x0c\x030\xff\x0b\x034\xff\x08\x038\xff\x08\x03<\xff\x08\x03@\xff\x05\x03D\xff\x00\x03H\xff\xfd\x02L\xff\xff\x02P\xff\xfe\x02T\xff\xfd\x02X\xff\xfe\x02\\xff\x02\x03`\xff\x01\x03d\xff\xfb\x02h\xff\xfd\x02l\xff\xff\x02p\xff\xff\x02t\xff\xfc\x02x\xff\xfe\x02|\xff' 1 33.362310825840595
All resolved, thanks. In total, from all the samples, approximately 100,000 are obtained
Hi, there is a problem. If remove the sleep to obtain the maximum polling frequency, then zero values ("-1.2596387693469735") appear, which distort the final result.
result fragment: 1 -1.2596387693469735 1 -1.2596387693469735 1 41.078069146083955 1 -1.2596387693469735 1 -1.2596387693469735 1 -1.2596387693469735 1 -1.2596387693469735 1 -1.2596387693469735 1 -1.2596387693469735 1 -1.2596387693469735 1 -1.2596387693469735 1 -1.2596387693469735 1 -1.2596387693469735 1 -1.2596387693469735 1 -1.2596387693469735 1 -1.2596387693469735 1 -1.2596387693469735 1 -1.2596387693469735 1 -1.2596387693469735 1 -1.2596387693469735 1 -1.2596387693469735 7 41.15273882494715 1 -1.2596387693469735 1 -1.2596387693469735 1 -1.2596387693469735