Author Topic: MCP4922 dual DAC - VoutB not working  (Read 1189 times)

0 Members and 1 Guest are viewing this topic.

Offline NoobiqTopic starter

  • Contributor
  • Posts: 12
  • Country: sk
MCP4922 dual DAC - VoutB not working
« on: May 26, 2020, 06:51:43 pm »
Hello

i 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/4yZGRaJ9
http://www.kerrywong.com/2013/10/24/building-a-constant-currentconstant-power-electronic-load/
 

Offline MarkF

  • Super Contributor
  • ***
  • Posts: 2539
  • Country: us
Re: MCP4922 dual DAC - VoutB not working
« Reply #1 on: May 26, 2020, 07:51:41 pm »
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: [Select]
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);

}
 

Offline MarkF

  • Super Contributor
  • ***
  • Posts: 2539
  • Country: us
Re: MCP4922 dual DAC - VoutB not working
« Reply #2 on: May 26, 2020, 07:53:51 pm »
sendSPI() function to output one SPI byte.

Sorry I don't remember the Arduino command and setup to do SPI outputs.

Edit:
Code: [Select]

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);

« Last Edit: May 26, 2020, 08:02:16 pm by MarkF »
 

Offline M0HZH

  • Regular Contributor
  • *
  • Posts: 204
  • Country: gb
    • QRPblog
Re: MCP4922 dual DAC - VoutB not working
« Reply #3 on: May 26, 2020, 08:05:31 pm »
Not sure if it applies, but on MPC4728 I had issues with grounding the LDAC pin directly; 10k resistor works fine.
 

Offline MarkF

  • Super Contributor
  • ***
  • Posts: 2539
  • Country: us
Re: MCP4922 dual DAC - VoutB not working
« Reply #4 on: May 26, 2020, 11:06:56 pm »
Not sure if it applies, but on MPC4728 I had issues with grounding the LDAC pin directly; 10k resistor works fine.

Using the MCP48xx Series, I tied the LDAC pin directly to ground without any issues.
 

Offline NoobiqTopic starter

  • Contributor
  • Posts: 12
  • Country: sk
Re: MCP4922 dual DAC - VoutB not working
« Reply #5 on: May 27, 2020, 04:22:18 pm »
Thanks for the info. I thought the solution would be simpler, but i don't really know what to do with this :-[  guess i will just use MCP4921. In the end, it probably won't matter that much.

i thought external reference voltage is less noisy.
« Last Edit: May 27, 2020, 04:26:00 pm by Noobiq »
 

Offline MarkF

  • Super Contributor
  • ***
  • Posts: 2539
  • Country: us
Re: MCP4922 dual DAC - VoutB not working
« Reply #6 on: May 27, 2020, 04:58:56 pm »
Thanks for the info. I thought the solution would be simpler, but i don't really know what to do with this :-[  guess i will just use MCP4921. In the end, it probably won't matter that much.

i thought external reference voltage is less noisy.

The 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:

997499-0
 

Offline MarkF

  • Super Contributor
  • ***
  • Posts: 2539
  • Country: us
Re: MCP4922 dual DAC - VoutB not working
« Reply #7 on: May 27, 2020, 05:08:12 pm »
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.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf