Closed MarkRivers closed 2 years ago
Attached is an all Linux example featuring the USB-2408-2AO, running ulTIn() in a 250 mS continuous loop (I have also run this at 500 mS and 100 mS sleep). Granted I am showing the data in degrees F. It does not show the aberration you are seeing. Note that since this function returns static values (not data returned in an array) there really is no sample rate supplied to the ulTIn function, that is a 'function' of the sleep() timer. There is a data RATE parameter but that is set for settling time for the 24 bit A/D converter. Not to be confused with Sample Rate. to be clear, Sample Rate is not the same as Data Rate. 2408_TIn.zip
@jeffreyg3 I fully understand the difference between the rate at which I read the temperature (controlled by sleep) and the data rate, which is the averaging time in the 2408. It is controlled by this function call:
err = ulAISetConfigDbl(devHandle, AI_CFG_CHAN_DATA_RATE, 0, dataRate);
This dataRate is what I was calling samplingRate, which may be the source of the confusion.
As you will recall from another recent issue I had on Linux it is necessary to set AI_CFG_CHAN_DATA_RATE because it is not read from the non-volatile memory (as it is on Windows) and defaults to a very short time which leads to very noisy temperature measurements.
My issue that that if I set dataRate to 60 it works fine. If I set it to 20 or less it works fine on Windows, but returns occasional spurious values on Linux. I have an application where I am seeing noise on the thermocouple with 60 Hz data rate, so I want to increase the averaging in the device by slowing down the data rate.
Please run the test program in the link in my original message and I am sure you will reproduce the problem.
@MarkRivers per our off github conversations, this issue has been resolved to your satisfaction. Please close this thread/topic.
This problem is due to the cold junction compensation (CJC) value occasionally being read incorrectly from the device. This problem was observed on Ubuntu 18 and Centos 8.
The following is a workaround which adds a 100 microsecond sleep in AiUsb24xx::updateCjcValues().
corvette:~/devel/libuldaq-1.2.1>git diff
diff --git a/src/usb/ai/AiUsb24xx.cpp b/src/usb/ai/AiUsb24xx.cpp
index 38a3aa9..9341c71 100644
--- a/src/usb/ai/AiUsb24xx.cpp
+++ b/src/usb/ai/AiUsb24xx.cpp
@@ -534,6 +534,8 @@ void AiUsb24xx::updateCjcValues()
if(daqDev().getDeviceType() == DaqDeviceId::USB_2416 || daqDev().getDeviceType() == DaqDeviceId::USB_2416_4AO)
dataCount = 8;
+ // This usleep call is needed on Intel processors, otherwise occasionally the first 1 or 2 bytes of the CJC response are 0xFF so the value is
+ usleep(100);
daqDev().queryCmd(CMD_CJC, 0, 0, (unsigned char*) &data, dataCount * sizeof(short));
Measurement Computing should decide if this is the correct fix, or whether some other change should be made.
I am having trouble with ulTIn on the USB-2408-2A0 with sampling times less than 60 Hz on for Linux. It works fine with cbTIn on UL for Windows.
I have written a test program to demonstrate the problem.
https://github.com/epics-modules/measComp/blob/UL_for_Linux_Direct/measCompApp/src/test_TIn_1.cpp
These are the comments at the beginning of the program that explain how to run it, and the problem I observe.
This is the output when running on Windows with sampleRate=60 Hz, OTD disabled, 20 readings. It works fine, the standard deviation of the readings is 0.004 degrees.
This is the output when running on Windows with sampleRate=20Hz, OTD disabled, 20 readings. It works fine, the standard deviation of the readings is still 0.004 degrees.
This is the output when running on Linux with sampleRate=60 Hz, OTD disabled, 20 readings. It works fine, the standard deviation of the readings is 0.006 degrees.
This is the output when running on Linux with sampleRate=20 Hz, OTD disabled, 20 readings. It does not work correctly. Most of the readings are OK, but 2 of the readings are -7.1 degrees, rather than 21 degrees.
There are some applications where I need to average for more than 1/60 second. This works on Windows but fails on Linux.