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

Could not start stream exception


  • Please log in to reply
4 replies to this topic

#1 kenny.stjernstroem

kenny.stjernstroem
  • Members
  • 7 posts

Posted 15 December 2014 - 01:37 PM

I'm using an U3-HV to stream some data. It has worked before but now I get an exception saying "Could not start stream". I've coded a .net application using LJUDDotNet version 3.45.0.0. Earlier in the project I used 3.42 but after I a reinstallation of windows I had to move to 3.45 because that one was installed with the Labjack driver I installed. I don't know if that has anything to do with this problem.

 

This is my code for setting up the U3:

                //Open the first found LabJack U3.
                u3 = new U3(LJUD.CONNECTION.USB, "0", true); // Connection through USB
                //Start by using the pin_configuration_reset IOType so that all
                //pin assignments are in the factory default condition.
                LJUD.ePut(u3.ljhandle, LJUD.IO.PIN_CONFIGURATION_RESET, 0, 0, 0);

                //Configure FIO0, FIO1 and FIO2 as analog, all else as digital.  That means we
                //will start from channel 0 and update all 16 flexible bits.  We will
                //pass a value of b0000000000000111 or d7.
                LJUD.ePut(u3.ljhandle, LJUD.IO.PUT_ANALOG_ENABLE_PORT, 0, 7, 16);


                //Configure the stream:
                //Set the scan rate.
                LJUD.AddRequest(u3.ljhandle, LJUD.IO.PUT_CONFIG, LJUD.CHANNEL.STREAM_SCAN_FREQUENCY, scanRate, 0, 0);

                //Give the driver a 5 seconds buffer (scanRate * 4 channels * 5 seconds).
                LJUD.AddRequest(u3.ljhandle, LJUD.IO.PUT_CONFIG, LJUD.CHANNEL.STREAM_BUFFER_SIZE, scanRate * 4 * 5, 0, 0);

                //Configure reads to retrieve whatever data is available without waiting (wait mode LJUD.STREAMWAITMODES.NONE).
                //See comments below to change this program to use LJUD.STREAMWAITMODES.SLEEP mode.
                LJUD.AddRequest(u3.ljhandle, LJUD.IO.PUT_CONFIG, LJUD.CHANNEL.STREAM_WAIT_MODE, (double)LJUD.STREAMWAITMODES.SLEEP, 0, 0);


                //Define the scan list as AIN0 then AIN1.
                LJUD.AddRequest(u3.ljhandle, LJUD.IO.CLEAR_STREAM_CHANNELS, 0, 0, 0, 0);
                LJUD.AddRequest(u3.ljhandle, LJUD.IO.ADD_STREAM_CHANNEL, 0, 0, 0, 0);
                LJUD.AddRequest(u3.ljhandle, LJUD.IO.ADD_STREAM_CHANNEL_DIFF, 1, 0, 32, 0);
                LJUD.AddRequest(u3.ljhandle, LJUD.IO.ADD_STREAM_CHANNEL, 2, 0, 0, 0);

                //Execute the list of requests.
                //LJUD.GoOne(u3.ljhandle);

                //Set timer to channel FI04.
                LJUD.AddRequest(u3.ljhandle, LJUD.IO.PUT_CONFIG, LJUD.CHANNEL.TIMER_COUNTER_PIN_OFFSET, 4, 0, 0);
                //Enable timer0.
                LJUD.AddRequest(u3.ljhandle, LJUD.IO.PUT_CONFIG, LJUD.CHANNEL.NUMBER_TIMERS_ENABLED, 1, 0, 0);
                //Set CLock base.
                LJUD.AddRequest(u3.ljhandle, LJUD.IO.PUT_CONFIG, LJUD.CHANNEL.TIMER_CLOCK_BASE, CLOCKFREQ, 0, 0);
                //Set divisor
                LJUD.AddRequest(u3.ljhandle, LJUD.IO.PUT_CONFIG, LJUD.CHANNEL.TIMER_CLOCK_DIVISOR, SAMPLEDEVISOR, 0, 0);
                //Set timerMode
                LJUD.AddRequest(u3.ljhandle, LJUD.IO.PUT_TIMER_MODE, 0, (double)LJUD.TIMERMODE.FALLINGEDGES16, 0, 0);
                //Add timer0 to stream list.
                LJUD.AddRequest(u3.ljhandle, LJUD.IO.ADD_STREAM_CHANNEL, 200, 0, 0, 0);


                //Execute the list of requests.
                LJUD.GoOne(u3.ljhandle);

This is the code for starting stream:

 

                LJUD.eGet(u3.ljhandle, LJUD.IO.START_STREAM, 0, ref actualStreamRate, 0);

When I started working with this application I got your U3_SimpleStream example running smooth but now i get the same exception in that program as well when the stream is to be started.

 

Besides changing the DLL version used I have also changed from LJUD.STREAMWAITMODES.NONE to LJUD.STREAMWAITMODES.SLEEP. But it does not work when changing it back either.



#2 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 15 December 2014 - 03:32 PM

With the code you provided I wasn't able to reproduce your problem in driver 3.45 with a U3-HV, and I would expect code that works with driver 3.42 to work in 3.45.

 

Make sure you are running the latest U3 firmware v1.46. You can check firmware in LJControlPanel or LJSelfUpgrade, and upgrade firmware in LJSelfUpgrade if needed.

 

If you do have the latest U3 firmware, please answer the following so we can try to reproduce the issue:

 

What version of Windows are you running?

 

What are the values of scanRate, CLOCKFREQ and SAMPLEDEVISOR in your code?



#3 kenny.stjernstroem

kenny.stjernstroem
  • Members
  • 7 posts

Posted 16 December 2014 - 12:28 PM

Firmware is up to date and windows version is 8.1, swedish. Values as follow.

public const double SAMPLEDEVISOR = 100;
const double CLOCKFREQ = (double)LJUD.TIMERCLOCKS.MHZ48_DIV;
double scanRate= 1000; //Hz


#4 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 16 December 2014 - 03:40 PM

I think the issue is that you interrupted a previous stream without a STOP_STREAM call, so further streams cannot be started since stream mode is still running. Power cycling your U3 should help resolve the issue, but to handle the issue in code stop the stream first. For example, after you open your U3 try stopping stream mode just in case (note that an exception will be thrown if your U3 is not in stream mode and you try to stop it, so the following code ignores that error):

u3 = new U3(LJUD.CONNECTION.USB, "0", true); // Connection through USB
try {
    LJUD.ePut(u3.ljhandle, LJUD.IO.STOP_STREAM, 0, 0, 0);
} catch(Exception e) {}


#5 kenny.stjernstroem

kenny.stjernstroem
  • Members
  • 7 posts

Posted 18 December 2014 - 12:43 AM

Now I got another exception which I think has nothing to do with the Labjack so this probably solved the issue.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users