A Software-Based Color-SSTV/FAX480/Wefax System John Langner's great article on Slow-Scan TV (reference 1) really peaked up my interest in creating such a system. And his statement "..be sure to use an external crystal-controlled timing source....any attempt to use software timing loops is doomed to failure" was just too much of a challenge to ignore. Since we had managed to make some respectable 64 color (or gray shades) Wefax systems (references 2 and 3) for both Commodore and IBM machines using only a simple clipper interface between the receiver and computer, it didn't appear that demodulating the SSTV signal would be that much more difficult. What has resulted is a Color- SSTV/FAX480/Wefax system for IBM and clone PC's that is essentially built with software. We will not re-plow ground that John has already covered so well. If this article prompt's your interest, you should definitely read his article (reference 1) to fill in the gaps and learn some- thing about the history of SSTV. HARDWARE Figure 1 is the simple clipper circuit. It is identical to that used in reference 3 with the addition of an extra coupling circuit used in Transmit mode to connect the computer to the trans- mitter audio input. This should go into the input where the phone- patch normally connects (often labelled Line input). If you already have a phone-patch, you can eliminate the isolation transformer, T2 in figure 1, and go directly into the phone line terminals of the patch. All patches I'm aware of have transformer isolation, but a simple ohmmeter check will verify that is true in your patch. Resistor R-x is chosen to set the proper level for the fax audio going into the transmitter. Fax is a 100% duty cycle signal so don't set the level higher than your rig can handle without over- heating. R-x ended up being 43K in my system where I went directly into the phone-patch. In the interest of hardware minimization, we have not included any low pass filtering on the audio coming out of the computer. This is a square-wave signal rich in harmonics, not unlike what is generated in the speech clippers in many SSB transceivers. No additional filtering is required with mechanical or crystal filter type SSB transmitters, but if you wanted to use this on an old AM or phasing type SSB rig, or on VHF/UHF FM type transmitters, spe- cial audio filtering to give the required spectral purity would be required. Telephone company type approval is required to send such signals over the phone lines and undoubtedly they would require very restrictive spectrum control filters. Each of these cases would require a unique design which we have not addressed. There is nothing critical about the circuit values in the schematic nor is the construction critical. Do use a socket for the IC. Normal perf board construction with short leads works fine. Hundreds of these have been built with the most common problem being wiring errors. For some reason the pin numbers on the IC get confused with the pin numbers on the serial port connector. The most important piece of hardware is the computer. It should have an 80286 or better microprocessor. I have used an old 12 mhz 286 laptop with the system but it definitely gives poorer results than the 386 machine at 16 mhz or 33 mhz. You need a VGA color monitor which can provide 640x480 at 256 colors without inter- lace and a VGA (usually labelled as SVGA) video card that offers a 640x480x256 mode. There are many, many different types of cards offering this mode. Our software is configured to directly address six of the most common SVGA chip types and also includes a VESA standard choice. If your card does not match one of the 6, you'll need a VESA driver program (a TSR program) for your specific card. These are available from the card manufacturer or you may find one in recent programs you have purchased. I'm told that BBS:(416)729- 4609 has many of these if all else fails. SOFTWARE As in previous Wefax programs, we have used GWBASIC as the programming tool. While most of the real guts of the program are contained in assembly language code (.ASM files), it is interfaced to the user through BASIC and all of the modifications to the core program (.ASM files) to adapt them to the multitude of SSTV/FAX modes is accomplished by POKE's in the BASIC program. This allows the experimenters with only a limited knowledge of BASIC program- ming to modify the program to add other modes, etc. In deference to a few of my friends who complained about learning any BASIC, I have included a SYSTEM CONFIGURATION list in the programs which can be filled out by anyone; the program uses this to figure out what POKE's to make. My work is aimed at the experimentally inclined, however, so be prepared to learn a little BASIC if you want to maximise the utility of the system.. One other difference from most recent programs is the system is strictly keyboard controlled. I find Mouse controlled menu selection most awkward and since many laptop computers only have one serial port (where all the FAX action is) they would be pre- cluded from using the program. PROGRAM CONFIGURATION CHOICES Like Langner does in Pasokon our previous Wefax programs have counted clock pulses between zero crossings (reference 2) of the incoming fax signal to measure the audio frequency. The clock frequency affects the accuracy with which you can measure the audio frequency, but in general all of the clocks in computers are easily fast enough to give far more resolution in the measurement than you can display. The 1.193 mhz clock used by IBM PC's to run the time- of-day display is a natural choice since it is common to all ma- chines. It also keys a programmable timer which the PC has avail- able for generating audio tones. My Wefax programs have used this tone timer to set up the sample-data period over which you make a measurement of the incoming audio frequency. The high resolution programs used a 1024 hz square wave tone with a different sample being gathered each 1/2 cycle. This 2048 samples per second just about matches the optimum for the typical Ham receiver bandwidth, so we decided to retain it for the SSTV program. Also we found that the unmodified Wefax would copy the AVT-90 mode directly. Of course it showed up as four (instead of three) successive black and white frames on the 1024 x768 Wefax screen, but perfectly synchronized. Further, this sampled-data or pixel rate gave exactly 320 pixel wide AVT-94 pictures which just matches the screen on a PC. This suggests that the AVT mode formats may have evolved from computer based Wefax formats. Once I had decided to use the Wefax pixel rate, I just copied SSTV picture data tagged with the mode used and then made a series of guesses as to how many pixels were in each line until I got a coherent set of pictures---typically three RGB frames. The result- ing image allowed me to then measure the length of the various 1200 hz synchronizing pulses, the pixels per color frame, and make a close estimate of the exact timing for each line. These numbers were poked back into the Wefax program and then the line timing for that mode was tweaked into place by copying pictures in that same mode on the air. Fortunately I didn't spend too many weeks on this torturous process before I ran into Bert, W5ZR, who just happened to have that data all collected for the most popular modes. That along with the wealth of information in Langner's article greatly increased my rate of progress. I started with 16 shades (ie,4 bits) per RGB color which gave me the potential of 4096 (16x16x16) different colors but finally abandoned that for 64 shades (6 bits) per color which allows 262,144 different colors. This fully uses the capability inherent in the most common SVGA video cards. While it takes more memory, you can always reduce the files to the lower resolution with some fairly simple manipulation if the compressed file sizes become a problem. Langner chose 32 shades (5 bits) per color for his Pasokon color resolution. With Windows driving the computer hardware mar- ket, memory costs have had the fastest decrease per year of any hardware element, so at least my choice was consistent with market trends. It is worth noting that changing from 4 bits to 6 bits would have been a major effort on some hardware based systems, but was a minor change here in the software. When it came to displaying the resulting color pictures on the screen, I opted for filling the screen with the picture (like a TV). Having no need for Mouse selected menus the full screen was available. Since the color modes had a maximum of 320 pixels wide and 240 pixels down in the actual picture frames, just doubling each pixel in both directions gave maximum picture size without overscan when using a 640x480 VGA screen. This larger display was a two edged sword,however, since it made defects in the picture proc- essing more obvious. It forced me to make improvements in both the fax demodulation software and in the color registration. These improvements fed over to the Wefax to give much better satellite photos--ground features are much more visible now. Since all of the displays I had seen of attempts to show a variety of color pictures on a 256 color VGA board had left me unsatisfied, I decided to create my own technique. While describing how I accomplished it is beyond the scope of this paper, I leave it for you to judge the results. Figure 2 shows a typical Scottie 1 picture. It fills the screen vertically but not horizontally. The AVT94 mode in figure 3 fills it horizontally but not vertically. All of the modes except the AVT modes include a 1200 hz line sync pulse of some sort to re-sync each line. I chose to use this only to sync the beginning of each picture and adjusted the crys- tal-controlled line timing in each mode to eliminate slanted pic- tures. This is much more immune to interference and after copying hundreds of pictures on the air I have found this to be the optimum choice for all but the Robot modes. Here there are a variety of line timings that show up on the air, so I had to add line sync capability for the two Robot modes. Actually you can copy in a synchronous fashion if the station you are working has the latest Robot modifications so we kept both capabilities. Ralph Taggart introduced his FAX480 mode (reference 4) while we were in the midst of developing this program. With the flexibil- ity built into the BASIC/.ASM structure described above I was able to add FAX480 to the available modes within a couple of hours. Since my processing was setup for 64 shades of gray, I kept it for this mode. Ralph was limited to 16 shades (presumably) by his hardware base. Once you have the higher pixel resolution, however, I expect people will also want the real photographic quality of 64 shades. After all, it takes up no more r-f spectrum or time to transmit than 16 shades. Finally, we had to make choices on the Transmit program. One of the common practices in use on SSTV is to retransmit a picture you just received so people out of the skip zone of the original transmitter can see it. We included the capability in the Receive/Transmit program to parrot back any picture just received in the mode it was originally sent in since that was relatively simple. While you can transmit any picture you receive and have saved, we chose to exclude the Robot modes when it came to the program used to create new picture files. This was both to conserve our time to more important tasks and because I believe the Robot color modes will fade with time due to the extremely accurate tuning required to maintain color fidelity and the fact that chroma information is shortchanged to maintain compatibility with the old black and white systems. This is not to denigrate the Robot systems since they still give some of the best pictures going, but I have noted that many people with the Robot hardware are now using Scottie and Martin modes most of the time---and their pictures are gorgeous! DESCRIPTION OF PROGRAMS RT.BAS---This is the receiving and retransmit program. On receive, you only need to choose the mode from the menu, and wait for the picture to be completed. As of this writing Robot 36 and 72 modes are available in either a synchronous or a line-synced mode. Other modes (all synchronous) are Scottie 1 and 2, Martin 1, AVT90, AVT94, Wraase 48, FAX480 and Wefax. I have the info to include AVT125 but it is so inferior to FAX480 that I didn't. AVT188 can be copied as AVT94 but you won't get the whole picture. I definitely want to include the Scottie DX mode but haven't yet heard it on the air. The receiving does not yet include automatic recognition of modes from the VIS header, but the transmit does include the VIS headers and the AVT picture sync count down sequence, so others can use auto recognition on your transmitted pictures. When receiving, if you fail to get the mode selection made in time to catch the frame sync you can bypass directly to copying by hitting the Spacebar. On all but the AVT modes, the next line sync is picked up and starts the picture. The AVT modes will just copy out of sync. But since the program allows you to scroll horizontal- ly across the RGB color frames you can re-sync after the picture is copied. There is a barely detectable loss in color registration on AVT modes when you miss the sync, but that's better than losing the whole picture. Having noted that a few of the systems I've copied have a nonstandard color registration I also included the ability to adjust color registration after the picture is received. This shouldn't be needed very often, but is handy to have. You also can SAVE the picture--usually after you have scrolled the picture so the CRT screen frames just the part you want to keep. TX.BAS---You can transmit any picture file with this. When queried, you give the mode and the file name and after a brief pause while it loads, hit G(o) to transmit. To avoid additional switching complexity, VOX is used to turn on the transmitter. Since all pictures start with a long 1900 hz calibration tone, any VOX delay has no impact. VU.BAS---As it's name infers, this program allows viewing a file picture. It has the same adjustments available as the RT.BAS. One that I haven't mentioned yet, applicable only to the Robot modes, is the ability to "re-tune" (in 10 hz increments) the pic- ture as you view it's color balance. QRM seen in the pictures is of two types, some of it giving signals inside the 1500-2300 hz range where the fax is and the other giving signals that measure outside this range. Allowing for some tuning tolerance, the program identifies color bytes outside the range as being "ringers" and substitutes the value of the previous byte for the damaged one. I could have gotten more sophis- ticated and taken the average of all four surrounding bytes but when I tried the simpler version it worked so well we kept it. Note that we are replacing only one color byte, not the whole pixel when a ringer occurs.(Note to Paul Pagel--we can supply Before and After pictures to illustrate the improvement if you have room.) SLIDESHO.BAS---Once you collect a bunch of pictures, this program gives you the vehicle to display them in slide-show fash- ion. It is best placed in your DOS or TOOLS directory where it can be called up from anywhere in the directory tree. My pictures are collected by mode into compressed archive files. Also, I use a RAMDISK to access the extra memory above 640k. A simple batch file, SSARC.BAT, clears the RAMDISK, decompresses the chosen archived file into many picture files in the RAMDISK, and loads in SLIDE- SHO. All files are then viewed sequentially wihout having to refer to their name. TIFCONV.BAS---This converts pictures which are in a 640x480, 24 bit color, TIFF format into the proper format to be transmitted in any of the modes except Robot. TIFF is the most common format used to transfer higher resolution pictures between programs. I have used this program with both the Computer Eyes/RT and SSC frame grabbers. The picture which outputs from this can be viewed with VU.BAS and of course is bounded by 320x240 with 18 bit color. Four TIFF bytes are averaged to get each output byte (except in FAX480). This gives some desirable smoothing to the (affordable) real time grabber images. In FAX480, the three color bytes per pixel are combined to give a gray shade pixel. LABEL.BAS---To add call signs and other text to the SSTV formatted pictures, this program was generated. It takes any TIFF 1 bit (ie;black and white) file and creates a mask cut out where the black is. You can superimpose over the SSTV picture where the mask is cut out either any color you want or transfer a cut out of any background file. Typical background files might be a picture of a shiny brass plate, a highly polished piece of mahogany,or an orange peel---anything with an interesting pattern. The letters look like they were cut out of the background picture. Obviously you can use squares or circles in addition to fonts to transfer a piece of one file onto another one. We use a cheap hand scanner (which I have never found any previous use for) to capture any interesting fonts that show up. You can get a three dimensional effect by painting a color through the mask, then moving the mask a few pixels and rerunning through LABEL with a background file or another color. Or run several different masks through LABEL in sequence to get different colors or patterns on different letters. FILE FORMATS When I started copying pictures, the data bytes were saved in exactly the sequence received, with formats labelled as S1, S2, M1, etc. This ends up using 3 bytes per pixel, which seems a bit prof- ligate. One of the oldtimers in SSTV looked at my pictures which he thought looked OK but complained that 6 bits per color looked like too much memory. The Pasokon uses 5 bits in the Targa format which squeezes the colors for one pixel into 2 bytes. A 50% increase in bytes did seem to be a high price to pay. After looking at the Targa format, however, it occurred to me that it might not compress too well. I took several typical pictures taken in the hamshack and ran them through to form Targa, TIFF, and Scottie 1 formatted pictures. Then I compressed all the files using PKARC which doesn't remove any information. To my surprise, the Scottie 1 files (10 samples) averaged a squash factor of 49% while both the Targa and TIFF files only squashed by 10 to 11%. So the 3 byte/pixel S1 format used less memory in compressed form than the 2 byte/pixel Targa format! Being a little suspicious of the large difference, I examined the large collection of archived SSTV files copied on the air that I have. Here the squash factor averaged only 34% with the lowest squash factors being heavily QRMed pictures. My discrimination in deciding what to save has increased as more pictures were collected and that shows up in the data as improved squash factors over time. Interesting! There may be other compres- sion algorithms designed for Targa which do better. SUMMARY We have presented a brief description of a basic Color- SSTV/FAX480/Wefax system which is constructed almost entirely with software. It is still being added to. The software is free, is not copy protected and can be obtained from the ARRL BBS at (888)888- 8888. Since I expect to be cruising on my sailboat LADY when this is published, mail won't be answered until late spring (except for Christmas holiday). You may be able to locate me on the Slow-Scan frequency, 14,230 khz., if you need information sooner. Ben Vester, K3BC 8/14/93 References: (1) J. Langner, "Slow-Scan TV--It isn't expensive anymore!", QST, Jan 1993, pp 20-30. (2) B. Vester, "C-64 Wefax Improvements", Technical Correspond- ence, QST, Jan 1988, pp 47-49 (3) B. Vester, "Improved HF Weather Facsimile Programs", Techni- cal Correspondence, QST, Sept 1991, pp 40-41 (4) R. Taggart, "A New Standard for Amateur Radio Analog Facsim- ile", QST, Feb 1993, pp 31-36