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

Streaming data with Labview


  • Please log in to reply
11 replies to this topic

#1 thecrown

thecrown
  • Members
  • 2 posts

Posted 02 June 2014 - 08:45 AM

Hi,

I´m new to both Labview and Labjack and have encountered several difficulties while trying to stream my three analog inputs using Labjack U6 and the LJStreamUD on Labview.

What I want to do Is:

 

1) write the gathered data on a file. This is working already, but I do not want to write as many as 500 values per second on file, rather collect the data at the specified scan rate of 500 Hz over several seconds (4 or 5 sec.), calculate the average of the collected data over this interval and then log this average value on file. Question: Can I achieve this with the LJStreamUD? If yes, how?

 

2) another very frustrating issue is that the default values of the controls are not saved properly. They appear to be saved as the new default values, but when I start the programm on the next day and press the "Start Stream" button, the controler will switch back from these defaults to their original values (e.g. the negative Channels will all be at "199" again). I also loose my scaling equations and to eliminate errors while measuring, I need these default input settings to be saved properly. Can anyone help me out there?

 

3) Do you think the LJStreamUD is a good tool for what I want to do at all, or would you recommend me to approach the task differently? I´ve been working on it over the past three weeks and the VI is still not doing what I want it to. I am very thankful for your help

 

Best,

David

 



#2 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 02 June 2014 - 08:55 AM

1 & 3.  No, the simple LJStreamUD application does not support that.  If you want to use LabVIEW, I would start with the example "U6 easy Stream Full.vi" and then modify it as needed.  Another possible solution to consider is DAQFactory (http://www.azeotech.com/board/).

 

2.  There are no known issues with saving defaults.  I just tested with LJStreamUD 1.17 by setting -Ch in the first row to 1, then closing LJStreamUD, and when I reopened it was still set to 1.  I take it yours behaves differently?  Does everything go back to default, or are just some things changing?



#3 thecrown

thecrown
  • Members
  • 2 posts

Posted 03 June 2014 - 01:44 AM

First of all, thank you very much for your quick answer.

 

1&3. Since we work with Labview, DAQFactory is not an option unfortunately. Thus, I will try to work with the "U6 easy Stream full.vi" from the examples and try to modify it. I have already played with it before but have dismissed it, because it does not have the "scaling equation" and the "write to file" operations already built in.

My question is: In order to change my data values according to the scaling necessary AND write data on a file, do I need to use the labjack functions or can I just take the aquired 2-D array of data and use Labview functions like "Write to Spreadsheet" to further process the data? What is the easier approach?

 

2. The saving defaults option did not work properly when I turned off the computer, restarted it and wanted to use the "LJStreamUD" again. I don´t have any problems doing the same with the "Easy Stream Full.vi". Thank you.



#4 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 03 June 2014 - 08:45 AM

 

1&3.  My question is: In order to change my data values according to the scaling necessary AND write data on a file, do I need to use the labjack functions or can I just take the aquired 2-D array of data and use Labview functions like "Write to Spreadsheet" to further process the data? What is the easier approach?

 

In my opinion it would be easier to use and understand the basic LabVIEW functions & techniques for scaling and file I/O, rather than trying to use pieces from LJStreamUD.  That way you are just using normal array techniques in LabVIEW, and nothing special developed by LabJack.

 

 

 

 

 

2. The saving defaults option did not work properly when I turned off the computer, restarted it and wanted to use the "LJStreamUD" again. I don´t have any problems doing the same with the "Easy Stream Full.vi". Thank you.

 

If you want to look into it further ... is it different whether you use LJStreamUD.exe or LJStreamUD.vi?

 

Have not seen or heard of that before.  The thing to look at would be the file ljstreamud.cfg.  When you close LJStreamUD and then look at that file does it seem to be updated correctly?  After you reboot does the file still seem to be correct?



#5 alkaram

alkaram
  • Members
  • 18 posts

Posted 22 July 2014 - 01:56 PM

Hello. I also have a question in regards to streaming with LabJack. 

 

I'm very new to data acquisition and using the LabJack. I'm currently trying to use DAQFactory for our data acquisition and control needs but I also have the option of using LabView if needed. I am trying to measure light, temperature, pH, gas flow rate, and CO2  at the same time using analogue inputs. The light I will be measuring is a high power LED and clearly oscillates in intensity around 120 Hz (http://i.imgur.com/miqnYkt.png).  This oscillation means the sampling frequency can change the reported intensity (esp if the sampling primarily falls on a high or low end of the period).  I thought the best way obtain a true average was to stream the light data at around 5000 and average across the period.    I've played with DAQFActory examples for streaming one and four channels as given here: http://labjack.com/s...ples/daqfactory and I've had some luck but still get minor oscillations within my average.  I also didn't have all the sensors connected at this time and the program still seemed to struggle with streaming and I wasn't able log any averaged data directly to a file without crashing. 

 

So I have a few questions: 

 

1) Do I have to stream all analogue inputs if I need to stream only the light measurements?  We don't need to sample the any of the other sensors at a frequency of 5000 times a second and I know the streaming takes a lot of power.  Does LabView offer this capability if DAQFactory does not? Or is this restraint inherent in how the LabJack transfers data.

 

2) Do you have any advice on capturing the true average of the light without using stream mode in DAQFactory or even LabView? 



#6 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 22 July 2014 - 02:09 PM

Stream takes over the analog input system, so during a stream you cannot read analog inputs via command/response.  That is a limitation in hardware.

 

Which LabJack are you using?  What is the typical voltage swing of the signal?

 

