Session 11: Week 22/23: <em>Simulating an RC Circuit</em>




Document: Software Engineering 1: Lab Exercises

next Exercise 1: Basic Simulation Program (60%)
up Software Engineering 1: Laboratory Exercises
gif Exercise 4: Plotting a Histogram (20%)

Session 11: Week 22/23: Simulating an RC Circuit

The program(s) developed in this session must not use any facilities of the safe-c library - they must rely on the facilities of the Standard C Library instead.

Consider the following schematic diagram of a simple RC circuit:

 
Figure 1: Simple RC Circuit

The capacitor is assumed to be initially charged up to some voltage denoted v(0), corresponding to a charge level of:

The switch is closed at time t = 0. The capacitor then discharges by causing a current to flow through the resistor.

Denote the instantaneous signals in the system as follows:

Suppose that, at some time t, the value of q(t) is known. It then follows that the following values may be calculated:

Consider now what happens over a "small" interval of time, which I shall denote . If this interval is "small" enough we can take the current to be approximately constant over this interval. Thus, the change in the value of q over this interval can be approximated by:

and the value of q at the end of the interval can be calculated (approximately) as:

Since we now know the value of q, one time "step" later, we can now repeat all the calculations to calculate the values of v, i and q one time step later also - and thus calculate how much q will change by over one further time step. And so on. By repeating this procedure, one can calculate the state of the circuit (at least approximately) into the indefinite future, once we know the state at some initial time.

In fact, this basic method is so powerful that it can be extended to (approximately) predict the time behaviour of arbitrarily complex electronic circuits under arbitrary stimulation - and such simulations are a crucial tool in the design of all modern electronic circuits.






Document: Software Engineering 1: Lab Exercises

next Exercise 1: Basic Simulation Program (60%)
up Software Engineering 1: Laboratory Exercises
gif Exercise 4: Plotting a Histogram (20%)



McMullin@eeng.dcu.ie
Tue Apr 30 14:15:37 GMT 1996