CCW Using DSP and your Shack's Computer --------------------------------------- CCW (Coherent CW) has been around amateur radio since the seventies, but because of stringent technical demands for rock-solid frequency control at both the transmitting and receiving ends, it has been out of reach for all except the most ardent devotees. The general idea is that by synchronizing the receiver to the trans- mitter's keying, it is possible to realize an advantage of some 20 dB or so in Signal-to-Noise Ratio over conventional methods of copying CW. In some cases it can make enough difference to enable us to copy a very weak signal which would otherwise be unreadable. If we took two quartz clocks and set them both precisely at mid- night, they would agree on what time of day it was (within limits) for quite a while to follow. This is the basic idea of CCW: we get the transmitter and receiver synchronized at the beginning of a QSO; then with highly accurate and stable timebases at each end, they remain in sync for the rest of the QSO without requiring any further operator intervention. The standard keying rate for CCW has been established at 12 WPM. At this rate, each "dit" requires 100 milliseconds to sound, each "dah" 300 msec. The spaces between the elements are all exact multiples of 100 msec. The keying rate not only has to be stable, it must also be accurate enough so that over the course of a normal QSO (say 30 minutes) - the received dits and dahs will start and stop at the appointed times with no more than a millisecond of error. If we can meet this tolerance requirement, then after getting into sync the receiver knows that during any given 100 msec 'window' - the key at the transmit end must have been either up (for the entire 100 msec) or down (for the entire 100 msec) - it could not possibly have changed somewhere in the middle of the window. This is useful information that would otherwise have to be transmitted at the expense of additional bandwidth or power. With this knowledge, the receiver can employ a very narrow "matched filter" to reject most of the noise. How narrow? Well, on the order of 9 Hz wide, that narrow! This special kind of filter is also called an "integrate and dump" filter. It has an interesting frequency response, sort of like a comb with the tines pointing downwards. The main lobe is usually centered on 800 Hz, and there are absolute nulls (notches) at all frequencies spaced away from 800 Hz by some integral multiple of 10 Hz. The response falls off rapidly if the incoming tone is not centered within the narrow passband of this lobe however. For best results we must strive to keep the received CW tone within plus or minus one Hz of the nominal (800 Hz) frequency. This stability is not easy to achieve with 'ordinary' receivers. For example, at a frequency of 14 Mhz, holding a received CW tone within a Hertz calls for a local oscil- lator stability of better than 0.1 ppm over 30 minutes or so. Many CCW practitioners have phase-locked the master oscillators in their rigs to some external frequency standard such as WWVB in order to achieve this sort of performance. The actual physical construction of the "integrate and dump" filter was no piece of cake either. Essentially, the circuit shifts the frequency of the incoming audio down to baseband, splitting it up into two separate channels (in-phase and quadrature). These channels are integrated separately for the 100 msec window, then at the end of the interval, the voltages on the integrating capacitors are sampled-and-held, all the charge is dumped off the capacitors as fast as possible, and the filter starts over with the following window. The two channels must be balanced for optimum performance, the timing has to be meticulous, and there is always the problem of how to get those capacitors fully discharged without wasting too much time at the beginning of each new keying period. If the capacitors aren't fully discharged, then there is energy "bleed-through" from one keying window to the next, blurring the distinction between mark and space; if we wait long enough for the capacitors to almost fully discharge, then we must throw away the first part of each 100 msec window, at a cost of perhaps a few dB in SNR. For more information about CCW, see the articles by Weiss in CQ magazine (June and July issues, 1977), and also the articles by Woodson in QST magazine (May and June issues, 1981). Some of the ARRL handbooks have also covered CCW, for example, the 1990 Handbook, page 21-16. With all of these technically challenging requirements, it is easy to understand why CCW has never emerged from the laboratory and taken the ham community by storm! Up until now, that is... Introducing: COHERENT - a new breakthrough in Digital Signal Processing (DSP) that allows anyone with an IBM-compatible computer in the shack to work CCW. With the COHERENT software package, you can use your PC for both sending CCW (replaces the old VE3OBE/VE2IQ or similar keyboards), and for receiving CCW (replaces the old integrate & dump hardware filter). The system uses modern DSP techniques for better receive performance than a physical filter could deliver, and having a computer at the heart of things allows us to incorporate automatic tuning and frame tracking in real-time, thus eliminating the re- quirement for exotic secondary frequency standards. The only additional hard- ware you will require is one of those "Sigma-Delta" interface boards to sample the audio coming out of your receiver's external speaker jack, digitize the audio at 7,200 samples per second, and send the resulting stream of numbers to the PC via one of its serial ports. A math co-processor is not required, but a mouse (Microsoft compatible mouse) - may be useful. The "Sigma-Delta" interface board is described in detail in the feature article, "Receiver Spec- tral Display using DSP" in Jan '92 QST, and also in the 1993 ARRL Handbook. It's a little circuit board about 4 inches long and 1.8 inches wide, powered by a 9-volt battery. If you don't already have one, you can get one from VE2IQ (see address and price info below) at the same time you order your COHERENT software package. COHERENT - Technical details... ------------------------------- 1. Bringing up the program. Make sure the Sigma-Delta interface circuit is connected to one of the available serial ports, and type COHERENT to activate the program. The default serial port is COM1. If you wish to use another port for some reason, you can invoke COHERENT with the name of the COM port to use as a command line parameter. For example, to run the Sigma-Delta board on COM2, you would bring up the system with: COHERENT COM2 . Unlike the FFT audio spectrum analyzer program that also uses the same Sigma-Delta interface, the COHERENT program will not abort if it fails to receive a measurement from the board every 138 microseconds, but of course, you must have the Sigma-Delta board connected and powered up if you want to receive any CCW, hi! You just crank up the audio level (Rx volume control) until you see the red CLIPPING! warning flash on in the upper right corner of the screen, then you back off the audio a bit so it doesn't clip any more, and you're in business. 2. Sending CCW using the PC. If you want to send absolutely formidable CCW with impeccable timing so even the old-fashioned CCW stations can copy you easily, then you must meet their standards for transmitter stability and keying accuracy. In simple terms, this means you must find some way to put your transmitter exactly on the designated frequency and keep it there, and you must adjust the oscillator on the computer's motherboard to provide the nominal 1.193180 Mhz clock input to timer "0". DOS uses this clock to keep track of the time of day, so there is usually a trimmer cap somewhere to let us set it to the correct frequency. COHERENT uses this 1.193180 Mhz clock to measure out the 100 msec keying win- dows, so their long term accuracy will be only as good as you can set this clock. If your computer clock drifts in frequency as the machine warms up, you may want to turn the system on well in advance of an anticipated CCW QSO to let the oscillator stabilize, or you might even consider a TCXO or oven- stabilized clock for your computer. One way to measure the accuracy of this oscillator is to set the time on your computer using the DOS "time" command, let the computer run for say 24 hours, then see how many seconds you gained or lost over the course of the 24 hour period. Compare the time to something reliable, of course, like the WWV time ticks. Don't be fooled into believing your computer's oscillator is right on frequency just because your battery backed-up clock keeps good time while the computer is turned off! Those lithium-backed clocks use a 32.768 Khz quartz watch crystal for good long term accuracy, and may often keep time to within a second or so each day. What counts here though, is how good the timekeeping is while the computer is running. COHERENT divides the 1.193180 Mhz clock by 59659 using the program- mable divider in Timer 0, to get an interrupt every 50 msec. Two of these interrupts make exactly 100 msec, which is our CCW keying interval. DOS normally sets this divider up to divide by 65536, resulting in an interrupt every 54.9254 msec, or 18.2065 interrupts per second. DOS then counts out 1,573,040 of these interrupts over the course of 24 hours in order to know what time it is while the computer is running. COHERENT adjusts the DOS timekeeping counters to compensate for the slightly faster interrupt rate, so the DOS clock will not appear to gain time as a result. COHERENT splits up the monitor screen into four (4) sub-screens: The STATUS (at the top of the physical screen), BUFFER, CHAT, and ESC fields, from top to bottom of the screen. Lines scroll within each of these four sub-screens just like each sub-screen were the entire screen on a normal display. Several fields in the top (STATUS) screen are updated automatically every 100 milli- seconds. Whenever the cursor is in the CHAT area, whatever you type in at the keyboard will be sounded out (via the PC's built-in speaker) as coherent Morse code. Don't worry about the sending speed; you can type ahead as far as you like. If you make a typing error and catch it in time, you can erase the last character in the buffer with the 'backspace' key before it actually goes out. If you prefer, you can store a message in a buffer (give the BUFFER command). Then you can send out the contents of this buffer whenever you like with the SEND command. You can even save the contents of the buffer on disk in a named file and recall it later for sending. There is a counter in the status screen to let you know just how many seconds it will take to send the entire message in the buffer. The counter follows the contents of the buffer as you type, so you can monitor your typing to result in a message of a given length, or to make sure it does not exceed some number of seconds, etc. To issue commands to COHERENT, you must first hit the ESC key to get out of the usual CHAT (sending) mode. Hitting ESC gets you into the command (bottom) screen. The system will prompt you with a list of commonly used commands. You would normally type in the full command as shown (followed by enter) - but if you want to save keystrokes, you may shorten the command as much or little as you like. Just be sure you enter enough of the command to distinguish it unambiguously from other commands that might start with the same letter. If you enter a command that needs parameters, the system will prompt you for them, but once you become familiar with the patter, you may just enter the parameter(s) on the same line following the command verb, and the system will accept them without further prompting. Once a command has been executed by COHERENT, he will return your cursor to the CHAT screen, and anything you type will be sent out. When sending CCW, COHERENT sounds the tone (approximately 800 Hz) through the PC's speaker. He also keys the RTS (Request-to-Send) line (pin 4 of the 25-pin RS232 connector) at the same time. You can use a very simple little circuit to generate a contact-closure to ground to key your transmitter with this signal. Minus 12 volts while the key is up, and plus 12 volts while key is down. A simple opto-isolator should do the trick, or if you don't mind connecting the grounds of your computer and radio together, a single VMOS FET such as a VN2222LL will work just fine. 3. Receiving CCW using the PC. In order to copy CCW, the receiving station must be synchronized to the transmitter's keying. Normally this is done by having the transmitter send out a known bit pattern (30 seconds of alternating mark / space frames) at the start of each QSO, allowing the receiver to lock on and stay synch- ronized. In its sending mode, COHERENT can easily generate such a sync pattern: just use the "$" character for each 30-second sync pattern, or the "%" key for a 1-second sync pattern. You can enter either $ or % as many times as you wish to make up a sync pattern of any arbitrary length. It is customary for the sending and receiving stations to agree in advance on the exact frequency and time of the QSO (sked), including who is to send the first sync train. The QSO should be started within a second or so of the appointed time. When the operator at the receiving station knows that a sync pattern is being transmitted he tunes in the exact frequency and types the SYNC command into his computer. COHERENT enters the SYNC mode and starts to lock in on the incoming dits. COHERENT displays the amplitude for both MARK and SPACE frames, as well as the MSR (Mark / Space Ratio). If a tone is detected its frequency will also be displayed. The nominal value is 800 Hz, and COHERENT can track signals only within the narrow range of 800 Hz plus or minus five (5) Hertz, so you must tune the signal initially, preferably within one hertz, by some other means. If you have an accurately calibrated synthe- sized receiver with a read-out to the 10 Hertz level, you can usually set the thing right on the desired frequency and it will result in an 800 Hz CW tone that is within plus or minus 5 Hz of the proper pitch. You can tell when the program has locked onto the sync pattern because it will stop hunting with the "Phase Cycle" value displayed at the third line down from the top of the STAT screen, and the MSR parameter will be at its maximum. The maximum Mark/Space Ratio is only achieved when the frames are perfectly in-sync. If you do not wish to let COHERENT try to synchronize automatically, you can disable it (set AUTOTRACK Off), and you can use the left and right arrow keys to synchronize manually. Try to maximize the spread between the displayed MARK and SPACE amplitudes. When satisfied with the synchronization, hit ESC to leave the SYNC mode. The program will then enter the RECEIVE mode automatically and start sounding out the filtered dots and dashes on the pc's speaker. Note that there is always a 100 millisecond delay between the received Morse code and the sounded code. This is because COHERENT waits until after each 100 msec frame has ended before making the decision as to whether it was a MARK or a SPACE, hence the 100 msec delay. At the end of each 100 msec window, COHERENT compares the measured amplitude against a threshold value: if the amplitude was greater than this threshold it was a marking window, else it was a spacing window. The threshold may be adjusted manually with the UP DOWN arrow keys, or preferably by moving the mouse vertically. Moving the mouse upwards raises the threshold, downwards lowers it. The threshold changes less rapidly when it is smaller - i.e. when the threshold is close to zero counts (the signal is presumably very feeble) - you have to move the mouse further for a given amount of change in the threshold value. If you enable the AUTOTHRESH feature, you can specify Fast, Medium, Slow time constants for an automatic "AGC-like" threshold adjusting system that tries to follow the QSB and always maintain an optimum threshold value. In any case, manual input is still allowed. In either SYNC or RECEIVE, whenever COHERENT deems a window was MARKing, it attempts to measure the frequency of the received CW tone. It actually does this by computing the phase angle of the 800 Hz audio tone, and noting how much the phase shifts from one 100 msec window to another later one. By noting how much phase shift occurs (and whether it's leading or lagging) over a known time period, COHERENT is able to calculate how much the incoming frequency differs (and whether up or down) from the nominal 800 Hz, and this resulting frequency display is updated each 100 milliseconds whenever the signal is MARKing. The AUTOTUNE feature works as follows. First the measured frequencies are averaged (smoothed) a bit to eliminate jitter due to noise. Then if the measured frequency is off by more than half a Hertz (0.5 Hz) in either direction, the program issues a pulse on an RS232 line to attempt to bring it back into the centre of the filter's passband. COHERENT assumes the receiver is one of the newer models with DDS that can FINE-TUNE in 1 Hz steps (the TS850S is such a rig). In the Fine mode you can use the microphone UP/DOWN buttons to move the receiver up or down in precise 1-Hertz steps. COHERENT issues a pulse on the DTR (pin 20) line when it wants to shift the input tone 1 Hz lower, and a different pulse on the TXD (pin 2) line when it wants to shift the input tone 1 Hertz higher in pitch. The pulses are 100 msec in duration; each pulse is a shift in RS232 voltage from minus 12 volts to plus 12 volts and back again. You can use the same simple circuit to interface these signals to your mic UP/DOWN buttons as you used to key the rig, i.e. an optoisolator or a VN2222LL fet. If this system is enabled and running, once COHERENT locks onto an 800 Hz CCW tone, it will track it indefinitely, keeping it centered within the filter's passband (never more than half a Hertz off frequency). If your receiver cannot be remotely tuned in this fashion, then you will have to monitor the displayed frequency on the CRT, and manually retune the receiver (hopefully you have a real fine tune mode, hi!) to try to keep the received tone as close to 800 Hz as pos- ible. The big advantage of the AUTOTUNE system, of course, is that you only need a rig that's reasonably stable to copy CCW. Once locked onto the signal, the software will track out any drifting (at either the transmit or receive ends). This is a very big step forward over previous methods which required expensive frequency standards at both stations. The other thing we have to worry about is maintaining frame synchroni- zation over the course of a QSO. There is a "Phase Cycle" number displayed in the STATUS screen. This number can vary from 0 thru 79 inclusive. At 7,200 digitized samples per second, there are exactly 720 samples in each 100 msec keying window, and this corresponds to 80 cycles of 800 Hz audio. The Phase Cycle number identifies the relative audio cycle (assuming a continuous, coherent reference tone) - at which the window starts (or ends). You can ad- just this phasing control manually with the left/right arrow keys on the PC's keyboard. The left arrow makes the window start 1 cycle (1.25 msec) earlier, the right arrow slides the window so it starts 1.25 msec later. You can also use the left and right buttons on the mouse to accomplish this. The mouse buttons are preferable, because striking keys causes UART overruns with some BIOSes. Apparently they disable the interrupts a while to see if you are going to hold the key down or not. If they keep the interrupts off for more than 150 microseconds or so, this could very easily cause COHERENT to miss a sample. Missing a few samples now and then is not the end of the world because each sample covers only 135 microseconds of time, but if enough over- runs occur, the phasing will start to lag, because COHERENT counts out the 720 samples to know when each window starts/stops. It has been found that using the Mouse (either clicking the buttons or moving the mouse) does not cause any problems, so the mouse is a preferred input device. If your serial port uses the newer 16450 UART with a FIFO buffer built-in, then of course there will never be any overruns, period. If the AUTOTRACK feature is enabled, COHERENT attempts to follow the incoming Morse code tones over a longer time scale, and to establish what the drift is (if any) between the received framing and the internally derived time frame. Then, if COHERENT decides the SNR would be improved by ad- justing the Phase Cycle counter slightly, it will do so automatically. Once locked in, assuming there is enough signal energy to track, COHERENT will automatically maintain frame synchronization indefinitely, without requiring any operator action. The way this is done may be of interest to technically-inclined readers. Instead of implementing just one integrate and dump filter in DSP, COHERENT actually implements three (3) such filters, staggered in time over the course of three (3) consecutive cycles (each cycle represents 1.25 msec) of the 800 Hz audio tone. These 'dump' values are designated Early, Current, and Late. At the end of each window, the program uses the Current data to decide if that window was Marking or Spacing. But then it checks the other two windows dis- placed from it in time by 1.25 milliseconds before and after. If it was a marking window and the Early data would have resulted in a larger amplitude, then an argument is made to start windows 1 cycle earlier. Similarly, if it was a space window and starting earlier would have reduced the measured amplitude, that is also an argument for starting earlier. If it was a MARK window and the later window had a larger amplitude, it's evidence in favour of delaying the window start by one cycle of the 800 Hz tone. Similarly if it was a space window and the delayed window would have a lower measured ampli- tude at 800 Hz. After many such arguments are made, the results are weighed, and if the consensus after many trials is that the SNR would be better overall if we started the windows 1.25 msec earlier, then the system does just that. This is made possible by the fact that using DSP we are able to create three IDENTICAL matched filters. We don't have to worry about choosing component values to the nearest tenth of a percent. The three DSP filters are absolute- ly the same in their amplitude response characteristics - the only difference is they cover three windows in time that overlap each other by all except the 1.25 milliseconds staggering time corresponding to one cycle of audio at 800 Hz. The three DSP filters are operated using the same actual digitized samples; were the three filters to be aligned time-wise, their outputs would agree down to the last count. This makes it feasible to compare their outputs to see if moving the window a little in either direction would improve the overall performance of the receiving system. 4. Running a CCW Beacon... With COHERENT, you can enter a short message in the Send Buffer (in- cluding the 30-second sync preamble) and program it to be sent out automati- cally every so often. For example, you might program the beacon generator to send a CCW message every five minutes exactly, starting at midnight GMT. The purpose of this is to let your listeners know in advance just when the sync pattern is being transmitted in case the signal is too weak to hear. You set your computer's time of day clock as precisely as possible (e.g. while listening to WWV) - and if the timebase oscillator in your PC is properly adjusted, the CCW beacon message will go out faithfully right on the dot. You will need to check it once a day or so to make sure it hasn't drifted too far off Boulder's clock. 5. Lowfer operation... Many lowfer stations (those operating in the band from 160..190 Khz) use CCW because it helps their tiny (1 watt max) CW signals get through the noise. CCW is very practical in the LF band because the frequency stability requirements at both the transmitter and the receiver are more easily met. To hold a transmitted carrier within plus or minus one hertz at 180 Khz, your timebase only has to be good to within 5 ppm or so; to do the same thing at 180 Mhz would be one heck of a lot more difficult. Another advantage of CCW is that it allows many more signals to be packed into a crowded band without any increased interference. As long as the carriers are spaced exactly 10 Hz (or some multiple of 10 Hz) apart, there is absolutely no mutual interference, because the CCW receiving filter automatically notches out the unwanted fre- quencies. This is a great boon in a congested band. The following items are available by mail from the author: Sigma-Delta printed circuit board (pcb) (double-sided, plated board with solder mask both sides) .......................... $ 24 Sigma-Delta kit (includes pcb plus all other components to build) .......................... $ 49 (includes COHERENT CCW software disk) Sigma-Delta board assembled and tested, ready to hook up .......................... $ 95 (includes COHERENT CCW software disk) For all orders, please include $5 for shipping and handling - this will cover shipment by air mail to anywhere on the planet. Shipping and Handling .......................... $ 5 All prices quoted in U.S. dollars. Will accept either US or the equivalent in CDN funds at the current rate of exchange. US checks and money orders fine. Most orders shipped the next working day. Order from: Bill de Carle VE2IQ 29 Sommet Vert St-Adolphe d'Howard, PQ Canada J0T 2B0