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 Explanation.


  • Please log in to reply
6 replies to this topic

#1 CeeTee

CeeTee
  • Members
  • 10 posts

Posted 27 October 2010 - 11:47 AM

Greetings

Could I ask somebody to explain some of the streaming rates in easy terms please.

I am writing a DELPHI program that is attempting to read one channel of streamed data from a U6. I have this working within a thread but I am abit confused over the actual stream timings (scan rates, samples Etc).

I have set the stream frequency at a figure of 2000 as follows,

AddRequest(lngHandle,LJ_ioPUT_CONFIG,LJ_chSTREAM_SCAN_FREQUENCY,2000,0,0). Am I correct in thinking this is 2000 scans a second?.

Then within the thread I read the U6 as follows,

lngErrorcode := eGet(lngHandle, LJ_ioGET_STREAM_DATA, LJ_chALL_CHANNELS, 200, @adblData); Does this mean that it reads the 200 sets of data every tenth of a second?.

Should I then add another channel do I get 200 sets of data from each channel every two tenths of a second or 100 sets of data from each channel every tenth of a second?.

Thanks in advance.

#2 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 27 October 2010 - 01:21 PM

Am I correct in thinking this is 2000 scans a second?.

Yes, your put_config to special channel LJ_chSTREAM_SCAN_FREQUENCY sets the scan rate to 2000 scans/s.

Does this mean that it reads the 200 sets of data every tenth of a second?.

That command will read 200 scans (or less depending on WAIT mode), which corresponds to 1/10s of data. The timing of how often that happens depends on how you have written your read thread and which WAIT mode you are using:

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

Should I then add another channel do I get 200 sets of data from each channel every two tenths of a second or 100 sets of data from each channel every tenth of a second?.

If you have 1 channel in your scan list, then 200 scans is 200 samples and is 1/10s of data. If you have 2 channels in your scan list, then 200 scans is 400 samples but is still 1/10s of data.

#3 CeeTee

CeeTee
  • Members
  • 10 posts

Posted 27 October 2010 - 01:57 PM

Wow! Thanks for the quick reply and straight forward answers.

The wait mode that I am using is,

AddRequest(lngHandle,LJ_ioPUT_CONFIG,LJ_chSTREAM_WAIT_MODE,LJ_swSLEEP,0,0);
Which I have assumed means that it will wait until the required amount of samples are taken before presenting them for reading?.

The thread I am using is a standard DELPHI TThread,

procedure counter.Execute;

begin

i:=1;

while (not Terminated) do
  begin
  lngErrorcode := eGet(lngHandle, LJ_ioGET_STREAM_DATA, LJ_chALL_CHANNELS, numScans, @adblData);
  ErrorHandler(lngErrorcode, 0);
  numScansRequested := numScans;
  lngErrorcode := eGet(lngHandle, LJ_ioGET_CONFIG, LJ_chSTREAM_BACKLOG_COMM, dblCommBacklog, 0);
  ErrorHandler(lngErrorcode, 0);
  lngErrorcode := eGet(lngHandle, LJ_ioGET_CONFIG, LJ_chSTREAM_BACKLOG_UD, dblCommBacklogUD, 0);
  ErrorHandler(lngErrorcode, 0);
  i := i + 1;
  Synchronize(UpdateCaption);
  if terminated then exit;
  end;

end;

procedure counter.UpdateCaption;
  begin
    Form2.Label1.Caption := IntToStr(i);
    Form2.Edit3.Text:=('Iteration # ' + IntToStr(i));
    Form2.Edit4.Text:=('Number read = ' + FloatToStr(numScansRequested));
    Form2.Edit5.Text:=('Scan = ' + FloatToStr(adblData[0])+ '  '+ FloatToStr(adblData[1]));
    Form2.Edit6.Text:=('Comm Backlog = ' + FloatToStr(dblCommBacklog));
    Form2.Edit7.Text:=('Comm Backlog UD = ' + FloatToStr(dblCommBacklogUD));
    Form2.Edit8.Text:=('Scan Ends ='+FloatToStr(adblData[198])+'  '+FloatToStr(adblData[199]));
    Form2.Edit9.Text:=('NumScans ='+FloatToStr(NumScans));
 end;

This seems ok, although I am not trying to attempt to much within the thread yet, still testing the basic's.

Once again many thanks.

#4 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 27 October 2010 - 02:05 PM

Yes, since you are using the SLEEP mode your call to LJ_ioGET_STREAM_DATA will wait for the specified amount of data, and thus that line of code controls the timing of your loop.

#5 CeeTee

CeeTee
  • Members
  • 10 posts

Posted 27 October 2010 - 02:30 PM

Just one last question. Between the sampling blocks are there any significant delay's or is the streaming constant?.

#6 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 27 October 2010 - 02:36 PM

Do you mean between each scan? They either happen at the scan rate you specify, or if that is not possible you get an error. See the first paragraph here:

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

#7 CeeTee

CeeTee
  • Members
  • 10 posts

Posted 27 October 2010 - 02:51 PM

Yes.

Reading that section of the manual answers that question. 'Stream is a continuous hardware timed input mode'

All questions answered. A big thanks.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users