I would simplify the circuit by using a MCP4822 which is a 12-bit DAC without Vref.
That said:
If you want to have the same reference voltage for both DACs, you could tie pins 11 and 13 to the reference and turn on buffering inside the MCP4922. You would only have the one adjustment pot instead of two.
The SHDN (pin 9) should be tied to +5V as shown in your circuit.
You need to send the desired value to the MCP4922 twice. Once for DAC-A and again for DAC-B.
uint8_t DAC_A = 0x5000; // DAC selection bit = 0
// Buffer Vref = 1
// Gain selection = 0
// Output shutdown = 1
uint8_t DAC_B = 0xD000; // DAC selection bit = 1
// Buffer Vref = 1
// Gain selection = 0
// Output shutdown = 1
float voltage = 0.0; // Output voltage
float Vref = 4.0; // Reference voltage
void main(void) {
uint8_t msb,lsb;
uint16_t value;
// Set value
value = 4095.0 * voltage / Vref;
// Send to DAC_A
msb = DAC_A | (uint8_t)((value)>>8);
lsb = (uint8_t)(value & 0xff);
sendSPI(msb);
sendSPI(lsb);
// Send to DAC_B
msb = DAC_B | (uint8_t)((value)>>8);
lsb = (uint8_t)(value & 0xff);
sendSPI(msb);
sendSPI(lsb);
}
sendSPI() function to output one SPI byte.
Sorry I don't remember the Arduino command and setup to do SPI outputs.
Edit:
uint16_t value;
// DAC_A
value = DAC_A | (uint16_t)(4095.0 * voltage / Vref);
SPI.transfer16(value);
// DAC_B
value = DAC_B | (uint16_t)(4095.0 * voltage / Vref);
SPI.transfer16(value);