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.


How to set DAC config defaults with Python?

  • Please log in to reply
2 replies to this topic

#1 Miky

  • Members
  • 3 posts

Posted 24 March 2015 - 12:57 AM

With LJControlPanel I am able to set all config defaults. DAC0/DAC1, too.


But with Python? After U3 HV power up:


import u3

daq = u3.U3()
print daq.dac0
print daq.dac1
print daq.readRegister(5000)
print daq.readRegister(5002)


Result is:




Now I tried readDefaultsConfig() which is using readDefaults():


cfg = daq.readDefaultsConfig()
for key,value in cfg.iteritems():
  print '%-18s: %s' % (key,value)


and got the right values.


configU3() is using bytes, and therefore cannot read/write DACx if in 16 bit mode. But method arguments are Python integers, silently used as bytes.


If I do configU3(DAC0=<somevalue not 0>,DAC1=<somevalue not 0>), the DAC values after power up are near 0 - configU3() DAC0/1 results are 0 as shown above. Or is it a must to set the CompatibilityOptions bit 1 for 8 bit DAC operation to use configU3() this way?


Also all not given method arguments were set to 0 and written if other arguments with same writemask bit are used. You have to be very careful using this method for setting config defaults.


What is the right way?


Configure I/O without configU3(), DACx with writeRegister(5000/5002), followed by setDefaults()?


"Configure I/O":  configAnalog()/configDigital() followed by getDIState()/setDOState() calls, since configIO() cannot configure CIOx and digital I/O?


Some more examples would be nice.


That being said, I am very impressed by the Python support.


#2 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 24 March 2015 - 01:54 PM

Using configU3, the DACs are 8-bit values and CompatibilityOptions does not need to be set for 8-bit. However, it looks like the current U3 firmware is not setting the DACs using configU3, though this used to work properly in older firmware versions. I'll have to check with the firmware person on this, but normally you can use configU3 to configure most power up defaults. For timer/counters, configure the current settings and use setDefaults() to make them the default. configU3 doesn't configure the timer modes.


Right now I would recommend setting your current analog outputs (DAC), analog inputs (AIN), and digital I/O settings to the default settings you want and call setDefaults(). What you mentioned sounds good (writeRegister(5000/5002), configAnalog()/configDigital(), getDIState()/setDOState() calls), and you can call setDefaults() after configuring everything.

#3 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 07 April 2015 - 04:41 PM

To update this topic relating to ConfigU3 and setting the DACs with it, this is no longer supported in the current versions of the U3-LV/HV firmware. If you need to set the default DAC values, use the SetDefaults function instead.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users