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.
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.
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.
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.
I don't even know what I was thinking - yes, a LED ...
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.