Você está na página 1de 26

DACs and SPIs

ECE3534
Material from various sources including slides from KTH
in Sweden (J. Barton, J. Kim, C. Neel)
Topics
Digital-to-Analog converter basics
SPI Interface
Required Reading
http://en.wikipedia.org/wiki/
Serial_Peripheral_Interface_Bus
http://www.linear.com/pc/downloadDocument.do?
navId=H0,C1,C1155,C1005,C1156,P2048,D2170
Chapter 9 of the Spartan3E Starter Kit Users Guide
DACs
5
What is a DAC?
A digital-to-analog converter (DAC) is a circuit that produces an
analog current or voltage that is proportional to an analog reference
(voltage or current) and an N-bit binary word.
V
out
= k x V
ref
x (Binary Word)
6
In English
DACs generate piecewise continuous signals from digital code.
OR
DAC converters are devices that receive a binary word from the
microprocessor and convert it to a scaled analog voltage (or current).
7
DAC Configuration
8
DAC Circuit Types
Two types of DAC Circuits:
1. Binary weighted
2. R-2R ladder
9
N-Bit Binary Weighted DAC
10
N-Bit Binary Weighted DAC
11
Binary Weighted Principles
12
Principles Contd
V
0
= -R
f
I
0
V
0
= voltage output from amplier
R
f
= feedback resistance
Resolution= V
R
/2
N
Note: For a gain of 1, R = 2R
f
13
Principles Contd
V
0
= -R
f
I
0
V
0
= voltage output from amplier
R
f
= feedback resistance
Resolution= V
R
/2
N
Note: For a gain of 1, R = 2R
f
14
Example
Find output voltage and current for a binary weighted resistor DAC
of 4 bits where :
R = 10 k Ohms, R
f
= 5 k Ohms and V
R
= 10 Volts. Applied binary
word is 1001.
15
Solution
R
f
= (R/2)
R 2R 4R 8R
V
o
V
R
1-bit
MSB
2-bit 3-bit 4-bit
16
Solution Contd
17
Solution Contd
Binary input = 1001 = 9
From example, V
0
= 5.625V
V
0
/V
R
= 5.625V/10V = 9/16
18
R/2R ladder DAC
Most popular single
package DAC
Resolves BWL problems
Only two resistor values
Linear Technologies
SPI DAC
LT2626
Sending Data to the DAC
SPI_SCLK
SPI_MOSI
DAC_CS_N
These SPI signals are controlled by bits in the
GPIO register mapped at 0x40010000
DAC SPI Word Format
Conveyed on SPI_MOSI
The voltage on the DAC A output pin
is equal to:
(value on D[9:0] / 4096 ) * 3.0 volts
DAC Commands
SPI Control in MicroBlaze
unused
1 1
AMP_CS_N
DAC_CS_N
SFLASH_CS_N
SPI_MOSI
SPI_SCLK
Address = 0x40010000
write only
Note: *_n sufx means ACTIVE LOW
Keep the unused Chip Selects
deasserted with a 1.
Operation (1 of 2)
To send a word to the DAC:
Start with DAC_CS_N high
Set DAC_CS_N low
Shift out 24 bit word (4 bit cmd, 4-bit DAC addr, 12
bit DAC value, 4 dummy bits)
Set DAC_CS_N high
Operation (2 of 2)
Sending a bit:
Start with SCLK = 0
Assert bit on MOSI line
Set SCLK = 1
Set SCLK = 0
Do this for each
of the 24 bits
in the SPI word

Você também pode gostar