APRS repeater using PIC18F26K22 MCU

 

Foreword:

Internet has been sweeping almost everything away, so we thought the age of packet radio was over. Fortunately Bob Bruninga WB4APR saw it differently, and he developed the APRS protocol at the end of the eighties. APRS stands for Automatic Position Reporting System. The name of the protocol suggests this system is used for communicating our geographical position only. However, the APRS protocol is much more complex and is useful for many purposes. With the help of this protocol in addition to our position we can send meteorological information, telemetric data, and personal messages and above all, it can help in case of emergency or provide information about several useful activities. The base of the whole system is the AX.25 (packet radio) protocol. In this case only UI frames are used. The APRS system is not a network. It is not necessary to build up routes, and because only UI frames are used, it is not necessary to log in to a network. It is enough to send out our information, and in case we are in the vicinity of an APRS digipeater then the system completes all tasks when receiving our packets.

The whole system can be divided into three parts:

  1. User equipment, e.g. tracker, meteorological station, telemetric station.
  2. Digital repeaters, which receives primary data and transmits them in the system.
  3. Internet gateways, which play the role of a transition unit between the amateur radio system and the Internet, making it possible to get our sent information into its intended destination. Usually this is a website which can present the information in a more user friendly format on a map.

Because in Europe the 144.800 MHz frequency was chosen for the APRS system, there is no need for additional frequency coordination.

 

Hardware:

In connection with the digipeater I built around the PIC16F867A processor, I have received several feedbacks that its reception was good only with a clear and very high-quality input signal. Everybody wished for the return of the good old TCM3105. I decided to give another chance for that modem IC. That is why I have designed a completely new degipeater. Since the decoding of the audio signal is carried out by the modem IC, the accurate timing in the processor was not important. This allowed me the comfort of not having to write the software in assembler. The advantage of this is also that it was not difficult to implement new functions, but unfortunately there was not enough room for it in the PIC16F876A. I have chosen the PIC18F26K22 because it has the largest memory among the 28-pin MCUs and its price is acceptable as well. Since microcontrollers these days integrate many peripherals, the whole equipment requires only 3 ICs (plus voltage regulator), 2 crystals, 5 connectors and some passive components altogether. The used voltage regulator may be a bit overkill here, but it can provide 1 A of current without cooling. Who has enough room may use a linear regulator, but if a GPS receiver is also connected, one needs to use a rather large heat sink (which is not suitable for a battery powered portable mode of operation). As the 28-pin IC has been chosen because of its memory size, some free inputs remained, which may be used to change configuration parameters.

The functions of the jumpers are:

That let the program have enough time for each task, inner PLL is switched on in the processor, and like the 10 MHz crystal reports a 40 MHz clock rate.

Software:

The software consists of several main functional parts.

Command interpreter  - The basic part of the program which is responsible for communication with the program itself. This module interprets the entered text and executes the given command.

Radio reception of incoming data - This module receives incoming signals, handles NRZI coding and bit stuffing. It puts raw ASCII characters into the temporary container. The success depends on this part of the program. If received signals are processed well, the other tasks are just playing with the data.

Monitor - The purpose of this module is to display what happens on the radio channel. It may operate in four possible ways.

 Trace - Displays the raw traffic of the channel. It sends received data in hexadecimal form to the serial port. It has three possible variant:

Beacon - This part of the program broadcasts the power on state of our device. One may choose from two types of messages. BTEXT 1 is the message which is sent by the digipeater in defined regular intervals. In case we set a BTEXT 2 message as well, then the TAIL command sends this text.

Example

If TAIL 5 then 4 times BTEXT1 and 1 time BTEXT2
!4815.91N/01949.21Ey BCDIGI v.2.2 Qth Filakovo
!4815.91N/01949.21Ey BCDIGI v.2.2 Qth Filakovo
!4815.91N/01949.21Ey BCDIGI v.2.2 Qth Filakovo
!4815.91N/01949.21Ey BCDIGI v.2.2 Qth Filakovo
!4815.91N/01949.21EyPHG32304/A=000577 BCDIGI v.2.2 APRS Repeater with PIC18F26K22 – http://www.om3bc.com

