| Author |
Message |
|
|
Posted: Feb 10, 2008 - 09:42 PM |
|

Joined: Jul 28, 2007
Posts: 67
|
|
I am trying to build an AVR NWS weather radio SAME message decoder.
I have been researching the SAME (specific area message encoding) system, and its AFSK with a 2083.3 Hz bit 1 tone, and a 1562.5 Hz space tone.
also it has a 520.83 bitrate.
im not quite sure how to make a UART to read a 520.83bps rate. the AFSK decoder to decode the tones into bits, i can handle that. its not knowing how to read in the bits into a 520.83bps UART.
once i read in the bits into SRAM, i can handle it from there also. its the UART and bit-bang timing that i dont quite understand.
any ideas? |
|
|
| |
|
|
|
|
|
Posted: Feb 10, 2008 - 09:51 PM |
|


Joined: Apr 25, 2006
Posts: 2036
Location: Germany
|
|
use 16MHz oscillator frequency and use
pre-divider=1920 in an AVR:
16MHz/16/1920=520.83333.. Bit/sec. |
|
|
| |
|
|
|
|
|
Posted: Feb 10, 2008 - 09:59 PM |
|

Joined: Oct 07, 2002
Posts: 978
Location: Skørping Denmark
|
|
First I don't knoow how SAME works.
to find the two tone you need to sample the two tones, either with a filter (goetchel is very simple) or just by timming zero crossings. So as I can see a 0 is 3 full periods and a 1 is four, that's simple but how does the header work ? (the start of a message) and do you need to syncronize on the bits or can it be done at the header only ?
I would get a .wav file on a PC and the see what is needed using a PC C compiler (or often I use excel because it's so easy to plot with).
I think you will need a interrupt at 2083.3*4 Hz.
I would send the message from a buffer at a least 1200 baud.
Jens |
|
|
| |
|
|
|
|
|
Posted: Feb 21, 2008 - 11:13 PM |
|

Joined: Jul 28, 2007
Posts: 67
|
|
well getting the AFSK tones into 0s and 1s isnt hard. im going to use an AFSK decoder IC with bandpass filters.
but when it becomes its serial bitstream is where im going to have my problems.
im going to have my 520.83bps going to a port pin. |
|
|
| |
|
|
|
|
|
Posted: Feb 22, 2008 - 12:09 AM |
|


Joined: Nov 22, 2002
Posts: 7176
Location: Tangent, OR, USA
|
|
You do not use the UART. This is not async serial. It is a constant bit stream with no start or stop bits (section A.1.2). The header consists of 8 characters, every one being 0xAB. So, shift the bits into a shift register until you see that bit pattern and that syncs you to the frame. From then, on, shift 8 bits and read, shift 8 bits and read.
Jim |
_________________ Jim Wagner
Oregon Research Electronics, Consulting Div.
Tangent, OR, USA
|
| |
|
|
|
|
|
Posted: Jun 22, 2008 - 08:43 PM |
|

Joined: Jul 28, 2007
Posts: 67
|
|
|
ka7ehk wrote:
You do not use the UART. This is not async serial. It is a constant bit stream with no start or stop bits (section A.1.2). The header consists of 8 characters, every one being 0xAB. So, shift the bits into a shift register until you see that bit pattern and that syncs you to the frame. From then, on, shift 8 bits and read, shift 8 bits and read.
Jim
I know this thread is rather old, but I would like to pick back up on it again.
I'm not quite understanding what your saying, when you say shift until you see that bit pattern.
you have to shift at a certain speed? how would I calculate the speed at which to shift at? i know its 520.83bits per second, with a 1.92ms bit period.
only thing that comes to mind is shift one step, wait 1.92ms, shift another bit, and wait another 1.92ms.
I'm not exactly sure how to delay exactly 1.92ms. |
|
|
| |
|
|
|
|
|
Posted: Jun 22, 2008 - 08:57 PM |
|


Joined: Mar 27, 2002
Posts: 9264
Location: Lund, Sweden
|
|
|
Quote:
I'm not exactly sure how to delay exactly 1.92ms.
Use a timer.
Also, search this site for "bit banging" to find discussions on a related technique. Those talk will probably be on decoding asynch serial (eg. RS-232) but the techniques will be usable in your case also even though the link protocol differs.
One thing to ponder is to sample at three times the data rate, and have a "majority vote" on each bit (or simply deem the decoding as bad if there is a minority vote). |
|
|
| |
|
|
|
|
|
Posted: Jun 22, 2008 - 09:00 PM |
|

Joined: Feb 12, 2005
Posts: 7302
Location: Cratfield, England
|
|
You set a timer that runs every 1.92ms
You sample things like you would do with a UART. i.e. having got started, you read half-way through a bit period.
David. |
|
|
| |
|
|
|
|
|
Posted: Jun 22, 2008 - 09:04 PM |
|

Joined: Feb 07, 2007
Posts: 2395
Location: New Delhi, India
|
|
You can also consider using the excellent debouncing techniques mentioned elsewhere in this forum to get the bitstream into the AVR. Sampling at several times the expected bit rate as suggested above is one way.
Don't know the AFSK decoder you are using, but make sure the output is switching cleanly. If in doubt, use a Schmitt trigger to clean it up. |
_________________ If you think education is expensive, try ignorance.
|
| |
|
|
|
|
|
Posted: Jun 24, 2008 - 01:03 AM |
|

Joined: Jul 28, 2007
Posts: 67
|
|
another thing i stumbled upon is dividing a 1mhz crystal by 1920, and that gives the exact 520.83bps bitrate.
If i did this, i could use that division clock output to an interrupt pin, to read a bit each time that interrupt hits. wouldnt this work also? (im not familiar enough with math to figure out timers).
Im not sure exactly how to divide a 1mhz clock by this either. hehe. Thanks. |
|
|
| |
|
|
|
|
|
Posted: Jun 24, 2008 - 01:07 AM |
|

Joined: Jul 28, 2007
Posts: 67
|
|
| the AFSK decoder have seperate outputs. one output is high if the mark tone is detected, and another output is high if the space tone is detected. so you have a 10 and 01 situation. if its 11 or 00 its noise and to be ignored. |
|
|
| |
|
|
|
|
|
Posted: Jun 24, 2008 - 01:12 AM |
|

Joined: Jul 28, 2007
Posts: 67
|
|
The only thing that I have come up with is this:
AVR at 1Mhz. and a timer0 prescale at 8.
after 240 counts its at 520.83.
I'm not sure if my math is right, but i figured 1mhz / 8 is 125000, and i take this divide by 240 counts, its 520.83... So, im assuming this means, that i will hit count 240 exactly 520.83 times per second. (give or take the time required to reset the timer).
So, what do i do, reset the timer, wait until the count hits 240, then read the bit? shift it in, and then reset the counter, and wait again? Thanks.
your saying to read halfway in the bit, im not sure how exactly to do this. |
|
|
| |
|
|
|
|
|
Posted: Jun 24, 2008 - 01:17 AM |
|

Joined: Nov 03, 2006
Posts: 1120
|
|
| Don't bother about dividing a clock yourself, configure a timer as a counter to output an interrupt every 1.92ms. You can just use a prescaler to get it within range, and modify the TOP value to fine tune to exactly your bit time.. You could also resync the timer everytime you catch a preamble, so you don't lose sync over time... |
|
|
| |
|
|
|
|
|
Posted: Jun 24, 2008 - 01:45 AM |
|

Joined: Jul 28, 2007
Posts: 67
|
|
| only way i know how i could sync it, is as soon as i see a high bit, i start the timer, and stop it when i see the low bit, record and write the value to EEP or something. |
|
|
| |
|
|
|
|
|
Posted: Jun 24, 2008 - 01:47 AM |
|

Joined: Jul 28, 2007
Posts: 67
|
|
well if my math and thinking is correct, what i do know is if I use a 1mhz clock on the AVR, use timer0 with prescale of 8, the timer value will be at 240 approximately 1.92ms in. and it will hit 240 about 520.83 times per second. (plus or minus a few clocks to set/reset/clear timer).
And on a bit-bang you have to read half-bit times.
So the way i have it thought up is like this:
Wait 960uS. (about 120 timer value).
Read the bit, shift it.
Wait 1.92ms (about 240 timer value - time lost from reading/shifting bit so about 238).
Read next bit, shift it.
repeat cycle. after 8 bits shifted. check if AB. if not, then throw it out. and try again.
if AB, start SAME mode, and then store in RAM. increment RAM pointer, and bounce back to read subroutine to go read again.
I see where the timer would have to be adjusted because it takes time to crunch code to do stuff. so i have to trim off or add time to the timer when i go off and do stuff like shift the bits, save in ram, check and branch etc etc etc.
right?
but then again the timer is always counting no matter what your doing, so itll hit 120 or 240 or w/e your defined value is quicker. heck i dunno. |
|
|
| |
|
|
|
|
|
Posted: Jun 24, 2008 - 02:06 AM |
|


Joined: Sep 04, 2002
Posts: 13373
Location: Orlando Florida
|
|
| If you attach a wav file with some known content, and assert with grand aplomb that we are all so stupid that we cant possibly decode the file within a week, you will have 3 or 4 guys submitting the results of their SAME decoder within hours. If you can cajole or somehow coax them into selling/loaning/giving you the c source to their program, you are all set. |
_________________ Imagecraft compiler user
|
| |
|
|
|
|
|
Posted: Jun 24, 2008 - 04:31 AM |
|

Joined: Jul 28, 2007
Posts: 67
|
|
|
bobgardner wrote:
If you attach a wav file with some known content, and assert with grand aplomb that we are all so stupid that we cant possibly decode the file within a week, you will have 3 or 4 guys submitting the results of their SAME decoder within hours. If you can cajole or somehow coax them into selling/loaning/giving you the c source to their program, you are all set.
?? lol.. you just confused the heck outta me. hehe. |
|
|
| |
|
|
|
|
|
Posted: Jun 24, 2008 - 04:37 AM |
|


Joined: Sep 04, 2002
Posts: 13373
Location: Orlando Florida
|
|
| Can I just record it off a shortwave receiver? What freq? |
_________________ Imagecraft compiler user
|
| |
|
|
|
|
|
Posted: Jun 24, 2008 - 06:06 PM |
|

Joined: Jul 28, 2007
Posts: 67
|
|
no. SAME is broadcasted from the NWS weather radio network. the 162.xxx area of the band.
there is a sample file on wikipedia. |
|
|
| |
|
|
|
|
|
Posted: Jun 24, 2008 - 08:48 PM |
|


Joined: Apr 25, 2004
Posts: 3034
Location: Denmark
|
|
|
techknight wrote:
The only thing that I have come up with is this:
AVR at 1Mhz. and a timer0 prescale at 8.
after 240 counts its at 520.83.
I'm not sure if my math is right, but i figured 1mhz / 8 is 125000, and i take this divide by 240 counts, its 520.83... So, im assuming this means, that i will hit count 240 exactly 520.83 times per second. (give or take the time required to reset the timer).
So, what do i do, reset the timer, wait until the count hits 240, then read the bit? shift it in, and then reset the counter, and wait again? Thanks.
your saying to read halfway in the bit, im not sure how exactly to do this.
Are you using a real Xtal or the internal OSC (witch isn't very precise)
/Bingo |
|
|
| |
|
|
|
|
|