459MHz UHF legal Tx and Rx - Arduino based programability.

Started by Devonian, July 10, 2011, 02:54:30 PM

Previous topic - Next topic

Devonian

OLRS now has a great additional bit of software/code - a Spectrum Analyser !

http://www.rcgroups.com/forums/showthread.php?t=1617297

http://forum.flytron.com/viewtopic.php?f=7&t=335

First version of executable and code is here:
http://forum.flytron.com/viewtopic.php?f=7&t=335&start=10#p2484

Nigel
You're only jealous 'cos the voices aren't talking to you  :D

Coyote

Education and schoolin is good, but FPV is gooder :)

Splashy

I might be doing something hideously wrong but when I run the RX as a spectrum analyzer I am finding the peak for my thundead modded TX at 43900 not the 45900 that I was expecting. Am I doing something very silly or misinterpreting the results.

thundead

hey guys :) saw this over @ Flytorn. look interesting :D Been buried in uni crap but I'll have a quick look when I've got some spare time :)
If you like my work feel free to contribuite to my Pringles & Red Bull Fund :) http://forum.flytron.

Coyote

Quote from: Splashy on March 20, 2012, 08:23:51 PM
I might be doing something hideously wrong but when I run the RX as a spectrum analyzer I am finding the peak for my thundead modded TX at 43900 not the 45900 that I was expecting. Am I doing something very silly or misinterpreting the results.


Can you put a screenshot of your GUI ?
Education and schoolin is good, but FPV is gooder :)

Devonian

I can't compile in Mihai's v3.3 RX.

It's OK if I just add the <code> in the Rx tab, but as soon as I add

// Enable spectrum-analyzer?
#define SPECTRUM_ANALYZER 1

in the config.h tab it bleats about...
thUndeadMOD3_RX:920: error: expected constructor, destructor, or type conversion before '(' tokenthUndeadMOD3_RX:923: error: expected unqualified-id before 'while'

in line

// When running frequency scanning we want 50 khz between each channel, meaning 200 channels = 10 mhz.
_spi_write(0x7a, 0x01); // 50khz step size (10khz x value)

Too tired and I need some sleep!

Nigel
You're only jealous 'cos the voices aren't talking to you  :D

papa_lazerous

Nigel it would seem the spektrum analyser software was written to work with Melih's FW it's entirely possible that it doesn't work with Thundeads
FW as its quite different in how it's structured and how it handles the RF module...

thundead

definitely won't work properly with my fw as I've changed everything in Melih's fw. lower baud, different packet structure etc.

Quote from: papa_lazerous on March 20, 2012, 10:22:22 PM
Nigel it would seem the spektrum analyser software was written to work with Melih's FW it's entirely possible that it doesn't work with Thundeads
FW as its quite different in how it's structured and how it handles the RF module...
If you like my work feel free to contribuite to my Pringles & Red Bull Fund :) http://forum.flytron.

Devonian

Same error in Melih's v1.11.
I'm using Arduino v0023

What am I doing wrong?

Neeeed sleeeep

Nigel.
You're only jealous 'cos the voices aren't talking to you  :D

thundead

Nigel, as far as I can tell, you will need to comment out the rx or tx part inthe config.h

Quote from: Devonian on March 20, 2012, 10:40:57 PM
Same error in Melih's v1.11.
I'm using Arduino v0023

What am I doing wrong?

Neeeed sleeeep

Nigel.
If you like my work feel free to contribuite to my Pringles & Red Bull Fund :) http://forum.flytron.

Splashy

Quote from: Coyote on March 20, 2012, 09:37:35 PM
Quote from: Splashy on March 20, 2012, 08:23:51 PM
I might be doing something hideously wrong but when I run the RX as a spectrum analyzer I am finding the peak for my thundead modded TX at 43900 not the 45900 that I was expecting. Am I doing something very silly or misinterpreting the results.