The frequency of BTEXT 1 BEACON EVERY n, repetition of BTEXT 2 may be chosen by TAIL EVERY n command. In the first case n means time in minutes, the value may be 0 and 99, in the second case the value of n may vary between 0 and 9. Zero means beacon text is disabled in both case and will not be transmitted. You can obtain the same by using BEACON OFF or TAIL OFF command as well. There may be commands regarding temperature, running time and supply voltage which meaning is

The commands t, s, h, l, and a are only valid for the temperature sensor connected to the P13 connector. The T1, T2, T3, T4, and T5 values always show the actual temperature. The unit of the temperature (Celsius or Fahrenheit) can be selected by TEMP C or TEMP F command. The unit is transmitted after the temperature value. In case of measuring supply voltage, a voltage divider must be used to prevent the MCU input from getting higher voltage than 4 V.
The \r command displays the time elapsed since the last start of the TNC.
The \f command inserts the value of the counter into beacon text. The input of this counter is the P3 connector and the appearing value is the half of the number of impulses sent to it. This input is first of all appropriate to measure the number of turns of fans used in PCs where the  appearing value is equal to the turns per minute of that fan. Connections: Black is GND, red 12V, yellow P3 pin 2. The voltage & temperature value sent in beacon text is completely independent of those described in telemetry part.

The APRS system rules are applicable for the beacon text format APRS.

Calibrate - This command may be used to verify and calibrate data transfer speed towards the radio. 600 Hz square wave signal must be appear on pin 27 of the MCU.  This frequency can be changed by U(p) or D(own) commands and exit using the E(nd) command. According to experience the calibration is not necessary. This command can be used to switch the radio to transmit continuously which makes it possible to adjust deviation.

Digipeat - The task of this program is to incorporate this device into the APRS system. Its function is roughly like this.Interprets data received on the radio. In case it finds its own callsign in the list of repeaters, it drops the whole packet to avoid creation of a loop. If it finds WIDE, then decrements the SSID of the WIDE. When SSID is zero then replaces it with its own callsign. If not, then it inserts its own callsign in front of WIDE. Then it sends the whole packet. If the value of the SSID is zero of the highest WIDE in the received packet, then it does not forward that packet. A list of callsigns can be given to the digipeater, which the repeater should ignore. Such case may be when some of the neighboring repeaters were set up incorrectly and there is a risk to create a loop. The program is watching the sender of the packets continuously. In case it finds any packet arriving through several routes, then it repeats the given packet only at the first time. This is necessary when the repeater hears several other repeaters. It is not required to let that given packet to be repeated all times. Next function is the FILL IN DIGI. In this case digipeater repeat only packets from the source stations.
If you don’t disable the repeater using DIGIpeat OFF command, then it will operate in both tracker and telemetry mode.

Tracker - This part of the program is an independent unit. After closing jumper P8 you get a complete tracker. In this mode the equipment communicates with GPS receiver through the serial port. Based on the set parameters and the received data, it sends the actual position according to speed or set interval. It can be done so, that it sends the raw data (RMC, GLL, GGA) without processing or sends the processes and compressed data according to APRS MIC-E specification (this is the recommended form - less data can get through with higher probability without errors). This can be chosen by the P5 jumper (Default position is open which is the MIC-E format). The frequency of sending is influenced by P6. In closed position it sends data according to the HOLD OFF parameter. Do not choose value less than 30. The value is in seconds. Use this option for testing or during hiking, and do not fill the band with garbage when we are standing for long minutes. The value of HOLD OFF time may be between 10 and 99. When the jumper is open, then times belonging to speeds are as follows:

0          4          11          24         50          80          120             km/h
    256      200       120          60         30           20           10      sec

