Projects Links

Click on the "Links"  to go to Project and About Pages Click for Projects Links                                 About the Vess...

Wednesday, November 18, 2020

Amateur Radio FOX Hunt Transmitter

Fox hunting is an activity in radio transmitter hunting in which the hunters use radio direction finding techniques to locate a radio transmitters (the fox) which is hidden within a designated search area. 

This activity is most popular among amateur radio enthusiasts, and one organized sport variation is known as amateur radio direction finding.

Constructing an Arduino Uno/BaoFeng  Fox Transmitter

Hardware Components 

  • BaoFeng UV-5R
  • Arduino Uno
  • 5V One Channel Relay Module Relay Switch with OPTO Isolation High Low Level Trigger
  • BAOFENG Speaker MIC for BAOFENG UV-5R 
  • Enclosure box for Arduino Uno & Relay 
  • 18650 Battery Holder with Leads with common 2.1mm DC power plug 
  • three 18650 Lithium-Ion 3000mAh Batteries
  • SMA female to SMA male 12" cable
  • SMA female to female connector
  • Plastic Ammo Box 


The Completed FOX Transmitter

The Fox Transmitter is housed in a plastic ammo box obtained from Harbor Freight for $2.99.  An SMA male to male connector is mounted on the ammo box lid.  An SMA female to female connector connects the BaoFeng antenna to the ammo box.  In the pictures shown, SMA to BNC, BNC to BNC, BNC to SMA connectors are used.   This would allow for remotely mounting the antenna using a BNC cable. To provide the internal antenna connection, a 12" long SMA female to SMA male cable connect the external antenna to the BaoFeng UV-5R.   A piece of hard foam was placed inside the ammo box with cut outs for mounting the BaoFeng and the Arduino box.


Fox Transmitter.  Note: can be locked
with a common padlock.
 

Fox Transmitter main components
consisting of a BaoFeng UV-5R and
an Arduino with Relay Module.
Main components shown with Arduino
battery pack mounted to enclosure.  To
operate Fox, insert Arduino power plug
 and turn on the BaoFeng UV-5R.  


Power Pack Construction
The FOX transmitter uses the built-in BaoFeng battery for normal HT operations.  The Arduino is powered by 3 18650 Lithium batteries (I used Sony/Murata VTC6 18650 3000mAh).  The batteries were connected in series using a 18650 battery holder purchased from Amazon (2 holders @ $6.99). The battery holder wire leads were connected to a common 2.1mm DC power plug which was cut off from end of an old 9V AC/DC power adapter.   The three 18650 batteries provides 3000 mAh at 10.8 V which is enough power for over 8 hrs of operation.  In actual use, the BaoFeng battery drains before the Arduino battery pack.  Note: the Arduino Uno maximum power consumption is 5V@800mA giving  (3000 mAhrs)*(10.8 V)/(5 V)/(800 mA) = 8.1 hrs.   Also, it is trivial to quickly replace the BaoFeng or 18650 batteries with spares. 


Arduino & Relay Enclosure Construction
The Arduino Uno and the Relay Module were mounted using nylon screws to a 4"x3" piece of 1/8" clear acrylic.  The acrylic was then mounted using VHB tape to a metal enclosure box of interior dimensions 4-1/2" x 3-1/2" x 1-1/8".  Two holes were drilled in the enclosure box.  One hole sized larger that the power plug was lined up with the Arduino power socket when in the enclosure. The second hole was slightly larger than BaoFeng transmission cable.  The transmission cable was inserted through the enclosure hole below connecting the cable wires to the unit.  A double wrapped zip-tie was placed near the cable wire for a cable wire strain relief. 

Arduino/Relay mounted in enclosure.




BaoFeng Cable Connection
The BaoFeng transmission cable was made from a BaoFeng handheld speaker mic that was purchased from Amazon for $7.59.  The handheld mic end was cut off exposing 4 wires: red, green, black, & white.    The red and green wires go to the Arduino Uno.  Green wire to the Arduino ANALOG IN socket/pin "A0" for audio from the BaoFeng and red wire to the Arduino DIGITAL (PWM~) socket/pin  "~5" for the audio to the BaoFeng.   The other two cable wires (white & black) connect to the Relay Module for PTT transmission.  The black wire connects to the Relay "NO" connection and the white wire connects to the Relay "COM" connection.


Transmission & PPT cable connections.


PPT cable connections to Relay.






Arduino Wire Connection
The remaining 3 wire connections connect the Arduino to the Relay for PTT operation.  Connect a wire (shown as yellow) from Arduino DIGITAL socket/pin "7" to the Relay "IN" connection (this is your TX on/off signal), connect a wire (shown as red) from Arduino POWER "5V" socket/pin to the Relay "DC+" connection, and connect the final wire (shown as blue) from Arduino POWER "GND" socket/pin to the Relay "DC-" connection.


Arduino wire connections.

Close up of wire connections.




