Go Down

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

rdsman

I wouldn't duplicate my hardware example just yet.  I still have a lot of adjustments to make, some hardware, some code.  I now have multiple Arduinos (Arduinii ?).  I plan on programming one to emulate the output of the XR2211 and see where it takes me......

PS:  Can someone tell me how to post a picture?  All I get is

HerrProfessor

Do you need sample audio files?  I've got several that I can send if you want (TOA, SVR, TOR). Just let me know

Thanks,
tsc

HUDIBRAS

Yes please the one you most want to be decode, more or less than 10Mb sample?

rdsman

Here is my shot at using an Arduino to emulate what a XR2211 receives from a NOAA Weather Service SAME message.

Code: [Select]
/*
 
  Arduino program for emulating the XR2211 receiving National Weather Service (NWS)
  Specific Area Message Encoding (SAME) messages.

  Compiled with Arduino version 1.0 using ATMEGEA328 - Not Intended To Be Universal!

  Characters are shifted out LSB first.  The received bits are inverted - A low = "1" and a high = "0".  This is how the XR2211 receives data.
 
  28 JAN 2012
 
*/
#include "Arduino.h"
#include <avr/delay.h>
//
//  SAME Message Constants.
//
#define BIT_TIME  1.908  // Bit Time adjusted to generate 1.92 ms bit timing.  Averages out real close.
#define CARRIER_DELAY 2  // Number of bits received before carrier detect is active - goes low.  Anything greater than "0" is OK.
#define PREAMBLE  0xAB
#define PREAMBLE_COUNT  16
#define MESSAGE_COUNT 3
#define EOM_COUNT 3
//
//  SAME Message Strings.
//
const char MESSAGE[] = "ZCZC-ORG-EEE-PSSCCC-PSSCCC+TTTT-JJJHHMM-LLLLLLLL-";  //  Sample messsage from page A-3 of the Technical Specifications.
const char EOM[] = "NNNN";
//
//  Global Variables.
//
int bit_count;
int i;
//
//  Setup Loop.
//
void setup()
{
  pinMode(13, OUTPUT);  //  Digital Pin 13 - On to indicate activity.
  digitalWrite(13, LOW);
 
  pinMode(12, OUTPUT);  //  Digital Pin 12 - Carrier Detect.  Goes low during Carrier Detect.
  digitalWrite(12, HIGH);
 
  pinMode(11, OUTPUT);  //  Digital Pin 11 - RX Data.  High = 0, Low = 1 (Bits are inverted).
  digitalWrite(11, HIGH);
}
//
//  Main Loop.
//
void loop()
{
  for (i = 1; i <= MESSAGE_COUNT; i++)  //  Sends the SAME message 3 times with a 1 second delay between messages.
    {
      transmit(MESSAGE);
      delay(1000);
    }
 
  delay(5000);  //  Delay 5 seconds.

  for (i = 1; i <= EOM_COUNT; i++)  //  Sends the SAME end of message 3 times with a 1 second delay between messages.
    {
      transmit(EOM);
      delay(1000);
    }
 
  delay(5000);  //  Delay 5 seconds.
}
//
//
//
void transmit(const char *str)
{
  PORTB |= (1 << PORTB5);  // Turn on the LED.
   
  send_preamble();
 
  while(*str)
    send_char(*str++);
   
  _delay_ms(BIT_TIME * CARRIER_DELAY);  //  Carrier detect is delayed at both the start and stop.
 
  PORTB |= (1 << PORTB4);  // Turn off Carrier Detect.
 
  PORTB &= ~(1 << PORTB5);  //  Turn off the LED.
}
//
//
//
void send_preamble()
{
  bit_count = 0;  //  Reset the bit counter.
 
  for (int i = 1; i <= PREAMBLE_COUNT; i++)
    {
send_char(PREAMBLE);
    }
}
//
//
//
void send_char(byte tx_char)
{
  for(int i = 0; i <= 7; i++)
   {
     if (bitRead(tx_char, i))
       PORTB &= ~(1 << PORTB3);  //  A "1".
     else
       PORTB |= (1 << PORTB3);   //  A "0".
     
     _delay_ms(BIT_TIME);
     
     PORTB |= (1 << PORTB3);    //  Return to the natural state.
     
     bit_count++;               //  Increment the bit counter.
     
     if (bit_count >= CARRIER_DELAY)  //  Generates the carrier detect on time delay.
       PORTB &= ~(1 << PORTB4); 
   }
}
//
//  The End.
//