The two LEDs on the right of the serial port socket show if there is a connection with the GPS receiver. If the CRC of received data is correct then the upper LED lights up. When the GPS receiver has found our actual position (it may take some time according to the receiver) than the lower LED lights up as well, showing everything is all right with the GPS receiver and the equipment is ready to pass along our geographical position. Naturally till this state does not set in, the tracker does not send any kind of data through the radio. If the tracker is not used in a car, we may choose another symbol from the  table of the graphical symbols, which is to be written among the parameters. By jumpers P7 and P8 we can choose what we are doing right now even during drive or walk. (Only in MIC-E mode.) Four possibilities can be chosen by these two jumpers:

When the jumper is in default position (open) it means en route, because this is the most often used situation.

Telemetry - This mode can be used to send on telemetry data. The hardware is able to send 5 analog or temperature signal, and 4 one bit signals. This mode can be reached by issuing the TELEMETRY ON command or by closing the P9 jumper. The command interpreter works as well, and several parameters may be changed in this mode too. More details can be found here: http://www.aprs.net/vm/DOS/TELEMTRY.HTM. The length of PARM, UNIT, and EQNS may be maximum 80 characters long. The length of BITS may be maximum 50 characters long. The U1 to U5 inputs are sent first on the manner set in the definition (voltage, temperature). Then comes the 8 bit unit from which the upper four are always 0, and the lower four gives the states of P5, P6, P7, P8 (zero when closed, one when opened). The time between two transmissions depends on the setting of BEACON EVERY n, the frequency of the parameter broadcasts can be set by TAIL EVERY n command. In normal cases only data will be sent in the T#sss,111,222,333,444,555,xxxxxxxx format. In intervals set by the TAIL command, the PARM, UNIT, EQNS, and BITS texts are sent as well. The interval between two packets is then five seconds. DEFS command sets whether an analog source or a DS1820 thermometer is connected to the corresponding input. The format of this command is DEFS 12345. For example the DEFS AA00T setting means that the first two inputs (U1 and U2) are analog voltage, the next two (U3 and U4) are not used, and the last one (U5) is the thermometer. When any of the first two inputs (or both) are also connected to a thermometer, then the command would look DEFS TT00TT (AT00T, TA00T, etc.). When using thermometer do not forget to connect the 4.7 k resistor which is necessary for the thermometer operation. If raw data is set on (RDATA ON), then value for voltage is from 0 to 999, and for temperature is n = (temperature + 50)*2 (EQN:0,0.5,-50). In case when we are the addressee of the packet with telemetric data, this packet does not get transmitted, but the content of the packet appears on the serial port. At this time it is beneficial to turn off monitoring using the MON OFF command. In this case the telemetry data is sent only to the serial port, where they can be easily processed by a PC.

It is necessary to grant these parameters, when setting up the program or you may choose from these opportunities as follows:
 

