cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Adventurer
Adventurer
8,574 Views
Registered: ‎02-11-2014

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

Jump to solution

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
Historian
Historian
12,932 Views
Registered: ‎02-25-2008

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

Jump to solution

@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.

View solution in original post

9 Replies
Highlighted
Professor
Professor
8,567 Views
Registered: ‎08-14-2007

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

Jump to solution

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
Adventurer
Adventurer
8,564 Views
Registered: ‎02-11-2014

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

Jump to solution

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
Professor
Professor
8,560 Views
Registered: ‎08-14-2007

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

Jump to solution

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
Adventurer
Adventurer
8,557 Views
Registered: ‎02-11-2014

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

Jump to solution

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
Professor
Professor
8,549 Views
Registered: ‎08-14-2007

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

Jump to solution

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
Adventurer
Adventurer
8,544 Views
Registered: ‎02-11-2014

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

Jump to solution

Hi Gabor,

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

0 Kudos
Highlighted
Adventurer
Adventurer
8,539 Views
Registered: ‎02-11-2014

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

Jump to solution

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
Historian
Historian
12,933 Views
Registered: ‎02-25-2008

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

Jump to solution

@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.

View solution in original post

Highlighted
Adventurer
Adventurer
8,509 Views
Registered: ‎02-11-2014

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

Jump to solution

Thank you very much

0 Kudos