WEFAX Mode User Manual

  1. Introduction
  2. Features
  3. Operation
  4. Bugs and annoyances
  5. Copying

1.Introduction
WEFAX Mode is a Guest mode for the decoding, displaying and saving of Wefax and Radiofax images, produced by processing the audio samples stream from the SSB demodulator.

2. Features
Software AF/FM Frequency Discriminators
WEFAX Mode carries out demodulation of the Audio Frequency-Modulated Wefax signal with fairly simple DSP FM discriminator algorithms. There are two such FM discriminators, an I/Q Phase Detector and a Bi-Level Tone detector, one of which can be selected from the "FM Detector" popup menu item. The default is the I/Q Phase Detector which is usually more suitable for general use, as the Bi-level detector posterizes the Wefax image, and is mostly useful for receiving stations that transmit a white|black image only.

The I/Q Phase Detector Estimates the frequency of the incoming Wefax audio signal by calculating the instantaneous phase angle of the audio signal. This is done by saving audio samples from the Demodulator in a ring buffer with a length in samples that represents a quarter cycle of the center frequency of the Wefax signal. This would normally be 1900 Hz (the range of Wefax signal frequencies is 1500 Hz to 2300 Hz) but because the sample rate of audio is 48 kHz, a frequency of 2000 Hz is used as the center frequency. This gives us 24 samples per cycle so that the quarter cycle is a round 6 samples long. Samples spaced 6 positions apart in the ring buffer would be in quadrature at the center frequency and for frequencies above and below this, the phase angle will vary accordingly and this can be used to calculate frequency.

The Bi-level detector works by implementing two Goertzel tone detectors, one on the White frequency (2300 Hz) and one on the Black frequency (1500 Hz). By comparing the signal levels as measured by the Goertzel detectors, the frequency of the Wefax carrier signal can be estimated. These level comparisons are limited to only 5 thresholds, therefore the Bi-level detector produces a posterized Wefax image.

The calculated frequency of the input AF signal is scaled and threshold-ed so the a value of 0 to 255, for the brightness level of the relevant Wefax image pixel can be calculated and used to create the Wefax image. The standard frequency range for transmitting Wefax and Radiofax images is 1500 Hz for black and 2300 Hz for white. Here is the complete specification for the Wefax image transmission process, as generally accepted by most Wefax stations:

Signal Duration IOC576 IOC288 Remarks
Start tone 5s 300 Hz 675 Hz 200 Hz for color fax modes.
Phasing signal 30s White line interrupted by a black pulse.
Image Variable 1200 lines 600 lines At 120 lpm.
Stop tone 5s 450 Hz 450 Hz
Black 10s
Signal Scope
WEFAX Mode has a simple oscilloscope type display of the incoming audio signal as produced by the FM discriminator. This can be used to monitor the Wefax/Radiofax signal as received by the radio receiver.

"Waterfall" display with CAT
WEFAX Mode has a "Waterfall" (audio Spectrum) display derived from an IFFT of the receiver's audio output. The Waterfall display has two vertical white lines at each side of window, which indicate the position of the White and Black frequencies. The position of these lines depends on the specified White and Black frequencies (normally 2300 Hz and 1500 Hz). Wefax/Radiofax signals are mostly concentrated around the White frequency, so the Spectrum display usually shows a band of signals either side of this frequency. For proper tuning of a Radiofax signal, this spectrum band should be centered on the White frequency line at the right of the Spectrum display. Most Wefax/Radiofax stations on the short waves specify the carrier frequency, while the modulation is Upper Side Band (USB) and it is centered in the middle between the white and black frequencies, e.g. (2300 + 1500) / 2 = 1900 Hz. So the receiver must be tuned to 1.9 KHz lower than the specified carrier frequency. For example DDK3 transmits on 7880 KHz so the receiver must be tuned to 7878.1 KHz USB. Some stations, like SVJ4 in Athens, specify the receiver dial frequency, e.g. 8105.0 KHz, which gives the right AF output frequencies already.

