Here's an example of adding an external D/A converter to
achive much higher resolution and accuracy compared to the LabJack's existing two analog
outputs, which suffers from a rather significant noise problem.
The circuit above uses a Linear
Technology LTC1658
14-bit D/A converter. The LT1019A
is a 2.5 volt reference.
A problem with the CS pin (extra clock pulse) prevents read-back from
working properly, meaning this device can't be included in an SPI loop used for
read-back. In practice this isn't a problem as you can still attach it to the
LabJack's SPI pins - just use a different CS pin than ones used for read-back and place it
in a write-only SPI chain.
The LabJack SPI mode pin-out is shown in the following table.
Signal |
LabJack Pin |
MOSI |
D13 |
SCK |
D15 |
CSN |
User selectable, D0-D7 |
The following sample code utilizes the LabJackWrapper class
to write the D/A.
LabJackWrapper labjack = new LabJackWrapper( -1 );
int spiMode = 2; // dac output ok, but read-back doesn't work
int spiMsDelay = 0;
int spiHusDelay = 0;
int spiControlCS = 1; // >1 means we want LabJack to implement and control a chip select pin for us
int spiCsLine = 0; // '0' means use D0 as the chip select line
int spiCsState = 0; // specify active state (low) of chip select line, i.e. CSN
int spiConfigD = 1; // we want LabJack to configure I/O pins for us
labjack.configSPI( spiMode, spiMsDelay, spiHusDelay, spiControlCS, spiCsLine, spiCsState, spiConfigD );
GenericSPI dac = new GenericSPI( 14 );
GenericSPI unused = new GenericSPI( 2 );
labjack.addSPI( dac );
labjack.addSPI( unused ); // LTC1658 has two dummy bits
dac.setBits( 16383 ); // set output to 2.5V
LabJack Analog Output Noise
Because the LabJack analog outputs are "ratiometric with the +5 volt
supply" any noise present on the +5 volt supply will appear on the analog
outputs. This noise is system dependent (ex.depends on USB hub power supply
regulation, cable quality, etc.).
The image below shows an actual noise measurement on the LabJack +5 volt
supply. While the analog outputs are filtered, this noise still feeds through and
reduces the effective resolution of the 10-bit analog outputs.
This noise was measured while the LabJack was active and appears to be
related to dynamic current consumption during USB communications. |