wiki:Docs/Prog/Manual/ApplicationLibraries/lib825ev/DAC

Version 3 (modified by Don Wilson, 6 years ago) ( diff )

--

Analog Output (DAC Digital to Analog Conversion) Functions

Example - Application manually setting DAC output voltage

// Application should call this when starting up to initialize the DAC output
void SetupDAC(void)
{
    // Setup DAC to not track gross or net weight but be controlled manually
   DACOutputRange outputrange = dacOutput0to10V;

   if(SetDACReg(nDAC, dacAD5422Control, 0x3FF0 | (uint16)outputrange, WAIT_ACK) != OK)
       printf("\n\nSetDACOutputRange error\r\n");

   float fMaxOutput = 10.0; // Maximum output 10 volts

   if(SetDACFloat(nDAC, dacMaxOutput, fMaxOutput, WAIT_ACK) != OK)
       printf("\n\nSetDACFloat max output error\r\n");


}

// Application may call this any time change in voltage output is desired
void SetDACVoltage(float voltage)
{
     uint16 value = (uint16)(0xFFFF * (voltage / 10.0));
     SetDACReg(nDAC, dacAD5422Data, value, WAIT_ACK);
}



Note: See TracWiki for help on using the wiki.