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

BACKLOG UD clarification

LJ_chSTREAM_BACKLOG_UD backlog

  • Please log in to reply
1 reply to this topic

#1 startek

startek
  • Members
  • 2 posts

Posted 14 July 2013 - 07:15 PM

I'm getting occasional UD backlog and not sure why. I'm programming in Delphi.

 

I'm scanning 8 analog channels. Initially I was specifying a 2 second buffer at 1000Hz so I scaled it back to 200Hz with 100,000 sample buffer size (100k Doubles) and 100ms between reads. This is done in its own thread.

 

On my desktop (development) machine, which is modern and fast (3.4GHz i7) I'm getting about 23 or 24 scans each time - fair enough, it obviously takes a bit more than 100ms between reads as I'm just calling Sleep(100) in the thread. The actual time reading the buffer is quite fast, usually around 65µs but peaked at 720µs.

 

On the target system (1.6GHz Atom) it reports about the same number of scans each time - peaked at 32. The low-level reading & processing is a fair bit slower, typically around 200µs but peaking at 10ms!

 

In either case these timings seem fine, using up to 10% of the available time reading from the LJ on a slow computer. However on both systems I'm getting occasional UD backlog. On the desktop (one every minute or two - just got 2 @ 128 samples each). On the low-spec (Atom) laptop I'm getting them a bit more frequently (2 to 5 times a minute; just got 128,64,128,96 & 32 samples).

 

I have updated to the latest firmware and drivers on the laptop.

 

The question is: why am I getting any UD buffer overruns at all? My buffer is 100,000 samples (@200Hz & 8 channels this should give me over a minute of data if my program goes to sleep).

 

If I run the LJStreamUD program on the laptop (with or without charting active) I get occasional UD backlog (<1% every few seconds/tens of seconds). It doesn't grow.

 

Does the backlog mean I have lost this data?

 

I've attached the LabJack part (unit) of the code, which is based on the Delphi sample. FWIW below is the threaded code. There are some proprietary/project calls there but you can see how it calls the code in the attached LJ unit.

procedure TLabJackThread.Execute;var  ti : Double;begin  try    StartLabJack(False);    try      while not Terminated do      begin        try          ti := GetSysCounter;          LabJackRead;          FReadTime := GetSysCounter - ti;          if not Terminated then            SendData;        except          on E : Exception do          begin            DoThreadException(E.ClassName, E.Message);            Terminate;          end;        end;        if not Terminated then          Sleep(FSleepDelay);      end;    finally      StopLabJack;    end;  except    on E : Exception do      DoThreadException(E.ClassName, E.Message);  end;end;

Attached File  uLabJackCopy.pas   11.06KB   534 downloads



#2 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 15 July 2013 - 05:20 PM

An occasional UD backlog is fine and does not mean a buffer overrun or data loss occurred. The UD backlog is how much data is in the UD stream buffer as of the last stream packet read by the driver. If you notice the backlog is growing then that is an indication that you are not reading from the buffer fast enough and an eventual overflow will occur. Your UD stream read call will return the error value 8 (LJE_BUFFER_OVERRUN) when a UD buffer overflow occurs.

 

For UD driver and streaming documentation, which includes the backlogs, please refer to this section in the User's Guide:

 

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users