## An application of math to biology

Stanislaw Ulam also had an interest in the application of math to biology. One example that may have relevance is the subfield of cellular automata founded by von Neumann and Ulam. As an example of this class of problems imagine dividing a plane into a several small squares like a checkerboard with several objects placed in nearby squares. Then specify rules for the appearance of new objects or the disappearance of old objects in new squares depending on whether adjacent squares are occupied or not. With each application of the rules to all the squares, the pattern of occupied squares evolves with time. Depending on the initial configuration and the rules of growth, some computer generated cellular automata evolve into patterns of snowflakes or crystals and others seem to have an everchanging motion as if they are alive. In some cases, colonies of self replicating patterns expand to fill the available space like the growth of coral or bacteria in a petri dish.

Reference: Adventures of a mathematician, S. Ulam, 1991 edition.

Cheers, cheers, cheers,

Nalin Pithwa

## Conversion of analog to digital signal

There are several sources of errors during conversion of analog signal to digital signal. Control and prediction/quantification of these errors is very important for the overall quality of a digital control system. However, in practical control systems, the price is also one of the most important limiting factors and the designer is forced to compromise solution. Also, it seems to me, apart from the three P’s (price, power, performance),another very important parameter is security including protection of the IP of the company.

In control systems, it is necessary to observe the work of the controlled object. This is usually achieved in power electronics systems by measuring currents and voltages. So, essentially such a digital control system processes analog currents and voltage signals by converting them to digital form.

Typical circuits of analog inputs for measuring voltages and currents :- in the voltage measurement circuit, voltage from the voltage divider goes through the amplifier input and the antialiasing filter to the sample-and-hold circuit and ADC. Finally digital signal corresponding to the measured voltage is sent to the processor control system. A similar process takes place in the current measurement circuit, where instead of a voltage divider, current transducer is applied. (Current and voltage measurement issues will be discussed later on this blog).

Let us consider a very simple example of a power electronic circuit.with an open loop/multi rate digital control. (this circuit may be part of the control system for DC/DC, DC/AC, AC/DC, AC/AC converters or active power filters etc). An open system is chosen here for study purposes as a feedback system anslysis is much more involved.

Analog input signal $x(t)$ is converted to digital form $x(n)$ by an A/D converter with sampling ratio $f_{s1}$ and $b_{1}$-bit resolution. In the next stage, a digital control algorithm using DSP is executed. The algorithm is calculated with $b_{2}$-bit resolution and sampling ratio $f_{s2}$. Finally, output control signal $y(n)$ is transferred to a digital PWM with $b_{3}$-bit resolution sampling ratio $f_{s3}$. The PWM controls output power switches $S_{1}$ and $S_{2}$. The switches work with switching frequency. The digital PWM with two power switches $S_{1}$ and $S_{2}$ and an analog output filter $L_{C}$ and $C_{C}$ works as a digital to analog D/A power converter. It converts energy from a direct current source (DC) to the output. Typically the main issue is the quality of the output voltage and current. Therefore, the following signal parameters should be considered:

• $f_{s1}, f_{s2}, f_{s3}$ — signal sampling ratios
• $b_{1}, b_{2}, b_{3}$— signal resolution in bits.
• $f_{C}$ — transistor switching frequency
• THD — total harmonic distortion ratio.
• SNR — output signal to noise ratio.
• SINAD — output signal to noise and distortion ratio.

Finally, the required SINAD value of output current or voltage of power electronics circuit are dependent on the application. For example, for battery charger SINAD value equal to 30 dB is sufficient. However, for the high quality audio power amplifier the SINAD value should be bigger than 100 dB. As we can see the spread of these parameters of digital control systems for power electronics circuits is very high. Now-a-days there is a huge offer of A/D converters and DSPs, so it is easy to choose circuits with adequate parameters $b_{1}$, $b_{2}$, $f_{s1}$ and $f_{s2}$. The only considerable limitation may be the cost of these circuits. The last stage, with digital PWM may be a bottleneck of the whole system, especially for high resolution, for example, high quality power audio amplifier with parameters : $f_{s3}=44.1$kHz and $f_{s3}=44.1$kHz and $b_{3}=16$ bit, the clock frequency of PWM counters can be calculated using the equation: $f_{h} =f_{s3}2^{b3} \approx 2.8$GHz.

The calculated value of clock frequency is too high for ordinary digital circuits, therefore, resolution of digital PWM should be reduced. However, it will result in deterioration of the signal-to-ratio.

Total Harmonic Distortion:

