<hmtl>

# OP25 Multiprotocol Digital Voice TX

The OP25 project in 2009 released an encoder and software TX for P25 (conventional phase I C4FM/FDMA) based on the fullrate IMBE codec contribution from Pavel Yazev.

With the addition of a software AMBE halfrate encoder the OP25 Group now releases an updated TX with voice encoders for-

- P25
- DMR
- YSF
- DSTAR

This release was tested using a PC soundcard connected to the direct modulator input (i.e., 9,600 data port) of an Icom IC-820H configured for high speed data operation [AMOD/PACT switch set to PACT]. Not all PCs tested successfully so perhaps the choice of sound card isn't irrelevant, or the interface circuit needs more work... The software TX drives the audio output at optimum (close to full) signal levels; no output level adjust is provided within the app. Soundcard gain/loss must be carefully adjusted using a Linux sound mixer app so that the proper FM deviation is achieved (see below).

This release has also been tested with the HackRF SDR; other SDR devices supported by gr-osmosdr should work as well.

### INSTALLATION

After cloning the repo change to the top level directory:

    git clone https://git.osmocom.org/op25
    cd op25

Next install OP25:

    ./install.sh

You may be asked for your password for permission to install the OP25 files in the system libraries.

### STARTING THE PROGRAM

After installing OP25 cd to the `op25/gr-op25_repeater/apps/tx` subdirectory. Here's an example command line:

    python dv_tx.py   -r -f ~/uncompressed.wav -p dstar -c dstar-cfg.dat

Hackrf Example:

    python dv_tx.py  -p dmr  --args hackrf -q -21 -Q 925187500 -c dmr-cfg.dat -f ~/file1.wav -F ~/file2.wav  -r

In this example we've selected the dstar protocol with input from a wav file (must be standard rate 8000/S16_LE/mono). Below is a full list of options.

    Multiprotocol Digital Voice TX (C) Copyright 2017 Max H. Parke KA1RBI
    Usage: dv_tx.py [options]

    Options:
      -h, --help            show this help message and exit
      -a ARGS, --args=ARGS  device args
      -b BT, --bt=BT        specify bt value
      -c CONFIG_FILE, --config-file=CONFIG_FILE
                            specify the config file name
      -f FILE1, --file1=FILE1
                            specify the input file slot 1
      -F FILE2, --file2=FILE2
                            specify the input file slot 2 (DMR)
      -g GAIN, --gain=GAIN  input gain
      -i IF_RATE, --if-rate=IF_RATE
                            output rate to sdr
      -I AUDIO_INPUT, --audio-input=AUDIO_INPUT
                            pcm input device name.  E.g., hw:0,0 or /dev/dsp
      -N GAINS, --gains=GAINS
                            gain settings
      -O AUDIO_OUTPUT, --audio-output=AUDIO_OUTPUT
                            pcm output device name.  E.g., hw:0,0 or /dev/dsp
      -o OUTPUT_FILE, --output-file=OUTPUT_FILE
                            specify the output file
      -p PROTOCOL, --protocol=PROTOCOL
                            specify protocol
      -q FREQUENCY_CORRECTION, --frequency-correction=FREQUENCY_CORRECTION
                            ppm
      -Q FREQUENCY, --frequency=FREQUENCY
                            Hz
      -r, --repeat          input file repeat
      -R, --fullrate-mode   ysf fullrate
      -s SAMPLE_RATE, --sample-rate=SAMPLE_RATE
                            output sample rate
      -t TEST, --test=TEST  test pattern symbol file
      -v VERBOSE, --verbose=VERBOSE
                            additional output

### MULTI-CHANNEL TRANSMITTER

The `multi_tx.py` demonstration app transmits four RF channels, one for each of the supported protocols. It requires SDR hardware (such as the HackRF); any device supported by the gr-osmosdr driver and libraries should work. Example command line:

`python multi_tx.py --args hackrf --gains rf:0,if:0 -q -19.5 -Q 442187500 -f ~/rand3.wav -R`

