ad: elecraft

Icom arduino band voltage decoder

Discussion in 'Homebrew and Kit Projects' started by WA4SIX, Apr 20, 2020.

ad: L-HROutlet
ad: l-rl
ad: Left-2
ad: FBNews-1
ad: Left-3
ad: OK1UUad-1
ad: L-MFJ
ad: Subscribe
  1. WA4SIX

    WA4SIX Ham Member QRZ Page

    Modded from http://www.5b4wn.com/main/a1921.html

    Using an ULN2803A Darlington array for relay driving. 2 spare Darlington pairs will key amp (160M & 30M)

    Here's the sketch.

    Ed

    //icom band decoder
    //Marios Nicolaou 5B4WN (c) 2009 7 24
    //Use the code at your OWN risk
    //GPL licence
    //Modified by Ed Grafton WA4SIX
    //Mod is to directly select pin, instead of BCD




    int icomBandPin = 5; // select the input pin for the potentiometer
    //int realVoltage = 8; // variable to store the value coming from the sensor Volts
    int sensedVoltage=0;
    int H=5;
    int G=6;
    int F=7;
    int E=8;
    int D=9;
    int C=10;
    int B=11;
    int A=12;
    float calculatedVoltage=0;
    int band=0;
    int counter =0;
    int previousValue=0;
    void setup() {
    Serial.begin(9600);
    pinMode(A, OUTPUT);
    pinMode(B, OUTPUT);
    pinMode(C, OUTPUT);
    pinMode(D, OUTPUT);
    pinMode(E, OUTPUT);
    pinMode(F, OUTPUT);
    pinMode(G, OUTPUT);
    pinMode(H, OUTPUT);
    }
    void loop() {
    // read the value from the sensor:
    sensedVoltage = analogRead(icomBandPin);


    //get 5 consecutive values
    // counter++;

    if (counter==5) {

    calculatedVoltage = float(sensedVoltage)*5/1024;

    Serial.print (sensedVoltage);
    Serial.print (" - ");
    Serial.print (calculatedVoltage);
    Serial.print (" - ");
    band=getBand(calculatedVoltage);

    Serial.println(band, DEC);
    delay (20);

    } else {
    if (abs(previousValue-sensedVoltage)>10) {
    //means change or spurious number
    previousValue=sensedVoltage;
    } else {
    counter++;
    previousValue=sensedVoltage;
    }


    }

    }

    int getBand(float voltage) {
    int band=0;
    digitalWrite(A, LOW);
    digitalWrite(B, LOW);
    digitalWrite(C, LOW);
    digitalWrite(D, LOW);
    digitalWrite(E, LOW);
    digitalWrite(F, LOW);
    digitalWrite(G, LOW);
    digitalWrite(H, LOW);

    if (voltage>4.20 && voltage<4.68) {
    band=160;
    digitalWrite(A, HIGH);
    } else if (voltage>3.50 && voltage<4.20) {
    band=80;
    digitalWrite(B, HIGH);
    } else if (voltage>=2.95 && voltage<3.50) {
    band=40;

    digitalWrite(C, HIGH);

    } else if(voltage>=2.30 && voltage<2.95) {
    band=20;

    digitalWrite(D, HIGH);

    } else if (voltage>=1.70 && voltage<2.30) {
    band=15;

    digitalWrite(E, HIGH);

    } else if (voltage>=1.2 && voltage<1.7) {
    band=10;

    digitalWrite(F, HIGH);

    } else if (voltage>=0.75 && voltage<1.2) {
    band=6;

    digitalWrite(G, HIGH);
    } else if (voltage <0.75) {
    band=30;
    digitalWrite(H, HIGH);

    }
    return band;

    }
     
    WA7ARK, AF7XT and US7IGN like this.
  2. WA4SIX

    WA4SIX Ham Member QRZ Page

    This circuit is for automatic control of my Metron MA-1000 while mobile. I will add a relay to bypass the LPF section for 6 meters & add an outboard ICE 6M LPF.
    Radio is an IC-7000. Antenna is an HS-1800 screwdriver with BetterRF 7000 controller.
    There will eventually be a horizontal antenna for 6M, whether 1/2 wave or full wave.

    Ed
     
    AF7XT likes this.

Share This Page

ad: elecraft