{"id":336,"date":"2011-11-04T19:00:02","date_gmt":"2011-11-04T18:00:02","guid":{"rendered":"http:\/\/pa3hcm.utreg.net\/?p=336"},"modified":"2021-01-18T20:14:07","modified_gmt":"2021-01-18T19:14:07","slug":"automatic-antenna-tuner-using-an-arduino","status":"publish","type":"post","link":"https:\/\/www.pa3hcm.nl\/?p=336","title":{"rendered":"Automatic antenna tuner using an Arduino"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"alignright\"><a href=\"http:\/\/pa3hcm.utreg.net\/wp-content\/uploads\/2014\/01\/arduino-tuner-2.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"225\" src=\"http:\/\/pa3hcm.utreg.net\/wp-content\/uploads\/2014\/01\/arduino-tuner-2-300x225.jpg\" alt=\"OLYMPUS DIGITAL CAMERA\" class=\"wp-image-343\" srcset=\"https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/01\/arduino-tuner-2-300x225.jpg 300w, https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/01\/arduino-tuner-2.jpg 600w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/figure><\/div>\n\n\n\n<p>The Arduino board is a fantastic tool for rapid prototyping, and can help radio amateurs in lots of homebrew projects. I wanted to demonstrate that it is very easy to build an automatic antenna tuner with the Arduino. I connected an old SWR meter to one of my Arduino boards. Furthermore I build a simple L-tuner with a fixed coil and a rotating capacitor (400pF). The capacitor is driven by a servo, also connected to the Arduino. By doing a full sweep with the capacitor, the Arduino tries to find the position with the lowest SWR. After the sweep it turns the capacitor to that position. You can view the video below to see the tuner in action. Mind the SWR meter (right needle) in the back while the capacitor is rotating.<\/p>\n\n\n\n<!--more-->\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-4-3 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Automatic antenna tuner using an Arduino\" width=\"1290\" height=\"968\" src=\"https:\/\/www.youtube.com\/embed\/dknD2woRGNU?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<figure class=\"wp-block-image alignnone\"><a href=\"http:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2011\/11\/20141215_193205.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"http:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2011\/11\/20141215_193205-1024x768.jpg\" alt=\"[Image]\" class=\"wp-image-1006\" srcset=\"https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2011\/11\/20141215_193205-1024x768.jpg 1024w, https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2011\/11\/20141215_193205-300x225.jpg 300w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption>This is how I obtained the SWR signal from my SWR meter: I simply connected wires (orange and black) to the meter input and the chassis. This is ok for this test, but for a real solution some filtering and limiting is required.<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Version 2<\/h2>\n\n\n\n<p>I was so surprised by the simplicity, that I decided to extend the tuner. The next step is to vary the inductor. Therefore I made a new one with an extra connection in the middle. The inductor is now 8cm long, 4cm diameter, and has 14 windings with a tap halfway. I added a relay to switch between the half or the full inductance. Now the software is modified, it does two sweeps with the capacitor, one with half induction, and another one with full induction. Again, it searches for the best combination. I tested it, and now it finds a nice SWR for almost any load! The movie shows a slow version, to allow you to see it working. The code below is the fast version, it tunes within 2 seconds!<\/p>\n\n\n\n<p>This is the circuit diagram:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><a href=\"http:\/\/pa3hcm.utreg.net\/wp-content\/uploads\/2014\/01\/arduino-tuner-schema.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"270\" src=\"http:\/\/pa3hcm.utreg.net\/wp-content\/uploads\/2014\/01\/arduino-tuner-schema.jpg\" alt=\"arduino-tuner-schema\" class=\"wp-image-344\"\/><\/a><\/figure><\/div>\n\n\n\n<p>The green part is the RF section, which is electrically isolated from the control section. The control section is connected to the Arduino board, pins are given. The SWR meter is not in the circuit, but should be placed between the tuner and the transmitter (TX). The DC output of the SWR-meter is connected to analog input 0 of the Arduino. Parts are not critical. The transistor can be any regular NPN type, e.g. BC547. The resistor is 2200 ohm in the circuit, but could also be 4k7 of 1k or anything between. The diode handles the backfire current of the relay, and could be of almost any type, e.g. 1N4148. The servo is a generic 180 degrees 5 volt servo and mechanically attached to the capacitor. The inductor is switched by a 5 volt relay, which must be capable to handle the desired RF power.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-4-3 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Automatic antenna tuner using an Arduino (version 2)\" width=\"1290\" height=\"968\" src=\"https:\/\/www.youtube.com\/embed\/fGk0VgoklYM?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><a href=\"http:\/\/pa3hcm.utreg.net\/wp-content\/uploads\/2014\/01\/arduino-tuner-1.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"450\" src=\"http:\/\/pa3hcm.utreg.net\/wp-content\/uploads\/2014\/01\/arduino-tuner-1.jpg\" alt=\"OLYMPUS DIGITAL CAMERA\" class=\"wp-image-342\" srcset=\"https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/01\/arduino-tuner-1.jpg 600w, https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/01\/arduino-tuner-1-300x225.jpg 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/figure><\/div>\n\n\n\n<p>Before using this code, remember it is still for demo purposes, so there is no code in there for a &#8220;tune&#8221; button or so. It simply tunes, wait 10 seconds, tunes again, waits 10 seconds, tunes again, etc&#8230; For building a real tuner, you will also have to compare the reflected power to the forward power. So you will have to read both meters, compare them, and depending on the results you probably want to alarm the user when no low SWR could be found.<\/p>\n\n\n\n<blockquote><pre>\/\/ AutoTuner v2.01\n\/\/ by PA3HCM \n\n#include &lt;Servo.h&gt;   \/\/ We will use a servo\nServo cap;           \/\/ for rotating the capacitor\nint capPin = 9;      \/\/ attached to pin 9\nint indPin = 13;     \/\/ Inductor relay on pin 13\nint reflPin = 0;     \/\/ Reflection input on analog pin 0\nint pos = 0;\n\nboolean bestIndPos = HIGH;\nint capPos = 0;\nint bestCapPos = 0;\nint refl = 0;\nint bestRefl = 1023;\n\nvoid setup() {\n  pinMode(capPin, OUTPUT);\n  pinMode(indPin, OUTPUT);\n  cap.attach(capPin);\n}\n\nvoid loop() {\n  \/\/ reset\n  bestCapPos = 0;\n  bestIndPos = HIGH;\n  bestRefl = 1023;\n\n  cap.write(0);      \/\/ turn capacitor to start position\n  delay(500);        \/\/ this will take a bit of time, so wait\n\n  \/\/ find best reflection with full inductance\n  digitalWrite(indPin, HIGH);\n  delay(200);\n  for(pos = 0; pos &lt; 180; pos += 3)\n  {\n    cap.write(pos);\n    delay(15);\n    refl = analogRead(reflPin);\n    if (refl &lt; bestRefl) {\n      bestRefl = refl;\n      bestCapPos = pos;\n      bestIndPos = HIGH;\n    }\n  }\n\n  \/\/ find best reflection with reduced inductance\n  digitalWrite(indPin, LOW);\n  delay(200);\n  for(pos = 180; pos &gt; 0; pos -= 3)\n  {\n    cap.write(pos);\n    delay(15);\n    refl = analogRead(reflPin);\n    if (refl &lt; bestRefl) {\n      bestRefl = refl;\n      bestCapPos = pos;\n      bestIndPos = LOW;\n    }\n  }\n\n  \/\/ select best capacitance and inductance\n  digitalWrite(indPin, bestIndPos);\n  cap.write(bestCapPos);\n\n  \/\/ wait before re-entering the loop...\n  delay(10000);\n}<\/pre><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Introduction The Arduino board is a fantastic tool for rapid prototyping, and can help radio amateurs in lots of homebrew projects. I wanted to demonstrate that it is very easy to build an automatic antenna tuner with the Arduino. I connected an old SWR meter to one of my Arduino boards. Furthermore I build a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":343,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13,14],"tags":[47,49,48],"class_list":["post-336","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-antennas","category-transmitters_and_receivers","tag-arduino","tag-movie","tag-tuner"],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":6}},"_links":{"self":[{"href":"https:\/\/www.pa3hcm.nl\/index.php?rest_route=\/wp\/v2\/posts\/336","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pa3hcm.nl\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pa3hcm.nl\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pa3hcm.nl\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pa3hcm.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=336"}],"version-history":[{"count":12,"href":"https:\/\/www.pa3hcm.nl\/index.php?rest_route=\/wp\/v2\/posts\/336\/revisions"}],"predecessor-version":[{"id":1946,"href":"https:\/\/www.pa3hcm.nl\/index.php?rest_route=\/wp\/v2\/posts\/336\/revisions\/1946"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.pa3hcm.nl\/index.php?rest_route=\/wp\/v2\/media\/343"}],"wp:attachment":[{"href":"https:\/\/www.pa3hcm.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=336"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pa3hcm.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=336"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pa3hcm.nl\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=336"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}