Field of the Invention
This invention relates to digital synchronization apparatus and, in particular, to apparatus for obtaining synchronization of decoding apparatus to a serial stream of digital data.
Background of the Invention
Many small computers utilize an audio-frequency magnetic tape recorder as an inexpensive auxiliary data storage device. In order to utilize an audio tape recorder in this manner, an interface circuit is provided between the computer and the tape recorder which converts digital signals produced by the computer into audio-frequency tone signals that can be recorded on magnetic tape by the recorder audio circuitry. Typically, a digital signal which represents a logical "one" is converted to an audio tone of a predetermined frequency. A digital signal which represents a logical "0" is converted to an audio tone of a different predetermined frequency. The audio tones produced by the tape recorder interface can then be conveniently stored on inexpensive audio magnetic tape.
Subsequently, the recorded information can be retrieved from the tape by "playing back" the tape and reconverting the resulting audio tones into digital signals suitable for use by the associated computer.
In order to achieve reasonable information recording density on the magnetic tape only a single cycle of each audio frequency is used to represent a digital "bit". Therefore, the serial stream of audio information which is retrieved from the tape consists of a frequency-modulated waveform containing a pattern of various frequencies corresponding to the digital pattern of "1"s and "0"s in the information originally stored on the magnetic tape.
While audio tape storage is inexpensive and reliable, a synchronization problem can occur because some audio tape recorders cause an inversion of the audio signal when a stored signal is retrieved from the tape. Other tape recorders do not invert the signal when the stored information is retrieved. Whether an inversion occurs depends on specifics read circuitry in the tape recorder and may vary from brand to brand and among different models in the same brand of tape recorders. An inversion can prevent the computer-tape recorder interface from properly synchronizing to the audio signal output from the cassette recorder so that a conversion can be performed between the audio signals on the digital levels required by the associated computers.
One simple prior art solution to the inversion problem is an inverting switch. When an inverting switch is used the recorder interface first attempts to synchronize to the incoming signal and if synchronization does not occur the switch must be manually moved to invert the waveform and allow synchronization to take place. This approach is inconvenient and, in some cases, the operator of the computer may not be aware of the source of the problem and, therefore, may not be able to correct it.
It is, therefore, an object of this invention to provide cassette interface synchronization circuitry which can synchronize to a waveform whether the waveform is inverted or not.
It is a further object of the invention to perform synchronization with simplified circuitry.
It is a still further object of the invention to perform the synchronization automatically without the need for manual operator intervention.
Summary of the Invention
The foregoing problem is solved and the foregoing objects are achieved in one illustrative embodiment of the invention in which positive-going and negative-going signal transitions in an incoming audio-frequency signal from a tape recorder are detected and means are provided for measuring the duration of two time intervals occurring between three successive signal transitions of the same sense. The two durations are than subtracted and the resulting difference compared to a predetermined number. If the calculated difference is greater than the number, the system is considered to be bit-synched by using signal transitions of the same sense as originally chosen. If the duration of the calculated difference is less than the predetermined number, the system achieves bit synchronization by using the transitions of opposite sense to those originally chosen. The system then achieves byte synchronization by shifting the incoming information into a shift register and checking the stored bits for a predetermined pattern.
More specifically, a software program in the computer and the tape recorder interface hardware interact by means of hardware "interrupts" to provide the detection and timing functions necessary to synchronize the incoming audio waveform. In particular, the incoming audio waveform is "squared" by a zero-crossing and limiter circuit and positive and negative going transitions of the squared waveform are detected by simple flip/flop circuitry in the tape recorder interface circuitry. In order to measure the time interval between transitions the computer starts a counter immediately after the detection of a positive-going transition. When another positive-going transition is detected, an interrupt "flag" is set by the interface hardware which, in turn, subsequently causes the computer to enter an interrupt routine which, in turn disables the counter. The number stored in the counter thereby represents the time interval between positive-going transitions. The computer then compares the number produced by the counter to a number which has been preprogrammed into the computer. If the counter number is greater than the preprogrammed number, then a decision is made that bit synchronization has been achieved using rising edges as bit cell boundaries and the computer proceeds to achieve byte synchronization. If the counter number is less than the preprogrammed number then the computer enables the negative-going edge detector to achieve bit synchronization.
Brief Description of the Drawings
FIG. 1 shows a typical arrangement of synchronization information, identification information and data on a magnetic tape suitable for use with the inventive synchronization circuitry.
FIG. 2 shows a typical incoming audio waveform produced by an audio-frequency tape recorder when stored digital data is played back and the squared waveform produced from that waveform.
FIG. 3 shows an inverted audio waveform and the squared signal produced by that waveform.
FIG. 4 is an electrical schematic diagram of the edge detector circuitry.
FIG. 5 is a flow chart of the software program used in the computer to process interrupts.
FIGS. 6 and 7 show flow charts of the software program used in the computer to achieve synchronization.
Detailed Description of the Invention
FIG. 1 of the drawing shows a schematic diagram of a length of magnetic tape on which digital data has been recorded. As mentioned previously, when this tape is used in conjunction with an audio-frequency tape recorder, data is actually stored as patterns of audio-frequency signals which are processed by the tape recorder circuitry to produce a series of audio-frequency tones upon playback. In order that synchronization can take place and data on the tape can be accurately located and retrieved, certain synchronization and identification information is also recorded on the tape.
Specifically, a fixed synchronization pattern is imbedded in the data, both in "leader" 100 located at the beginning of the magnetic tape and in "header" 107 located immediately before the data to be retrieved. Typically, the synchronization pattern in leader 100 consists of 128 bytes of alternating digital "1"s and "0"s.
After leader 100 is located name file block 101 in which a name associated with the tape is stored. Name file block 101 is followed by a blank space 102 on the tape that allows the computer software to evaluate the name stored in block 101. An additional synchronization leader consisting of 128 bytes of digital "1"s and "0"s follows blank space 102. Leader 103 is, in turn, followed on the tape by a plurality of data blocks of which only two (blocks 104 and 105) are shown. Finally, an "end of file" block is located at the physical end of the tape which, when read, informs the associated computer that it has reached the end of the tape.
Each of blocks 101 through 106 is also subdivided into a number of synchronization and identification blocks which enable the computer to interpret the stored information and retrieve the stored data. The format of each block is identical and for clarity only data block 104 is shown in detail.
In particular, each block begins with a header 107 which typically consists of one byte of code 55 in hexadecimal notation which is equivalent to one byte of alternating "1"s and "0"s. Header 107 is followed by a synchronization block 108. This block contains a predetermined pattern which, as will be described in more detail below, is used to obtain byte synchronization. Typically this pattern is 07F in hexadecimal notation which is equivalent to the binary pattern 000001111111.
Synch block 108 is followed by a block type identification block 109 which contains information which indicates whether the block is a name file block, a data block or an end of file block. The type block is, in turn, followed by a length block 110 which indicates the number of data bytes which follow.
The length block 110 is followed by the actual data which may be from 0 to 255 bytes in length in the illustrative embodiment. Each block is terminated by a checksum block 120 which contains information allowing for error detection.
A portion of an audio waveform which is produced by the tape recorder circuitry when the synchronization pattern in the leader or header of the tape shown in FIG. 1 is read is shown in FIG. 2, line A. Typically, in a medium speed interface, for example, 1500 baud, digital "1"s are encoded as an audio signal at approximately 2400 hertz and digital "0"s are recorded at an audio signal having a frequency of 1200 hertz. Each digital bit is represented by a single cycle of the corresponding audio frequency.
Since the audio waveform is continuous, in order to synchronize to such a waveform, the synchronization circuitry must determine the location of bit cell boundaries designated as 200 and 201 in FIG. 2. To begin the synchronization process, the audio waveform is first converted into a digital waveform by a zero crossing detector and limiting circuit, resulting in the waveform shown in line B of FIG. 2. This waveform has a "high" level when a positive excursion of the waveform shown on line A occurs and a "low" level when a negative excursion of the waveform shown in line A occurs.
A comparison of lines A and B of FIG. 2 shows that the bit cell boundaries occur on the positive-going transitions of the waveform in line B.
However, as discussed previously, due to the properties of some tape recorders, it is possible that the waveform recorded as shown in line A of FIG. 2 may in fact be played back with an inversion as shown in line A in FIG. 3. When the waveform shown in line A of FIG. 3 is passed through zero crossing and limiter circuitry the waveform shown in FIG. 3, line B is produced. In this waveform, bit cell boundaries occur on the negative-going transitions of the waveform.
Unfortunately, it is not possible for the system to know in advance whether a particular tape recorder being used with the computer has an inversion or not; therfore, it is not possible for the system to known in advance whether to use positive-going or negative-going transitions as bit cell boundaries.
In order to select a transition in the proper sense as a bit cell boundary, the inventive synchronization circuitry uses positive and negative transition detectors in combination with a simple computer routine which computes the duration of the time interval of two successive positive-going transitions. By comparing this duration with preestablished limits the apparatus can decide whether positive-going or negative-going transitions should be used as bit cell boundaries.
FIG. 4 of the drawing shows the limiting circuitry and edge detectors used in the illustrative embodiment of the invention. An audio signal from the tape recorder, such as the signal shown in line A of FIG. 2 or 3, is provided to the synchronization circuitry via terminal 400. This signal is applied, via resistors 405 and 420, to amplifier circuit 430 which operates as a zero-crossing detector. Resistor 405 and capacitor 410 are used in conjunction to provide filtering and diode 415 is used to prevent the input signal from driving the input of amplifier 430 negative. Resistor 420 in conjunction with resistor 426 provide a voltage divider which reduces the level of the signal that is applied to the negative input of amplifier 430. In the absence of any signal applied to amplifier 430, its output is normally held high by resistor 440 and voltage source 435. This high signal is applied to a voltage divider consisting of resistors 431 and 432 which in conjunction with resistor 427 connected to voltage source 425 holds the positive terminal of the amplifier at approximately 50 millivolts to provide a threshold for the incoming signal. Resistors 431 and 432 also provide hysteresis for the zero-crossing detector.
The output of zero-crossing detector 430 therefore becomes "high" when the audio input signal has a positive excursion and becomes "low" when the audio signal has a negative excursion. This output is applied, via lead 441, to the clock input of D flip/flop 455 and, via invertor 442 and lead 443, to the clock input of D flip/flop 450.
Flip/flops 450 and 455 act as edge detectors which detect a negative-going transition (falling edge) or a positive-going transition (rising edge), respectively. These detectors can be controlled by the computer via leads 490-493. For example, the rising edge detector can be enabled when the computer places a "high" signal on ENCASINTR lead 491. This "high" signal is applied to the D input of flip/flop 455. When zero-crossing detector 430 provides a rising edge via lead 441 to the clock input of flip/flop 455, the "high" signal appearing at the D input of flip/flop 455 is shifted to its output Q and its Q output becomes "low" indicating that a rising edge has been detected.
Similarly, when the computer places a "high" signal on the ENCASINTF lead, via terminal 490, this signal is applied to the D input of flip/flop 450. A falling edge produced by zero crossing detector 430 is inverted by invertor 442 and applied as a rising edge to the clock input of flip/flop 450 causing its Q output to go low, signalling the detection of a falling edge.
Both flip/flops may be cleared and reset by the computer when it places a "low" signal on the CASIN lead 492. This "low" signal is applied to the clear input of both flip/flops 450 and 455, clearing them, and removing the "low" signal from the Q outputs. In addition, the "low" signal on the CASIN lead enables buffer gate 490, via lead 491 which transfers data on the output of the zero-crossing detector 430 to output D0. Therefore, a "low" signal on the CASIN lead clears the flip/flops and displays the data present at the interface input on the D0 lead.
When one of the edge detectors is enabled by the computer and subsequentially detects an edge, the "low" signal present at the corresponding output of flip/flops 450 or 455 is applied, via leads 460 and 465, respectively, to NAND gate 470. In response to a "low" input at either of its inputs, NAND gate 470 applies a "high" signal to inverter 477 which, in turn, provides a "low" signal, via lead 481, to the INT terminal.
The INT terminal is an interrupt terminal which is inspected periodically by the computer when interrupt routines are "enabled". Interrupt routines may be enabled under control of the computer by operation of appropriate circuitry which allows the interrupt signal on terminal INT to be forwarded to the computer. When the computer detects a signal which acts as a "flag" on this terminal, as described in detail below, it enters an interrupt routine and examines the output of the edge detectors to determine if an edge has, in fact, been detected. The computer interrogates the edge detectors by placing a "low" signal on the status lead RDINTSTATUS 493. A "low" signal on this lead enables buffer gates 475 and 476, causing the outputs of flip/flops 450 and 455 to be applied, via leads 480 and 482, to the D1 and D0 output terminals, respectively.
As mentioned above, the interface circuitry shown in FIG. 4 cooperates with the software programs which achieve synchronization by means of hardware "interrupts". When an interrupt occurs, the computer stops its normal processing routine and proceeds to examine a predetermined location in memory. In this location is stored the address of an interrupt branch routine which directs the computer to an entry point in an interrupt routine which the computer then performs before returning to the routine that the computer was processing prior to the occurrence of the interrupt.
An interrupt routine which may illustratively be used to process interrupts produced by the tape recorder interface is shown in flow chart form in FIG. 5. This routine has two entry points, D and E, (labelled as points 500 and 501 in FIG. 5). At any given time the entry point to the routine is determined by the address stored in the interrupt branch routine and by which of leads ENCASINTR or ENCASINTF has a "high" signal thereon. Entry point 500 is used as a result of an interrupt on the detection of a rising edge and entry point 501 is used as a result of an interrupt on the detection of a falling edge. Normally, during the initial set-up of the computer routines the address in the interrupt address location is set so that, upon an interrupt, the computer enters the routine through entry point 500 corresponding to the detection of a rising edge.
Upon entering the interrupt routine via point 500, the computer sets the "E" register to a binary "1" as shown in step 505. An entry into the routine at point 501 causes the computer to set the "E" register to binary "0".
In either case, the routine proceeds to step 510 in which the pulse counter is corrected by adding six counts (the time taken by the interrupt processing routine). Normally, interrupt processing takes approximately 180 system clock cycles (also called "T-states") which is an equivalent time to six pulse counts.
In step 515, the computer clears the interrupt signal and simultaneously reads data from the zero-crossing detector by placing a "low" signal on the CASIN lead, which, as previously described, resets the edge detectors and causes data at the output of the zero-crossing detector to appear on the D0 lead.
In step 521, the data on the D0 lead is compared to the contents of the enable register. If there is a match, as indicated by advancement of the program to step 530, valid data has been detected and the interrupt routine returns control of the system to the routine to which the computer was processing prior to the interrupt. If, on the other hand, there is no match between the data and the enable register, as indicated by the routine proceeding to step 525, the computer reenables the interrupt mechanism and returns to the processing program.
The interrupt routine is used in connection with a simple counting routine in order to produce a count number (or time the duration between either two successive falling edges or rising edges). The counting routine (not shown) periodically increments a counter until the routine is interrupted by the occurrence of either a rising or falling edge (depending on which detector is enabled). When such an interrupt does occur, control of the system is transferred to the interrupt routine, as previously described, which verifies a valid interrupt and returns control to the program which called the counting routine. At that point the count number residing in the counter indicates the time duration between either rising or falling edges (depending on which edge the interrupt occurs).
The computer routine which interacts with the circuitry in the tape recorder interface to detect bit cell boundaries and synchronize to the incoming data is shown in FIGS. 6 and 7. Prior to executing this routine, the computer performs various checks (not shown) to ensure that the system is not attempting to synchronize on noise signals. Typically, these checks may include the repetitive sampling of data to ascertain whether the data falls within certain specified limits and therefore constitutes proper digital signals. After the computer has determined that it is, in fact, looking at actual data, it enters the synchronization routine via step 600.
In step 605, the routine clears both edge counters. The computer then proceeds to step 610 in which a "loop counter" is set to 64. The loop counter counts the number of checks that are made during the routine. Repetitive checks are necessary to ensure that the system does not attempt an improper sysnchronization to noise.
In step 620, the computer detects a rising edge. This is done by calling the aforementioned counting routine which will then return control to the synchronization routine upon a rising edge interrupt.
In step 625, the computer determines the duration of one "pulse" which consists of the time interval between two successive rising edges. It does this by again calling the counting routine and interrupting on a rising edge. Since the counting routine has just returned on the rising edge due to step 620, the first interrupt that occurs on a rising edge will result in the counting routine producing a count number which is proportional to the time duration occurring between two successive rising edges.
In step 630 this count is stored. The computer again calls the counting routine which returns a count number for the time duration that started upon the detection of the second rising edge and terminated on the detection of the third rising edge. The number produced by the counting routine is therefore proportional to the duration of the second "pulse" interval occurring between successive rising edges.
In step 640, the count produced in step 635 is subtracted from the count stored in step 630 and the absolute value of the difference is taken.
In step 645, this difference is compared to a predetermined decision number or "point". If this difference is greater than the predetermined decision number, in step 655 the rising edge counter is incremented and the routine proceeds, via step 660 and 700, to step 705, where the loop counter is decremented by one.
In step 710, the loop count is checked. If it is not equal to zero the routine returns, via steps 711 and 615, to continue timing.
If, on the other hand, in step 645 the computed difference is less than the decision number, the computer increments the falling edge counter in step 650 and continues via steps 650, 700 and 705 to decrement the loop counter.
At some point, in a subsequent pass through the timing loop, the loop count will equal 0 indicating that 64 timing checks have taken place. When this occurs, in step 715 the computer checks to see whether 64 consecutive rising edges have been detected. If so, this indicates that the system has been properly synchronized to rising edges and the computer proceeds to step 735 in which the incoming data is examined for synchronization to obtain byte synchronization.
If, on the other hand, in step 715 the rising edge count is not equal to 64 indicating that 64 consecutive rising edges have not been detected, the computer proceeds to step 725 in which checks to see whether 64 falling edges have been detected. If not, this indicates that there has been an error during the detection or timing routines and the computer returns, via step 726 and 600, to the beginning of the routine and attempts to resynchronize at the bit level.
If, in step 725, however, 64 falling edges have been counted indicating proper synchronization on a falling edge then in step 730 the interrupt mask is changed. This change, in turn, causes the computer to enter the interrupt routine via step 501 for the falling edge interrupts.
In either case, eventually the computer proceeds to step 735 in which byte synchronization is achieved. In this step the time intervals either between rising or falling edges (as determined by the previous synchronization routine) are timed using the counting routine and the interrupt routine as previously described. The resulting time durations are compared to preset limits to determine whether a "0" or a "1" has been received. The corresponding "0" or "1" levels are entered into a register sequentially as shown in step 735.
In step 740, the contents of the register are compared to the predetermined synchronization pattern (illustratively, the synch word is 07F in hexdecimal notation). If the contents of the register do not equal the synchronization pattern, the computer returns to step 735 and inserts an additional bit into the register simultaneously shifting out the bit shifted into the register eight periods earlier. This operation is continued until the synch pattern appears in the register and byte synchronization is achieved. In this case if the routine proceeds to step 745 returning control of the system to the main program.
Although one illustrative embodiment of the invention has been shown other modifications and changes within the spirit and scope of the invention would occur to those skilled in the art. For example, it is apparent that different computer routines may be used to achieve alternative embodiments within the scope of this invention.
An illustrative coding of the previously described routines are set forth in Z-80 machine language on the following pages. This language is suitable for use with the Z-80 microprocessor integrated chip manufactured by Zilog, Inc., Cupertino, California. The Z-80 language is explained and described in the "Z-80 User's Programming Manual," published by Zilog, Inc., Cupertino, California. ##SPC1##