wjasper / Linux_Drivers

Open source Linux device drivers
GNU General Public License v3.0
110 stars 64 forks source link

[USB-201] Values falsely go to 240V #13

Closed tsangiotis closed 6 years ago

tsangiotis commented 6 years ago

Hello! Thanks again for your work on these libraries.

I am trying to measure 10 second signals from 3 channels on the DAQ. Halfway through the measurement, the values go to 240 Volts. This cannot be correct.

I did not have this problem when measuring 2 channels at this or higher samples/frequency combinations.

I also tried multiple lower frequency combinations with no luck.

I have connected the USB-201 to some low voltage sensors but that happens even with empty terminals.

On my Android phone using the official apps I do not get these problems.

Here is the output of the test program on this scenario.

pi@raspberrypi:~/Linux_Drivers/USB/mcc-libusb $ ./test-usb20X
Success, found a USB 201!
wMaxPacketSize = 64
Calibration Table: 0   Slope = 1.047608   Offset = -98.731369
Calibration Table: 1   Slope = 1.050400   Offset = -102.073601
Calibration Table: 2   Slope = 1.050379   Offset = -106.377792
Calibration Table: 3   Slope = 1.046370   Offset = -93.619308
Calibration Table: 4   Slope = 1.045421   Offset = -88.599319
Calibration Table: 5   Slope = 1.045835   Offset = -95.363976
Calibration Table: 6   Slope = 1.045499   Offset = -92.245171
Calibration Table: 7   Slope = 1.049401   Offset = -99.425209

MFG Calibration date = Tue Aug 29 02:18:37 2017

USB 200 Testing
----------------
Hit 'b' to blink
Hit 'c' to test counter
Hit 'd' to test digital IO
Hit 'i' to test Analog Input
Hit 'I' to test Analog Input Scan
Hit 'C' to test continuous sampling.
Hit 'o' to test Analog Output (202/205 only).
Hit 'r' to reset the device
Hit 's' to get serial number
Hit 'S' to get Status
Hit 'e' to exit
I
Testing USB-20X Analog Input Scan.
Enter number of scans: 330000
Enter number of channels [1-8]: 3
Enter sampling frequency [Hz]: 33000
...
...
...
Channel 2  Sample[207650] = 0x9e2 Volts = 2.353516
Channel 0  Sample[207651] = 0x806 Volts = 0.029297
Channel 1  Sample[207652] = 0x876 Volts = 0.576172
Channel 2  Sample[207653] = 0x9e6 Volts = 2.373047
Channel 0  Sample[207654] = 0x805 Volts = 0.024414
Channel 1  Sample[207655] = 0x875 Volts = 0.571289
Channel 2  Sample[207656] = 0x9ec Volts = 2.402344
Channel 0  Sample[207657] = 0x806 Volts = 0.029297
...
... [Error happens around that sample]
...
Channel 0  Sample[655344] = 0x806 Volts = 0.029297
Channel 1  Sample[655345] = 0x875 Volts = 0.571289
Channel 2  Sample[655346] = 0x9e3 Volts = 2.358398
Channel 0  Sample[655347] = 0x806 Volts = 0.029297
Channel 1  Sample[655348] = 0x875 Volts = 0.571289
Channel 2  Sample[655349] = 0x9e3 Volts = 2.358398
Channel 0  Sample[655350] = 0x805 Volts = 0.024414
Channel 1  Sample[655351] = 0x875 Volts = 0.571289
Channel 2  Sample[655352] = 0x9e4 Volts = 2.363281
Channel 0  Sample[655353] = 0x805 Volts = 0.024414
Channel 1  Sample[655354] = 0x876 Volts = 0.576172
Channel 2  Sample[655355] = 0x9e3 Volts = 2.358398
Channel 0  Sample[655356] = 0x806 Volts = 0.029297
Channel 1  Sample[655357] = 0x875 Volts = 0.571289
Channel 2  Sample[655358] = 0x9e4 Volts = 2.363281
Channel 0  Sample[655359] = 0x805 Volts = 0.024414
Channel 1  Sample[655360] = 0xc828 Volts = 240.195312
Channel 2  Sample[655361] = 0xc823 Volts = 240.170898
Channel 0  Sample[655362] = 0xc7a3 Volts = 239.545898
Channel 1  Sample[655363] = 0xc828 Volts = 240.195312
Channel 2  Sample[655364] = 0xc823 Volts = 240.170898
Channel 0  Sample[655365] = 0xc7a3 Volts = 239.545898
Channel 1  Sample[655366] = 0xc828 Volts = 240.195312
Channel 2  Sample[655367] = 0xc823 Volts = 240.170898
Channel 0  Sample[655368] = 0xc7a3 Volts = 239.545898
Channel 1  Sample[655369] = 0xc828 Volts = 240.195312
Channel 2  Sample[655370] = 0xc823 Volts = 240.170898
Channel 0  Sample[655371] = 0xc7a3 Volts = 239.545898
Channel 1  Sample[655372] = 0xc828 Volts = 240.195312
Channel 2  Sample[655373] = 0xc823 Volts = 240.170898
Channel 0  Sample[655374] = 0xc7a3 Volts = 239.545898
Channel 1  Sample[655375] = 0xc828 Volts = 240.195312
Channel 2  Sample[655376] = 0xc823 Volts = 240.170898
Channel 0  Sample[655377] = 0xc7a3 Volts = 239.545898
Channel 1  Sample[655378] = 0xc828 Volts = 240.195312
Channel 2  Sample[655379] = 0xc823 Volts = 240.170898
Channel 0  Sample[655380] = 0xc7a3 Volts = 239.545898
Channel 1  Sample[655381] = 0xc828 Volts = 240.195312
Channel 2  Sample[655382] = 0xc823 Volts = 240.170898
...
...
...
Channel 1  Sample[989986] = 0xc828 Volts = 240.195312
Channel 2  Sample[989987] = 0xc823 Volts = 240.170898
Channel 0  Sample[989988] = 0xc7a3 Volts = 239.545898
Channel 1  Sample[989989] = 0xc828 Volts = 240.195312
Channel 2  Sample[989990] = 0xc823 Volts = 240.170898
Channel 0  Sample[989991] = 0xc7a3 Volts = 239.545898
Channel 1  Sample[989992] = 0xc828 Volts = 240.195312
Channel 2  Sample[989993] = 0xc823 Volts = 240.170898
Channel 0  Sample[989994] = 0xc7a3 Volts = 239.545898
Channel 1  Sample[989995] = 0xc828 Volts = 240.195312
Channel 2  Sample[989996] = 0xc823 Volts = 240.170898
Channel 0  Sample[989997] = 0xc7a3 Volts = 239.545898
Channel 1  Sample[989998] = 0xc828 Volts = 240.195312
Channel 2  Sample[989999] = 0xc823 Volts = 240.170898
tsangiotis commented 6 years ago

Hello again,

I tested with smaller signals. While decrementing one second at the time, the problem goes away if I use six second signal.

It seems like some buffering issue.

Any ideas on the subject?

wjasper commented 6 years ago

The timeout variable in test-usb20X was hard coded to too small a value. I've put in a dynamic value that you may need to play around with, or set to 0 for infinite time. Different processors have different latency times, so it is hard to find a "one size fits all" algorithm. I've tested the code with your example on a desktop and it works now.