Thread Tools
This thread is privately moderated by grmis, who may elect to delete unwanted replies.
Jul 13, 2013, 03:09 AM
Registered User
grmis's Avatar
Thread OP
Build Log

10$ DIY RSSI diversity based on HK video switch


Here is a simple & very cheap DIY RSSI video diversity. It is based on an Arduino Pro mini (less than 4$ on eBay) and the following video switch from Hobbyking:

https://www.hobbyking.com/hobbyking/s..._Switcher.html (less than 6$)

One advantage of using this video switch is that almost no external component is needed. The video switcher is supposed to be connected to an RC receiver, but here the PWM signal needed to select the video source is generated by the arduino. I just added one push button to select one particular receiver, or the automatic mode (the one with best RSSI), as well as a 2 leds to indicate which receiver is actually selected, and what is the RSSI level (bar with 5 leds). This can obviously be extended to 3 receivers instead of 2. The system is powered by 5v taken from (inside) one of the receiver (here the 12-channel VRX sold by HK, 0.9-1.2GHz). I am using one ground plane antenna on receiver #1, and a patch antenna on the other (both from IBcrazy's design). I confess that I have not yet used this in the field... but on the bench everything looks ok

If needed (?) I could post the detailed schematics & arduino code.

Warning: some labels on the video switcher are incorrect ! Remove the cover to see the correct pin labels on the PCB.

EDIT (July 26th): I have done a few test flights with this diversity system and it works . I however noticed that some care is need to calibrate the two RSSI levels, even though the two video receivers are (in principle) identical. Their RSSI levels seem to differ a little bit and this must be take into account in the arduino code. I may add a potentiometer to be able to adjust "manually" some bias in favor of one receiver/antenna or another (at present I have to change the calibration parameters in the code -- which is not very convenient if you are on the field).
Last edited by grmis; Feb 12, 2014 at 04:40 AM. Reason: info about calibration
Sign up now
to remove ads between posts
Jul 13, 2013, 03:09 AM
Registered User
grmis's Avatar
Thread OP

Schematics


version 1
Last edited by grmis; Nov 11, 2013 at 08:41 AM. Reason: typo !
Jul 13, 2013, 03:10 AM
Registered User
grmis's Avatar
Thread OP

Arduino sketch RSSI diversity


Code:
                                                                                                                                                                                                                                                      
#include <Servo.h> // To generate a PWM signal for the video switch

const int rssi_PIN_A=7; //Analog pin conncted to the RSSI of receiver A
const int rssi_PIN_B=6; //Analog pin conncted to the RSSI of receiver B

// Calibration data
const int rssi_best_A=200;
const int rssi_worst_A=860;
const int rssi_best_B=200;
const int rssi_worst_B=874;

const int ledA_PIN=4; //digital pin conncted to the led indicating selection of receiver A
const int ledB_PIN=12; //digital pin conncted to the led indicating selection of receiver B
const int ledM_PIN=2; //digital pin conncted to the led indicating AUTO mode
const int button_PIN=6;//digital pin connected to the button used for selecting the mode: A, B or AUTO. Pulled to Vcc by some resistor.


//Hysteresis factor to prevent from switching back and forth too fast if both RSSI are almost the same.
const float hys=1.01;

const int video_sw_PIN=3;//digital pin connected to the video switch (PWM)
const int swA=45;// value to send (in PWM) in order to select source A
const int swB=135;// value to send (in PWM) in order to select source B

const int rssi_bar1_PIN=7;//digital pin connected to the rssi output (PWM)
const int rssi_bar2_PIN=9;//digital pin connected to the rssi output (PWM)
const int rssi_bar3_PIN=10;//digital pin connected to the rssi output (PWM)
const int rssi_bar4_PIN=8;//digital pin connected to the rssi output (PWM)
const int rssi_bar5_PIN=11;//digital pin connected to the rssi output (PWM)

Servo video_sw;

const int A=1;
const int B=-1;
const int forceA=A;
const int forceB=B;
const int AUTO=0;

int mode;

int video_source;
int rssi_val_A=0;
int rssi_val_B=0;
int rssi=0;

void setup()
{
    pinMode(ledA_PIN, OUTPUT);
    pinMode(ledB_PIN, OUTPUT);
    pinMode(rssi_bar1_PIN, OUTPUT);
    pinMode(rssi_bar2_PIN, OUTPUT);
    pinMode(rssi_bar3_PIN, OUTPUT);
    pinMode(rssi_bar4_PIN, OUTPUT);
    pinMode(rssi_bar5_PIN, OUTPUT);
  
    pinMode(button_PIN, INPUT);
    video_sw.attach(video_sw_PIN);
    // Start in AUTO mode:
    mode=AUTO;
    switch_to(A);digitalWrite(ledM_PIN,HIGH);
   
   Serial.begin(9600); 
   
    
  }

