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

U12 streaming using ljacklm driver


  • Please log in to reply
6 replies to this topic

#1 Martin Müllenhaupt

Martin Müllenhaupt
  • Members
  • 5 posts

Posted 15 August 2012 - 07:19 AM

Hi, I'm using the exodriver and the ljacklm interface to test streaming of an U12. I expect the U12 to be able to stream 4 analog channels at a rate of 300 scans/s (1200 samples/s). But calls to AIStreamRead seem to take too much time. I attached a little Qt and CMake based test program for demonstration. The output reads: [codebox]AIStreamRead took 604 ms for 64 scans. AIStreamRead took 640 ms for 64 scans. AIStreamRead took 1280 ms for 128 scans. AIStreamRead took 1920 ms for 192 scans. AIStreamRead took 2103 ms for 256 scans. AIStreamRead error: Timeout [/codebox] My system is Ubuntu 12.04 using the distributions libusb-1.0-0-dev package. Streaming seems to work under Windows. What am I doing wrong? Is the U12 Linux interface capable of analog channel streaming? Thanks for your help. Martin

Attached Files



#2 Martin Müllenhaupt

Martin Müllenhaupt
  • Members
  • 5 posts

Posted 16 August 2012 - 07:06 AM

I just tested my program on Windows with similar results: Calls to AIStreamRead take longer than I expect.

So the good thing is: This is not a Linux problem and probably easier to solve.

The LJStream example seem to run on Windows as expected.

I attached an updated version of my test project.

My code basically looks like:
long m_labjackId = -1;
long channelArray[4] = { 0, 1, 2, 3 };
long gains[4] = { 0 };
float m_currentScanRate = 100;
long res = AIStreamStart(&m_labjackId, 0, 0, 0, 1, 4, channelArray, gains, &m_currentScanRate, 1, 0, 0);
with periodic calls like:
float m_voltageBuffers[4096][4];
  long m_ioBuffers[4096];

  /* fill buffers with 0 */
  for (int i = 0; i < 4096; i++)
  {
	for (int j = 0; j < 4; j++)
	{
	  m_voltageBuffers[i][j] = 0;
	}
  }
  for (int i = 0; i < 4096; i++)
  {
	m_ioBuffers[i] = 0;
  }

  /* initialize a timer for the AIStreamRead call */
  QTime timer;
  timer.start();
  /* call AIStreamRead with 2 s timeout */
  long res = AIStreamRead(m_labjackId, numScans, 2, m_voltageBuffers, m_ioBuffers, 0, backlog, overVoltage);
  qDebug() << "AIStreamRead took" << timer.restart() << "ms for" << numScans << "scans.";

Any idea?

Thanks for your help!

Martin

Attached Files



#3 Martin Müllenhaupt

Martin Müllenhaupt
  • Members
  • 5 posts

Posted 16 August 2012 - 07:38 AM

I studied again the only C/C++ stream example I found: http://labjack.com/s...ples/vc6-stream

Output Linux:
AIStreamStart error = 0
Local ID = 0

AIStreamRead error = 0
1st Scan:  V1=0.068359, V2=1.425781,V3=1.420898, V4=1.425781
LabJack Scan Backlog = 73


AIStreamRead error = 0
1st Scan:  V1=0.068359, V2=1.425781,V3=1.425781, V4=1.425781
LabJack Scan Backlog = 109


AIStreamRead error = 0
1st Scan:  V1=0.063477, V2=1.435547,V3=1.425781, V4=1.425781
LabJack Scan Backlog = 182


AIStreamRead error = 0
1st Scan:  V1=0.068359, V2=1.425781,V3=1.425781, V4=1.425781
LabJack Scan Backlog = 256


AIStreamRead error = 0
1st Scan:  V1=0.068359, V2=1.430664,V3=1.430664, V4=1.430664
LabJack Scan Backlog = 329


AIStreamClear error = 0
Output Windows:
AIStreamStart error = 0
Local ID = 0

AIStreamRead error = 0
1st Scan:  V1=0.063477, V2=1.435547,V3=1.430664, V4=1.430664
LabJack Scan Backlog = 0


AIStreamRead error = 0
1st Scan:  V1=0.063477, V2=1.425781,V3=1.425781, V4=1.430664
LabJack Scan Backlog = 0


AIStreamRead error = 0
1st Scan:  V1=0.068359, V2=1.425781,V3=1.430664, V4=1.425781
LabJack Scan Backlog = 0


AIStreamRead error = 0
1st Scan:  V1=0.068359, V2=1.430664,V3=1.430664, V4=1.430664
LabJack Scan Backlog = 0


AIStreamRead error = 0
1st Scan:  V1=0.068359, V2=1.430664,V3=1.430664, V4=1.425781
LabJack Scan Backlog = 0


AIStreamClear error = 0

The scan backlog of the Linux version seem to reflect my problem. Strangely enough no backlog is shown in the Windows version of this program.

I attached the updated example.

Attached Files



#4 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 16 August 2012 - 05:05 PM

So you know, we are currently looking into this.

#5 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 19 August 2012 - 09:44 PM

In the ljacklm.c source code, try removing line 6023 in the AIStreamRead function, recompile, reinstall the driver, and see if that helps.
if(GetTickCount() > 4294967245U) Sleep(60);
That line can add an additional 60 ms delay to every USB read and looks to be Windows logic that doesn't apply to Linux/Mac. We need to do more tests before updating the driver on our site.

#6 Martin Müllenhaupt

Martin Müllenhaupt
  • Members
  • 5 posts

Posted 20 August 2012 - 01:48 AM

By removing line 6023 ljacklm.c of the source code the ljstream example seems to work as expected. Thank you for spotting this bug! I did some wrong assumptions about the expected time, leading to the wrong conclusion that this problem also exists on Windows. It was Linux related after all.

#7 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 23 August 2012 - 03:23 PM

I updated the ljacklm download on our site with delay removed in AIStreamRead.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users