# Forum: FPGA, VHDL & Verilog Scaling to a 12-bit ADC value

 Author: Wil (Guest) Posted on: 2015-08-26 14:49

Rate this post
 0 ▲ useful ▼ not useful
Hello,

I want to scale a current value(Icurr) (in Amperes) to a corresponding
12 bit value. The to-be scaled  current value(Icurr) and a 12-bit ADC
value(Iact) are given as inputs to a PID controller as actual(Iact) and
expected(Icurr) values.

I am not sure how to approach the scaling.

My idea of approach is to : For example take a 1V=4A value as an input
to ADC and find the corresponding 12bit value. Take it as reference to
scale Icurr accordingly. But I am also not familiar reading from a ADC
data sheet to find the approximate 12bit value for an input
voltage/current.

Any suggestions?

 Author: Lothar M. (lkmiller) (Moderator) Posted on: 2015-08-26 15:28

Rate this post
 0 ▲ useful ▼ not useful
First question:
Is your question related to FPGA, Verilog or VHDL?
If so: how?

Wil wrote:
> Any suggestions?
What hardware?

> But I am also not familiar reading from a ADC data sheet to find the
> approximate 12bit value for an input voltage/current.

> For example take a 1V=4A value
So you have a "device" that forms 1V out of 4A, meaning 2A result in
0.5V?

 Author: Schlumpf (Guest) Posted on: 2015-08-26 15:32

Rate this post
 0 ▲ useful ▼ not useful
typical:

Vin = Vref : Out = xFFF
Vin = 0    : Out = x000

Vin = Rshunt * I

Out = Vin * (xFFF / Vref)

 Author: Lothar M. (lkmiller) (Moderator) Posted on: 2015-08-26 15:37

Rate this post
 0 ▲ useful ▼ not useful
Schlumpf wrote:
> Out = Vin * (xFFF / Vref)
But the slope of this calculation is 1/4096 wrong.
But you can ignore the deviation if you want...  ;-)

For a 12 bit ADC this formula is correct: Out = Vin * (x1000 / Vref)

: Edited by Moderator
 Author: Schlumpf (Guest) Posted on: 2015-08-26 15:42

Rate this post
 0 ▲ useful ▼ not useful
Lothar M. wrote:
> But the slope of this calculation is 1/4096 wrong.

right :-)

 Author: Wil (Guest) Posted on: 2015-08-26 15:44

Rate this post
 0 ▲ useful ▼ not useful
Lothar M. wrote:
> First question:
> Is your question related to FPGA, Verilog or VHDL?
> If so: how?
>
Yes, I want to implement the scaling in VHDL
> Wil wrote:
>> Any suggestions?
> What hardware?
>
Altera Cyclone IV
>> But I am also not familiar reading from a ADC data sheet to find the
>> approximate 12bit value for an input voltage/current.
>

>> For example take a 1V=4A value
> So you have a "device" that forms 1V out of 4A, meaning 2A result in
> 0.5V?
Yes, A Dual Op_Amp gives out 1V=6A (seeing from the layout)

 Author: Wil (Guest) Posted on: 2015-08-26 16:18

Rate this post
 0 ▲ useful ▼ not useful
Schlumpf wrote:
> typical:
>
> Vin = Vref : Out = xFFF
> Vin = 0    : Out = x000
>
> Vin = Rshunt * I
>
> Out = Vin * (xFFF / Vref)

So here to get a 12 bit value, Should I just consider Vin=1V
(irrespective out of the 4A i.e. 1v=4A ?).

Or do I need to calculat the correspoding voltage for 4A? (V= 4*Rshunt)
How do I find Rshunt from the datasheet?

The datasheet for LTC1407 says Vref=2.5V.

So for Vin=1 Out should be 1638.

 Author: Lothar M. (lkmiller) (Moderator) Posted on: 2015-08-26 16:23

Rate this post
 0 ▲ useful ▼ not useful
Wil wrote:
> The datasheet for LTC1407 says Vref=2.5V.
> How do I find Rshunt from the datasheet?
Because at Imax you want full scale inputof 2.5V  for the ADC you have
to calculate Rshunt = Imax/2.5V

Buuuuuut(!):
This will only work if you can accept 2.5V voltage voltage drop over
your shunt...

• $formula (LaTeX syntax)$