Can you put a screenshot of your GUI ?




the relevant bit in my OpenLRS_RX.pde is :

//############ MAIN LOOP ##############
void loop() {
 
  unsigned char i,tx_data_length;
  unsigned char first_data = 0;

 
  receiver_mode = check_modes(); // Check the possible jumper positions for changing the receiver mode.
 
  load_failsafe_values();   // Load failsafe values on startup
 
  if (receiver_mode == 1) Red_LED_Blink(3); // 3x Red LED blinks for serial PPM mode.
 

  Red_LED_ON;

  RF22B_init_parameter(); // Configure the RFM22B's registers

  frequency_configurator(CARRIER_FREQUENCY); // Calibrate the RFM22B to this frequency, frequency hopping starts from here.

  to_rx_mode();

  sei();


  //Hop to first frequency from Carrier
  #if (FREQUENCY_HOPPING==1)
    Hopping();
  #endif   
 
  RF_Mode = Receive;
   
  time = millis();

  last_pack_time = time; // reset the last pack receiving time for first usage
  last_hopping_time = time; // reset hopping timer

  //Spectrum_Analyzer();

  // ========================================================================================================                       
// Spectrum-analyzer part
// ========================================================================================================

#if (SPECTRUM_ANALYZER_ENABLED == 1)

unsigned char read_serial =0;
char serial_buf =0;
int temp_buf[3] = {0,0,0};
unsigned char buf_index =0;

long totalreading;
int rssi_max = 0;
int rssi_min = 255;
long number_average = 100;

int start_freq = ((430-240)/10);
int end_freq = ((440-240)/10);

// When running frequency scanning we want 50 khz between each channel, meaning 200 channels = 10 mhz.
                        _spi_write(0x7a, 0x05);    // 50khz step size (10khz x value)

                  // Run infinite loop..
                        while (1==1) {
                   
               // Empty line when a full scan is completed
                    Serial.println();
               
               // Scan from 240 mhz to 470 mhz.
                    for (unsigned int k = start_freq; k<end_freq;k++) {
               
               // 0x40 = 240 mhz.
               // 0x41 = 250 mhz
               // 0x42 = 260 mhz.
               
                         unsigned int center_frequency = 0x40+k;                                                   
                           _spi_write(0x75, center_frequency);                 
                           _spi_write(0x76, 0x00);   
                           _spi_write(0x77, 0x00);     

                 
                  // Scan 200 x 50 khz = 10 mhz.
                        for (unsigned int i =0; i < 200; i++) {
                            _spi_write(0x79, i);
                           delay(1);                           
                           
                           if (_spi_read(0x0C)==0) {RF22B_init_parameter(); to_rx_mode(); }// detect the locked module and reboot     
                           
                           totalreading=0;
                           rssi_max = 0;
                           rssi_min = 255;
                           
                     // Used to average readings and find max if using frequency-hopping transmitter.
                             for (unsigned int j =0; j < number_average; j++) {
                               
                               // Always check for incoming serial-data:
                               if (Serial.available())  {     
                                 serial_buf = Serial.read();
                                 
                                 if (serial_buf == 35) {
                                     read_serial =1;
                                 }
                                 
                                 else if (read_serial == 1) {
                                 
                                     if (serial_buf == 44) {
                                     buf_index++;
                                     }
                                     
                                     else if (serial_buf > 47 && serial_buf < 58){
                                      temp_buf[buf_index] = temp_buf[buf_index]*10 + (serial_buf-48);
                                     }
                                     
                                     else if(serial_buf == 10) {
                                       j=30000;
                                       k=30000;
                                       
                                       read_serial =0;
                                       start_freq = (temp_buf[0]-240)/10;
                                       end_freq =   (temp_buf[1]-240)/10;
                                       number_average = temp_buf[2];
                                       
                                       temp_buf[0] =0;
                                       temp_buf[1] =0;
                                       temp_buf[2] =0;
                                       buf_index =0;
                                       
                                       delay(100);
                                     
                                       /*
                                       Serial.print("Start_freq: ");
                                       Serial.print(start_freq);
                                       Serial.print("End_freq: ");
                                       Serial.println(end_freq);
                                       */
                                     }
                                   }
                                     
                                     
                               }
                               
                               
                               
                               
                               
                               Rx_RSSI = _spi_read(0x26); // Read the RSSI value   
                                totalreading += Rx_RSSI;
                             
                              if (rssi_max < Rx_RSSI) {
                               rssi_max = Rx_RSSI;
                              }
                             
                              if (rssi_min > Rx_RSSI) {
                               rssi_min = Rx_RSSI;
                              }
                             
                               rx_reset();
                               delayMicroseconds(250);
                             }

                             //Serial.print("Channel: ");
                             Serial.print(24000+k*1000+i*5);
                             Serial.print(",");                             

                              totalreading = totalreading / number_average;
                             
                             Serial.print(rssi_max);       
                             Serial.print(",");   
                             
                             Serial.print(totalreading);                                                 
                             Serial.print(",");                             
                             
//                             Serial.print(i);
//                             Serial.print("\t");                             
                             //Serial.print("   RSSI min:");
                             //Serial.print(rssi_min);                         
                             
                             //Serial.print("   RSSI max:");
                             
     
         

                             Serial.print(rssi_min);   
                             Serial.println(",");                                   

                             //Serial.print("   RSSI avg:");


                           
                           
                          }
                         
                          }
                       
                        }
                 
#endif
                       
// ========================================================================================================
// Spectrum-analyzer part END
// ========================================================================================================

and in my rfm22b i replaced the frequency_configurator with

     void frequency_configurator(long frequency){
     
        // frequency formulation from Si4432 chip's datasheet
      // original formulation is working with mHz values and floating numbers, I replaced them with kHz values.
     
      unsigned int frequency_constant = 19000;//default 430-440Mhz
     
      if ((frequency>=400000) && (frequency<410000))  frequency_constant = 16000; // 16 for 400–409.9 MHz band from datasheet
      if ((frequency>=410000) && (frequency<420000))  frequency_constant = 17000; // 17 for 410–419.9 MHz band from datasheet
      if ((frequency>=420000) && (frequency<430000))  frequency_constant = 18000; // 18 for 420–429.9 MHz band from datasheet
      if ((frequency>=430000) && (frequency<440000))  frequency_constant = 19000; // 19 for 430–439.9 MHz band from datasheet
      if ((frequency>=440000) && (frequency<450000))  frequency_constant = 20000; // 20 for 440–449.9 MHz band from datasheet
      if ((frequency>=450000) && (frequency<460000))  frequency_constant = 21000; // 21 for 450–459.9 MHz band from datasheet
      if ((frequency>=460000) && (frequency<470000))  frequency_constant = 22000; // 22 for 460–469.9 MHz band from datasheet

      frequency = frequency / 10;
      frequency = frequency - 24000;
     
      frequency =  frequency - frequency_constant;
     
      frequency = frequency * 64; // this is the Nominal Carrier Frequency (fc) value for register setting
     
      byte byte0 = (byte) frequency;
      byte byte1 = (byte) (frequency >> 8);
     
      _spi_write(0x76, byte1);   
      _spi_write(0x77, byte0);

    }


Coyote

That's deffo showing your channels are on 433 not 459
Education and schoolin is good, but FPV is gooder :)

Splashy

But I am definitely running Thundeads Mod on 459 Mhz.
Even I could not have got it wrong on 3 modules ... better scurry away and check though..

I take it that everyone else is getting the peak on 459

Coyote

I ve not tried but ill flash an rx tomorrow and let you know
Education and schoolin is good, but FPV is gooder :)

Devonian

You're only jealous 'cos the voices aren't talking to you  :D