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.



  • Please log in to reply
1 reply to this topic

#1 madmax81

  • Members
  • 4 posts

Posted 16 October 2014 - 02:28 PM



I try to read a timer from my LabJack with following code but it throws a TIMER_SHARING_ERROR and I can't figure out the reason.


Thanks in advance.


Firmware Version: 1,460

Bootloader Version: 0,270

Hardware Version: 1,300

Driver Version: 3.45

               double rpmValue = 0;
               double[] dummyDoubleArray = { 0 };

                //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);

                //First requests to configure the timer and counter.  These will be
                //done with and add/go/get block.

                //Set the timer/counter pin offset to 4, which will put the first
                //timer/counter on FIO4.
                LJUD.AddRequest(u3.ljhandle, LJUD.IO.PUT_CONFIG, LJUD.CHANNEL.TIMER_COUNTER_PIN_OFFSET, 4, 0, 0);

                //Use the 48 MHz timer clock base with divider.  Since we are using clock with divisor
                //support, Counter0 is not available.
                LJUD.AddRequest(u3.ljhandle, LJUD.IO.PUT_CONFIG, LJUD.CHANNEL.TIMER_CLOCK_BASE, (double)LJUD.TIMERCLOCKS.MHZ48_DIV, 0, 0);
                //LJUD.AddRequest(u3.ljhandle, LJUD.IO.PUT_CONFIG, LJUD.CHANNEL.TIMER_CLOCK_BASE, LJUD.TIMERCLOCKS.MHZ24_DIV, 0, 0);  //Use this line instead for hardware rev 1.20.

                //Set the divisor to 48 so the actual timer clock is 1 MHz.
                LJUD.AddRequest(u3.ljhandle, LJUD.IO.PUT_CONFIG, LJUD.CHANNEL.TIMER_CLOCK_DIVISOR, 48, 0, 0);
                //LJUD.AddRequest(u3.ljhandle, LJUD.IO.PUT_CONFIG, LJUD.CHANNEL.TIMER_CLOCK_DIVISOR, 24, 0, 0);  //Use this line instead for hardware rev 1.20.

                //Enable 1 timer.  It will use FIO4.
                LJUD.AddRequest(u3.ljhandle, LJUD.IO.PUT_CONFIG, LJUD.CHANNEL.NUMBER_TIMERS_ENABLED, 1, 0, 0);

                //Execute the requests.

                //Request a read from the timer.
                LJUD.eGet(u3.ljhandle, LJUD.IO.GET_TIMER, (LJUD.CHANNEL)1, ref rpmValue, dummyDoubleArray);


#2 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 16 October 2014 - 03:42 PM

It looks like you are trying to read from a timer that has not been enabled. Timers start on channel 0, so if one timer is enabled then only timer0 is available. If you enable 2 timers, timer1 will also be available and your read call would be valid. Do a timer read call like this instead with your current settings:

LJUD.eGet(u3.ljhandle, LJUD.IO.GET_TIMER, (LJUD.CHANNEL)0, ref rpmValue, dummyDoubleArray);

Your current configuration (or at least the code provided) will default to system timer low mode (default) since you are not configuring the timer mode. For general timer/counter documentation, look here:




For UD driver pseudocode on timer/counters, look here:




Last, in the .NET examples there is a timer/counter C# example for the U3:



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users