Status Indicators:
There are three Status Indicator icons in the WEFAX Mode Control Frame:
o The "Start Tone" Indicator shows a green "LED" icon when WEFAX is listening for a Wefax/Radiofax Start tone. If this stage in the decoding of Wefax images is skipped by the user, this indicator shows a red "cancel" icon and if a start tone is detected, it shows a green "tick" icon.
o The "Sync Pulse" Indicator shows a green "LED" icon when WEFAX is synchronizing itself with the Phasing Pulses transmitted by the station. If this stage in the decoding of Wefax images is skipped by the user, this indicator shows a red "cancel" icon and when synchronizing is complete, it shows a green "tick" icon.
o The "Decoding" Indicator shows a green "LED" icon when WEFAX is decoding the Wefax/Radiofax image from the incoming signal from the receiver. If this stage in the decoding of Wefax images is skipped by the user, this indicator shows a red "cancel" icon and when decoding is completed (a Stop Tone has been detected), it shows a green "tick" icon.
o The "Save Img" Check Box can be used to disable or enable Saving of the decoded Wefax image. The "Save Img" Indicator shows the status of the Wefax image Save functionality. If saving is disabled then the "x" icon is shown. Otherwise a green "LED" indicates that saving is enabled and a green "tick" icon indicates that image saving to file has been successful. A red "LED" indicates a problem with image saving.
o At the right of the Wefax Control frame, a Level Bar indicates the level of either the Start or Stop signal, depending on the current operation. The Level Bar indicates Green color if the signal is above the "Detected" threshold, Orange color if the signal is between the "Detected" and "Activate" threshold and Red if the Start/Stop signal is not detected. WEFAX expects the level of the Start/Stop signal to first rise into the Green sector and then fall below the Orange sector (Hysteresis), before it is considered as successfully detected.

Image Slant Correction:
Unfortunately Wefax/Radiofax stations do not follow a consistent or standard format of image transmission and this makes it difficult to decode images in a uniform way. Some stations transmit a regular Phasing (Sync) pulse at the start of each image line. This pulse is usually about 55-60 pixels long and it is black color on a mostly white line. WEFAX can use this pulse to synchronize decoding of images so that there is little or no slanting of the image content, due to slight timing differences between the transmitting and receiving stations. Some stations just do not transmit in-image phasing pulses and others transmit shorter or intermittent pulses, making it impossible to actively synchronize sender and receiver. In this case WEFAX can de-slant images pre-emptively by applying a correction factor, calculated from measuring the slant of a saved image. This de-slanting factor is in (pixels/1000 lines of image) and it can be specified either permanently in the Stations Treeview Window (and saved to the Stations file) or set before decoding in the Fix Slant spin button. Positive figures compensate for slanting to the left and negative figures for slanting to the right.

The slant correction factor is calculated as follows: First receive and save a wefax image, one that contains a vertical line or the trace of the phasing pulse, if transmitted, and then open the Wefax image in and image editor like the Gimp. Measure the horizontal position in pixels of the vertical line at the top and bottom of the image and find the difference (in pixels). Then measure the vertical position of the line at the top and bottom of the image (this is the height of the line in pixels). Divide the slant of the vertical line with the height and multiply by 1000, to calculate the slant correction factor in pixels/1000 lines. If the image is slanted to the right, the correction factor is negative, otherwise positive. This value can then be entered in the stations file, either using the stations Treeview window or if necessary using a text editor.

Status Text Messages:
The "WEFAX Messages" text view port prints various messages from WEFAX Mode regarding the status of various operations, error conditions and other information relevant to WEFAX's operation. Pending operations are shown in black, successful completions in green, canceled operations in orange and error messages in red.

Wefax/Radiofax Stations List
The Stations Treeview Window presents a list of Wefax/Radiofax stations and some of the relevant parameters for decoding images. For each station row, there are the following columns:
o The Name of the station.
o The Frequency in Hz it transmits on, including a 1900 Hz compensation to take into account the use of USB mode, and frequency shift from 1500 Hz to 2300 Hz (center frequency 1900 Hz).
o The RPM (transmission speed) value in lines/min.
o Image resolution in pixels/line.
o The IOC (Index Of Co-operation) value.
o The Image Slanting correction factor in pixels/1000 lines.
When a station is selected from the Bookmarks, the Receiver frequency will be set to the Station frequency and the proper settings (bandwidth, BFO frequency) will be set up. The Wefax/Radiofax decoding parameters are also entered into the relevant items in the pop-up Menu. To navigate the Treeview list, the Up and Down buttons can be used, as well as the Up/Down arrow keys in the keyboard.

