1. Introduction

 
The Simplecortex has one Analog output pin. This tutorial will teach you how to use the DAC pin to create an analog output. For this tutorial the DAC library is needed. This library can be downloaded from our repository.
 
2. Includes

 
To begin it is needed to include the libraries. This is done by these commands:

#include “dac.h”
 
The libraries for the microcontroller itself and the variables have to be included to:

#include “lpc17xx.h”
#include “lpc_types.h”
 
3. Write to the DAC

 
First the DAC has to be initialized in the main code with the command:

DACInit();

To write a value to the DAC the command use this code:

DACSetValue(Value);

The DAC is a 10 bits DAC, this means that a value of 1023 will make the output equal to power supply (3.3V for the Simplecortex). A 0 for value will make the output equal to 0V and a value of 512 will make the output equal 1.65V. The formula to calculate the output variable is:
Voutput = (value / 1023) * Power supply voltage.
To set the Analog output to 1.1V the correct command is:

DACSetValue(343);
 
1.1V = (343/1023) * 3.3V
Copyright 2011. Joomla 1.7 templates - Joomla template maker. The Simplecortex is developed by BRC-Electronics