8051_DAC
This 8051 project shows digital to analog conversion. To simulate circuit in this project, initially activate Mixed Mode simulator from the Schematic Editor window. Simulation can be performed by selecting Run Transient analysis / Oscillograph from Simulation menu.
The circuit contains an 8051 chip, Synchronous 4-bit Binary Up/Down Counter (SN74191), Parallel Input Complete Dual 12-Bit DAC (AD8582) and Voltage Source.
In this project, two synchronous 4-bit binary Up/Down counters are cascaded to generate a count sequence upto 255 starting from 0. The clock given to the counter is also connected to the INT0 pin of 8051. For each clock pulse, 8051 receives an interrupt pulse. On receiving the interrupt pulse, the data that appears at Port P1 from the counter is transferred to Port P0. The data at P0 is given to DAC and is stored in any of the two internal registers depending upon the channel chosen and the state of LDA or LDB. The voltage resolution is multiplied for each bit value change, and the corresponding analog voltage is shown at the output.
The program is as shown:
#include <8051.h>
void int_t0 () interrupt 0; // Interrupt function declaration
void main ()
{
EA = 1; // EA is set to enable all interrupts
EX0 = 1; // EX0 is set to enable External Interrupt 0
for ( ; ; ) // Infinite loop
{
}
}
void int_t0 () interrupt 0 // Interrupt function definition
{
P0 = P1; // Data at Port P1 is copied to Port P0
}
The source code in the
code editor window
has to be
compiled
after making any modifications
(editing).
Also the code can be
debugged
during
simulation.