Digital To Analogue Converter Power Supply.
Introduction:
This project is a simple DC voltage generator with a 0 to 5V variable output.
This is based on the initial post by Brandon a few days ago.
All credit is to him for planting the seeds for a new set of experiments.
The device is a Microchip MCP4921.
This is a 12-Bit DAC which means it can use 4096 different values with a 5V reference.
The device is controlled using the SPI bus, which means it is very straightforward to use.
This is not a power supply in the sense of a bench supply, it is only to demonstrate the principles, and is only capable of supplying a few mA
Calculation:
12 Bits = 4096 steps
5V / 4096 =1.220703125 mV- Step
The data to send to the device is calculated as follows.
Data To Send = Desired Output/mV-Step
To program 2.5V
Data To Send = 2.5/0.001220703125
Data To Send = 2048
Before the data is sent, bits 12 & 13 need to be set.
Data To Send = Data To Send |3 << 12
In other words, OR the Data with 3, then left shift 12.
This 16 bit value then needs splitting to 2 x 8 bit bytes to send to the SPI Bus.
High Byte =( Data To Send >>8) & 255
In other words Right Shift 8 then AND with 255
Low Byte = Data To Send & 255
In other words AND with 255
Using The SPI Bus:
The data is sent to the SPI bus as follows.
Pull C0 High
INIT the SPI bus in Flowcode
Pull C0 Low
Send SPI High Byte
Send SPI Low Byte
Pull C0 High.
The DAC output will then be 2.5V dc for an input as in the above examples.
Hardware:
EB 006 Programmer
EB 014 Keypad
EB 017 Patch Board
EB 076 Touch Screen Display (Used to make showing the data easier)
PIC 16F877A Microcontroller
MCP4921 DAC Device.
MCP4921 Pin Outs:
1 Vdd 5V
2 CS C0
3 SCK C3
4 SDI C5
5 LDAC GND
6 Vref 5V
7 Vss GND
8 Vout Output
Usage:
Using the touch screen display allows more data to be displayed than using a standard 2 x 16 LCD.
On first power up or pressing the reset button, a simple user guide is displayed.
To pass this point, the screen is swiped.
The actual voltage is entered as a 4 digit variable without the decimal point. This is then added by dividing the 4 digit value entered by 1000.
This is then converted to a string to display on the LCD.
The system will output this level until a new value is entered.
Pressing # will set the output to zero.
Experimental data shows the accuracy to be about 0.5 measured on my Fluke 87/5 3.5 Digit Meter
The meter has a basic DC accuracy of 0.05% + 1 digit.
Currently, I have not implemented any checking for entries over 5 V.
If a value is entered, the output will be Input-5, though the display will show the entered value.
Example
Entered 6.5V
Display = 6.500 V
Output = 1.500 V
- System.JPG (99.83 KiB) Viewed 16904 times
- Display.JPG (79.3 KiB) Viewed 16904 times