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