3. Operation

WEFAX Mode User Interface
The main WEFAX's window has the following widgets:

1. The Wefax/Radiofax Image Viewport: This is the main part of the WEFAX Mode window and it is used to display the Wefax/Radiofax image as it is decoded progressively. Right clicking on the window opens the main Pop up Menu. When image decoding is over, the displayed image is saved in a PGM file format in ~/.lhpsdr/wefax/images/ folder. The Wefax image can be processed, while it is being received, either by contrast stretching or bi-level (black-white) threshold. These functions are selected from the "Enhance Image" item in the Pop up Menu.

2. The Signal Input Display: This is the small window at the bottom left of the WEFAX Mode window, with the dark green background. It can display either the output of the FM discriminator (e.g. the incoming Wefax signal) or the amplitude of the AF signal supplied by the radio receiver.

3. The Spectrum/Waterfall Display: This is to the right of the Signal display and it has a black background. It is used to display the Spectrum of the incoming Wefax signal, as produced by an IFFT function, in the form of a "waterfall". This display can be used to tune the Receiver to the right frequency. The Wefax signal's spectrum is normally concentrated around the White frequency of 2300 Hz and it produces a fairly wide strip down the Waterfall. By clicking on this strip, it is possible to tune in the Receiver, fairly accurately.

4. The WEFAX Control Frame: This frame contains a couple of buttons, one for starting WEFAX and one for skipping between operating modes of WEFAX. The "STANDBY" button puts WEFAX in the Receive mode, whereby the button label indicates "RECEIVE" in green and the top "Start Tone" red indicator changes to green. In this condition WEFAX waits for a Wefax Start tone, to initiate the image decoding process. The "Skip" button causes WEFAX to skip forward to the next mode, e.g. from waiting for a Start tone to Synchronizing with the Phasing pulses, or from this mode to Decoding the Wefax image. This makes it possible to bypass missed stages in the Wefax image transmission sequence. The appearance of the indicators shows Non-Function (Red), Operating (Green), Skipped (Red X) and Finished (Green tick).

There is also a vertical Level Gauge at the right side of the frame. This gauge indicates the output of the Start Tone detector when WEFAX is waiting for one, or the output of the Stop Tone detector while an image is being decoded. I added this gauge as there were some problems detecting start/stop tones and I wanted an indicator to help me investigate.

5. The Messages Text Viewport: Various messages are printed here by WEFAX to indicate current status, operations like saving images, error conditions etc.

6. The pop-up Menu: This opens on a right-click on the Wefax Image window. It has the following items:
o Bookmarks List: Opens the Stations List Treeview window from which a Wefax/Radiofax station can be selected by clicking on a Treeview row. It is also possible to move between stations by clicking the Up or Down buttons or the Up/Down arrow keys on the keyboard. The Delete button removes a row, whereas the New button creates a new row, which can be filled either manually or by middle clicking on the row. In this case the row will be filled with the currently used values of the Wefax parameters and the Receiver's frequency will also be set.
o FM Decoder: Select one of the two available Wefax carrier signal decoders, the Zero Crossing detector or the Bi-level Tone Detector.
o RPM: Select the RPM (Lines/min) value used by the station. Default is 120 RPM (lines/min).
o Resolution: Select the image resolution in pixels/line. The default is 1200 pix/line.
o IOC Value: Select the IOC (Index of Co-operation) value of the station. The default is 576.
o Phasing Lines: Select the number Phasing lines to examine at the start of image transmission. There is no universally followed standard unfortunately, with some stations transmitting as few as 10 phasing lines and others up to 60. The default of 20 lines will not work for stations transmitting less than this. As of version 1.7, the number of phasing lines to listen for can be specified and saved in the Stations List Treeview window. This will override any selection made from the popup menu, when a station is selected from the list.
o In Image Phasing: Enable synchronization with in-image phasing pulses transmitted by some stations.
o Image Enhancement: Select "Normalize Image" to stretch the contrast of the image as it is being received or "Bi-level Image" to threshold the image to only Black or White values.
o Image File Format: Select the Image File format: JPEG, PGM or Both, if needed. WEFAX has a simple built-in JPEG encoder for gray scale images that can reduce the image file size considerably. The JPEG file format is the default.
o Quit: Quits WEFAX Mode.

