Other Parts Discussed in Thread: DAC11001A
Tool/software:
Hello,
I am trying to connect BP-DAC11001EVM with ESP32. But somehow, I cannot see any output at the DAC side. My ESP 32 is establishing the communication with the DAC. But I don't see any voltage at the output. I have attached the code below that I am using. Please let me know what the issues could be.
Code:
import machine from machine import Pin, SPI import math import time # SPI Configuration spi = SPI(1, baudrate=1000000, polarity=0, phase=0, sck=Pin(18), mosi=Pin(23)) cs = Pin(5, Pin.OUT) # Chip Select for DAC ldac = Pin(16, Pin.OUT) # LDAC for DAC cs.value(1) ldac.value(1) # Function to send 20-bit data to DAC (in 24-bit format) def send_to_dac(cs, value): cs.value(0) spi.write(value.to_bytes(3, 'big')) cs.value(1) # Generate single-phase sine wave def generate_sine_wave(frequency=50, amplitude=1.0, sample_rate=1000): step = 0 while True: # Generate a sine value between 0 and full-scale (20-bit) sine_val = int((amplitude * (math.sin(2 * math.pi * frequency * step / sample_rate) + 1)) * ((2**20 - 1) / 2)) send_to_dac(cs, sine_val) time.sleep_us(10) # Delay before toggling LDAC ldac.value(0) time.sleep_us(10) # Delay after toggling LDAC ldac.value(1) step = (step + 1) % sample_rate time.sleep(1 / sample_rate) # Start generating the signal generate_sine_wave(frequency=50)