WhereAVR for APRS GPS/Telemetry
"WhereAVR"은 아트멜사의 ATmega8 기반의 APRS 위치추적(Tracker)/TNC(무선 모뎀)용입니다.
기존의 무선모뎀은 송수신기 + 모뎀 + MPU로 구성되어 있었으나, 이 장치는 모뎀을 생략하고,
ATmega8 (현재는 ATmega88로 업그레이드 됨)에서 모뎀의 하드웨어를 펌웨어 만으로 처리하였다.
WhereAVR은 작고, 가볍고, 저소비 전력, 그리고 저렴한 상용으로 나오는 TinyTrak과
공개소스 OpenTracker 같은 아마추어무선 패킷장치(APRS) 추적기(tracker)입니다.
경이로운 아날로그와 디지털 입/출력을 완전히 복합한 장치로,
매우 좋은 역량의 AX.25(Layer X2와 Layer X3의 중간수준) 패킷 변복조기이다.
실지로 TNC(무선모뎀)없는 원격명령의 수신이 가능하다.
이것은 휴대용 무선기의 스피커와 마이크 잭에 직접 연결하도록 설계되었다.
하나의 경고, 그러나, 현재는 다른 제품처럼 멋진 설정 지원기(utiliy)를 가지고 있지 않다.
나는 윈도우즈 프로그램을 못한다. 그래서 이 특징은 기다려야 할 것이다.
음성통신용 일반 무선기기(RAdio Tranciever)로 데이터를 전송하려고 할 때,
데이터 장치와 무선기기 사이에는 반드시 무선모뎀(Terminal Node Controller)을 사용해야 하는데,
이때, TNC의 입/출력은 무선기의 저주파 신호인 스피커 출력과 마이크 입력에 연결된다.
APRS는 데이터의 송신원으로 GPS를 사용하고, 원격지에서 수신된 신호는 송신자의 위치와 ID를 표시한다.
Inspiration for this project stemms from recent activity with a local college,
The University of Alabama in Huntsville, and their high-altitude balloon projects.
As part of the electrical engineering senior design course, students propose, design,
and build a series of experiments which are routinely lifted to 95,000 feet and above.
A common package on every flight is a "communications package", which houses a radio, tnc, and battery pack.
The TNC is a Kantronics KPC3 Plus which they use for GPS tracking and telemetry,
as well as attempting to initiate a cut-down commands.
The problem is that the TNC seems to be a point of contention, often causing much consternation.
Since I too enjoy ballooning, I set out to design a board which could be interfaced to a GPS receiver
and used as a tracker, could also send telemetry,
and possibly even decode packets in order to command actions in the payload.
Naturally, it would also have applications in remote monitoring such as weather stations,
repeater control, actuation in difficult to access areas, etc.
My goals for the board were for it to be cheap, low power, and light, as well as dependable
and easy to reproduce. Oh, one more thing... I did NOT want to have to use an MX614!
(1) 하드웨어 부품
From the start, I knew I would be designing the board around the Atmel ATmega8.
And there are several reasons for this.
I have had a lot of luck using the ATmega8 in prior projects and find it easy to program.
It can be programmed in-circuit, has a variety of built-in functions, and runs blazingly fast.
I had also found it to operate in extreme conditions just fine
- a situation I'd be subjecting it to at -30 degrees Celcius on balloon flights.
Finally, the price of around $3.00 each makes them nearly disposable.
Beyond the microprocessor itself, there are a couple active components and a handful of passives.
Some of the components are for direct microprocessor support - the 14.7456 MHz crystal being one.
But most components are in support of additional features.
They can be left off the design if the feature they support is not desired.
I'll discuss the sections of the schematic further below:
I have a couple LED's for transmit and DCD detect indication,
and a level converter for the GPS receiver.
There is also a section set aside for loading voltage dividers
in order to scale inputs to send into the analog-to-digital converter.
Mega8 소프트웨어 Modem방식의 TNC 회로도
복조된 신호는 ATmega8의 ADC로 직접 입력되고, ATmega8 출력의 4비트 DAC는 변조신호를 직접 출력한다.
데이터 전용 무선기기를 사용할 때에는 복조출력과 변조입력으로 연결되는 전용 콘넥터에 직접 연결한다.
무선으로 데이터를 송수신하는 문자전송 장치의 전체 구성
GPS, TNC와 무선기를 이용한 DGPS 장치의 구성
송신 TTY를 GPS 수신기로 교체하고, GPS 출력을 TNC로 연결하면,
수신 TTY에 송신측 GPS의 위치정보가 나타나고
수신 TTY를 DGPS 수신기로 교체하면, 수신 DGPS에 송신측의 GPS 신호로 보정된
보다 정밀한 위치정보가 나타난다.
또한, GPS 신호를 데이터로 송신하는 DGPS 무선송신국들이
국가 기반시설로 해안을 따라서 설치되어 운용중이다.
Like the other trackers, I chose to generate the 1200-baud audio signal
using a straightforward resitor digital-to-analog ladder.
If you compare this section of the circuit to that of the TinyTrak,
you will find it is a component-for-component copy.
I hope Byon doesn't mind. By presenting a rising or falling binary value
on the port connected to the resistors, an analog signal is generated.
With the proper software, you can generate nice sine-waves used to
modulate the carrier transmitted by a radio.
The output of this d-to-a converter is hooked to the radio microphone jack.
I also wanted to decode pakcet as well, remember?
To that end I chose to build a simple zero-crossing audio signal detector
using the internal comparator of the ATmega8.
The incomming signal is capacitively coupled to the center
of a voltage divider running from power to ground.
This point is then connected to one of the camarator input pins of the microprocessor.
This divider is set to a voltage very near to a 1.25v bandgap reference,
which is contained in the chip and is chosen via software as the other input to the comparator.
In this arrangement, every time the incoming signal passes through "zero" volts,
the internal comparator triggers a software interrupt.
For pure sinewaves, this "zero-crossing" occurs twice per cycle.
By measuring the period between interrupts, I can tell the incomming audio frequency.
(4) GPS 수신 레벨 변환기
This circuit is another straightforward design.
All I do is use a single transistor as an inverter driven with the input from the GPS.
Now that I think of it, I could leave out the pullup resistor as the ATmega8 has internall pullups. Oh well. :)
(5) 전원 공급기
I needed 5 Volts to run the microprocessor and offboard GPS receiver.
I decided I wanted a boost converter of some type for the design.
It's easy to use a simple LM7805-variant to regulate a higher voltage to 5 Volts,
but boosting sub-5 Volts is more challenging.
So I figured it would do well to go ahead and provide a place
for some surfance mount components to do just that.
Turns out it was a good idea*.
The design is based on a National LM2731 [pdf datasheet].
It is an efficient swtiching design. In lieu of explaning the circuit,
I'll just refer you to the datasheet.
I replicated their 5-Volt reference circuit and used their suggested board layout.
It works great.
*For the radio on balloon flights, I use an Alinco DJ-S11T.
It is small and lightweight, and while it has a poor stock antenna,
this can be fixed without too much work.
What's nice though is that the radio holds three normal AA-sized batteries,
and I use those three batteries to power the rest of the box by running some wires out of the radio case.
During flights, I use Energizer Lithium batteries.
Three of them can run the entire communications package, consisting of the radio, the WhereAVR board,
and a Garmin GPS 18, for almost 24 hours. But with only three AA batteries,
I only have at most 4.5 Volts to work with. The boost circuit of the power supply handles this fine.
In fact, the board continues to run long after the radio ceases to operate.
The radio gives up at 3.25 Volts, the WhereAVR runs down to 2.1 Volts.
(6) 인쇄 기판 설계
For this project I decided to design a board and have a few built.
I figure a balloon payload is always at risk for loss if it can't be found after landing,
and having a few spare replacements around takes the edge off losing a payload.
In the downloads section below you'll find a couple board files in ExpressPCB format.
One card holding two boards meets their "Miniboard" format.
That way I only pay $10 a board. You'll also find a file showing just one board.
I included this one to show it oriented upright for easier viewing.
Mega8 AX25 패킷장치의 부품 배치도
This is where all the cool stuff happens. Software in the WhereAVR is written totally
in C and compiled with the freely available GNU GCC compiler.
The compiler is part of the WinAVR suite of development tools
for the Atmel AVR and it couldn't suit my needs better.
It is an open-source program, comes with great documentation,
and support is available through many groups on the web.
At the bottom of this page you will find a link to all of the source code for this project.
In it you may find I went overboard with commenting my code, but I can't help it.
Not only can it help others learn a few tricks,
but it also helps me years from now when I look back over it and ask,
"What on earth was I thinking when I wrote this?"
(1) 정현파 발생기
The MARK/SPACE modulation tones generated by the WhereAVR are born in the digital world.
Since the D-to-A converter is only 4-bits,
the sinewave values are approximate, and range from zero to 15.
Zero is 0 Volts, and 15 is 5 Volts. In a spreadsheet,
I set up a mock sinewave spanning this zero to 15 integer spread.
It was split into 16 equally-spaced segments (ie. each segment is 8/pi) and for each segment,
the nearest integer approximation to that value was chosen.
An interrupt service routine is programmed to increment to the next value each time it is called.
To get a MARK sinewave at 1200 Hz., the routine is called at 19,200 Hz.
And likewise the routine is called at 35,200 Hz. to generate the 2200 Hz. SPACE tone.
Refer to the source code linked below for more details.
(2) ax.25 문장 생성
I feel like referring you to the source for this section, so I will.
There you will find an ax25.c file which should explain most of what is going on.
But as a primer, I will direct you to two other references.
One is the APRS101.pdf document.
It is definitely something you want to check out as it defines all of the standard APRS messages. Secondly,
I must point out that my source file grew out of the one by Zack Clobes,
W0CZ, a memeber of RCKARA.
It's hardly recognizable since I essentially rewrote it to make sense to my brain,
but his work is definitely in there. As is John Hanson's, W2FS, who I believe wrote it originally.
(3) 패킷 복조(Demod)와 복호(Decoding)
Recall what I began explaining in the hardware section.
There I mentioned that when an input signal is conditioned and sent into the analog comparator,
I am able to detect zero-crossings of the signal.
And recall how a tone (a sinewave) crosses zero twice per cycle.
[Draw one and prove it to yourself.] Well as it turns out in 1200 baud packet
for the two tones MARK and SPACE (or 1200 Hz. and 2200 Hz., respectively),
at least one cycle of each tone is contained in the incoming audio signal for each tone toggle.
When the zero-cross triggers an interrupt in the micro,
I take note of the time which has passed since the interrupt was last called.
And based on this time, I can tell the frequency of the signal which is input.
Amateur radio packets are easy to generate, but a challenge to receive.
Each bit in each byte is sent least significant bit first, and each bit is prepresented as a toggle,
from MARK to SPACE or SPACE to MARK, for the value of zero, or the absense of a toggle for a 1.
The MARK/SPACE toggle rate for all zeros is 1200 Hz. But what if we want to send all ones?
Well, then after every five consecutive ones, a "filler" toggle must be inserted.
This keeps the receiver synchronized to the transmitter.
Each time the comparetor interrupt occurs,
it additionally checks to see if the last tone detected is the same as the new tone detected.
If it is, it sets a "tone just toggled" variable to true.
Another timer-based interrupt service routine, which runs at 9600 Hz.) looks for "toggle" to be set
and uses this to stay synchronized with the remote transmitting station.
After each "toggle" it starts a sampling routine which waits 1.5 bit periods before it samples the next bit,
and then each bit after that is sampled after one bit period has transpired and so on...
until ANOTHER toggle is sensed, which then serves to keep everything in sync and it all starts over.
If the toggle occurs after five consecutive ones, it is ignored since it is filler.
If it occurs after six consecutive ones is is recognized as a special "Flag" character,
which precedes valid ax.25 sentences.
Ok, I'll be the first to admit that I butchered the explanation.
I will gladly post a link to a better explaination here if someone points me to one.
Since I'm talking about links, here's a link to Mike Berg's page.
His page was the inspiration for this project.
Unfortunately, my assembly is so rusty that I didn't get much from his source,
but I know it works great because I have witnessed a chip programmed with his code in action.
(4) Message 생성과 처리
The rest isn't much more than messing with character arrays.
I store my "canned" transmit headers, one with a path and one without, in EEPROM.
I also store status text and whatnot in there.
You'll see the code for reading those sections in the source.
When creating and decoding sentences,
it's important to remember that all the bytes in the header are shifted one bit to the left.
And only the last byte has bit zero set, signaling the end of the header.
This took me hours to figure out.
Actually, there are hundreds of hours in the code, but that was the one "brainslap" realization.
Currently, the WhereAVR is programmed to acknowledge any message consisting of one character
and a request for acknowledgement.
It also sends all the valid decoded packets it receives out the serial port pin.
This was super-useful for debugging, and pretty cool to boot. :)
I addition to hundreds of hours of bench operation,
the WhereAVR has flown on three flights above 90,000 ft The first time it worked up to altitude,
but stopped working at balloon burst due to a presumed power faliure.
On the second flight it worked flawlessly, transmitting it's position
and acknowledging commands during the entire flight.
Unfortunately, it became almost inextricably caught in a tree upon return.
After a tortuous 45 minutes of hell at the end of a tree branch being violently shaken,
the eyebolt was finally torn from its styrofoam enclosure.
Despite this, the board and the tattered box's contents continued operating for another 15 hours.
The third flight was also a successful test... though I'm afraid I'll never get the board back
as it floated out over the Atlantic and was going 111 mph on a beeline for Bermuda. :)
All in all I feel I was successful in accomplishing what I set out to do,
and that was to essentially build my own no-frills TNC with as little as possible.
I'm continuing to make improvements as time goes on.
Eventually, it might be nice to reduce the design to surface mount to save further
on weight and ease of construction.
Yes, I find surface mount easier than through-hole.
Also, I have only used little more than half of the 8K program space of the ATmega8,
so there's tons of space left in there for all kinds of fun bells and whistles.
소스 : WhereAVR_18JUL2005.zip : http://www.knology.net/~gdion/files/WhereAVR_18JUL2005.zip
회로 : ax25.sch : http://www.knology.net/~gdion/files/ax25.sch
기판 : 단면 파일 : http://www.knology.net/~gdion/files/ax25_single.pcb
기판 : 양면 파일: http://www.knology.net/~gdion/files/ax25.pcb
|AVR 13.56MHz RFID 읽기/쓰기 장치의 제작|
|ATmega8 UI-TNC 무선모뎀의 제작|