How to output constant DC voltage via onboard DAC's?

Using the Giga R1 Wifi board...

How to have DAC0 or DAC1 output a constant DC Voltage...
Like 1.5 volts DC or 750 mV or whatever.

I can output various wave forms but I need a constant DC Voltage out.

Hopefully someone can provide some sample code so I can see how to do this.

Thanks for any help.

PS - Can you confirm that A0 thru A11 can only take analog input...
and not create an analog output voltage?

PSS - I understand the max range for DAC0 and DAC1 = 0.55 to 2.75V... right?

1 Like

That's weird. You do the more complex thing and the simpler thing you fail. If you want constant output you just write the value to the DAC and don't change it.

1 Like

The DAc cant be used as a power supply

That is the question - How do you write a single value to the DAC?
Can you supply code sample.

And, not trying to use it as a power supply.
The main program will periodically want to change the output voltage of the DAC depending on various circumstances.

Thanks for any help.

just have one sample in your waveform

I have still been unable to get the DAC to output a constant DC voltage on the Giga R1 Wifi board.

This page implies analogWrite should work on DAC0 andDAC1 (pins A12 & A13) but it doesn't.
Example: analogWrite(12,value)
Where value = 0 to 0xfff (4095 decimal... or is the max 255?decimal)
Regardless I can't get that to work.

This page has code sample to create a Wave Form Generator using Arduino_AdvancedAnalog.h
But this technique requires constant demands on the processor continuously feeding data in to a 33 byte deep buffer and then feeding that to the DAC.

Assuming the DAC has a single input register and is fed one chunk of data at a time to convert...
Then there must be a simple way to just load that register one time and have the DAC output the equivalent DC voltage until the next time the input register is written to.

Will some kind soul please share the code with me to write a single value to the DAC input register so I can get some sleep at night.
I'm sure it is something simple I've missed but I'm about to abandon the Giga R1 DAC and just put some external ones on the i2C bus... but hopefully someone will save me that extra hardware.
Thanks for any help !!!!!

If someone finds the answer, it would be useful if the document here:

were updated, because it doesn't mention a single thing about outputting a single stable value, and IMNSHO, it should, merely because that's a useful way to test hardware.
I expect 'someone' will have to fire up a github, or some other, tool request to do this, and that ain't me.

Source code seems to indicate it’s taken into account with a call to a specific function named analogWriteDAC().

Would be worth investigating if that function gets called

Also seen this

Where they say

void dac_setup(void); (new)

Configure the DAC (for xmega CPUs that support it). Call one time within the 'setup()' function if you want the functionality of a DAC.

The 'e5' series has a single DAC with 2 channels. The 'a4' and 'a4u' series' have two DACs with 2 channels each. The 'd4' series has no DAC, and for the 'd4' series, this function is not supported. Other CPUs vary depending on their architecture.

The default implementation uses the internal 1V reference for the output on the DAC. So a value of 4095 should generate a 'full scale' output voltage of 1.00V. To change this behavior, you can modify DACA.CTRLC register (and if available, the DACB.CTRLC register) to use a different reference voltage.

For more information, see the appropriate xmega CPU documentation, and 'A' and 'E' series documentation, regarding the DAC.

1 Like

Won't it even be able to power a simple diode, like 2V and 20mA? :thinking:

Thanks

not with any precision.

1 Like

If by diode, you mean LED, does it really matter? Or are you trying to amplitude-modulate, or something equally non-linear?

1 Like

I don't even know what I was thinking :rofl: - yes, a LED :innocent:...

I need a reference voltage for a project of mine, at around 3V. However - doing a bit of searching - I've decided to go for integrated dc-dc buck converter, like the TI TPS62698. I could just utilize the 3.3V of the arduino, both powering a led and achieving a nice, precise 3V reference. I've got a device with an output of either 2.7V or 3.3V, and I'm planning on lighting up a led if the voltage is above 3V.

Oh, btw, I was planning on using it with a LM211 or LM311 Comparator, getting 3V reference voltage from the TPS62698, and triggering a LED when the device voltage is above 3V. :innocent:

I also need to do exactly this too.

Fran (or anyone else) have you found a way to give one of the GIGA DACs a value to be output as fixed level?

In my case I have an analog comparator and I want to set its reference level in software.

TIA, Joe

OK I finally found the updated Arduino docs for AnalogWrite which say:

"... GIGA R1 boards have true analog output when using analogWrite() on pins DAC0 and DAC1 ."

Note the correct pin references are A12 and A13, not DAC0 and DAC1 which aren't recognized by the compiler, nor just 12 and 13 which are digital pins.

You don't even need to preconfigure the output pin. The specific syntax that works is:

analogWrite(A12, 255);

where 255 is an 8-bit value for the 0-3.3 voltage scale. On my specific GIGA board 0 = 0.019V and 255 is 3.216V

And I've confirmed that it works in 12 bit resolution too.

 analogWriteResolution(12);
 analogWrite(A12, 2010);

gives 1.569V output.

2 Likes