creativecontrol_circuitpython_ltc166x
CircuitPython library for control of LTC166X 8-bit and 10-bit DACs.
Author(s): Thadeus Frazier-Reed
Implementation Notes
The library provides options for storing all DAC values in a list or a list of lists for DAC daisy-chains. A channel may be marked for no update using a negative number (i.e. -1) This value will be skipped or a no change message will be sent in the case of a daisy-change.
TODO:
Add Sleep and Wake control
Influenced by http://www.kerrywong.com/2010/05/02/a-library-for-ltc1665ltc1660/
Hardware:
Linear Technologies LTC166X datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/166560fa.pdf
Multiple LTC1665/LTC1660’s can be controlled from a single 3-wire serial port (i.e., SCK, DIN and CS/LD) by using the included “daisy-chain” facility. A series of m chips is configured by connecting each DOUT (except the last) to DIN of the next chip, forming a single 16m-bit shift register. The SCK and CS/LD signals are common to all chips in the chain. In use, CS/LD is held low while m 16-bit words are clocked to DIN of the first chip; CS/LD is then pulled high, updating all of them simultaneously.
Software and Dependencies:
Adafruit CircuitPython firmware for the supported boards: https://circuitpython.org/downloads
Adafruit’s Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
- class creativecontrol_circuitpython_ltc166x.LTC1660(sck: Pin, mosi: Pin, csel: Pin, debug: bool = False)
Extended class for 10bit Octal DAC
- class creativecontrol_circuitpython_ltc166x.LTC1665(sck: Pin, mosi: Pin, csel: Pin, debug: bool = False)
Extended class for 8bit Octal DAC
- class creativecontrol_circuitpython_ltc166x.LTC166X(sck: Pin, mosi: Pin, csel: Pin, debug: bool = False)
LTC166X 8 or 10-bit digital to analog converter.
- Parameters:
sck (microcontroller.Pin) – SPI clock pin.
mosi (microcontroller.Pin) – SPI output pin.
csel (microcontroller.Pin) – SPI chip select pin.
debug (bool) – Debug the SPI output values.
- get_bit_depth()
Return bit_depth based on device used.
- get_device_range()
Return device range based on device used.
- sleep(dac)
Put DAC in sleep mode.
- wake_no_change(dac)
Wake DAC with no value updates.
- write_chained_dac_value(value: list, address: int, chain_length: int)
Write a single DAC value to a chain.
- write_chained_dac_values(dac_values: list)
Write list of values to a chain of DACs. All lists should be the same length. Do not update if value is < 0. This allows for comparison of update frames and only updating if value has changed.
- Parameters:
dac_values (list) – list of lists of values from 0 to device range.
Each list represents a DAC’s channel values. [[DAC 1], [DAC 2], [DAC 3], etc.]