#### Re: Tuner? Well Sure!

Diver Martin <diver.martin@...>

K3NG provides a good starting point. But I found a few flaws in the algorithm that he uses, at least so I think.  Here is the comment I put in my code for my ATU, and my thoughts.  Warning:  Long read ahead.  You might wish to just mark this one as read unless you're into the nitty gritty of ATU code revD.

/* Tuning Algorithm Description
*
* This tuning algorithm is a refinement of the algorithm used by k3ng and others.
*
* Editors note:  **This is based on my assumptions and understanding of the algorithms.  They could be totally wrong!
*
* This algorithm allows for all possible L/C/CX combinations to be potential candidates.  For reference, the k3ng algorithm does a
* matrix scan, wherein (assuming 8 inductors, and 8 capacitors) it does a scan of all individual C values with all individual L
* values.  That is, if C and L are values from 0 to 255, a value of * 1 (0001) is say 0.0625uH, a value of 2 (0010) is 0.125uH, a
* value of 4 (0100) is 0.25uH, and so on.  Capacitor values start at 10pF would be 1=10pF, 2=20pF, 4=40pF, etc such that if you
* set C=180, that should be a value of 128 + 32 + 16 + 4 or 1800pF.
*
* The K3NG algorithm** tries (almost) all values of L and C where only one L/C is selected, that is first C is set to 1 (10pF),
* and then L is set to 0.0625, 0.125, 0.25, 0.5, 1, 2, 4, and 8uH.  (L = 1, 2, 4, 8, 16, 32, 64, and 128).  C is then set 2 (20pF),
* and this is repeated.  C is then set to 4 (40pF) and all 8 inductors are tried.  At this point, you now have an 8x8 grid / matrix
* of SWR measurements.  Whichever combination yielded the best (lowest) SWR reading, you focus on that point and then scan from +/- 8
* or 16 values depending on the algorithm for a 'best' match.  (You repeat this 8x8 array measurement, as you do it once for the
* capacitor on the High-z side, and once on the low-z side, for 8x8x2=128 total measurements).  For example, say the first stage
* yielded a result of CX=0, L=16 and C=32 as the lowest SWR of 2.5:1.  You would then scan from L=8 to L=24 and C=16 to C=48 in a
* similar grid fashion to arrive at finding L=22, C=36 as the best combination yielding a 1.5:1 SWR.  Great, all tuned up!
* Except there's a flaw in this algorithm, a significant one at that.  Lets say the first round yields best match at L=128 (for
* the purposes of this exercise, lets assume capacitance is irrelevant).  You then scan from from L(round1) +/- 16 so you try all
* values of L between L=112 to 144.  But you don't find a match...  why not?  Because the best match was at L=100.  So why did the
* algorithm not try L=64?  Lets see.  L=64 +/- 16 yields L from 48 to 80.  L=100 is literally an unobtainable value.
*
* So to refine on the algorithms used above, my algorithm is a 3-stage algorith, but instead of a non-linear power of 2 matrix,
* I use linear values.  Because this tuner has 7 inductors, 8 capacitors, and 1 relay for switching CX (high-z/low-z), I use a
* 7-6-6 and 6-5-5 matrix.  That is, I scan 7 values of C from 0 to 255, and 6 values of L from 0 to 128 in stage 1.  So the first
* scan matrix is 7x6 values.  You'll note that when the algorithm is first triggered (look above about 115 lines up) that
* L=11 and C=18 are the initial values, and that each round, L is incremented by 22, and C incremented by 36.  This means we try
* inductance values L=11, 33, 55, 77, 99, and 121.  C values tried are 18, 54, 90, 126, 192, 198 and 234.  The downside to doing
* a linear scan is that it will flip a lot more relays.  Boo hoo!  From there, the best L/C value is picked + highz/lowz, and
* then proceeds to stage 2, incrementing L/C by 4 and 6.  So if L=11 and C=18 are picked, then L=0+(4/2)=2, L=6, L=10, L=14, and
* L=18 (5 values)are tested to cover the L=0 to L=22 range (remember, round one tested L=11 and L=33, so we want to ensure we can
* cover to the midpoint between 11 and 33, which is 22).  The capacitor does the same, except it'll go from C=3, C=9, C=15, C=21,
* C=27, and C=33 to cover C=0 to 36 (round 1 was C=18 and C=54).
*
* The final stage is naturally a simple by-1 increment.  So if L=2, C=3 were the best values, it'll do L=0, L=1, L=2, L=3, and L=4
* as well as C=0, C=1, C=2, etc (I think you get the idea by now).
*
* You'll notice an odd -1 in there... that's because the Actual L/C values are 0-127 and 0-255, whereas this algorithm really ends
* up covering 1-256 and 1-128, so I subtract one... at least, that's my story and I'm sticking too it.  Either way, we can show
* coverage as well by simple multiplication:  6*5*5 = 150 (and we just need 0-128), so we're almost over-covered.  7*6*6 = 252,
* which is just a few shy, so there might be a few values (a grand total of 3) where we might not reach the best SWR, but we'll
* get pretty close.
*
* This algorithm could easily be extended to more rounds for faster search times.  This is an exercise for later, because I fear
* one little issue:  THe SWR is not always linear with a clearly distinct 'null'.  For example of a 1-dimensional tuner (ignoring
* capacitance), if during round L=33 gave SWR=3.0 and L=121 gave SWR=3.1, you'd pick L=33.  But what if L=33 was near a 'local'
* null in SWR where it never got better than 2.5:1, whereas the 'best' match was at L=140 with SWR 1:1.  You'd never find it. Now,
* Granted, this can happen now... but the finer your first stage, the less likely, and this is an important consideration for
* going to multiple rounds.  For example, lets go extreme with 8 rounds, and only 2 values each.  Test L=32 and L=96 (L=0 to 128).
* You can see how a non-linearity in the SWR curve vs inductance might pick the wrong L value.  The one advantage to an 8-round
* tuning system is (Lets say we have L=0-255 and C=0-255 for simplicity).
* 1 round, extreme, you'd need 256*256 measurements = 65535 to cover all possible measurements
* 2 rounds, you need 16*16 + 16*16 = 512 total measurements.
* 3 rounds (as above), 7*6 + 6*5 + 6*5 = 102 total measurements
* 4 rounds (4*4*4*4=256, works out nicely), you need 4x (4x4) matricies, or 4*16 = 64 total measurements
* 6 rounds (256^ (1/6) = 2.51, so we'll have to go (3*3*3*3*2*2) or 39 total measurements
* 8 rounds (2 each) = 4*8 = 32 total measurements
*
* So as you can see, there is an advantage to doing more rounds, but your tradeoff is you're more vulnerable to local nulls in
* the SWR of your antenna.
*
*/

On Sun, Dec 31, 2017 at 2:32 PM, Glenn wrote:
My 1st post. Have a look at the K3NG ATU (Google K3NG TUNER). While he designed it as a balanced tuner, I have built an unbalanced version for around 20W or so. Using standard footprint 'cheap' relays. Actually the relays are the bugbear of an ATU, finding the right type and rating and low cost, since in this example there are 18 relays. From what I can see, latched relays are very expensive especially when you need 18. The trade-off is current draw, as per some posts here.

I used AD8307 Log detector chips in the SWR section. Caps used were 3kV rated 1812 sized smd although available in VK, might be harder to find in USA.

K3NG uses an Arduino NANO and a simple 2 line LCD module.  To keep size down, one of the 0.96" OLED displays might be a candidate.

glenn
vk3pe

--
Martin Held - AE7EU
http://ae7eu.com/
-------------------------------------------------------------------------------
If there aren't any questions, then what is there to learn?

Join BITX20@groups.io to automatically receive all group messages.