cancel
Showing results for 
Search instead for 
Did you mean: 

DAC output not working properly

fabricepeden
Associate II
Posted on December 23, 2013 at 17:09

Hi everybody,

I'm using the DAC1 output on my STM32F Up to a 12 bits values of around 1000, it works correctly, but after, the output voltage still be at 1.8V (whatever my value to be converted : 3000, 4000..). I have already checked VDDA, VREF+ and VSSA (3.3V and 0V). This output is connected on one input of my four AOPs (LMV358). Please find my code below :

/* Preconfiguration before using DAC----------------------------------------*/
GPIO_InitTypeDef GPIO_InitStructure;
DAC_InitTypeDef DAC_InitStructure;
/* DAC Periph clock enable */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC, ENABLE);
/* GPIOA clock enable (to be used with DAC) */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
/* DAC channel 1 (DAC_OUT1 = PA.4) configuration */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 ;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
//GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure); 
DAC_InitStructure.DAC_Trigger = DAC_Trigger_None;
DAC_InitStructure.DAC_WaveGeneration = DAC_WaveGeneration_None;
DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Enable;
DAC_Init(DAC_Channel_1, &DAC_InitStructure);
/* Enable DAC Channel1 */
DAC_Cmd(DAC_Channel_1, ENABLE);
and then :
DAC_SetChannel1Data(DAC_Align_12b_R,DISCOVERY_DAC0_35mA_BOUCLE);
If you have any idea or suggestion, thank you in advance.

14 REPLIES 14
jj2
Associate II
Posted on December 23, 2013 at 20:07

Have not reviewed your code - however the fact that the DAC behaves properly up to some critical point - and then ceases to increase in output - suggests that some, ''external limiting factor'' may be in play.

Iirc - that op-amp - when powered from 3V3 - may not be fully accepting of an input signal beyond the levels you report.  (again from memory - neither that op amp's output - nor signals input - may approach the op amp's supply V.)  Review of the op amp's spec will detail.

Quick easy test could see:

a) temporarily ''break'' the connection - your DAC output to op amp.  Replace w/10K load resistor tied to ground.  Repeat your test - observe if VDac now reaches expected levels.

b) power the op amp from 5V rather than 3V3.  This likely enables that op amp to accept higher V levels.
fabricepeden
Associate II
Posted on December 24, 2013 at 12:16

Thank you for your answer.

I've tried to disconnect all my AOPs except one. When I give the value 3000 to the DAC, I measure on my AOP 2.26V (the value that I expect). If I add one AOP, this value decrease to 2.08V and the same if I add other AOPs.

So it's a problem of impedance between AOP and µc ?

raptorhal2
Lead
Posted on December 24, 2013 at 21:16

The LMV358 will work down to 2.7V reference according to the datasheet, so using 3.3V is probably not the problem.

You didn't say if the DAC feeds the + or - amp inputs. Minus inputs could overload the DAC, depending on the input resistor value. The same is true if you use a voltage divider to the + input.

Cheers, Hal

fabricepeden
Associate II
Posted on January 06, 2014 at 12:22

Thank you for your answer.

The thing that I've tried is to add a AOP in voltage follower mode. It's better (output voltage reaches up to 2.7V), but now I would like to understand why this value cannot goes up to 3.3V in my application.

When I measure the impedance between my DAC and the input of my AOP (LMV358), I found 350kOhm, or I expected to have more than 1Mohms ?

Thank you in advance,

raptorhal2
Lead
Posted on January 06, 2014 at 20:33

I am puzzled by your description. If you are using an AOP in voltage follower mode, the DAC output should go directly to the plus AOP input. There shouldn't be 350K ohms resistance between them.

Ask a circuit design expert to look at what you are doing. I can't tell what is wrong looking through this forum knothole.

Cheers, Hal

fabricepeden
Associate II
Posted on January 07, 2014 at 07:35

I think I misspoke.

The DAC is directly plug on the plus of my AOP, so there is no resistance between DAC output and plus input.

But, if I measure directly the DAC output ,everything is OK (up to 3V3), and if I add my voltage follower, the maximum voltage that I measure is 2.7V. So it's this issue that I'm trying to understand.

Thank you.

frankmeyer9
Associate II
Posted on January 07, 2014 at 08:26

Perhaps your voltage follower represents a too high load to the DAC.

If I remember correctly, the output resistance was about 1 megaohm in unbuffered mode.

You can configure a buffered mode to reduce the output resistance to 15k, but have to live with a reduction of output swing of up to 200mV. Check the datasheet for exact numbers.

fabricepeden
Associate II
Posted on January 09, 2014 at 09:14

Thank you for your answer.

I've checked with/without the internal buffer, and there is no change.

I've tried to measure the current between the DAC output and my input plus of my AOP, and it's lower than 0.1µA (I cannot measure below with my tools).

I've asked the technical ST team to help me to understand what happen.

frankmeyer9
Associate II
Posted on January 09, 2014 at 11:15

As I understood your last posts, everything is fine as long as nothing is attached to your DAC output (i.e. without your voltage follower/opamp circuitry).

This certainly suggests you external circuitry is the culprit, and is pulling the DAC output in undesired directions.

Have you tried a simulation (some SPICE derivate, for instance), or asked a hardware designer for assistance ?