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

Unable to stop Streaming Labjack U6 (Error Code 5)


  • Please log in to reply
4 replies to this topic

#1 CeeTee

CeeTee
  • Members
  • 10 posts

Posted 12 November 2012 - 01:48 PM

Hello there

I have an intriguing issue. For several months we have been using a self written Delphi (XE2) program (Diesel Engine Governor Test Rig) that uses a Labjack U6 to stream data. I use 3 differential voltage channels to record 3 voltages in 3 separate tests.

Test 1 = Channel 1 only (F100-F101)
Test 2 = Channel 2 only (F102-F103)
Test 3 = Channel 2 and 3 only. (F102-F103 & F104-F105)

Now as I mentioned we have been using this software for several months doing all 3 tests with no issues seen (we use XP and Windows 7 (32 Bit) computers), but we have allowed one of our agents to use this software so they can do the same testing as we do ourselves (I think that they are using Windows 7 possibly 64 Bit). Initially all was fine but a problem has just been reported by them that error code 5 (unable to stop stream) has appeared but only when conducting Test 3. Streaming works fine for Test 1 and 2 where I take 3000 samples over 16 seconds.

Below is my Dephi code for Test 3 that works for us but seems to have an issue for our agent.

The scan rate is only 4 because we sample for approx 180 seconds and only take 350 samples it is a slow hysteresis check.


//Configure the stream:
  lngErrorcode := AddRequest(lngHandle, LJ_ioPUT_CONFIG, LJ_chAIN_RESOLUTION, 13, 0, 0);
  ErrorHandler(lngErrorcode, 0);
  lngErrorcode := AddRequest(lngHandle, LJ_ioPUT_AIN_RANGE, 2, LJ_rgBIP10V, 0, 0);
  ErrorHandler(lngErrorcode, 0);
  lngErrorcode := AddRequest(lngHandle, LJ_ioPUT_AIN_RANGE, 4, LJ_rgBIP1V, 0, 0);
  ErrorHandler(lngErrorcode, 0);
  lngErrorcode := AddRequest(lngHandle, LJ_ioPUT_CONFIG, LJ_chSTREAM_SCAN_FREQUENCY, scanRate, 0, 0);
  ErrorHandler(lngErrorcode, 0);
  lngErrorcode := AddRequest(lngHandle, LJ_ioPUT_CONFIG, LJ_chSTREAM_BUFFER_SIZE, scanRate*2*16, 0, 0);
  ErrorHandler(lngErrorcode, 0);
  lngErrorcode := AddRequest(lngHandle, LJ_ioPUT_CONFIG, LJ_chSTREAM_WAIT_MODE, LJ_swSLEEP, 0, 0);
  ErrorHandler(lngErrorcode, 0);
  lngErrorcode := AddRequest(lngHandle, LJ_ioCLEAR_STREAM_CHANNELS, 0, 0, 0, 0);
  ErrorHandler(lngErrorcode, 0);
  lngErrorcode := AddRequest(lngHandle, LJ_ioADD_STREAM_CHANNEL_DIFF, 2, 0, 3, 0);
  ErrorHandler(lngErrorcode, 0);
  lngErrorcode := AddRequest(lngHandle, LJ_ioADD_STREAM_CHANNEL_DIFF, 4, 0, 5, 0);
  ErrorHandler(lngErrorcode, 0);
  lngErrorcode := GoOne(lngHandle);
  ErrorHandler(lngErrorcode, 0);
  lngErrorcode := GetFirstResult(lngHandle, lngIOType, lngChannel, dblValue, lngTemp, dblTemp);
  ErrorHandler(lngErrorcode, 0);
  lngGetNextIteration := 0;	//Used by the error handling function.
  while lngErrorcode < LJE_MIN_GROUP_ERROR do
    begin
    lngErrorcode := GetNextResult(lngHandle, lngIOType, lngChannel, dblValue, lngTemp, dblTemp);
    if lngErrorcode <> LJE_NO_MORE_DATA_AVAILABLE then
    ErrorHandler(lngErrorcode, lngGetNextIteration);
    lngGetNextIteration := lngGetNextIteration + 1;
    end;

I have other code here which is setting up an on screen chart.......

    //Start the stream.
    lngErrorcode := eGet(lngHandle, LJ_ioSTART_STREAM, 0, dblValue, 0);
    ErrorHandler(lngErrorcode, 0);

  loopH:
    numScansRequested := numScans;
    lngErrorcode := eGet(lngHandle, LJ_ioGET_STREAM_DATA, LJ_chALL_CHANNELS, numScansRequested, @adblData);
    i := i + 1;
    valuesa[i]:=10+adbldata[0];
    valuesb[i]:=1000*adbldata[1];
    {Edit1.Text:=FloatToStr(valuesa[i])+' '+FloatToStr(valuesb[i]);}
    if i=SampleH+1 then
      begin
      goto stopstreamH;
      end;
    goto loopH;
    end;