FILTER ON/OFF - when ON, only the printable characters are sent to the serial port
ECHO ON/OFF - when ON, sends back the
received characters on the serial port
TEMP C/F – the unit of the temperature measurement
TXDelay – the time between activation of PTT and the sending of the first data – actually the number of FLAGs sent before each packet
PERSistence - the watching of a busy channel.
TXTail -
the time between the last data and deactivating PTT – the number of FLAGs sent after each packet – the smallest possible value is 2
GPS $GPRMC/$GPGGA/$GPGLL which raw packet is to be sent in tracker mode - MIC-E always uses RMC
TRace RCV/XMIT/OFF – tracking mode for testing
MONitor ALL/RCV/XMIT/OFF – monitoring of the channel
DIGIpeat ON/OFF – switching the repeater on and off
FILLindigi ON/OFF – switching the "Fill In Digi" mode on and off
SUPPress ON/OFF – enables or disables sending of multi packets
CONverse ON – to switch interactive mode on (can be switched off by CTRL-C)
CALibrate ON – calibration of the channel towards the radio
BEACON EVERY n – beacon sending repetition time
TAIL EVERY n -
In TNC mode of operation, every nth beacon will send text set in BTEXT 2, otherwise text set in BTEXT 1. In tracker mode of operation, every nth message will be appended with the text set with the TTEXT command.
SYMBOL – it can be chosen to what symbol to appear on the map on http://www.aprs.fi/ website
HOLDOFF n -
if we do not want to send our position according to the actual speed, then the repetition time can be set with this parameter, where n is the time in seconds.
UCAL n - Calibration of analogue input U1:
Apply voltage to input U – possibly across a voltage divider (ensure maximum 4 V is on the MCU pin!). Adjust a given voltage – say 12 V and type in UCAL 12 and the MCU will calculate the coefficient and saves this value.
VCAL n Calibration of analogue input U2: It’s the same procedure as in case of UCAL.
XCAL n Calibration of analogue input U2: It’s the same procedure as in case of UCAL.
SERCOM –
serial port data rate in TNC mode, possible values are 48 (4800), 96 (9600), 192 (19200), 384 (38400), 576 (57600) and 115 (115200) bauds.
GPSCOM -serial port data rate in GPS mode. (Some as before.)
UNproto – callsign of the far station –APE260 (PIC processor) plus the version number of the software, VIA repeaters.
Maximum three VIAs may be used (generally WIDE1-1, WIDE2-2, WIDE3-3). For example UNPROTO APE200 via WIDE1-1 via WIDE2-2 via WIDE3-3. Instead of via you can use v only.
MYCall – own callsign (mandatory)
BTEXT 1 – the first beacon text, this one is sent more frequently, its maximum length is 200 characters
BTEXT 2 – the second beacon text, its maximum length is also 200 characters
TTEXT –
this text is sent in tracker mode appended to every nth message sent, it can also contain voltage and temperature values, its maximum length is 100 characters
DCALL –callsigns to be banned. You can put in altogether ten callsigns.
All callsigns are to be entered using a separate command. By using DCALL RESA one may remove all banned callsigns, and by DCALL RESn the nth callsign.
PARM – parameters in telemetry mode.
UNIT – units in telemetry mode.
EQNS – conversion constants in telemetry mode.
BITS – the active state of one bit inputs plus the name of project in telemetry mode.
DEFS –definitions of inputs in telemetry mode.
RDATA - raw data in telemetric mode
PARAM ON/OFF – in case of ON parameters, in case of OFF the BTEXT 1 is to be sent.

The last but important command is HELP. In our final despair with our problem we may ask for help.

It is enough to use the part of commands written in capital letters.

The repeater can be programmed with parameters from a remote place. In case of trouble the only help can be this possibility. For this, it is necessary to set a password with the REMOTE command. It may be any ten character long text. The default is 0000000000. This password must be set both in the local and in the remote controlled TNC. Remote control can be carried out by putting the callsign of the TNC to be controlled as the UNPROTO callsign in our own TNC.  Issue the command CONVERSE ON in our own TNC. By this we get into interactive mode, which means that the text typed in at our station will be sent without change, so that the addressee is the UNPROTO callsign, and we are the sender. Next to the two callsigns at the beginning of the data field is the password, then a space, and then the typed text itself, which may be a command and the belonging parameter. We can work as if we were directly connected to the serial port. Only the commands DISP and HELP will not works, because the answer would not fit into a single packet. We can leave the CONVERSE mode by pressing CTRL+C.

There are five connectors on the PCB – serial port, radio, supply voltage, thermometer and analogue input.

The connections are as follows:

Serial port:
          2 - TxD
          3 - RxD
          4 - +5V (in case of closed jumper)
          5 - GND
          9 - +5V (in case of closed jumper)

Radio:
          1 - +12 V in (supply voltage)
          2 - audio out
          3 - GND
          4 - GND
          5 - audio in
          6 - PTT

Power supply:
Outer connector GND
Center connector +8V to +24V may be applied.

Thermometer DS1820:
           1 - +5V
           2 - DQ
           3 - GND

Analóg bemenet:
           1 - GND
           2 - U1 (U input)
           3 - U2 (V input)
           4  - U3 input
           5  - U4 input
           6  - U5 (T) input
           7 - +5V

There are four LEDs on the PCB. Functions of these are as follows:

           D5 - DCD
           D6 - GPS data is correct
           D7 - Equipment switched on/GPS data arrives

           D8 - PTT

