Hi All,
With a channel list defined like:
POS_IN_NAMES = ["CORE_TIMER", "STREAM_DATA_CAPTURE_16", "AIN0", "AIN1", ... "ANIN13", "CORE_TIMER", "STREAM_DATA_CAPTURE_16"]
We're noticing that the values reported in "AIN0" are not what is expected. The values seem to increase or decrease with each sample (the channel is connected to a low-impedance source, and properly ground referenced).
If I remove "CORE_TIMER", "STREAM_DATA_CAPTURE_16" from the channel list, the reported data remains steady.
I suppose that we're doing something wrong in the setup of reading Core_Timer. Any good ideas?
Data and code below.
With Core Timer (notice column #3 is decreasing):
18829.0, 61014.0, -10.0296916962, -10.5794315338, -5.2149720192, -9.17303276062,
21133.0, 61075.0, -10.0252714157, -10.5810098648, -5.21307754517, -9.17177009583,
23437.0, 61136.0, -10.018324852, -10.5806941986, -5.21339321136, -9.17208576202,
25741.0, 61197.0, -10.0107460022, -10.5810098648, -5.21623516083, -9.17082214355,
28045.0, 61258.0, -10.0164299011, -10.5810098648, -5.21244621277, -9.17113876343,
30350.0, 61319.0, -10.0107460022, -10.5810098648, -5.2143406868, -9.17082214355,
32653.0, 61380.0, -9.98422241211, -10.5810098648, -5.29454374313, -9.17082214355,
34957.0, 61441.0, -9.99779987335, -10.5810098648, -5.21118307114, -9.17177009583,
37261.0, 61502.0, -9.99180030823, -10.5810098648, -5.21686697006, -9.16924381256,
39565.0, 61563.0, -9.98327541351, -10.581325531, -5.21307754517, -9.17019081116,
WIth CoreTimer removed from channel list (the AIN0 channel is now in column 1):
5.85449361801, -10.5803785324, -5.20549917221, -9.17492771149,
5.84186172485, -10.5797472, -5.2137093544, -9.17208576202,
5.86523103714, -10.5800628662, -5.20613098145, -9.17240142822,
5.84912490845, -10.5797472, -5.20676231384, -9.17303276062,
5.84723043442, -10.5797472, -5.2099199295, -9.17145442963,
5.83838796616, -10.5800628662, -5.20770978928, -9.17208576202,
5.85165166855, -10.5797472, -5.21213054657, -9.17177009583,
5.84975671768, -10.5794315338, -5.2102355957, -9.17145442963,
5.84849357605, -10.5797472, -5.20897293091, -9.17240142822,
5.84280920029, -10.5797472, -5.20865678787, -9.17082214355,
Thanks...
Code below:
from labjack import ljm
import time
import sys
filename = "trickle_data.csv"
OFILE = open(filename,'w')
MAX_REQUESTS = 200 # The number of eStreamRead calls that will be performed.
#Possible Analog Input resolutions
AN_IN_RES_DEFAULT = 0
AN_IN_RES_16BIT = 1
AN_IN_RES_19BIT = 2
#Make your choice here...
AN_IN_RES_CURRENT = AN_IN_RES_16BIT
#How long each CORE_TIMER tick is, in seconds.
CPU_CORE_TIMER_TICK = 1.0/40000000.0
# Open LabJack
handle = ljm.openS("T7", "Ethernet", "192.168.0.50", )
info = ljm.getHandleInfo(handle)
print("Opened a LabJack with Device type: %i, Connection type: %i,\n" \
"Serial number: %i, IP address: %s, Port: %i,\nMax bytes per MB: %i" % \
(info[0], info[1], info[2], ljm.numberToIP(info[3]), info[4], info[5]))
# Stream Configuration
POS_IN_NAMES = [
#"CORE_TIMER",
#"STREAM_DATA_CAPTURE_16",
"AIN0",
"AIN1",
"AIN2",
"AIN3",
"AIN4",
"AIN5",
"AIN6",
"AIN7",
"AIN8",
"AIN9",
"AIN10",
"AIN11",
"AIN12",
"AIN13",
"CORE_TIMER",
"STREAM_DATA_CAPTURE_16"
]
NUM_IN_CHANNELS = len(POS_IN_NAMES)
#Add positive channels to scan list
aScanList = ljm.namesToAddresses(NUM_IN_CHANNELS, POS_IN_NAMES)[0]
#max scan rate = 100,000 samples / Number of Analog channels.
#max scn rate here = 100,000/14 = 7142 scans/second.
scanRate = 10
#The number of scans returned by each call to the LJM_eStreamRead function.
#Increase this parameter to get more data per call of LJM_eStreamRead. A
#typical value would be equal to ScanRate or 1/2 ScanRate, which results
#in a read once or twice per second.
#This results in a blocking-read of the DAQ device. IF multiple daq's are
#present, then start a new thread for each device, or consider adjusting
# http://labjack.com/support/ljm/users-guide/constants/ljmstreamscansreturn
scansPerRead = 1
# Configure the analog inputs' negative channel, range, settling time and
# resolution.
# Note when streaming, negative channels and ranges can be configured for
# individual analog inputs, but the stream has only one settling time and
# resolution.
#The value passed for Resolution_Index is from 0-8, where 0 corresponds
#to default, 1 is roughly 16-bit resolution (RMS or effective), and 8
#is roughly 19-bit resolution.
#For stream readings the default of 0 corresponds to Resolution_Index=1.
aNames = ["AIN_ALL_NEGATIVE_CH", "AIN_ALL_RANGE", "STREAM_SETTLING_US",
"STREAM_RESOLUTION_INDEX"]
aValues = [ljm.constants.GND, 10.0, 0, AN_IN_RES_CURRENT] #single-ended, +/-10V, 0 (default),
#0 (default)
ljm.eWriteNames(handle, len(aNames), aNames, aValues)
try:
# Configure and start stream
print(aScanList[0:NUM_IN_CHANNELS])
scanRate = ljm.eStreamStart(handle, scansPerRead, NUM_IN_CHANNELS, aScanList, scanRate)
print("\nStream started with a scan rate of %0.0f Hz." % scanRate)
print("\nPerforming %i stream reads." % MAX_REQUESTS)
totScans = 0
i = 1
while i <= MAX_REQUESTS:
print("Getting read #%s."%str(i))
ret = ljm.eStreamRead(handle) #this will block until the data is ready.
# Note that the Python eStreamData will return a data list of size
# scansPerRead*TOTAL_NUM_CHANNELS, but only the first
# scansPerRead*NUM_IN_CHANNELS samples in the list are valid. Output
# channels are not included in the eStreamRead's returned data.
data = ret[0][0:scansPerRead*NUM_IN_CHANNELS]
ostr = ""
for idx in range(len(data)-1):
ostr = ostr + str(data[idx]) + ', '
#last point
ostr = ostr + str(data[idx +1])+'\n'
OFILE.write(ostr)
print(ostr)
scans = len(data)/NUM_IN_CHANNELS
totScans += scans
i += 1
OFILE.close()
print("\nTotal scans = %i" % (totScans))
print("LJM Scan Rate = %f scans/second" % (scanRate))
print("Skipped scans = %0.0f" % (totSkip/NUM_IN_CHANNELS))
except ljm.LJMError:
ljme = sys.exc_info()[1]
print(ljme)
except Exception:
e = sys.exc_info()[1]
print(e)
print("\nStop Stream")
ljm.eStreamStop(handle)
# Close handle
ljm.close(handle)
So I see that in the 3rd column of the first data set the value decreases from -10.03 to -9.98. In the next data set the value in the first column is bouncing around 5.84 to 5.86.
I notice that although the 1st column in the second data set is not decreasing, it is very noisy. Does that noise level seem right for your signal?
Does it make sense to you that the value is -10 and then +5 volts?
What do you see if you test with that channel jumpered to GND.
Does it make a difference if you make the CORE_TIMER the last channel (or channels) in the scan list rather than 1st?
Maybe the image below will help.
Notice when "Core_Timer" and "Stream_Data_Capture_16" are included, the next channel (AIn0) is affected (increases), with finally, a large step during a wrap-around. Data attached.
When the timer channels are removed from the front of the list, one no longer sees any correlation with the timer.
Yes, AIn0 looks noisier than what I'd hope. For now I'm blaming my own electrical issues.
Thank you for looking into this.
-Chris
I have reproduced the issue on our end with the latest beta firmware. We will need to look into this further.
Please try beta firmware 1.0193: https://labjack.com/support/firmware/t7
Let me know how it goes.
Everything seems to work as hoped using 1.0193.
Thanks for the quick response! You guys provide amazing support.
-Chris
NER.com