stopstreamH:
  //Stop the stream
  lngErrorcode := eGet(lngHandle, LJ_ioSTOP_STREAM, 0, dblTemp, lngTemp);
  ErrorHandler(lngErrorcode, 0);
Can you tell me if there is an issue with the code that I have used because we cannot replicate the problem they are seeing, Test 1 and 2's code is almost identical basically just uses a single channel.

I am not sure that there is a code problem (I can always learn) but any pointers or suggestions will be gratefully received.

#2 CeeTee

CeeTee
  • Members
  • 10 posts

Posted 12 November 2012 - 03:19 PM

Just heard from our agent that it is now coming up with the same error on Test 1 and 2. So it seems that streaming starts and then can not stop in all Test sections now. Weird!. What happens if you try and stop streaming if streaming is not taking place?. Would it come up with this error?.

#3 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 12 November 2012 - 05:08 PM

Just heard from our agent that it is now coming up with the same error on Test 1 and 2. So it seems that streaming starts and then can not stop in all Test sections now. Weird!.

What happens if you try and stop streaming if streaming is not taking place?. Would it come up with this error?.


Error #5 happens when the driver sends the U6 a command to stop a stream, and the U6 responds with an error. From what I am aware of, the only common cause of this is if the stream is not already running. So stopping the stream and checking for the error is a good way to check if the stream is going or not.

Thus, I would bet that is the case here. As for the cause, there are potentially two reasons that could be. The first would be some issue with the stream configuration, so that when the stream is started it doesn't actually start. If this was the case, an error would be thrown when you start the stream, which doesn't seem to be happening here. The other potential cause is that the buffer is over flowing. If the buffer over flows, or the it gets a timeout when reading, it will stop the current stream.

I think the likely cause here is a buffer overflow. 4 scans per second is very slow for streaming. The U6 collects a number of samples before it sends a packet out to the PC with that data. This is the packet that the driver waits for and can timeout on. If you are streaming to slowly, it's possible that the driver might be hitting it's timeout and then telling the stream to stop. The easy way to check this, is just to increase the scan rate, say to 40 and see if the problem goes away (you might have to adjust buffer sizes to make sure the buffers don't overflow).

Another option is to change the LJ_chSTREAM_SAMPLES_PER_PACKET value, which is how many samples will be taken before the U6 tries to send a packet. The normal value for this is 25 I believe. You might try adjusting it to say, 4 (using LJ_ioPutConfig) and seeing if that fixes the problem. That will cause the U6 to not wait as long before it sends out a packet.

You can also check the value of LJ_chSTREAM_BACKLOG_UD which will tell you how much the buffer on the UD is filling, to see if that could be the cause.

As to why one PC would have this problem and not another, I'm not sure. When you read the stream data are you getting valid data back? How many points do you get?

#4 CeeTee

CeeTee
  • Members
  • 10 posts

Posted 13 November 2012 - 03:30 AM

Many thanks for the quick reply. I will work through your suggestions but I like the idea that the stream is not actually starting and have asked if they can confirm that the LED is flashing when it is supposed to be reading. I think this may take some time for we are based in the UK and our agent is in the US and I cannot replicate the problem here. Does computer speed have any bearing on Labjack performance?, I mention this because I am aware that the agents are using brand new laptops. I have also suggested that they do a complete reinstall of our software and the Labjack drivers etc. always a good fall back option just in case. Will let you know the outcome. Thanks...

#5 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 13 November 2012 - 04:02 PM

Many thanks for the quick reply.

I will work through your suggestions but I like the idea that the stream is not actually starting and have asked if they can confirm that the LED is flashing when it is supposed to be reading. I think this may take some time for we are based in the UK and our agent is in the US and I cannot replicate the problem here. Does computer speed have any bearing on Labjack performance?, I mention this because I am aware that the agents are using brand new laptops.

I have also suggested that they do a complete reinstall of our software and the Labjack drivers etc. always a good fall back option just in case.

Will let you know the outcome. Thanks...


The computer speed shouldn't really play a role, especially at low speeds. The one exception to this would be if you are doing complex, intensive analysis on the data that is being brought in, in which case the PC would need to be fast enough to keep up. However, the amount of processing power needed to pull the data off the LabJack and send it to the program is incredibly low. I'm guessing most people's cell phones would be more than powerful enough to handle it.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users