| | 4 | |
| | 5 | == Example - Application manually setting DAC output voltage == |
| | 6 | {{{ |
| | 7 | void SetupDAC(void) |
| | 8 | { |
| | 9 | // Setup DAC to not track gross or net weight but be controlled manually |
| | 10 | DACOutputRange outputrange = dacOutput0to10V; |
| | 11 | |
| | 12 | if(SetDACReg(nDAC, dacAD5422Control, 0x3FF0 | (uint16)outputrange, WAIT_ACK) != OK) |
| | 13 | printf("\n\nSetDACOutputRange error\r\n"); |
| | 14 | |
| | 15 | float fMaxOutput = 10.0; // Maximum output 10 volts |
| | 16 | |
| | 17 | if(SetDACFloat(nDAC, dacMaxOutput, fMaxOutput, WAIT_ACK) != OK) |
| | 18 | printf("\n\nSetDACFloat max output error\r\n"); |
| | 19 | |
| | 20 | |
| | 21 | } |
| | 22 | |
| | 23 | // Application may call this any time change in voltage output is desired |
| | 24 | void SetDACVoltage(float voltage) |
| | 25 | { |
| | 26 | uint16 value = (uint16)(0xFFFF * (voltage / 10.0)); |
| | 27 | SetDACReg(nDAC, dacAD5422Data, value, WAIT_ACK); |
| | 28 | } |
| | 29 | |
| | 30 | |
| | 31 | |
| | 32 | }}} |