LabJackPython: New support for SetDefaults and ReadDefaults

We recently added new power-up defaults functionality to UD series (U3, U6, UE9) firmware. This came in the form of two new functions: SetDefaults and ReadDefaults.

SetDefaults will write the current configuration of the LabJack to flash. If the device is power cycled, it will load this configuration right when it starts up.

Have timers setup? Their configuration is saved.
Have DAC0 set to 1.2 volts and DAC1 set to 2.1 volts? Saved.
Have every other pin on your U3 configured for digital? Stored.

Get the LabJack exactly how you want it, then call SetDefaults and you’re good to go. If you’re on Windows, you may be familiar with the “Config. IO Defaults” panel in LJControlPanel. You may have asked yourself, “How do they do that?” Now you know, SetDefaults.

Now, there are a few of us who work on Mac OS X or Linux. Before, we were SOL. Enter the latest improvement of LabJackPython. You can now call SetDefaults on any UD series device from LabJackPython. There is also support for the sister function ReadDefaults, to read back the stored values.

>>> import u3
>>> d = u3.U3()
>>> d.writeRegister( 5000, 1.2 ) # Set DAC0 to 1.2 using Modbus
>>> d.configIO( FIOAnalog = 15 ) # Set the first four FIOs to analog.
>>> d.setDefaults()

It doesn’t get much simpler than that. Just configure the device the way you want it and call setDefaults() on it.

If you ever are curious what the defaults are, you can read them back using ReadDefaults. Using the mapping from your LabJack’s User’s Guide, Section 5.2.22 on the U3, you can read back what has been stored.

>>> import u3
>>> d = u3.U3()
>>> d.readDefaults(0)
[0, 0, 0, ..., 0]

or you can use the convenience function readDefaultsConfig() which will read in the mapping for you:

>>> import u3
>>> d = u3.U3()
>>> d.readDefaultsConfig()
{ 'FIOAnalog': 15, 'DAC0': 65341, ... }

For now, this feature is only available on the latest version of LabJackPython on GitHub. It will be incorporated into the next tagged release, which is due out in June.

Related Tags: