Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Community Forums
- :
- Forums
- :
- Programmable Devices (Archive)
- :
- Spartan® Family FPGAs (Archived)
- :
- spartan3E- ADC 2's complement output to orginal in...

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Highlighted

kathy1

Adventurer

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

06-12-2014 07:55 AM

8,569 Views

Registered:
02-11-2014

Hi

I am trying to do analog to digital conversion using analog circuitary in the spartan3E boards. if I set gain in preamplifier as -1 and my Vin is 1V, then the ouput will be 4259 as per equation ; D[13:0] =Gain x((Vin-1.65V)/1.25V )X 8192.

I am getting this result, but how can I retrieve back my orginal input voltage (1V)? Can anyone give me an idea?

Thank you

kathy

0
Kudos

1 Solution

Accepted Solutions

Highlighted

bassman59

Historian

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

06-12-2014 04:16 PM

12,927 Views

Registered:
02-25-2008

@kathy1 wrote:

Hi Gabor,

I am sorry, i didnt understand. Can you explain more about the conversion?

Easy. Instead of working in units of decimal volts, work in millivolts.

1.000 V = 1000 mV.

Millivolts are represented as an integer, not a float, so it's all easy to handle.

Given the original transfer function:

Vin = 1.65 + (1.25 / (8192 * Gain) * D[13:0])

Just scale everything to millivolts instead of volts:

mVin = 1650 + (1250 / (8192 * Gain) * D[13:0])

Now you have a result in millivolts. Easy to display.

----------------------------Yes, I do this for a living.

9 Replies

Highlighted
##

Jump to solution

gszakacs

Professor

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

06-12-2014 08:30 AM

8,562 Views

Registered:
08-14-2007

Re: spartan3E- ADC 2's complement output to orginal input signal

You show this equation:

D[13:0] =Gain * ((Vin-1.65)/1.25 ) * 8192

I changed the x to * to indicate multiplcation, and removed the voltage units to make it clearer. So you want to solve the equation for Vin:

Vin = 1.65 + (1.25 / (8192 * Gain) * D[13:0])

Gain is -1. So in your case that's

Vin = 1.65 - (1.25/8192) * D[13:0]

For a code of 4259, my calculator returns 1.000128174, so this looks right.

So now the real question is do you want the FPGA to do this calculation? Or were you just wondering how to get the voltage back from the raw numbers?

-- Gabor

0
Kudos

Highlighted
##

Jump to solution

kathy1

Adventurer

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

06-12-2014 08:52 AM

8,559 Views

Registered:
02-11-2014

Re: spartan3E- ADC 2's complement output to orginal input signal

Hi Gabor, Thanks for the reply . I am also getting that result in calculation but I want that "1V" to display.

So do you think, If I need my signal back and display then i have to do this calculations in FPGA?

0
Kudos

Highlighted
##

Jump to solution

gszakacs

Professor

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

06-12-2014 08:57 AM

8,555 Views

Registered:
08-14-2007

Re: spartan3E- ADC 2's complement output to orginal input signal

Well, if you want the display on the Spartan 3E kit LED's, then the FPGA would need to do it. If you're transfering the data to a PC, then you could do it in the host computer before displaying it on the PC's monitor.

-- Gabor

0
Kudos

Highlighted
##

Jump to solution

kathy1

Adventurer

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

06-12-2014 09:10 AM

8,552 Views

Registered:
02-11-2014

Re: spartan3E- ADC 2's complement output to orginal input signal

Hi Gabor,

Thank a lot , now I understand. I want to display result in LCD. I have a custome 16 bit processor module unfortunately it is not a floatingpoint processor. I think I have to modify my processor to do these calculation.

Thanks

kathy

0
Kudos

Highlighted
##

Jump to solution

gszakacs

Professor

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

06-12-2014 10:19 AM

8,544 Views

Registered:
08-14-2007

Re: spartan3E- ADC 2's complement output to orginal input signal

You don't really need floating point to do this calculation. It's a matter of scaling to find the size of integer you need to keep enough resolution for the display. It looks like you have 14 input bits. Thats 16 thousand counts, and if your desplay will have 4 1/2 digits you want to scale the answer by 10,000 so 1V displays as +1.0000 assuming you have the capability to display the sign and decimal point. Then you just need to keep enough precision in your intermediate results that you don't lose displayable digits due to rounding. You could do this in logic or in the soft processor. Either way you don't really need floating point math.

-- Gabor

Highlighted
##

Jump to solution

kathy1

Adventurer

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

06-12-2014 11:11 AM

8,539 Views

Registered:
02-11-2014

Re: spartan3E- ADC 2's complement output to orginal input signal

Hi Gabor,

I am sorry, i didnt understand. Can you explain more about the conversion?

0
Kudos

Highlighted
##

Jump to solution

kathy1

Adventurer

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

06-12-2014 11:31 AM

8,534 Views

Registered:
02-11-2014

Re: spartan3E- ADC 2's complement output to orginal input signal

Hi gabor,

I will explain about my aim. Well my goal is to get the decimal value of the analog input voltage. Here my analog input is body temperature.My question is to get the decimal value of input voltage (eg vin=0.67v) we have to use below mentioned equation right?

Vin = 1.65 - (1.25/8192) * D[13:0].

Here I have real numbers like 1.65,1.25 and you mean there is NO need Flaoting point calculation?

Thanks

kathy

0
Kudos

Highlighted

bassman59

Historian

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

06-12-2014 04:16 PM

12,928 Views

Registered:
02-25-2008

@kathy1 wrote:

Hi Gabor,

I am sorry, i didnt understand. Can you explain more about the conversion?

Easy. Instead of working in units of decimal volts, work in millivolts.

1.000 V = 1000 mV.

Millivolts are represented as an integer, not a float, so it's all easy to handle.

Given the original transfer function:

Vin = 1.65 + (1.25 / (8192 * Gain) * D[13:0])

Just scale everything to millivolts instead of volts:

mVin = 1650 + (1250 / (8192 * Gain) * D[13:0])

Now you have a result in millivolts. Easy to display.

----------------------------Yes, I do this for a living.

Highlighted
##

Jump to solution

kathy1

Adventurer

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

06-12-2014 05:14 PM

8,504 Views

Registered:
02-11-2014

Re: spartan3E- ADC 2's complement output to orginal input signal

Thank you very much

0
Kudos