void ShowRSSI(const int rssi) {
const int n=map(rssi,0,999,0,6);
if (n>0) digitalWrite(rssi_bar1_PIN,HIGH); else digitalWrite(rssi_bar1_PIN,LOW);
if (n>1) digitalWrite(rssi_bar2_PIN,HIGH); else digitalWrite(rssi_bar2_PIN,LOW);
if (n>2) digitalWrite(rssi_bar3_PIN,HIGH); else digitalWrite(rssi_bar3_PIN,LOW);
if (n>3) digitalWrite(rssi_bar4_PIN,HIGH); else digitalWrite(rssi_bar4_PIN,LOW);
if (n>4) digitalWrite(rssi_bar5_PIN,HIGH); else digitalWrite(rssi_bar5_PIN,LOW);

}

void switch_to(int source) {
  switch(source) {
      case A:
        video_source=A;
        digitalWrite(ledA_PIN,HIGH);
        digitalWrite(ledB_PIN,LOW);
        video_sw.write(swA);
        break;
      case B:
        video_source=B;
        digitalWrite(ledB_PIN,HIGH);
        digitalWrite(ledA_PIN,LOW);
        video_sw.write(swB);
        break;
  }
}

void loop() {

 
 rssi_val_A=analogRead(rssi_PIN_A);
 rssi_val_B=analogRead(rssi_PIN_B);

 //Serial.print("Raw RSSI A=");Serial.print(rssi_val_A);Serial.print("\n");
 //Serial.print("Raw RSSI B=");Serial.print(rssi_val_B);Serial.print("\n");

    
 // Rescaling
  rssi_val_A=constrain(map(rssi_val_A,rssi_best_A,rssi_worst_A,999,0),0,999);
  rssi_val_B=constrain(map(rssi_val_B,rssi_best_B,rssi_worst_B,999,0),0,999);
       
 //Serial.print("Scaled RSSI A=");Serial.print(rssi_val_A);Serial.print("\n");
 //Serial.print("Scaled RSSI B=");Serial.print(rssi_val_B);Serial.print("\n");
 //delay(2000);
       
       
   if (mode==AUTO) {
     if (((float) rssi_val_A > rssi_val_B*hys) && video_source==B) switch_to(A);   
     if (((float) rssi_val_B > rssi_val_A*hys) && video_source==A) switch_to(B);   
   }

 if (video_source==A) {
    ShowRSSI(rssi_val_A);
  } else {
    ShowRSSI(rssi_val_B);
  }
  



 
       
//Check the push button for possible mode change
  int but=digitalRead(button_PIN);
  if (but==LOW) {
      switch(mode) {
          case forceA:
          mode=AUTO;switch_to(A);digitalWrite(ledM_PIN,HIGH);break;
          case AUTO:
            mode=forceB;switch_to(B),digitalWrite(ledM_PIN,LOW);break;
          case forceB:
            mode=forceA;switch_to(A);break;
      }
      delay(500);
    }

 
delay(10);

}
Last edited by grmis; Aug 19, 2013 at 11:11 AM.
Jul 14, 2013, 08:13 AM
Registered User
grmis's Avatar
Thread OP

RSSI pin on 900Mhz video RX


For completeness, here is a picture where you can see the location of the RSSI on the 900Mhz tuner (inside 900Mhz video RX sold by HK).
Aug 11, 2013, 01:47 AM
Registered User
Nice solution.. ( will you be posting the sketch for this ? )
Aug 19, 2013, 11:13 AM
Registered User
grmis's Avatar
Thread OP
Quote:
Originally Posted by flyhigh300
Nice solution.. ( will you be posting the sketch for this ? )
Thanks. I have just posted the sketch (above).
Sep 05, 2013, 03:18 AM
9W2DLR
nice, how fast the video get switched? i have these laying around in my box maybe could do some test, hopefully the schematic will be up soon
Sep 05, 2013, 03:40 AM
Registered User
grmis's Avatar
Thread OP
Quote:
Originally Posted by skellator
nice, how fast the video get switched? i have these laying around in my box maybe could do some test, hopefully the schematic will be up soon
I do not know how fast it is in terms of "milliseconds", but if you look at the picture you can see something (brief change of luminosity or something like that) when the video input is switched. But for an FPV application with one omni antenna + directional antenna I think that is completely fine.

Schematic: since no external component is needed (except for the leds), you can basically see how to connect things together just by looking at the picture above. Concerning the arduino pins (which you cannot really see on the picture), they are indicated in the code:

Analog pin #7 connected to the RSSI of receiver A
Analog pin #6 connected to the RSSI of receiver B
Digital pin #4 connected to the led (+resistor) indicating selection of receiver A
Digital pin #12 connected to the led (+resistor) indicating selection of receiver B
Digital pin #2 connected to the led indicating AUTO mode
Digital pin #6 connected to the button used for selecting the mode: A, B or AUTO. Pulled to Vcc by some resistor (~10kOhms).
Digital pin #3 connected to the video switch (PWM)

