Support Forum

Share your projects and post your questions

Register   or   Sign In
The Forum

DAC Not getting 3.3V Voltage

1601 Views - Created 09/04/2019

09/04/2019

Posted by:
Adrian Saw

Adrian Saw Avatar

Hi there,

I have just bought the ADC DAC board and have been trying to set the DAC to generate a 3.3V sine wave.

For some reason I am not getting the full 3.3V when tested with a multimeter, it alternates from 0V to about 2.3V maximum.

It is currently at Gain Setting 2 and dropping it to Gain Setting 1 has certainly weakened the signal.

I have left it at Gain Setting 2 and would greatly appreciate thoughts on how to get it to achieve the 3.3V signal.

Thank you very much in advance!

Best wishes,
Adrian

09/04/2019

Posted by:
andrew

andrew Avatar

Location:
United Kingdom

andrew Twitter  andrew Website  

Hi Adrian

Do you have anything other than the multimeter connected to the DAC output that is drawing a current? A common cause of the voltage being low is if there is too much current being drawn from the DAC.

The MCP4822 DAC we use on the ADC DAC Pi can supply up to 25mA. If the current exceeds 25mA the voltage will begin to drop.

Also, try setting the DAC output to a value slightly less than 3.3V such as 3.2V. When the DAC gain is set to 2 the voltage will go up to the 3.3V power rail voltage so if that is slightly low the output voltage will also be low.

10/04/2019

Posted by:
Adrian Saw

Adrian Saw Avatar

Hi Andrew,

Thanks for getting back to me so quickly.

Nothing is connected to the DAC output other than the multimeter so I don't think any additional current is being drawn from it.

I am using the RPi 3B+ connected to a BitScope on USB and the ADC DAC Pi connected to the RPi via the GPIO pins. At the time the signal is generated, the BitScope is also in use by the RPi, so I wonder if the power drawn from USB affects the GPIO pins? I have not faced such an issue with a different DAC board that I've used previously of not producing the 3.3V signal required so a little puzzled if this is the issue.

I am not too clear about your last explanation regarding setting the DAC output value to slightly less than 3.3V such as 3.2V. From the code, the largest value it can accept is 4095 so I assume that the set_dac_raw() function sets this voltage based on 0 - 4095, with the assumption 4095 = 3.3V. Please can you advise the appropriate value I should input to test your solution out?

I have also included a copy of the code I'm using below for your reference, thank you very much for your help.

#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>

#include "ABE_ADCDACPi.h"

int DACLookup[40] = {0,2896,4095,2896,0,2896,4095,2896,0,2896,4095,2896,0,2896,4095,2896,0,2896,4095,2896,0,2896,4095,2896,0,2896,4095,2896,0,2896,4095,2896,0,2896,4095,2896,0,2896,4095,2896};

struct timespec ts1 = {0, 2000000L}; // 414L
struct timespec ts2 = {0, 8000000L};

int i;


int main(int argc, char **argv){
setvbuf (stdout, NULL, _IONBF, 0); // needed to print to the command line

if (open_dac() != 1){ // open the DAC spi channel
exit(1); // if the SPI bus fails to open exit the program
}

set_dac_gain(2);


while (1){
for (i=0; i<40; i = i + 1){

set_dac_raw(DACLookup[i],1);
nanosleep(&ts1, NULL);
}
nanosleep(&ts2, NULL);
i = 0;
}

close_dac();
return (0);
}

10/04/2019

Posted by:
andrew

andrew Avatar

Location:
United Kingdom

andrew Twitter  andrew Website  

Hi Adrian

The Bitscope shouldn't make any difference as it should be getting its power from the 5V rail while the ADC DAC Pi is powered through the 3.3V rail. Can you check the voltage on the 3.3V pin on the ADC DAC Pi to make sure it is 3.3V and there isn't a fault with the Raspberry Pi's 3.3V regulator?

With the comment I made about setting the voltage to 3.2V I was assuming you were using the set_dac_voltage() function which converts the voltage to a raw value but as you are using set_dac_raw() to set the voltage directly that wouldn't apply in your case.

Try running the code below, it should set the output on the DAC channel 1 to a constant 3.3V.



#include "ABE_ADCDACPi.h"

int main(int argc, char **argv){
// needed to print to the command line
setvbuf (stdout, NULL, _IONBF, 0);

if (open_dac() != 1){ // open the DAC spi channel
exit(1); // if the SPI bus fails to open exit the program
}
// set the dac gain to 2
// which will give a voltage range of 0 to 3.3V
set_dac_gain(2);

set_dac_raw(4095, 1);

close_dac();
return (0);
}


If the output voltage is lower than the voltage on your 3.3V power rail then there could be a fault with the ADC DAC Pi, in which case I will send you a replacement.

Sign in to post your reply

Note: documents in Portable Document Format (PDF) require Adobe Acrobat Reader 5.0 or higher to view.
Download Adobe Acrobat Reader or other PDF reading software for your computer or mobile device.