Arduino Sketch Code
Download and install the Arduino IDE software from https://www.arduino.cc/en/software.   This open-source Arduino Software (IDE) makes it easy to write code and upload it to the board. 

Arduino IDE set up: Connect the Arduino to you computer via a USB cable and start the Arduino IDE program.   From the Arduino "Tools>Board" menu select "Arduino/Genuino Uno" and select the USB port for the Arduino Uno via the "Tools>Port" menu.

The process of uploading the program code and operating the Arduino is simple.  Either open an existing sketch (the Arduino  C program code) or from the Arduino File Menu open New and cut and paste the below sketch code.  Once you have the sketch coded click on the upload button (right arrow on the top of the sketch window).  Wait a few seconds - you should see the RX and TX leds on the board flashing. If the upload is successful, the message "Done uploading." will appear in the status bar.  The sketch will then start running.  

The follow section on the myFox sketch code is under construction. 

Put the following text in a file named "myFox.ino" in a folder named "myFox" and then open the file and the Arduino IDE will run and open the sketch myFox.  

/*
Radio Fox Hunt controller
This transmits a CW Fox message.
It then waits a set amount of time and transmits again
This transmits by connecting to a radio's ptt and mic input.

*/

#define tonehz 700 //the approximate frequency of the tones in hz, in reality it will be a tad lower, and includes lots of harmonics.

#define dit 128 //64the length of the dit in milliseconds. The dah and pauses are derived from this.

#define rest 30000 //the ammount of time between transmits in ms 60000=60seconds

#define longlength 10000 //length of long tone in milliseconds 10000=10seconds

#define tx 7 //pin 7 on the board controls the tx, signal to 5v relay where you would have speaerk/mic pins conntected

#define audio 5 //the pin 5 on the board that controls audio output, conntected to mic on radio

String formMorse(String input);

  
//CW array
//DO NOT CHANGE
// 1 = dit , 2 = dah, 0 = space
// Letters/#                 A     B      C     D    E    F      G     H      I     J     K      L    M     N    O     P      Q      R     S    T    U      V     W      X     Y      Z       0        1      2       3       4       5       6       7       8       9                   
String morseTable[] = {"0","12","2111","2121","211","1","1121","221","1111","11","1222","212","1211","22","21","222","1221","2212","121","111","2","112","1112","122","2112","2122","2211","22222","12222","11222","11122","11112","11111","21111","22111","22211","22221"};

//String Text = "SO  SO SO"; //Use for LED testing
String Text = "KN4TRT FOX KN4TRT FOX"; //This is what will be transmitted
String code = formMorse(Text);

int TextChars = 15;
int CodeChars;

int duration;

int note = 1000000 / tonehz; //converts the frequency into period

void setup(){ //set the pins to output mode
  digitalWrite(tx, LOW); 
  pinMode(tx, OUTPUT);
  pinMode(audio, OUTPUT);
  pinMode(13, OUTPUT); //this is to see how the cw looks on board led pin 13
  
  Serial.begin(9600);
  Serial.println(Text);
  Serial.println(code);
  
}


void loop(){

  digitalWrite(tx, HIGH); // starts the radio transmitting
  delay(250);
  playcode(code);
  digitalWrite(tx, LOW); // Stops the radio's transmission

  delay(rest);
 // delay(rest+random(7000)); // Sets delay to a random interval 

}

void playtone(int note_duration){

  long elapsed_time = 0;
  long startTime=millis();
  if (note_duration > 0){

    digitalWrite(13, HIGH); //See when it is making a tone on the led
    
    while (elapsed_time < note_duration){

      digitalWrite(audio, HIGH);

      delayMicroseconds(note / 2);

      digitalWrite(audio, LOW);

      delayMicroseconds(note / 2);

      elapsed_time = millis()-startTime;
    }

    digitalWrite(13, LOW);

  }

  else{ //if it's a pause this will run

    delay(dit * 2);

  }
}

void playcode(String input){

  for (int i=0; i < input.length(); i++){
    Serial.print(input[i]);
    if (input[i] == '0'){ //See if it's a pause

      duration = 0;
    }

    else if (input[i] == '1'){ //See if it's a dit

      duration = dit;
    }

    else if (input[i] == '2'){ //See if it's a dah

      duration = dit * 3;
    }

    playtone(duration);

    delay(dit); //makes a pause between sounds, otherwise each letter would be continuous.
  }
  Serial.println();
}

String formMorse(String input){

    input.toUpperCase();

    String output = "";

    for(int i=0; i < input.length() ;i++){

        if (input[i] >= 65 && input[i] <= 90)

            output = output + morseTable[input[i]-64] + '0';

        else if (input[i] >= 48 && input[i] <= 57)

            output = output + morseTable[input[i]-21] + '0';

        else if (input[i] == 32)

            output = output + morseTable[0];

    }
    return output;

}



No comments:

Post a Comment