Since we did not find any code snippet or even info about the "soft_update" feature
we created are quick test to try the hardware variant via the LDAC pin.
Unfortunately we had no luck, this does not seem to work either. :-(
Code: Select all
# Test MPC4728 Quad-DAC synchronous update via LDAC pin
import time
from time import sleep
import board
import adafruit_mcp4728
from digitalio import DigitalInOut, Direction, Pull
MCP4728A4_DEFAULT_ADDRESS = 0x64
i2c = board.I2C() # uses board.SCL and board.SDA
# use for MCP4728A4 variant
mcp4728 = adafruit_mcp4728.MCP4728(i2c, adafruit_mcp4728.MCP4728A4_DEFAULT_ADDRESS)
LDAC = DigitalInOut(board.D5) # set LDAC Pin to D5
LDAC.direction = Direction.OUTPUT
#LDAC.pull = Pull.UP # does not work --> "Error: Pull not used when direction is output."
LDAC.value = True
# https://learn.adafruit.com/adafruit-mcp4728-i2c-quad-dac/python-circuitpython
# set Channel A and B to INTERNAL Vref (0V to 2,048V) or VDD (0V to VDD =5V)
mcp4728.channel_a.vref = adafruit_mcp4728.Vref.VDD
mcp4728.channel_b.vref = adafruit_mcp4728.Vref.VDD
#mcp4728.channel_a.vref = adafruit_mcp4728.Vref.INTERNAL
#mcp4728.channel_b.vref = adafruit_mcp4728.Vref.INTERNAL
# set Channel A and B gain=2 (0V to 4,096V) <- only working when using internal VRef
#mcp4728.channel_a.gain = 2
#mcp4728.channel_b.gain = 2
# optional save settings to eeprom
#mcp4728.save_settings()
while True:
LDAC.value = True # Update VA and VB should be latched
mcp4728.channel_a.value = 0
mcp4728.channel_b.value = 0
LDAC.value = False # Update VA and VB enabled
# print ("bottom left position \n")
sleep (0.005)
mcp4728.channel_a.value = 65535
mcp4728.channel_b.value = 65535
# print ("top right position \n")
sleep (0.005)
- Output VA (yellow) and VB (blue)
- Ch1-VA__Ch2-VB.png (37.56 KiB) Viewed 133 times
VB is about 660usec behind VA at the rising
and falling slope, where the falling slope should be synchronous.
So, there is no difference wether LDAC pin is HIGH or LOW.
- Output VA (yellow) and LDAC (blue)
- Ch1-VA__Ch2-LDAC.png (39.01 KiB) Viewed 133 times
VA is updated immediately and does not follow the LDAC pin.
Has anyone tested/used the LDAC synchronous update successfully, are we something missing?
thanks in advance for your time
RS