The "-Q" (frequency) option gives the frequency of the first of the four channels; the remaining channel frequencies appear at regular intervals (default spacing is 100 KHz). The channels are, starting at the lowest frequency: dmr, p25, dstar, and ysf. The ysf channel format may be set to "wide", using "-R" (default=narrow). The "-q" option is needed for PPM correction (unless a time base such as GPSDO is used). The input file ("-f" option) requires WAV format, 8000 samples/sec, S16_LE. Audio from the WAV file is transmitted on all frequencies. However if the "-A" option is given, program content for the second DMR time slot is instead taken live from the sound card audio input port ("-I" option).

### GENERAL

Input audio may come either from WAV files (8000/S16_LE/mono) or from the PC microphone / line input connector. If `-f filename` (or `-F filename` in DMR mode) is selected the input is read from file(s); otherwise the GR audio source is selected. Likewise output is sent to the soundcard unless `-o` is given. When using files the `-r` option can be specified to replay the input file(s) in a continuous loop. Without this option the program exits at EOF. The `-p protocol` option is used to select which of the four DV standards (dmr, dstar, p25 or ysf) is to be used. The dmr and ysf modes also utilize a configuration file, specified using the `-c filename` parameter. See the specific section (below) for more details on the configuration file.

There currently appears to be an audio bug that causes the audio to sound "overdriven" or "clipped". The dstar and to a lesser extent the ysf-halfrate coder is most affected by this; dstar suffers from an audio level pumping or AVC malady. UPDATE (Mar. 2017) A hack was added that greatly reduces this problem in ysf. At this point only dstar seems in need of further work.

Note: in general the program currently doesn't currently send "header" or "terminator" packets which typically appear once at the start/end of voice transmissions. Instead we rely on the ability inherent in all of these protocols to start receiving even for transmissions already in progress. For two of the four protocols (dstar and ysf in fullrate mode) this means we forfeit an opportunity to transmit the station callsign. This needs to be fixed in a future release...

### OPERATION

Proper FM deviation is set by adjusting the output levels using the 'alsamixer' app while monitoring with an FM deviation meter. The "Datascope" option in the scope.py OP25 gui app (running on a separate PC) can also be used to view the deviation. If this method is used scope.py must first be calibrated using a known accurate station. The test station is then adjusted to have the same deviation as the known station (leaving all receiver parameters unchanged other than perhaps the frequency). Note: if the sound interface has multiple audio bands (e.g., bass, treble, etc.) all such settings should be set to midrange; a flat response is required.

### DMR

DMR operates in Base Station (BS) mode and is 2-slot TDMA with both slots operating in Group Voice mode. [DMR Mobile Station mode utilizes time-slotted channel access and is not directly compatible with the usual FM transmitter hardware without serious modification]. The configuration file parameters that you are most likely to change are the Station Address (sa) and Group Address (ga) parameters [the latter is also known as the talkgroup ID]. See the comments in the sample DMR config file `dmr-cfg.dat` (supplied). It is also possible to disable one or both channels if desired.

### DSTAR

As of this writing DSTAR mode has an audio clipping bug causing the speech to have a distored, overdriven character. Given sufficient time this should be quite fixable. Also the "slow speed data" feature needs to be implemented. Until this is done the config file (if present) is ignored. As mentioned, the `-g gain` parameter can be used to adjust the input gain, although this doesn't fully cure all dstar quality issues.

### P25

The P25 coder was the earliest modulation format supported in OP25. It operates with a fixed NAC (Network Access Code) of 0x293 and transmits fullrate voice.

### YSF

The ysf mode supports both halfrate (default) and fullrate voice, with some clipping distortion noted in the halfrate mode. Fullrate mode is enabled using the `-R` option. The halfrate mode also supports the interspersed callsign and repeater ID data, but this is currently untested. See the sample ysf config file `ysf-cfg.dat` (supplied).

### CREDITS

Too many to list; thanks to Matt Ames, Pavel Yazev, Jonathan Naylor, unknown author(s) of DSD (DSDAuthor), Mathias Weyland, Sylvain Munaut; undoubtedly others.

©Copyright 2017, Max H. Parke KA1RBI