References: ( http://ernest.utreg.net/?page=arduino-tuner )
Ernest says: " 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. 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!

// AutoTuner v2
// by PA3HCM
#include // We will use a servo
Servo cap; // for rotating the capacitor
int capPin = 9; // attached to pin 9
int indPin = 13; // Inductor relay on pin 13
int reflPin = 0; // Reflection input on analog pin 0
int pos = 0;
boolean bestIndPos = HIGH;
int capPos = 0;
int bestCapPos = 0;
int refl = 0;
int bestRefl = 1023;
void setup() {
cap.attach(capPin);
}
void loop() {
// reset
bestCapPos = 0;
bestIndPos = HIGH;
bestRefl = 1023;
cap.write(0); // turn capacitor to start position
delay(500); // this will take a bit of time, so wait
// find best reflection with full inductance
digitalWrite(indPin, HIGH);
delay(200);
for(pos = 0; pos < 180; pos += 3)
{
cap.write(pos);
delay(15);
refl = analogRead(reflPin);
if (refl < bestRefl) {
bestRefl = refl;
bestCapPos = pos;
bestIndPos = HIGH;
}
}
// find best reflection with reduced inductance
digitalWrite(indPin, LOW);
delay(200);
for(pos = 180; pos > 0; pos -= 3)
{
cap.write(pos);
delay(15);
refl = analogRead(reflPin);
if (refl < bestRefl) {
bestRefl = refl;
bestCapPos = pos;
bestIndPos = LOW;
}
}
// select best capacitance and inductance
digitalWrite(indPin, bestIndPos);
cap.write(bestCapPos);
// wait before re-entering the loop...
delay(10000);
}
No comments:
Post a Comment