MCP4922 dual DAC - VoutB not working - Page 1
Forum section: electronics / beginners

author: Noobiq
author_rank: Contributor
timestamp: May 26, 2020, 06:51:43 pm
content: Helloi have this DAC in dummy load (not my design), controlled by Arduino (ATmega328p), but i ran into a problem.This is supposed to be 2x 12bit DACs in one chip, VoutA is first, VoutB second. VoutA works just fine, but not VoutB.it doesnt react to arduino, nor changes in ref. voltage.i tried to connect pin LDAC to ground (it should ensure both outputs are updated at the same time).replaced DAC and op-amps.not sure what should i do with SHDN pin, connect it to +5V or unconnected, but i tried both.Also i heard that if both ref. voltages are the same, i can use just one, but there was no explanation how to do it. Could it be as simple as just connect ref A to ref B ?Author of this is Kerry D. Wong, i just made some changes.arduino code:https://pastebin.com/4yZGRaJ9http://www.kerrywong.com/2013/10/24/building-a-constant-currentconstant-power-electronic-load/

author: MarkF
author_rank: Super Contributor
timestamp: May 26, 2020, 07:51:41 pm
content: 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.Code:uint8_t DAC_A = 0x5000; // DAC selection bit = 0// Buffer Vref = 1// Gain selection = 0// Output shutdown = 1uint8_t DAC_B = 0xD000; // DAC selection bit = 1// Buffer Vref = 1// Gain selection = 0// Output shutdown = 1float voltage = 0.0; // Output voltagefloat Vref = 4.0; // Reference voltagevoid main(void) {uint8_t msb,lsb;uint16_t value;// Set valuevalue = 4095.0 * voltage / Vref;// Send to DAC_Amsb = DAC_A | (uint8_t)((value)>>8);lsb = (uint8_t)(value & 0xff);sendSPI(msb);sendSPI(lsb);// Send to DAC_Bmsb = DAC_B | (uint8_t)((value)>>8);lsb = (uint8_t)(value & 0xff);sendSPI(msb);sendSPI(lsb);}

author: MarkF
author_rank: Super Contributor
timestamp: May 26, 2020, 07:53:51 pm
content: sendSPI() function to output one SPI byte.Sorry I don't remember the Arduino command and setup to do SPI outputs.Edit:Code:uint16_t value;// DAC_Avalue = DAC_A | (uint16_t)(4095.0 * voltage / Vref);SPI.transfer16(value);// DAC_Bvalue = DAC_B | (uint16_t)(4095.0 * voltage / Vref);SPI.transfer16(value);

author: M0HZH
author_rank: Regular Contributor
timestamp: May 26, 2020, 08:05:31 pm
content: Not sure if it applies, but on MPC4728 I had issues with grounding the LDAC pin directly; 10k resistor works fine.

author: MarkF
author_rank: Super Contributor
timestamp: May 26, 2020, 11:06:56 pm
content: Quote from: M0HZH on May 26, 2020, 08:05:31 pmUsing the MCP48xx Series, I tied the LDAC pin directly to ground without any issues.

author: Noobiq
author_rank: Contributor
timestamp: May 27, 2020, 04:22:18 pm
content: Thanks for the info. I thought the solution would be simpler, but i don't really know what to do with thisguess i will just use MCP4921. In the end, it probably won't matter that much.i thought external reference voltage is less noisy.

author: MarkF
author_rank: Super Contributor
timestamp: May 27, 2020, 04:58:56 pm
content: Quote from: Noobiq on May 27, 2020, 04:22:18 pmThe software solution is the same for both chip series (MCP48xx and MCP49xx).The only difference is Vref available in the MCP49xx Series.If you have DAC-A channel working, all you need to do is set the MSB (i.e. bit 15) and send the data again for DAC-B.Bit 15 controls which DAC you are setting.Depending on your PCB layout, the external Vref may actually may be more noisy. Not less.The advantage of the external Vref would allow a lower reference than the supply rail and could be referenced to something else in the circuit (which you do not have).Compare the command words for both series:

author: MarkF
author_rank: Super Contributor
timestamp: May 27, 2020, 05:08:12 pm
content: The two Vref circuits in the schematic will allow you to fine tune the current for exact match to your software settings. However, an issue occurs in that there are two (one for each half of the load). You need to balance both halves of the load with the two trim pots.If you decide to use the MCP48xx Series without Vref, you can fine tune the two outputs by adding constant values to each voltage calculation equation. Tweaking each half of the load after the circuit is assembled. Which is not a big deal for one-of DIY projects.