Jump to content

As of July 17, 2015, the LabJack forums here at forums.labjack.com are shut down. New registrations, topics, and replies are disabled. All forums are in a read-only state for archive purposes.

Please visit our current forums at labjack.com/forums to view and make new posts. To post on the current forums, use your labjack.com login account. Your old LabJack forums login credentials have been retired. There are no longer separate logins for labjack.com and LabJack forums.


Photo

Help required_ Urgent


  • Please log in to reply
11 replies to this topic

#1 Selvia

Selvia
  • Members
  • 9 posts

Posted 22 September 2013 - 09:34 PM

Hi,

 

I am using Labjack U3 (new to me) to stream data into an excel sheet through python. But I find that the program does an averaging of 400-600 samples before spitting data to the excel sheet. Please tell me how to eliminate this. And also how can i find the sampling frequency of Labjack U3. 



#2 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 23 September 2013 - 09:02 AM

Are you using Windows?  Are you using a streaming example in Python?

 

Here is general information about stream mode:

 

http://labjack.com/s...3/users-guide/3

http://labjack.com/s...users-guide/3.2

http://labjack.com/s...ers-guide/4.3.7



#3 Selvia

Selvia
  • Members
  • 9 posts

Posted 24 September 2013 - 07:16 AM

Thanks for the reply...

 

Yes I am using the streaming example in python.

 

The command (in vizard software which uses python) reads as follows:

 

Maxrequests=1000

d.streamConfig(NumChannels=2, PChannels=[0,1], NChannels=[31,31], Resolution=3, Scan Frequency=5000)

.

.

.

.

The data is appended into an array and then this is copied into an excel sheet

.

.

.

temp=[]

temp.append(r(A1NO)/len(r(A1NO))))

.

.

.

the streaming stops after the maxrequest (ie 1000 in this case) is completed. 

this is then saved to an excel sheet which gives me 1000 samples where each sample obtained in excel is an average of around 600 samples. I want to eliminate this averaging which is being done before the data being stored in excel sheet. 

 

Please do help me out.



#4 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 24 September 2013 - 11:45 AM

Try this to add the samples instead of the average of the samples to your temp list:

 

temp.extend(r['AIN0'])



#5 Selvia

Selvia
  • Members
  • 9 posts

Posted 25 September 2013 - 07:18 AM

Thanks a lot for the suggestion. But still the data is not being written properly into excel sheet. The excel sheet still has the data after the averaging is being done.  

The result I get after the command 'temp.extend(r['AIN0'])' needs to be written into excel sheet, but what really happens is I get the average of this 'temp.extend(r['AIN0'])' and number of data points in my excel sheet is equal to the maxrequests which I give. I want to write the data directly into excel sheet without averaging.

 

And I suppose my Maxrequests defines the data acquisition time, does it have any relation with the sampling rate?



#6 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 25 September 2013 - 12:25 PM

MAX_REQUESTS determines how many times in the example streamData is called in the loop. The ScanFrequency in the streamConfig call determines the sample rate.

 

As for "temp.extend(r['AIN0'])", that will add the AIN0 samples to your temp list without averaging assuming r['AIN0'] hasn't been modified and the streamData call does no averaging on the samples. Are you averaging the temp array or changing the r['AIN0'] list to an average? Also, you will want to double check that you are passing the temp list correctly to the Excel sheet.

 

So we can see more what is going on post your code that shows how you handle your samples and send them to your Excel sheet.



#7 Selvia

Selvia
  • Members
  • 9 posts

Posted 26 September 2013 - 02:00 AM

I am attaching the script used for data acquisition. Please check the code and let me know the changes I have to make in order to get each and every data samples that beings obtained through labjack in Excel sheet.



#8 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 26 September 2013 - 11:27 AM

It looks like you are writing only one item of your temp list per streamRead call which would make it look like an average still. In your stream read loop you will want something like this to iterate through your sample list and write all stream samples to your Excel sheet with your sheet.write call:

        #creating array of data
        dataCount += 1
        packetCount += r['numPackets'] #Not used in your code
        
        #This iterates through the AIN0 samples and writes them to the Excel sheet
        for sample in r['AIN0']:
            sheet.write(Row,1,float(str(sample))) #Not sure if the str conversion is neccessary 
            Row += 1

Note that the code is untested.

 

Alternatively you can try using your temp array still and send all the data after you are done streaming (in the finally area). The sheet.write loop code would look the same, though replace "r['AIN0']" with "temp".



#9 Selvia

Selvia
  • Members
  • 9 posts

Posted 27 September 2013 - 12:58 AM

Thanks a lot. It works fine. 

Some more help please.....

What is the max and min values of MAX_REQUESTS , NumChannels, Resolution, ScanFrequency ?

How do I determine the sampling frequency ? Is sampling frequency depending on all the above variables?

Suppose I specify- 

 

MAX_REQUESTS = 1

d.streamConfig( NumChannels = 1, PChannels = [ 0 ], NChannels = [ 31], Resolution = 2, ScanFrequency = 2500 )

 

the number of samples obtained  is 1200.

 

this changes with the change in the above variables.

Please specify the values of these parameters in case of using all 'AINO-AIN3' channels...

 

 

 

 

 

 



#10 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 27 September 2013 - 08:27 AM

Someone else can follow up a little later, but a quick response it to read the following sections so you get an understanding of how stream mode works.  Particularly Section 4.3.7 which describes how the UD driver works with stream mode:

 

http://labjack.com/s...3/users-guide/3

http://labjack.com/s...users-guide/3.2

http://labjack.com/s...ers-guide/4.3.7



#11 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 27 September 2013 - 11:18 AM

MAX_REQUESTS can be anything above 0. It controls how many times streamData is called in the stream examples loop. NumChannels can be 1-25, Resolution can be 0-3 which map to 12.8-bit, 12.9-bit, 11.3-bit and 10.5 bit, and max ScanFrequency depends on the sample rate. The max sample rate is 50K. Sample rate (sample frequency) = NumChannels * ScanFrequency.

 

AIN0-3 would look like this:

 

d.streamConfig( NumChannels = 4, PChannels = [ 0, 1, 2, 3 ], NChannels = [ 31, 31, 31, 31 ], Resolution = 2, ScanFrequency = 2500 )

 

Channels will have a 11.3-bit resolution.

 

The streamData method at max returns 1200 samples (can be lower with slower ScanFrequencies) which is split between NumChannels, and you will need to call streamData multiple times for more than 1200 samples.

 

For LabJackPython documentation use 'help' in the Python interpreter for the method or class you want documentation. For example:

 

import u3

help(u3.U3.streamConfig)

help(u3.U3.StreamData)

 

The LabJackPython source code also contains the documentation. Also, look at the StreamConfig low-level function documentation which is referenced in the the streamConfig doc:

 

http://labjack.com/s...rs-guide/5.2.10



#12 Selvia

Selvia
  • Members
  • 9 posts

Posted 27 September 2013 - 10:35 PM

Thanks a lot.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users