Streaming/saving U3 data with added test channel and dT


Recommended Posts

Hello,

I've tweaked an example file from Azeotech (see the attached .ctl file) where streaming 500Hz data from a U3 LV channels 1-4 is done, my streaming is from AIN channels 4-6 and here's my problem:

When trying to add a test channel just copying the results from AIN4 to AIN0(test channel) and adding a dT channel to study the time inbetween individual samples the data from the AIN0 and dT channels are only sporadically written to the logging file and I don't understand why. The data is added under the event for channel 4.

Also, my AIN6 channel is logging the Vref from a LJTickInAmp amplifier and the voltage that I see on AIN6 doesn't give me the correct 2.499V, rather 2.43V or something even though i put in a 32 in the OPC field for the channel.

The final question is if I can display the real scan rate in the GUI, I understand that it is not 100% equal to the value you put in the Start_Stream sequence!?

Regards

Marcus

U3_Stream_Simple_modified.ctl

Link to comment
Share on other sites

I'll try and answer, but will have the LabJack folks provide some additional input:

Logging: most likely you have a non-zero alignment threshold. This will cause data that comes quicker than that value to be tossed. Always make sure the align threshold is less than 1/2 the sampling interval.

Vref: this is probably the resolution of the input

Real scan rate: this is not always the same as the one input because the actual scan rate is achieved by using a divisor on a preset oscillator on the LabJack. So, if you pick a scan rate that can't be evenly divided into the oscillator frequency, the closest value is used.

Link to comment
Share on other sites

You need to specify the special 0-3.6V range when you add the channel to the scan list. Change the request in the Start_Stream sequence to something like:

AddRequest(ID,LJ_ioADD_STREAM_CHANNEL_DIFF,6,0,32,0)

The actual scan rate is passed back by the START_STREAM call in the Value parameter, so you probably need to just add a GetResult to get the Value. Or instead of add/go/get just use eGet.

http://labjack.com/support/u3/users-guide/4.3.7

Link to comment
Share on other sites

Thanks, the suggested Addrequest() command for the Vref voltage worked!

Now only two challenges remain :)

1. I've tried changing the Align Threshold and it does not work no matter what I put there, the log-file still looks bad, see an example in the attached picture. I don't know if it has anything to do with it but my laptop is 5-6 years old!?

2. Still don't understand how to retrieve and display the real sampling frequency, are you saying create a new sequence real_scan_rate (in this case retrieving it from channel 4) looking something like:

while(1)

Device.LabJack.GetResult(d_number, "LJ_io_START_STREAM", 4, @scanrate)

global real_scanrate=scanrate

endwhile

and then adding a variable value display to the GUI in order to display the real_scanrate?

Also, a weird thing when stopping the stream is that the test channel copying the streamed channel 4 is diplaying a sinusoidal wave, why is this?

post-8092-1329859420_thumb.jpg

Link to comment
Share on other sites

1. It appears your dt column simply doesn't have as many data points as the others. Also, when you are importing the file, Excel isn't treating it as a CSV file. That's why everything is appearing in the A column and you see the commas.

2. No, and the sequence you created is an infinite loop without any delay() and will hang DAQFactory. Also, you can't use getResult() unless you did a matching addRequest(). Use eGet() instead. Do it right after you start your stream.

3. if you see a sine wave in a Test channel then you likely forgot to set the Timing to 0.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.