# Analog signal to fpga

Discussion in 'Analog & Mixed-Signal Design' started by chaosmc, Jan 17, 2013.

1. ### chaosmc Thread Starter New Member

May 21, 2012
17
0
I am thinking of a feedback i want to experiment with and i am stuck. I have an analog signal (V1) from the output of an op-amp which is sinusoidal, 60Hz, 2V peak to peak, lets assume. I want to convert it to digital and make some calculations. For example 0.5-0.3V1.

I was thinking to put an a/d converter, the output of which will be connected to an FPGA. Then,somehow, i have to manipulate the output of the ADC and perform the function easily with some vhdl code (0.5-0.3V1 in our example).

I know that there are other methods to make this adding-subtracting procedure and it can be done even with analog approach only! But i want to use fpga in order to make my pwm pulses for my converter.

So in one point i have my analog signal, on the other point i have the fpga. What do you propose for the in between. If it is so simpe as i think (ADC only) i suppose that the output of the ADC will be an 8bit or 16bit number right? how can i treat this input in vhdl?

In that case, what ADC would you suggest?
FPGA hasn't built-in onboard ADC.

thanks

2. ### crutschow Expert

Mar 14, 2008
13,000
3,229
Seems like it would be much easier to use a microprocessor with a built-in A/D converter.

3. ### tshuck Well-Known Member

Oct 18, 2012
3,531
675
At the very least, it looks like you are going to need some analog signal conditioning. You are going to need to offset the incoming signal and change the gain to fit within the supply range(discussed below), so the ADC can measure it.

What I would do is run your ADC off the same voltage your FPGA I/O can handle, that way, there's no discrepancy in voltages.

Your ADC can be whatever you want, but since you are sampling such a slow signal, a SAR ADC would suffice. Pick one with a decent resolution(I'd go at least 10-bits); make sure it's maximum sampling frequency is at least 120Hz, which, would be utter rubbish if you find one that can't.

You could pick an ADC with either a serial or parallel interface, your sampled signal won't get much benefit from a faster connection.

Well, you'd have to maintain the sign of the signal, so, split your supply in half. Numbers above that are positive, numbers below it are negative. So, it you are wanting to show positive and negative, you'll need to flip the MSB.

4. ### WBahn Moderator

Mar 31, 2012
17,720
4,788
You need to sample much higher than 120Hz. That will, in theory, let you catch information content at 60Hz and below. But if your 60Hz signal is changing at all (and if it isn't, then there isn't a whole lot of point in sampling it to begin with) then you probably have information content at frequencies above that, as well. Maybe not. But you need to get a feel for what your highest frequency component of interest is and then sample at several times that.

Also, be sure to include an antialiasing filter otherwise you will see random noise transalted right down into your information signal.

A microcontroller is probably going to eb a bettre choice for you, but if you want to get some experience with FPGAs, then go for it.

5. ### tshuck Well-Known Member

Oct 18, 2012
3,531
675
Agreed, 2 times the highest frequency is the absolute minimum, but 8-10 times that is the preferred choice. I was speaking about the absolute minimum, given the signal specified, with no modulation of any sort(unless 120Hz is the highest frequency component).

I didn't realize the signal was an arbitrary assumption

6. ### WBahn Moderator

Mar 31, 2012
17,720
4,788
Oh, now that's opening a Pandora's Box!

Going off on an aside that is completely general in nature and has nothing specific to do with this thread, but that might hold some value for the OP in applying it to this problem. Maybe.

Humans make arbitrary assumptions probably thousands of times a day and, by and large, we make good ones, and the bad ones are pretty benign. But, occasionally, someone makes an assumption that is bad and a bunch of people get killed.

As engineers and technologies, we like to delude ourselves into thinking that we operate in highly precise world where everything is clearly specified and defined. While it's true we impose a lot more precision than everyday life, it's amazing how many arbitrary assumption we make in our own field -- and how many of them we are a bit embarassed and even shocked about once they are brought to our attention. Sometimes we then insist that things get better defined, and sometimes we end up having to admit that we have to just accept an assumption but at least with the knowledge we are doing so. What we seldom do is then appreciate how many other assumptions we continue to blindly make.

This is particularly the case, somewhat naturally, when working with a customer trying to solve a problem for them. The customer provides information and, to the best of their knowledge, have given a complete and precise description of the problem. We usually spot several things that, based on our experience and knowledge (after all, there's a reason the customer is willing to pay us to solve their problem), we know need more attention spent nailing them down. But it is also pretty common that we accept things at face value because we lack information that the customer has and that, had we known that information, we would have spotted the need for clarification but the customer had no reasonable basis to even suspect that we needed that other information. Von Clausewitz called it (or something that is basically it) the Fog of War; I call it the Friction of Business. Two parties exchange words and both think they understand what the other has said when, in reality, a significant miscommunication has just taken place.

OK. Enough rambling. How does this (hopefully) help the OP? Basically this -- there is a LOT of "friction of business" in any forum-type environment, so the more information you provide to us, such as how the signal you want to measure varies, makes it more likely that we can provide a good answer and less likely that we will make recommendations that turn out to be poorly suited to your situation.

maerle likes this.
7. ### chaosmc Thread Starter New Member

May 21, 2012
17
0
Thank you everybody for the technical and...philosophical answers but because i am trying to think simple i did some more research and i found this:

http://www.digilentinc.com/Products/Detail.cfm?Prod=PMOD-AD1

so as i said before, in one point i have my analog signal and on the other one i have the fpga! This magic thing will go in between. Simple, quick and cheap!

Am i right, or this cannot be done?!

Thank you!!

8. ### tshuck Well-Known Member

Oct 18, 2012
3,531
675
You could use this ADC, but one thing to remember is that the inputs for this device can only go from 0V to 3.3V. You will need to do some signal conditioning to get your signal between 0V and 3.3V. Also, your signal cannot swing negative, so you may need to add a DC offset to your signal(centered around 1.65V), provided you want to measure a signal that goes below 0V. Your sampling rate should be just fine.
This comes with some 500kHz Sallen-Key filters, so the highest frequency you will be able to measure with any accuracy will be 500kHz, with significant attenuation after that.

I should add, this board doesn't really help you much. Aside from having a pre-designed board, you don't get much of an advantage out of using it since many 3.3V Vref ADCs can get 12-bit resolution and even be under \$10. What this board does is simply give you the guarantee that it will work, which, you won't get if you roll your own. The choice is yours, but you do still need signal conditioning for this to work, which probably means you'll need to roll your own board anyway...