Go Down

Topic: Decode NOAA Weather Radio SAME codes (Read 19386 times) previous topic - next topic

HerrProfessor

Ok, me again. After several days of digging through parts bins and finding the same values you had from previous posts, I have hardware that definitely works!  My carrier detect picks up on the lock of the PLL and the waveform is much more defined. I tested several audio samples just to make sure, and each one locks with the data and drops the CD line when through.

As far as decoding this data stream goes, I'm still stuck on that. I'll try to continue where I left off several days ago.

rdsman - any progress on your end?

Thanks again for helping me out!
tsc

rdsman

HerrProfessor:

Good to see that you got the XR2211 working.  I'm finally back home and should be able to devote some time to this.  I should be able to post some code soon!

Ray


HerrProfessor

I have taken the CD output from the XR2211 and tied this to INT 0 (pin 2) on the Uno.  I have the data connected to pin 8 of the Uno.  In the sample sketch below, I'm basically waiting for the CD line to go active, then I begin the process of sampling readings, taking a majority vote, then shifting the bit in.  From there I'm displaying after each bit shift in so that I can hopefully see a recognizable character (that's why  I'm limiting the output to a-z, 0-9, A-Z).

Code: [Select]

/*
  NWR S.A.M.E. Decoder 

  Specifications for this format can be found here:
 
  http://www.nws.noaa.gov/nwr/same.pdf
 
  Created 13 Jan. 2012
  Modified 8 Feb. 2012
*/

const long sampleRate = 384;  //  this is the sample rate (384 us)...
const int ledPin = 13;        //  pin 13 used by on board LED...
const int dataIn = 8;         //  pin that accepts input from decoder...
boolean inputState = false;   //  stores the value read at the digital pin...
long sampleTime = 0;          //  used to store display time for LCD panel...
int sampleCount = 0;          //  used to keep track of samples taken...
int boolHigh = 0;             //  used to track HI bits...
int boolLow = 0;              //  used to track LO bits...
unsigned char rxData = 0;     //  used to store the bits...
boolean cdActive = false;     //  trigger when CD changes state...

void setup()
{
  //  Pin 8 connected to output of XR2211...
  pinMode(dataIn, INPUT);
  //  pull this pin HIGH...
  digitalWrite(dataIn, HIGH);
  //  Pin 13 has an LED connected...
  pinMode(ledPin, OUTPUT);
  //  turn the LED off
  digitalWrite(ledPin, LOW);
  //  add an interrupt to receive Carrier Detect...
  attachInterrupt(0, CarrierDetectOnISR, CHANGE);
  //  set com port baud rate...
  Serial.begin(9600);
}

void loop()
{
  //  only go active if CD changes state...
  if(cdActive)
  {
    if((micros() - sampleTime) > sampleRate)
    {
      //  our timer has started, so
      //  read the digital input pin...
      inputState = digitalRead(dataIn);
      //  increment the sample counter...
      sampleCount++;
     
      //  add the counts...
      if(inputState == 1)
      {
        //  this is a 1...
        boolHigh++;
      }
      else
      {
        //  this is a 0...
        boolLow++;     
      }
     
      //  if we have counted in 5 samples, then
      //  it's time to shift these bits in...
      if(sampleCount > 4)
      {
        //  reset the sample counter...
        sampleCount = 0;
   
        //  find out the winner...
        if(boolHigh > boolLow)
        {
          //  shift in a '1'...
          rxData = rxData >> 1;
          rxData = rxData + 0x80;
        }
        else
        {
          //  shift in a '0'...
          rxData = rxData >> 1;
        }
   
        //  reset the counters...
        boolHigh = 0;
        boolLow = 0;
       
        if((rxData > 0x20) && (rxData < 0x7A))
        {
          Serial.print((char)rxData);
        }
      }
     
      //  get the time stamp...
      sampleTime = micros();
    }
  }
}

void CarrierDetectOnISR()
{
  cdActive = !cdActive;
  Serial.println();
}


When I play my sample file, I get some things decoded but not the correct data.  I just don't know if I'm sampling too fast (or too slow), whether I'm shifting in properly, whether I'm delaying the sampling because of Serial.println(), etc.  I'm getting closer, but I just can't quite make it.  All I want to do with this sketch is verify I'm headed in the right direction.  Anything obviously wrong with the code that you can tell?

Thanks again!
tsc

rdsman

Change your code to this:

//  add the counts...
      if(inputState == 0)  // The bits are inverted!
      {
        //  this is a 1...
        boolHigh++;
      }
      else
      {
        //  this is a 0...
        boolLow++;     
      }


