MCP4921 12 bit DAC interfacing with PIC16F877 microcontroller via SPI Connectivity
In any real time project, MCP4921 12 bit DAC interfacing with PIC16F877 microcontroller via SPI Connectivity is very essential. Because in real world most of the input sensors and output devices are analog. So if we want to work with those we need to know the basic interfacing of those sensors and output devices with microcontroller. Here I give you tutorial project on “MCP4921 12 bit DAC interfacing with PIC16F877 microcontroller via SPI Connectivity”.
In this tutorial project we will see how we generate triangular Wave using MCP4921 12 bit DAC. As we know that MCP4921 is a 12 bit DAC. But the control word we have to send 16 bit including data. In below we see the bit structure for MCP4921.
From above picture it is clear that bit 12-15 is used for control word and bit 0 to bit 11 are used for send 12 bit data.
Now question is how we maintain that format to send every 12 bit data along with 4 bit control word at MSB?
Let take an example if we want to write data via DCAA with output gain 1X and power down control bit.
So for that our control word will be
Bit 15 = 0 (write to DACA )
Bit 14 = 0 (Un buffered)
Bit 13 = 1(Output Gain)
Bit 12 = 1 (Output power down control)
So control bit will be 0011 = 3 .
So if you want to write 12 bit data like 001000100010. Then you have to send 16 bit data 0011001000100010 (0x32 and 0x22).
So we can get maximum 4096 different value by 12 bit data format. If we use 5V reference voltage then we will get ( 5000/4096) .001220703125 mile volt per step.
So for sending 3 volt at output we have to send 2.5/ .001220703125 = 2048 (010000000000) along with 3(0011) at MSB. So the final 16 bit data will be 0011010000000000 ( 0x34 and 0x00).
EasyEDA: Ideas for Circuit Design, Innovation for Electronics Access
Free Circuit Design: Schematic – Simulation – PCB Layout – Gerber Viewer
Cheapest PCB Prototype: Only $2 for 10pcs 10×10cm PCBs, 24 hours Quick Turn, DHL Delivery in 3 Days
Current Project / Post can also be found using:
- pic spi dac
- pic16 dac example
- Pdf dac pic16f877
- pic dac projects