# RC Circuit discharge simulation project on FPGA

Status
Not open for further replies.

#### Cukkacan

##### Newbie level 5
Hey, i am struggle with a digital design project and i need suggestion.

First I would like to explain my project a little bit.
This project related to how to implent a numeric methods and prepare a module to this operation.

Description of the project: Initial voltage of capacitor will be adjust with 8 switches on spartan board and Vo value will be set with 1 button.
While discharging capacitor, Voltage value of capacitor will be shown on the 4 digit 7-segment display unit. R=2 and C=15. They are constant.

You know discharge equation is included exponential expression. I figured out this step by numeric methods. I derivated Taylor series to 4th element such as 1+(t/RC)+((t/RC)^2/2!)+((t/RC)^3/3!)+((t/RC)^4/4!). This equation is equal to be exp(t/RC) and It lets me to obtain this function Vc(t)=Vo/exp(t/RC).

I'll use a frequency divider to get 1Hz'ed clock to calculate Vc value for each t value. And will display this value on display unit.

I figured out how to display each digit of any 3 digit value seperately on 7-segment.

I have stucked on the how to perform ( 1 + (t/30) +((t/30)^2/2)+((t/30)^3/6)+((t/30)^4/24) ).

The easy, brute-force approach would be to use a look-up table. Depending on the precision required, this may or may not work for your application.

I found ** exponential operand. But i could not achieved using of that operand.

You can't synthesize that exponentiation operator.

If you can't use a lookup table, you're going to have to perform multiplication and division. It can be done (in fact, it's done all the time), but it gets messy in an FPGA.

• Cukkacan

### Cukkacan

Points: 2
More detailed description of the project:
RC circuit simulation: Initial capacity voltage will be adjusting by using 8 switch and 1 push button. The serial RC circuit will simulate discharging of capacitor. Vcapacitor will be displayed on 7-segment indicators consistently. R and C values are fixed and R= 2 ohms, C=15 farad.

I have described my problem above. Could you do a favor by posting related topics or projects to me ?

I would suggest a different approach. Time discrete simulation of the first order differential equation: Vc(t+1) = Vc(t)*(1-dt/RC).

• Cukkacan

### Cukkacan

Points: 2
i wish i figure out how to use real numbers and don't get ''Illegal operation with real number.'' error. I need to perform a calculation such as x*0.956.

Ty for you replies. I have changed my aspect. Now using this approach and it helped me a lot. b=a*35 then c=b/100 instead of a*0.35.

b=a*35 then c=b/100 instead of a*0.35
In FPGA we prefer binary fixed point numbers with powers of two as scaling factor. Instead of calculating a divison like c=b/100 we get e.g. c=b/128 which is just a shift operation. In VHDL, the IEEE fixed point package gives you the option to write arithmetic operation with fixd point numbers without thinking about the implementation details.

• Cukkacan

### Cukkacan

Points: 2
In FPGA we prefer binary fixed point numbers with powers of two as scaling factor. Instead of calculating a divison like c=b/100 we get e.g. c=b/128 which is just a shift operation. In VHDL, the IEEE fixed point package gives you the option to write arithmetic operation with fixd point numbers without thinking about the implementation details.

Then i need to perform b=a*45 and c=b/128 calculations to get 0.35, right ?

Then i need to perform b=a*45 and c=b/128 calculations to get 0.35, right ?
Yes, that's the basic operation for the suggested fixed point or "fractional" arithmetic.

• Cukkacan

Points: 2