(+ optional leds for the rssi bar connected to digital pins 7,8,9,10 and 11).

It takes a little bit of time to put this into some schematics...but I could do it if needed.
Sep 05, 2013, 04:12 AM
9W2DLR
great that should do fine, i try it out if i still have a mini pro spare in hand, I think a 3 position switch is better for selecting mode as you can do

RX 1 | AUTO | RX 2

so middle position will be always auto mode, I have a bunch of those perhaps i can use then but need to check the sketch first if it need to be modified , can you put the pin connection in the post number 2?

looking forward for more

Thanks
Sep 05, 2013, 04:21 AM
Registered User
grmis's Avatar
Thread OP
Quote:
Originally Posted by skellator
great that should do fine, i try it out if i still have a mini pro spare in hand, I think a 3 position switch is better for selecting mode as you can do

RX 1 | AUTO | RX 2

so middle position will be always auto mode, I have a bunch of those perhaps i can use then but need to check the sketch first if it need to be modified
You are definitely right, this is better... Because when I am flying with goggles, it is hard to be sure in which more I am since I cannot see the status leds.

The simplest thing to do would then probably to connect your 3-pos. switch to two digital pins on the arduino (with one pull up resistor for each) instead of one.
Sep 05, 2013, 04:44 AM
9W2DLR
Quote:
Originally Posted by grmis
You are definitely right, this is better... Because when I am flying with goggles, it is hard to be sure in which more I am since I cannot see the status leds.

The simplest thing to do would then probably to connect your 3-pos. switch to two digital pins on the arduino (with one pull up resistor for each) instead of one.
then i guess code need some modification, as it will need 2 digital pin did some search for a sample code if i have the time maybe i could do a test for the switch code

Quote:
// Calibration data
const int rssi_best_A=200;
const int rssi_worst_A=860;
const int rssi_best_B=200;
const int rssi_worst_B=874;
how do you get this value? sorry I'm not really familiar with arduino coding yet
Nov 11, 2013, 06:49 AM
Registered User
grmis's Avatar
Thread OP

Schematics


Since a few people asked.. here is some schematics for this rssi-diversity system (sorry for the delay) !

Note that with some receivers (like the 900-1200Mhz from HK), you can
pick (inside) some +5v line to power the arduino and the video switch.

EDIT (Feb. 2014): if the receiver has an inverted RSSI signal (which means that high voltage = poor signal), it may be usfull to add some pull-up resistor to it (like 20kOhms). Otherwise, if you switch off one of your receivers, its RSSI output will drop to zero and this will be (mis)interpreted has a good signal by the diversity system. With pull-up resistors (not shown on the schematics above) you do not have this problem: if you disconnect one receiver, the system switches to the other one.
Last edited by grmis; Feb 12, 2014 at 04:45 AM. Reason: Mention pull up resistor for inverted RSSI signals
Nov 11, 2013, 06:56 PM
Registered User
Wow!!!
Is several days that I'm looking around on the web for a good and simple diversity system.... And your is!!!
Definitely it is!
Now I have to order the video switch to hobby king , two airwave receiver for my frequency (5,8) and buy a Arduino!
I hope that if I use two identical receiver I'm out of the rssi unbalanced that you have....so no potmeter or other stuff!
Another thing.... The three way switch... Really better than a single button, so please prepare a variation of the code for arduino! Please!
my best compliments!
Ciao
Davide
Nov 11, 2013, 10:13 PM
Registered User
Corie's Avatar
Amazing! Thank you!
Nov 22, 2013, 10:18 AM
Registered User
Jack_LaLanne's Avatar
This is some cool stuff here Thank you so much for your effort of documenting it for us :-)

Will this Arduino board work? http://www.ebay.com/itm/390698481887

Also: Can you explain the mentioned procedure of RSSI level calibration ?
Last edited by Jack_LaLanne; Nov 22, 2013 at 12:55 PM.


Quick Reply
Message:
Thread Tools

Similar Threads
Category Thread Thread Starter Forum Replies Last Post
Discussion DIY Diverity Controller without RSSI Rangarid FPV Talk 13 Feb 25, 2017 09:26 AM
Discussion RSSI Pin for Hobby King HK-TR6A HK-T6A iacei FPV Talk 13 Oct 27, 2015 04:54 PM
Discussion 2.4ghz transmitter based on STM8S + corana DIY 2.4 ghz + Futaba skysport case xavier3596 DIY Electronics 39 Apr 08, 2014 10:59 AM
Help! Broken Limit Switch on E-Flite 10-15 main retract mattsimonton Flight Accessories 4 Apr 14, 2013 10:44 PM
Discussion DIY Telemetry System base on TI CC110L RF BoosterPack spy004 DIY Electronics 2 Mar 06, 2013 08:58 AM