Total harmonic distortion THD ratio is a form of nonlinear distortion in circuits in which harmonics (signals whose frequency is an integer multiple of the input signal) are generated. A wide-class of non-linear circuits can be described by the equation: $y(t) = a_{1}x(t) + a_{2}x(t)^{2}+a_{3}x(t)^{3}+ \ldots + a_{k}x(t)^{k}$

In linear circuits, only $a_{1}$ coefficient is nonzero.

THD ratio is measured in percents or in decibels (dB) and harmonic distortion is calculated as the ratio of the level of the harmonic to the level of the original frequency $THD = \frac{\sqrt{\sum_{k=2}^{N}U_{k}^{2}}}{U_{1}}$

where $U_{1}$ — amplitude of first or fundamental harmonic and so on.

A/D converters of TMS320F2837xD

TI is permanently engaged in the design of a wide range of microcontrollers/DSPs intended for use in power electronics systems. One of the most advanced is the TMS320F2837xD microcontroller/DSP family. The TMS320F2837xD includes four independent high performance A/D converters (with a total input of 24 channels possible), allowing the device to efficiently manage multiple analog signals for enhanced overall system throughput. Each ADC has a single SH circuit, and using multiple ADC modules enables it to perform simultaneous sampling or independent operation. The ADC is implemented using a successive approximation and it has the configurable resolution of either 16 bits or 12 bits. These ADC’s have many modes of operation. The most important is the possibility to sample four analog signals. So we cannot, quite clearly, sample 8 analog signals at a time.

Cheers,

Nalin Pithwa

## DSP Filter to generate Fibonacci numbers

The title is slight misnomer; but I am presenting below is a closed form expression for the nth term of the Fibonacci sequence.

Reference: Digital Signal Processing by Proakis and Manolakis, Sixth Edition.

The one-sided z-transform is a very efficient tool for the solution of difference equations with nonzero intial conditions. It achieves that by reducing the difference equation relating the two time-domain signals to an equivalent algebraic equation relating their one-sided z-transforms. This equation can be easily solved to obtain the transform of the desired signal. The signal in the time domain is obtained by inverting the resulting z-transform. For instance:

Example: The well-known Fibonacci sequence of integers is obtained by computing each term as the sum of the two-previous ones. The first few terms of the sequence are: $1,1,2,3,5, 8, \ldots$

Determine a closed form expression for the nth term of the Fibonacci sequence.

Solution: Let $y(n)$ be the nth term of the Fibonacci sequence. Clearly, $y(n)$ satisfies the difference equation: $y(n) = y(n-1) + y(n-2)$…..Equation A

with initial conditions $y(0)=y(-1)+y(-2)=1$…..B $y(1)=y(0)+y(-1)=1$….C

From the above, $y(-1)=0$ and $y(-2)=1$. Thus, we have to determine $y(n)$ for $n \geq 0$, which satisfies equation A with initial conditions $y(-1)=0$ and $y(-2)=1$.

By taking the one-sided z-transform of the equation A and using the shifting property, we obtain: $Y^{+}(z) = (z^{-1}Y^{+}(z)+y(-1))+(z^{-1}Y^{+}(z)+y(-2)+y(-1)z^{-1})$

or $Y^{+}(z) = \frac{1}{1-z^{-1}-z^{2}} = \frac{z^{2}}{z^{2}-z-1}$….equation D

where we have used the fact that $y(-1)=0$ and $y(-2)=1$.

We can invert $Y^{+}(z)$ by the partial fraction expansion method. The poles of $Y^{+}(z)$ are: $p_{1} = \frac{1+\sqrt{5}}{2}$, and $p_{2} = \frac{1-\sqrt{5}}{2}$

and the corresponding coefficients are $A_{1} = \frac{p_{1}}{\sqrt{5}}$ and $A_{2}=\frac{-p_{1}}{\sqrt{5}}$. Therefore, $y(n) = (\frac{1+\sqrt{5}}{2\sqrt{5}})(\frac{1+\sqrt{5}}{2})^{n}u(n) - \frac{1-\sqrt{5}}{2\sqrt{5}}(\frac{1-\sqrt{5}}{2})^{n}u(n)$

or, equivalently, $y(n) = \frac{1}{\sqrt{5}}(\frac{1}{2})^{n+1}((1+\sqrt{5})^{n+1}-(1-\sqrt{5})^{n+1})u(n)$.

One smallish comment: We can implement a difference equation of a filter as either FIR or IIR. Of course, based on the physical nature of the signal/processing, one or the other might be preferable.

Regards,

Nalin Pithwa.