Configuration and set-up
After compilation and installation, the ~/.lhpsdr/wefax/wefax.config run time configuration file MUST be edited for proper operation! To do this, load ~/.lhpsdr/wefax/wefax.config into your favorite editor and make sure that you review ALL the configuration fields in the file and that you properly edit all the ones that must be edited. There are more detailed instructions in the file itself so please follow them for a proper set-up.

Using the Stations Treeview List
The Stations Treeview Window opens when the "Station List" menu item is activated. The Stations Treeview can be used to select the desired Wefax/Radiofax station and to enter the decoding parameters into the relevant menu items. As well as selecting stations and entering decoding parameters, the Treeview can be used to edit all data in the columns of a selected row and save all Treeview data to the "stations" file in the ~/.lhpsdr/wefax directory. The following are the columns available in the list:
STATION NAME: The name of the Wefax station in the row.
FREQUENCY: The frequency of the station in Hz. This is normally 1900 Hz below the specified carrier frequency. This needs to be fine-tuned by tuning the Receiver, so that the trace of the White frequency (2300 Hz) in the Waterfall display is under the vertical white line at the right of the display. Clicking near the trace of the White frequency will automatically tune the receiver to the right frequency. This setting can be saved to the Stations List by middle click on the selected Station row.
S/B: The side band used by the Wefax station. This should normally be Upper Side Band but on a couple of occasions I heard one station using LSB, so I added this column.
RPM: The RPM or Line Transmission Rate of the station. This is normally 120 RPM or Lines/min but some stations (Kyodo News) use 60 RPM also.
PIX/L: The resolution of images in pixels/line. This is normally 1200 pix/line.
IOC: The Index of Cooperation. This is normally 576.
PHL: The number of phasing lines to listen for, after the Start Tone. The default is 20, but some stations (the Hellenic Met service) use only 10 but since 2-3 line may be missed at the start, due to a delay in the Start Tone detector, it is necessary to specify 10 for this station. For most others, a value of 40 can be specified if desired, since usually about 60 phasing line are sent.
SKEW: The image slant correction factor in pixels/1000. This is needed to compensate for the difference in timing between the sending and receiving stations. The right value must be found as described previously.

Receiving Wefax/Radiofax signals
Wefax/Radiofax signals are transmitted on the short waves by stations operating in the USB mode and with a Frequency Modulated output, in a Slow Scan TV format. White color is represented by a 2300 Hz signal and Black color with a 1500 Hz signal. The transmission begins with a few seconds of a Start Tone and then a number of Phasing (Synchronizing) lines are sent. These are used to synchronize the start of image lines at the receiving end with those of the transmitting end. The Phasing lines are black with a short white part at the beginning, and they are then followed by the image lines, with the height of the image (the number of image lines) being variable. Some stations transmit phasing pulses at the start of image lines, but these are short black lengths in mostly white lines. Unfortunately not all stations follow the accepted standards for Wefax transmissions, making it rather difficult to apply regular algorithms for sync detection.

To receive a Wefax/Radiofax station, set up the Receiver Mode to RFAX-U (Radio FAX - Upper Sideband). Tune in the Wefax station so that the trace of the White signal (2300Hz) is under the right vertical white line in the Waterfall. Also, by clicking on the White signal trace in this display, the Receiver will be tuned fairly accurately to the right frequency. If WEFAX Mode is started by clicking on the STANDBY button, it will wait until a Start Tone is received and when the Phasing Pulse signals begin, it will synchronize itself and enter the Image Decoding mode. The Wefax image is decoded line by line and displayed in the Image window. When a Stop Tone is received, WEFAX saves the decoded image and again it waits for the next Start Tone. If left to its own devices, it will continue in the way, automatically decoding and saving images.

4. Bugs and deficiencies
I have fixed whatever bugs I came across testing WEFAX Mode, but there may be some hiding, waiting for the right conditions to appear.

5. Copying This software package is released under the GNU Public License. Please see the COPYING file for more details.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.