Ray


HUDIBRAS

Hello HerrProfessor

If you have a triggering/train signal from pin5/6 to pin Arduino pin2 the VCO is not in lock.
These pins 5/6 XR2211 according to page 3 off datasheet named LDOQ and LDOQN.
These lines are stable LDOQ HIGH and LDOQN LOW only if there is LOCKDETECT, the VCO is in capture range.
Put in a heartbeat other Arduino pin to beat every time you read dataIn. Measure this heartbeat with scope! I bet there is time enough to read more than five times.
When you have a stable LOCKDETECT..

Let LOCKDETECT interrupt decide when to start reading/decode, remember to disable interrupt immediately before reading/decode. Still check LOCKDETECT if it fails stop reading and reactivate interrupt.
I hope this makes any sense!

Max

HerrProfessor

rdsman - I have changed that to a '0' as suggested, and still no change.

hudibras - yes, the CD line goes active on each valid hardware decode from the XR2211 (verified with scope).

HUDIBRAS

Hello HerrProfessor

CD should stay LOW if you connect LDOQN as long as transmission goes on. That shows the VCO is in capture range off the to different tones. If you have a pulstrain on LDOQN, adjust the pot. too it stays LOW. Unless you will not have a stable reading of the signal, you are trying to decode.

Normal it's use is to detect between noise and the two needed tones.

Max

HerrProfessor

#52
Feb 09, 2012, 08:05 pm Last Edit: Feb 09, 2012, 10:30 pm by HerrProfessor Reason: 1
Right - I understand that - and the CD output is functioning properly.  The issue now is simply trying to decode something using the sketch provided earlier.  I'm wondering whether or not I'm sampling the signal properly.  Using the following equations, I arrived at how often to sample then take the majority vote:

1/520.83 = 1.92 ms (period)

1.92 ms / 5 samples = 384 us (sample time)

If I have a majority vote for 1 during the sampling time, then I shift in a '0' (because as rdsman pointed out, the bits are inverted).  If I have a majority vote for 0 during the sampling time, then I shift in a '1'.

Once I have 8 bits, then I should begin testing (looking for the header (0xAB).  When I have that, I should be able to synch up and decode everything from there.

By the way, were you able to use the audio files with any luck?

Thanks,
tsc

HUDIBRAS

Hello HerrProfessor

I have your timing in mind, get back to that later
I have chaged int too FALLING, as I have a stable LOW from pin 5 when it sees one off the two tones.
Changed int as well too
cdActive = HIGH;//!cdActive;
  Serial.println("VCO now in LOCK");
Then i changed your output to
    Serial.print((char)rxData, BIN);Serial.print(" ");//just to separate the results to compare the bits against logic analyzer.
Now the timer you are using micros(), at F_CPU 16MHz it's about 1010088 pr second.
Serial.println(micros());delay(1000);Serial.println(micros()); shows that.
A heartbeat shows 400microseconds at scope, between reading dataIn just about right. I'll check it op with analyzer in weekend or after. Next week I'm off duty................at work off course.
I'll post my code to you!

Max

HerrProfessor

Hi rdsman -

Have you made any progress in decoding this data?  I made the changes you suggested, but no luck.

tsc

rdsman

HerrProfessor:

I have made some progress.  I am not ready to associate my name with it, just yet. Real soon!

Ray

HerrProfessor

Ok, thanks. Just curious, but have you changed any values on your XR2211 circuit?  Hudibras and I have been getting nowhere using the audio samples I've captured.

Thanks again for your help!!!
tsc

HUDIBRAS

Hello HerrProfessor

I borrowed a Arduino Uno from Kim. Put up with a AVR Dragon, analyzing JTAG to get SAME_TX perfect, just remove this line from it.
PORTB |= (1 << PORTB3);    //  Return to the natural state.
The spike disappears completely.
The spike shows if last transmitted bit is "0" and the first bit in next byte is "0".
Could you spend some time adding a startbit and stopbit and remove carrier delay, you have a TX with self designed speed!

Max

rdsman

There are no "Start" and "Stop" bits used.  (I wish there were!)  You can set the Carrier Delay to "0" to eliminate it.

Ray


HUDIBRAS

#59
Feb 16, 2012, 12:25 am Last Edit: Feb 16, 2012, 12:28 am by HUDIBRAS Reason: 1
Hello rdsman

Right, please implement it, setting delay to "0" isn't enough.
As you can see, the first bit is lost from SAME tx. We have to shift bit's to we get AB, there is 16 of them. lockbyte

Max

Go Up