How many scans do you average to get each light reading?  5000 to get 1 light reading per second?  If you are averaging sequential blocks of 5000 scans, and find that the average changes substantially, I would be suspect that the light intensity is actually changing ... is not super steady.



#7 alkaram

alkaram
  • Members
  • 18 posts

Posted 01 August 2014 - 08:41 AM

Hello,

 

I'm using the Labjack U6 

 

here is a graph of the voltage swing that changes as the light is closer to the sensor : http://imgur.com/CsMsH7Q

 

I'm using the MEAN function in DAQ factory to average...which I am assuming is a rolling average.   So with 5000 samples/second this leads to averaging around 42 samples on rolling basis.  



#8 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 01 August 2014 - 02:13 PM

You could add a filter to get rid of some of the 120 Hz oscillation.  Use a 1k series resistor with as big as capacitor you can find from AINx to GND ... at least 10 uF to do anything.
 
Unless you are trying to detect very fast changes in light, I would average over multiple cycles.  For example average over 1 second which will average 60 cycles.  I would do at least that if not more.  I would also suggest scanning at a multiple of 60, so perhaps 1200 or 4800 scans/second.  If you scan at 4800 scans/second, then every time you get a new set of 4800 scans you would average them all to get a single value which is the average of the last second.  For help on how to do that in DAQFactory post on the topic you have going on AzeoTech's forum:
 
 
Note that on the T7 we could use the AIN-EF system to compute the average in hardware, so you would just read a register that returns the average value.


#9 alkaram

alkaram
  • Members
  • 18 posts

Posted 05 August 2014 - 08:46 AM

Thank you again for your help.  I just want to summarize to make sure I'm understanding correctly.  

 

1.  The total stream rate for the LabJack U6 for all analog inputs is 50,000 samples/sec.  So if I had 5 analog inputs, I could technically stream all of them at a rate of 4800 and be fine?

 

2.   Since streaming takes over all analog inputs, will it be less computationally intensive to stream only 1 channel rather than all 5 at the same time?

 

I am also in the process of writing some sort of simple control loop for pH control using a solenoid gas valve for 99% CO2  and pH sensor.  I'm considering writing a master sequence that continually loops through as shown in pseudo-code below. Please note that this is very poorly written pseudo-code.  I am trying to figure out the best way to record and control experimental parameters.  This system will be changing slightly but doesn't need to be recorded on the stream-level.  I wouldn't know what to do with all that data! The light won't change much (if any) over a 1-5 minute time scale.  I'm also still trying to figure out the best way to easily implement a control-feedback algorithm and the one shown below is very basic.  I know I'll need to fine-tune it so  I don't get stuck in an infinite recursive loop within the pH control and miss recording other important parameters for large chucks of time. 

 

Start MasterSequence ()

        Turn on stream mode for light channel at 4800 samples/second

         Wait 1 minute while averaging as described above

        Turn off stream mode for light channel

 

        Record temperature for 1 minute

 

        Record pH for 1 minute 

    

        pH_Control() 

                 check pH 

                 If (pH > setpoint_upper)

                        start logging for mass flow meter

                        open CO2 solenoid valve for 1 second 

                        wait 1 minute

                        stop logging for mass flow meter 

                       pH_Control()

                 elIf (pH < setpoint_lower) 

                       open base pinch valve

                       wait 1 minute 

                       pH control()

                else

                      restart MasterSequence()

           

 

 



#10 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 05 August 2014 - 10:50 AM

1.  Yes, you can stream 5 channels at up to 10 kscans/second on the U6.

 

2.  Yes, if you stream 1 channel you are just doing 4800 samples/second, whereas if you stream 5 channels at 4800 scans/second that is 24000 samples/second.

 

 

Since nothing you are doing looks very fast, I suggest you make a sequence in DAQFactory called ReadLight, and whenever you want a light reading you call ReadLight.  The pseudocode for the sequence would look something like:

 

Config stream for 1 channel at 4800 scans/second.

Start stream.

Read 4800 scans as soon as available.

Stop stream.

Average 4800 readings to get your 1 second average light reading.



#11 alkaram

alkaram
  • Members
  • 18 posts

Posted 07 December 2014 - 08:57 PM

 

You could add a filter to get rid of some of the 120 Hz oscillation.  Use a 1k series resistor with as big as capacitor you can find from AINx to GND ... at least 10 uF to do anything.
 
Unless you are trying to detect very fast changes in light, I would average over multiple cycles.  For example average over 1 second which will average 60 cycles.  I would do at least that if not more.  I would also suggest scanning at a multiple of 60, so perhaps 1200 or 4800 scans/second.  If you scan at 4800 scans/second, then every time you get a new set of 4800 scans you would average them all to get a single value which is the average of the last second.  For help on how to do that in DAQFactory post on the topic you have going on AzeoTech's forum:
 
 
Note that on the T7 we could use the AIN-EF system to compute the average in hardware, so you would just read a register that returns the average value.

 

 

I had a follow up question about selecting the resistor and capacitor for the low pass filter.  Could you use, say, 1 uF capacitor with a 10k resistor ? Or is there a reason you have to use at least a 10 uF capacitor? In other words, is the RC value all that matters or do you have to have a minimum C? 



#12 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 08 December 2014 - 03:01 PM

I usually start by picking as big of resistor as I care to use, then select a cap to go with it.

 

With the U6/T7, we specify that all specifications are valid for any analog configuration if the source impedance is 1k or less, so that is why we said 1k here.  If you use bigger than 1k you will have to consider static error due to bias current and dynamic settling error, which might be fine with 10k for your particular configuration but with 1k you don't have to think about it.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users