Version 6 (modified by 6 years ago) ( diff ) | ,
---|
Analog Output (DAC Digital to Analog Conversion) Functions
Example - Application manually setting DAC output voltage
const int nDAC = 1; // First DAC card // 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) { // The DAC output is controlled by a 16 bit register so we multiple the maximum 16-bit value 0xFFFF times output percentage/100 desired. // For example maxium 10 V would be 0xFFFF * (10.0 / 10.0) = 0xFFFF * 1.0 = 0xFFFF, 5V would be 0xFFFF * (5.0 / 10.0) = 0xFFFF * 0.5 = 0x8000 uint16 value = (uint16)(0xFFFF * (voltage / 10.0)); SetDACReg(nDAC, dacAD5422Data, value, WAIT_ACK); }
Note:
See TracWiki
for help on using the wiki.