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;
uLabJackCopy.pas 11.06KB 665 downloads