Next step is to try and decode it correctly!

HUDIBRAS

Hello rdman
What are Arduino.h for, are you using IDE 1.0?

Are you checking/using (sync start) with the carrier from above sample. I haven't received sample yet, are they starting with 7E just like AX25?
I really look forward to a sound sample!

HerrProfessor

Hi Hudibras - I'm so sorry about the file, I've had the flu. I should be able to send to you tomorrow.

tsc

HerrProfessor

If anyone else needs some example audio files with the SAME data transmission, I have zipped up three files (Tornado Watch, Severe Thunderstorm Warning, and Tornado Warning) along with a readme file explaining the recordings and a decoded sample from another software based solution.  They can be downloaded from my website here:

https://umdrive.memphis.edu/tcanaday/www/SAME/SAME_Sample_Files.zip

rdaman - would you happen to have a schematic of your XR2211 circuit?  For some reason, my Carrier Detect line is always on, whether there is audio or not.  I don't think I have the circuit quite right.

Thanks everyone!!
tsc

HUDIBRAS

Hello rdsman
The timing off your TX part is perfect, calculated by logic sniffer to 526 baud.
The RX part is running without control, you'll have to intterupt FALLING to sync into place. Quickly disable interrupt.
Then check state halfway in first bit, and then check every full bit time to you got 8 bit (1 byte). Maybe you want to make with a software timer, then you can do a lot off other stuff.
Activate intterupt again after EOT "NNNN" EOM

rdsman

HerrProfessor:

I'm out of town for a few days, so I'll send you the schematic when I return.  When you say "It's always on" do you mean high or low?

HUDIBRAS:

I set the timing so that a single "1" or "0" would be as close to 1.92 ms as possible.  On the receiving side, I plan to sample each bit multiple times and make a majority vote on it.  All messages are repeated 3 times with 1 second between them.  The time between MESSAGE and EOM is completely variable.  I just threw it in there at 5 seconds so that anyone following this would have something to play with.



HerrProfessor

I'm using the LDOQ line (pin 6) on the XR2211.  I do not have this connected to Data Out (pin 7) like shown on Figure 11 of the XR2211 data sheet.  The output is always LOW, with or without audio in.

rdsman

Both pins 5 and 6 are open collector.  You either need an external pull-up resistor on use the internal pull-up in Arduino. 

pinMode(X, INPUT);
digitalWrite(X, HIGH);

If this doesn't do it, you have something else wrong.


HerrProfessor

ok, I was just trying to use a LED to indicate CD on my breadboard.  I used a 1K pull up.  When I get home, I'll try adjusting some values.

Thanks again!
tsc 

HerrProfessor

I was able to check the output with a scope just using a pull-up resistor (1K) and no LED attached.  No matter what, the output is always low (audio applied or no audio).

I don't think I have the XR2211 circuit set right - I'll just wait for the schematic to see how you have yours set up.  I am getting data pulses from pin 7, just no carrier detect.

Thanks,
tsc

HUDIBRAS

Carrierdetect is defined by CD and RD see page 17 in app.note. I have CD=100nF and RD=470K 10%, but not using carrier output. Try changing the pull-up to 4,7K or 10K! What are the values you are using for CD and RD?

HerrProfessor

pretty much the same except the capacitor - CD = 1 uF electrolytic, RD = 470 K (the same that rdsman advised he was using in a previous post).

Go Up