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

Read Timer Mode and Value (linux u3)

timerMode

  • Please log in to reply
3 replies to this topic

#1 eap

eap
  • Members
  • 2 posts

Posted 02 September 2014 - 08:20 AM

I cannot figure out how to read the timer mode on a u3.  I can write it, but no way to query the timermode. I do see the function in the UD driver, but I am on linux (exodriver & labjackpython).

 

Can I query the timerMode and Value? 



#2 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 03 September 2014 - 12:45 PM

Through low-level functions, no you can't read the currently configured timer mode. You can read the number of counters and timers enabled with the ConfigIO and the value with Feedback Timer#:

 

http://labjack.com/s...ers-guide/5.2.3

http://labjack.com/s...-guide/5.2.5.15

 

Using Modbus however it looks like you can read the Timer Config starting at address 7100 (Timer0Config) and is based on the byte setup from the Feedback Timer#Config IOType:

 

http://labjack.com/s...-guide/5.2.5.16

 

Timer0Config = 7100 and Timer1Config = 7102. For example (in LabJackPython):

import u3

d=u3.U3()

#Configure timers

timerConfig = d.readRegister(7100) #Timer0Config
mode = (timerConfig>>16) & 0xFF
val = timerConfig & 0xFFFF

Note that the UD driver only uses the low-level functions when configuring timer/counters, and saves the state of the timer configuration based on what was configured through function calls.



#3 eap

eap
  • Members
  • 2 posts

Posted 04 September 2014 - 07:34 AM

  • Thanks, that works perfectly!  The only note I'd make is that you're returning a 16-bit VALUE, whereas we sent an 8-bit, so I would add:
  • <code>
  • >>> print("value=%s" (val/256))
  • </code>
  • equivalent, but maybe better:
  • <code>
  • >>> val = (timerConfig>>8) & 0xFF
  • </code>

Is there a list somewhere of Register contents, or must we dig through the byte code to find that? 



#4 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 04 September 2014 - 01:30 PM

Thanks for pointing that out. My code was for timer modes that use 16-bit values. So to get the value it would look something like this for 16-bit and 8-bit values:

 

16-bit (0-65535):  val = timerConfig & 0xFFFF

8-bit (0-255):  val = (timerConfig>>8) & 0xFF

 

The Modbus map with all register addresses can be found here:

 

http://labjack.com/s...odbus/ud-modbus




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users