# Category Archives: tuning

## Part 4: Tuning the feedback controller

Our first order process is described by the equation yn+1 = ayn + kxn , where yn is the process output now (at time n),  xn is the process input between time n and time n+1, and yn+1 is the process output at time n+1.
a is the coefficient determining how quickly the process settles after a change in the input, and k is related to the process steady state gain (ratio of settled output to constant input).

If we set the input to be a constant x and the output settled value to be a constant y, then

y = ay + kx, and solving for y/x we get y/x = k/(1-a), the actual steady state gain.

In what follows the k will represent the actual steady state gain, the old k divided by (1-a)

The fist two plots show the process alone, with input set to 6 at time zero. In the first the steady state gain is set to 1, and in the second it is set to 2

Now we look a t the process under “direct” control, where the input is determined only by the chosen setpoint value. The two equations are

yn+1 = ayn + kxn  and  xn = Adn  (direct control: h is zero)

To obtain a controlled system with overall steady state gain equal to 1 (settled output  equal to desired output) it is easy to see that  has to be equal to (1-a)/k

It is not so obvious how the choice of h affects the performance of the controlled system. To do this we observe that the complete system is described entirely by the process equation and the controller equation together, and we can eliminate the xn from the two equations to get yn+1 = ayn + k(Adn + h(yn – dn))

which rearranged is yn+1 = (a + kh)yn + k(A – h)dn

Substituting   (1-a)/k for A, as found above, gives  yn+1 = (a + kh)yn + (1 – a – kh)dn

which has the required steady state gain of 1.

This final equation has the SAME structure as the process equation,
with a + kh in place of a

So now we will see how the value of the “a” coefficient affects the dynamic response of the system.

If h > 0 the controlled system will respond slower than with h = 0, and if h < 0 it will respond faster:

Setpoint changes were made at time 20 and at time 40

Congratulations if you got this far. This introduction to computer controlled processes has been kept as simple as possible, while using just the minimum amount of really basic math. The difficulties are in the interpretation and meaning of the various equations, and this something which is studiously avoided in school math. Such a shame.

Now you can run the program yourself, and play with the coefficients. It is a webpage with javascript:  http://mathcomesalive.com/mathsite/firstordersiml.html

Aspects and theoretical stuff which follow this (not here !) include the  backward shift operator z and its use in forming the transfer function of the system, behaviour of systems with wave form inputs to assess frequency response, representation of systems in matrix form (state space), non-linear systems and limit cycles, optimal control, adaptive control, and more…..

1 Comment

## MUSIC: tuning,harmonic, equal temper, beat frequency :MATH – part trois !

So, what is the difference in musical effect between the harmonic scale and the equal temper scale ?

Whenever two notes are played together the ear “hears” the two notes both separately and together. The “togetherness” is a consequence of the perception by the ear of a third note, usually quite faint, the beat note with associated “beat frequency”. The effect is very noticeable when two recorders are played, as the notes are very “pure”. A pure note is one which consists of vibrations at exactly one frequency, and this is described by a sine wave or sine function y = sin(2πkx) where x is time and k is frequency.

Below, and with many thanks to DESMOS, which made the job almost painless, are plots of the sum of a frequency 5 wave and a frequency 5+b/2 wave, for various decreasing values of b. (The first has b = 0 to show the sum of the frequency 5 wave with itself, giving a reference point of 2sin(5*2πx)

Now with frequencies 5 and 10

Now with frequencies 5 and 9

Now with frequencies 5 and 7, something going on here

Now with frequencies 5 and 5.75, notice the appearance of the beat in the signal

Now with frequencies 5 and 5.5

Now with frequencies 5 and 5.25

And finally with frequencies 5 and 5.05

The first thing to note is that the beat frequency is the difference between the two “added” frequencies. This can be seen by seeing the period of the beat in this last one as 20, which is a frequency of 1/20 or 0.05 (= 5.5 – 5). (The math for all of this will be in another post). See London police whistle

The second thing to note is that in the case of 5 and 5.75 the frequency ratio is 5.75/5 = 23/20, and this is greater than the relative frequency of the 9/8 whole tone (C to D), and a bit less than 6/5, one of the estimates for the interval C to Eflat. This one has quite a large effect on the perceived sound of the whole tone interval, and is one reason why it is difficult to hear the two notes separately.

Now we can see what this all means in the harmonic tuning system. Let us take the notes C and E, frequency ratios 1 and 5/4.

The difference is 5/4 – 1 = 1/4. What note, if any, is this?

We have seen that multiplying by 2 doubles the frequency and produces a note one octave higher, so dividing by 2 produces a note one octave lower. Do it again and we get a note two octaves lower.

So the beat frequency for the pair CE is the C two octaves down. I will write this as C,, and the C two octaves up will be C”.

This means that each (in this case) of the two notes C and E is a harmonic of the beat frequency.

Consequently the CE interval will appear to have more “body” than might be expected. Just try playing the C on its own and then with a quieter 2 C’s below added.

This can be done for all the intervals on the harmonic scale (results shown in the table below).

The main conclusion I have come to is that the reason a choir trained without a piano accompaniment has a fuller sound than one used to singing with a piano, or other musical “backing” is that the first type automatically tunes itself in the harmonic system, and consequently has the benefit of beat frequencies which are in tune with the notes being sung.

This is particularly noticeable with barbershop singing.

Let us compare equal temper with harmonic on the major third interval CB

Harmonic: interval is 1 to 5/4, beat frequency is 1/4 or 0.25 , nice !

Equal temper: interval is 1 to cube root of 2 (twelfth root of 2 raised to power of 4, 4 semitones from C to E), and this is 0.260. So when we look at the second harmonic of this we get 4*0.260 = 1.04, which is NOT C. It is a bit less that a semitone above, and creates a low volume buzz that causes the major third to feel harsh.

The fifth, C to G, is not as much affected as the two systems give almost the same frequency.

Table coming

1 Comment

Filed under a cappella, barbershop, harmonic, math, music, piano, singing, tuning