I recommend to set as high data rate as possible on serial port since the MCU is able to handleonly one peripheral at a time. If communication is too slow on the serial port, the MCU has not enough time to decode every packet. I have set the data rate to 38400 bps, so it does not loose packets even in heavy traffic. It is a better solution of course, to switch off monitoring using the MON OFF command. When one uses the equipment as a repeater it is not necessary to send everything to the serial port. This is necessary only when one wants to listen to data flow. In case one wants to see in detail what goes on the radio channel, then display can be switched by the TRace command. Then data is displayed in hexadecimal form instead of ASCII.
This equipment does not require any kind of adjustment, other than the levels of incoming and outgoing audio frequency signals. This APRS set may be fed from a separate PSU or from the radio, using its supply points. In case GPS receiver is not connected, its power consumption is negligible.


The size of the completed PCB is 50 by 120 mm.


The real size of PCB is 50 by 120 mm. Please note, that the drawing is mirrored for the so called toner transfer technique.


Program:

TNC firmware

You must see the following text after turning on the equipment if the data rate of the terminal program was set right (38400 8N1):

APRS DIGIPEATER V4.8
BY OM3BC FOR PIC18F26K22
Type HELP for Info
Temperature Sensor DS1820 Connected
cmd>

Type in HELP command and try to set up the TNC according to the appearing text. If you type in DISP command you can see the chosen values.

My setup is like this:

disp
Repeater running: 0 h.
Filter ON
ECHO ON
TEMPerature C
PERSistence 64
SLOTtime 30
TXDELAY 35
TXTAIL 2
GPS $GPRMC
TRace OFF
MONitor RCV
DIGIpeat ON
FILL in digi OFF
SUPPress ON
RDATA OFF
PARAM OFF
BEAcon Every 15
TAIL Every 5
SYMBOL />
HOLDoff 30
SERCOM 38400 Bd
SERGPS 4800 Bd
UNProto APBC48 V WIDE1-1 V WIDE2-2
MYCall OM3BC-2
DEAD CALLS
DEFS ATTAT
BTEXT 1 !4816.72N/01950.34E#PHG32304/A=000974 BCDIGI v.\z Qth Filakovo
BTEXT 2 !4816.72N/01950.34EyPHG32634/A=000974 BCDIGI v.\z APRS Repeater with PIC18F26k22 - http://www.om3bc.com
TTEXT Opel Astra mobil

OK
cmd>

or
PARM :OM3KKF-1 :PARM.Bat_A,Temp1,Temp2,Bat_B,Temp3,NC,NC,NC,NC,Camra,Chassis,Sun,door
UNIT :OM3KKF-1 :UNIT.Volts,Celsius,Celsius,Volts,Celsius,nc,nc,nc,nc,OPEN!,on,on,high
EQNS :OM3KKF-1 :EQNS.0,1,0,0,1,0,0,1,0,0,1,0,0,1,0
BITS :OM3KKF-1 :BITS.00001111,TEST PROJECT
if telemetry is active.

The beacon text could look so with a temperature and voltage values:

BTEXT 1 !4815.91N/01949.21EyPHG32304/A=000577 APRS Repeater with PIC18F26K22 Temp. \t in Filakovo U1: \u Volt, U2: \v Volt Runtime: \r h

The equipment which was placed into a HAMMOND 1455C1202 box looks like this.


Without box it looks like this:


I have been studying several similar equipment and I tried to include all solutions what I found useful. There is only 1.5 kB empty from the 65 kB memory, so you may not expect too many updates. This explanation is reticent, but you can find the most important information for sure.
The software may have some bugs. (Murphy’s Law is valid is my case too,
stating there is no perfect software, but if you happened to find one it must not be yours.)
If you have any comment which could help my endeavors, just let me know and drop a message to my E-mail address which can be found on my website.
I wish you success to build this equipment.
The drawings and the software in the MCU are the author's intellectual property. Commercial use is not allowed without the written permission of the author!

Special thanks to HA6NN for translating this text.