Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

interface SPI with Altera + DAC

Status
Not open for further replies.

cookie4u

Newbie level 3
Joined
Oct 6, 2009
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Canada
Activity points
1,314
I Have a group project at the moment,
and right now I have to send a square wave to a Digital to Analogue Converter and output a voltage analog signal to a waveform, connnected to an audio amplifier afterwards

I'm using a DAC MCP4922 : 12-Bit DAC with SPI™ Interface

my professor said i also need e^(t/Time Constant) and sine(x) together to make a sound , how will I do this?

Altera cannot compute sine functions , so how Will i solve this?
are there any sample code i can use to test the DAC?


what does it mean when a DAC is 12 bit?

Also, to use the DAC i have to interface it with the SPI, but I am new at this and i dont know where to start.
How can I test out how the DAC works?

any suggesstions and ideas i can go forward with it?

I have no background in digital to analogue converters, and I want to get some testing done by the end of this week , i would appreciate any help available

project:making an electronic drumset

How do i get it to work

help! i am very confused how to connect the DAC to altera
:?::idea::cry: i read some background info on DAC/SPI


*SEE POST BELOW*
TRYING TO GET THIS WAVEFORM - SPI on altera

waveform.jpg


what does SPI excatly do as well?
 

Re: how to connect Altera to DAC and program it with VHDL

It seems to me, that your project instructor expected some elementary knowledge of digital signal processing and digital electronics (e.g. regarding DA conversion). I guess, he also suggested some literature (or would at least on request).

Otherwise, you should have a library with basic text books and you still have internet text books, wikipedia and electronic manufacturers application literature. In my opinion, the MCP4922 datasheet gives an understandable explanation of 12 Bit resolution in the General Overview chapter.

But I wanted to give some help for your signal processing problem.
need e^(t/Time Constant) and sine(x) together to make a sound , how will I do this
I guess, he suggested to multiply both functions.

Altera cannot compute sine functions
It can in different ways.
- Use the cordic algorithm
- Use a sine table. It can be easily placed in FPGA internal memory. The VHDL tool can even calculate the sine table at compile time
- Use a second order differential respective difference equation to model the dampened oscillation directly

e^(t/Time Constant) can be simply modelled by a geometric progression, or in other words, a repeated multiply.
 

Re: how to connect Altera to DAC and program it with VHDL

Hi,

SPI is a 4 wires point to point communication protocol, best way to know how it works is to look at the DAC datasheet to learn the way that component wants to be driven.
For additional information you may check wikipedia or:
https://www.mct.net/faq/spi.html
 

Re: how to connect Altera to DAC and program it with VHDL

project instructor expected some elementary knowledge of digital signal processing and digital electronics (e.g. regarding DA conversion). I guess, he also suggested some literature (or would at least on request).

we learnt logic gates and stuff but mostly our group has to learn the stuff on our known, with little VHDL background
we have to program the altera board USING VHDL, and I only had a 1.5 hr lecture on VHDL, the rest we have to figure it out, and I hv no idea how to use VHDL to program the altera
how do i program clock signal, chip select, and serial data input?

also, how do i implement the LPM_ROm for it?
i know i have to, but how?
 

Hi,

I see, first of all you need to start from the clock. I don't know if your device has dedicated input for clocks, else you need to provide one in a FPGA creating it somewhere. You may use logic gates inside the FPGA for this purpose.
I suggest to create a clock at double the DAC frequency to ease the CS and signal generation. You then need to create a "simple" state machine to create proper SPI signal driving.
It is a bit complex to explain it in a forum, what I suggest you is to try to put on paper the waveform you need to generate, it will greatly help you in the design.
Then I suggest to use this kind of VHDL structure (VHDL RTL description):

if CK'event and CK='1' then
....
end;

This will create an hardware block with some logic that is evaluated each time the clock signal CK is high.
A last hint, take care of the frequency of the state machine generating the SPI waveform and the frequency at which you need to provide data to the DAC.

Good luck
 

u can test u r DAC by taking a sample voice file or any other music file and u can take the samples. store the samples in flash or any ram u have and sens those samples to the DAC.
 

need e^(t/Time Constant) and sine(x) together to make a sound

If I'm not mistaken, the multiplication of this function with your sin(x), is just another way to say that you are sampling your sin(x) function.
The sampled sin(x) function can then be output on the 12bit DAC
 

It's not about sampling, it describes an exponential drop of the sine amplitude, as observed with string or drum tone.

But of course, a DAC sampling frequency for replaying the waveformes has to be defined.
 

this is the waveform i want

waveform.jpg


and i am writing it as a state machine
how do i wrtie the VHDL part for making it write to a certain DAC/ making it buffer/ changing the GAIN/ and reading the data?

i have a *template* sort of code in quartus atm
 

No need to go for a state machine. Take an SPI controller from open cores. configure it for an 16 bit interface.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top