ABSTRACT
Maritime safety is of paramount concern to the scores of people who make a living from the sea. To ensure their safety and to provide safe navigation for ships, the most popularly used instrument worldwide is the Echo Sounder. The Echo Sounder is a real time embedded system whose applications include measurement of ocean depth, survey, dredging, defense and other scientific applications. Echo Sounding oceanography is defined as a process of measuring the water depth by emitting a sonic or ultrasonic signal and measuring the time it takes for the signal’s echo to return from the sea floor.
The Echo Simulator is an instrument that is used for testing and calibrating Echo Sounders, Sonar and other such devices. The heart of this project is the microcontroller which performs most of the functioning. The microcontroller we have employed is the 89C2051, an 8-bit microcontroller from ATMEL.
After the impulse transmitted by the apparatus being tested is received by the Echo Simulator, the latter sends back a simulated echo, which is digital in nature and whose basic parameters can be selected with extreme simplicity. Our project has been aimed at developing such an indigenous product.
1. INTRODUCTION
The need for intelligent devices has drastically revolutionized the electronic market during the past decade. The urge for such smart systems has led to the emergence of a new class of products namely Embedded Systems. An Embedded System is defined as a computing device, built into a device that is not a computer, and meant for doing specific computing tasks. These computing tasks could range from acquiring or transferring data about the work done by the mother device. In many cases the presence of an embedded device is far from obvious to the observer. Hence, Embedded Systems enable us to build intelligent machines. An average European household has around 250 embedded systems.
Embedded systems form an integral part of real time operating systems or RTOS. Real time refers to the scheduling of tasks, so that they are completed in the correct order within specified amount of time. In real time there are various degrees of accuracy called hard and soft real-time. Hard real-time systems are scheduled such that tasks are implemented within a precise number of microseconds, without exception. These are required for mission critical applications such as airplane navigation or landing systems and antilock brakes. These applications demand systems with extreme reliability as well as accuracy. Such accurate systems can be only developed using microprocessor based systems.
The heart of such real-time based embedded systems is the microprocessor and in many occasions the microcontrollers. Microcontrollers offer a ‘one-chip solution’ which drastically reduces parts count and design cost. Microcontrollers come in many varieties. Depending on the power and the features that are needed, you might choose a 4, 8, 16 or 32 bit microcontroller. With the advancement in VLSI technologies complete computers on single chips i.e. microcontrollers are being created in a very cost effective and compact form. Using these microcontroller’s versatility and compactness highly efficient systems can be fabricated.
Testing equipments are a real challenge and are more complex in design and operation than the test equipment. Such equipments mostly require real-time based operation. One such application is that of testing the Echo Sounder. Echo Sounders are used worldwide for meticulous measurement of water depths for hydrographic surveys, dredging, ship navigation, defense and scientific applications. An Echo Sounder provides safe navigation. The instrument that is used for testing and calibrating the Echo Sounder is called the Echo Simulator. It provides an echo corresponding to the depth after it receives a pulse from the Echo Sounder.
The microcontroller we have employed is the 89C2051 an 8 bit microcontroller from ATMEL. It is a 20 pin device and has 2 ports. This microcontroller has a 2K Flash on which the program can be written.
2. ECHO SOUNDER
2.1 Introduction
Echo Sounders basically perform Echo Sounding Oceanography which is defined as a process of measuring water depth by emitting a sonic or ultrasonic signal to the sea floor and measuring the time it takes for the signal’s echo to return from the sea floor. From this time obtained we can calculate the depth of the ocean bed
The purpose of the echo sounder is to provide safe navigation by detecting the clearance below the ship (particularly in shallow waters). The echo sounder can well in advance give warning to the ship if the ship is getting too close to any shallow areas or closing with the coastline. The original echo sounder was a long line with a piece of lead on the end and a series of marks along its length which, when dropped to the sea bottom, measured the depth of water.
The basic system consists of a display unit, a distribution box, a matching box and a transducer.
The electronic Echo Sounder works in a similar way to the radar. A transducer at the bottom of the hull sends out an electronic pulse which echoes back from the seabed. The echo is timed electronically and transposed into a reading of the depth of water under the hull. Multi-color displays in the monitor show not only the depth of water, but different types of sea beds, prominent features such as sunken wrecks, and sometimes even schools of fish. The more advanced sounders can transmit the pulse ahead of the boat and thus indicate the approach of navigational hazards such as reefs or shores in good time to avoid them.
There are 2 main uses for the echo sounder in coastal navigation. The first, as described above, is to help locate the ship’s position when used in conjunction with other electronic instruments, and secondly, to assist in navigation through shallow inshore passages and channels, or over bars.
Most Echo Sounders measure the time interval by means of electronic circuits and produce a continuous record of the depth of water beneath the vessel in the form of a chart or graph and stores all processed analog water column data and or an ASCII log file to a mass storage device via a standard parallel port.
2.2 Operating Mode
The echo sounder functions as both a single frequency and dual frequency instrument. Standard frequencies are 200 and 24 KHz or 210 and 33 KHz. In the single frequency mode, the user selects between the low and high frequency channel. In the dual frequency mode, the echo sounder interleaves and transmits from both the low and high frequency channel to offer the user two simultaneous acoustic representations of the bottom topography. The dual frequency echo sounding is also useful in differentiating the mud surfaces and sediment layer below it since higher frequency pulses are reflected by the silt while the lower frequency penetrates the bottom and produces the echo at various sediment layers and rocky bottom.
The transducer is available in 200 KHz or 50 KHz. The 200 KHz system is advantageous in rough weather or congested waterways where there are many bubbles or wakes of other vessels, it is suitable for most echo sounding applications in shallow waters on the continental shelf The 50 KHz system is recommended for deeper range of’ operation on large vessels.
The basic unit transmits a burst of electrical pulses to an acoustic transducer which converts electrical pulses into acoustic form. The received echo pulses are reconverted into electrical form by transducer and presented to the basic unit. The echo pulses are amplified in the basic unit and presented to a CPU digitizer. The CPU digitizer calculates the time taken between the transmission of pulses and received echo as‘t’. Now the depth range is also calculated by the CPU as
D = (c*t)/2
where c is the velocity of sound in water.
Compositional Details
1. Master Unit.
2. 33 KHz Transducer Assembly
3. 210 KHz Transducer Assembly
4. Repeater Unit
2.3 Technical Description
2.3.1 Master Unit
Power supply modules generate the various dc supplies required for the basic operation. The basic unit utilizes ultrasonic echo sounding on standard 33 and 210 KHz frequencies separately for detecting the depth range. The 210 KHz higher frequency signals are attenuated and reflected even by the sediment and silt layers at the sea bottom. 33 KHz penetrates these layers to be reflected by the underneath rocky bottom. Thus the two channels of echo sounder, together present the true picture of sea bottoms by showing the various depths of silt and rocky bottoms. The basic unit has got two distinct functional parts.
1. Digital portion.
2. Analog portion.
The digital portion contains the microprocessor which controls the transmission pulse triggering, and also counts the time taken for the echo from transmission, then by calculating the depth on both channels.
The analog portion triggers and generates a burst of electrical pulses to the transducer. The returned echo from the transducer is filtered, amplified and fed to digital portion for further processing which in turn presents a reshaped digital echo for finding the depth.
2.4 Purposes and facilities of the System
There are various applications or facilities provided by the echo sounder. This includes the dual frequency sounding which has already been mentioned. Another feature is the measurable depth; this ranges from 40 cm to around I500m. The sound velocity can be entered from 1400 m/s to l600m/s. The unit of depth can also be set as either cm or m using the toggle switch.
2.4.1 Testing
The accuracy and precision of such equipment is very vital as far as navigational people are concerned as this equipment’s performance is crucial. To test and calibrate such equipment, it is not feasible to take the equipment to a point in the sea where the depth is predetermined. Hence there should be some provision to test the instrument offshore i.e. in the industry itself. The testing equipment should therefore simulate an echo signal corresponding to a known sea depth. Comparing the readings of the equipments, we can test the quality of the device. It should also be able to test various other parameters of the device such as time varying gain etc.
3. ECHO SIMULATOR
The echo simulator is an instrument used for the test and calibration of echo sounders, sonar, and similar devices. After the impulse transmitted by the apparatus being tested is received by the Echo Simulator, the latter sends back a simulated echo, which is digital in nature and whose basic parameters can be selected with extreme simplicity.
The signal, since it is generated by a quartz crystal, is notably stable and accurate. In addition to this, it is possible to vary the frequency by 1 KHz steps thus permitting a reliable check on the tuning of the receiver being tested.
The timing of the echo impulses can be continuously changed in accordance with the input trigger pulse thus permitting the best reading of the trace on graph paper according to the chosen measure range.
It is possible to select a single echo or echo repetitively until successive pulses coming from the device under test. This will enable in testing parameters like time varying gain etc. of the device.
Using the thumbwheel switches the simulated depth of the echo simulator can be programmed from 1 to 9999 in two different measure units (cm or m) selected by an external toggle switch. The choice of a particular length measure unit and the assumption for a determined sound speed value is entirely left up to the user to change and modify one of the two length measure units, pre-cabled at the factory, or he can vary the speed, either slowing or increasing the speed of sound, thus meeting his present and future needs. The device is programmed permanently for a particular speed; mostly around 1500 m/s and the user may calibrate his equipment for other needs.
4. 2051 MICROCONTROLLER
4.1 Microprocessor and Microcontroller
Microcontroller was a by-product of the microprocessor development. The same fabrication techniques and programming concepts that make possible the general purpose microprocessor also yielded the microcontroller. Microprocessors and microcontrollers stem from the same basic idea, but there are some differences between the two. A microprocessor is a general purpose digital computer central processing unit (CPU). Although popularly known as “the computer on chip”, the microprocessor is in no sense a complete digital computer. The hardware design of a microprocessor CPU is arranged so that a small or a very large system can be configured around the CPU as the application demands.
On the contrary the design of a microcontroller incorporates all of the features found in a microprocessor CPU like ALU, PC, SP and registers. It also has added other features needed to make complete computer like ROM. RAM, parallel I/O serial I/O, counters, and a clock circuit.
The microcontroller is a general purpose device, but one that is meant to read data, performs limited calculations on the data and control its environment based on these calculation. A typical microcontroller has bit manipulation instructions, easy and direct access to I/O, and quick programme that is stored in ROM and that does not change over the lifetime of the system. Microcontroller is intended to be special purpose digital controller.
To summarize, the microprocessor is concerned with rapid movement of code and data from external addresses to the chip; the microcontroller is concerned with the rapid movement of bits within the chip.
4.2 Microcontroller Architecture
4.2.1 Microcontroller Hardware
The 8051 microcontroller generic part number actually includes a whole family of microcontrollers, which includes the 89C2051 and is available in N-Channel Metal Oxide Silicon (NMOS) and CMOS construction. The basic parts of 89C2051 and function are given below shows all the features unique to all microcontrollers:
Basic Parts of 2051
Ø Internal ROM and RAM
Ø I/O ports with programmable pins
Ø Timers and Counters
Ø Serial Data Communication
The basic parts also include the usual CPU components: program counters, ALU, working registers, and clock circuits. The 2051 architecture consists of these specific features:
Ø Eight-bit CPU with registers A (accumulator) and B
Ø Sixteen-bit program counter (PC) and data pointer (DPTR)
Ø Eight-bit program status word (PSW)
Ø Eight-bit stack pointer (SP)
Ø Internal ROM of 2K
Ø Internal RAM of 128 bytes
Ø Sixteen input/output pins arranged as two eight-bit ports: P1 and P3
Ø Two 16-bit counters TO and T1
Ø Full duplex serial data receiver/ transmitter :SBUF
Ø Control Registers :TCON, TMOD, SCON, PCON, IP, IE
Ø Two external and three internal interrupt sources.
Ø Oscillator and clock circuits.
The programming model of 2051 is a collection of 8-bit and 16-bit registers and 8 bit memory locations. These registers and memory locations can be made to operate using the software instructions that are incorporated as part of the design. The program instructions have to do with the control of the registers and digital data paths that are physically contained inside the 2051.
Each register with the exception of the program counter has an internal 1 byte assigned to it. Some registers have both bit addressing and byte addressing. Software instructions are generally able to specify a register by its address, its symbolic name, or both.
The 2051 Oscillator and Clock
The heart of the 2051 circuitry that generates the clock pulses by which all operations are synchronized. Pins XTAL1 and XTAL2 are provided for connecting a resonant network to form an oscillator. Typically a quartz crystal and capacitors are employed. The crystal frequency is the basic clock frequency of the microcontroller.
The oscillator formed by the crystal, capacitors, and on-chip inverter, generates a pulse train at the frequency of the crystal. The clock frequency f, establishes the smallest interval of time within the microcontroller, called the pulse time P. The smallest interval of time to accomplish any simple instruction, or part of a complex instruction, however is the machine cycle. The machine cycle itself is made up of 6 states. A state is the basic time interval for discrete operations of the microcontroller such as fetching an opcode byte, decoding an opcode, executing an opcode, or writing a data byte. Two oscillator pulses define each state.
Program instructions may require one, two or four machine cycles to be executed, depending on the type of instruction. Instructions are fetched and executed by the microcontroller automatically, beginning with the instruction located at ROM memory address 0000H at the time of the microcontroller is first reset.
To calculate the time any particular instruction will take to be executed, find the number of cycles C. The time to execute the instruction is then found by multiplying C by 12 and dividing the product by the crystal frequency:
T inst = (C * 12d) /
Program Counter and Data Pointer
The 2051 consists of two l6-bit registers. The program counters (PC) and the data pointer (DPTR). Each is used to hold the address of a byte in the memory.
Program instruction bytes are fetched from locations in memory that are addressed by the PC. Program ROM may be on the chip at addresses 0000H to 07FFH. The PC is automatically incremented after every instruction byte is fetched and may be altered by certain instructions. The PC is the only register that does not have an internal address.
The DPTR register is made up of two 8-bit registers, named DPHDPL, which are used to furnish memory addresses for internal code access.
A and B CPU Registers
The registers A and B hold results of many instructions, particularly math and logical operations, of the central processing unit. The A (accumulator) register is the most versatile of the two CPU registers and is used for many operations, including addition, subtraction, integer multiplication and division and Boolean bit manipulations. The B register is used with the A register for multiplication and division operations and has no other function other than as a location where data can be stored.
Flags and the Program Status Word (PSW)
Flags are 1-bit registers provided to store the results of certain program instructions. Other instructions can test the conditions of the flag and make decisions based on the flag states. The flags are grouped inside the program status word (PSW) and the power control (PCON) registers.
The 2051 has four math flags that respond automatically to the outcomes of the math operations and three general purpose user flags that can be set to 1 or cleared to 0 by the programmer as desired. The math flags include Carry (C), Auxiliary Carry (AC), Overflow (OV), and Parity (P). User flags are named FO, GFO and GF1; they are general purpose flags that may be used by the programmer to record some event in the program.
Internal Memory
The 2051 has internal RAM and ROM memory for program code bytes and for variable data that can be altered as the program runs. Unlike microcontrollers with Von Neumann architectures which can use a single memory address for either program code or data, but not for both, the 2051 has a Harvard architecture, which uses the same address, in different memories, for code and data. Internal circuitry accesses the correct memory based on the nature of the operation in progress.
The Stack and Stack Pointer
The stack refers to an area of internal RAM that is used in conjunction with certain opcodes to store and retrieve data quickly. The 8-bit stack pointer (SP) register is used to hold an internal RAM address called the top of the stack. The address held in the SP register is the location in internal RAM where the last byte of data was stored by a stack operation.
When data is to be placed in the stack, the SP increments before storing data on the stack so that the stack grows up as data is stored. As data is retrieved from the stack, the byte is read from the stack, and then the SP decrements to point to the next available byte of stored data. The SP is set to 07H when the 2051 is reset and can be changed to any internal RAM address by the programmer.
Special Function Registers
The 2051 operations that do not use the internal RAM addresses from 00h to 7FH are done by a group of specific internal registers; each called a Special Function Register (SFR), which may be addressed much like internal RAM, using the addresses from 80H to FFH. Some SFR are also bit addressable. This feature allows the programmer to change only what needs to be altered, leaving the remaining bits in that SFR unchanged.
Internal ROM
The 2051 is organized so that data memory and program memory can be in two entirely different physic memory entities. Each has the same address ranges. A corresponding block of internal program code, contained in the internal ROM, occupies the space from 0000H to O7FFH. The program cannot be in an external
4.2.2 Input/Output Pins, Ports and Circuits
One major feature of a microcontroller is the versatility built into the I/O circuits that connect the microcontroller to the outside world. To be commercially viable the microcontroller has to incorporate as many functions as were technically and economically feasible. The main constraint was the number of pins available. For this reason, 7 of the pins may be used for one of two entirely different functions, yielding a total pin configuration of 27. The function a pin performs at any given instant depends, first on what is physically connected to it and then, on what software commands are used to “program” the pin. Both of these factors are under the complete control of the programmer and circuit designer.
Each port has a D type output latch for each pin. The SFR for each port is made up of these eight latches, which can be addressed at the SFR address for that port. The port latches should not be confused with the port pins; the data on the latches does not have to be the same as that on the pins. Different opcodes access the latch or pin states as appropriate. Port operations are determined by the manner in which the microcontroller is connected to the external circuitry.
Port 1
Port 1 pin have no dual functions. Therefore the output latch is connected directly to the gate of the lower FET. Used as an input, a 1 is written to the latch, turning the lower FET off; the pin and the output to the pin buffer are pulled high by the FET load. An external circuit can overcome the high impedance pull-up and drive the pin low to input a 0 or leave the input high for a 1. If used as an output, the latches containing a 1 can drive the input of an external circuit high through the pull-up. If a zero is written to the latch, the lower FET is on, the pull-up is off, and the pin can drive the input of the external circuit low.
Port 3
The port 3 is an input/output port similar in operation to port 1 the input and output operations can be programmed under the control of P3 latches or under the control of various other special function registers. Each pin of port 3 may be individually programmed to be used either as input/output or as one of the alternate functions.
Port pin alternate functions
P3.0 RxD (serial input port)
P3.1 TxD (serial output port).
P3.2 INTO (external interrupt)
P3.3 INTl (external interrupt)
P3.4 TO (Timer/counter 0 external input)
P3.5 T1 (Timer/ counter 1 external input)
P3.6 WR (external data memory write strobe)
P3.7 RD (external data memory read strobe)
4.2.3 Counters and Timers
Many microcontroller applications require the counting of external events, such as the frequency of the pulse train or the generation of precise internal time delay between computer actions. Both of these starts can be accomplished using software techniques. Two 16 bit up counters, named TO and T1 are provided for the general use of the programmer. Each counter may be programmed to count internal clock pulses, acting as a timer, or programmed to count external pulses as a counter.
The counters are divided into two 8 bit registers called the timer low (TLO, TL1) and high (THO, TH1) bytes. All counter actions is controlled by bits states in the timer mode control register (TMOD), the timer/counter control register (TCON), and certain program instructions.
TMOD is dedicated entirely to the two timers and can be considered to be two duplicate 4 bit registers, each of which controls the action of one of the timers. TCON has control bits and flags for the timers in the upper nibble and control bits and flags for the external interrupts in the lower nibble.
Timer counter Interrupts
The timers have been included in the chip to relieve the processor of timing and counting chores. When the program wishes to count a certain number of internal pulses or external events, a number is placed in one of the counters. The number represents the maximum count less the desired count plus one. The counter increments from the initial number to the maximum and then rolls over to zero on the final pulse and also set a timer flag. The flag condition may be tested by an instruction to tell the program that the count has been accomplished, or the flag may be used to interrupt the program.
Timing
If a counter is programmed to be a timer, it will count the internal clock frequency of the oscillator divided by 12d. The resultant timer clock must be gated to the timer. The bit TRX in the TCON register must be 0, or the external pin INTX must be a 1. The counter is configured as a timer, and then the timer pulses are gated to the counter by the bit and gate bit or the external input bits INTX.
Timer Modes of Operation
The timers may operate in any one of the four modes that are determined by the mode bits, M1 and MO in the TMOD register.
Timer Mode 0
Setting timer X mode bits to 00b in the TMOD register results in using the THX register as an 8-bit counter and the TLX as a 5-bit counter; the pulse input is divided by 32d in TL so that the TH counts the original oscillator frequency reduced by a total of 384d.
Timer Mode 1
Mode 1 is similar to Mode 0 except TLX is configured as a full 8-bit counter when the mode bits are set to 0lb in the TMOD. The timer flag would be set in .1311 seconds using a 6 MHz crystal.
Timer Mode 2
Setting the mode bits to l0b in the TMOD configures the timer to use only the TLX counter as an 8-bit counter. THX is used to hold a value that is loaded into TLX every time TLX overflows from FFH to 00H. The timer flag is also set when TLX overflows.
This mode exhibits an auto reload feature: TLX will count up from the number in THX, overflow, and be initialized again with the contents of THX.
Timer Mode 3
Timer 0 and 1 may be programmed to be in mode 0, 1 or 2 independently of a similar mode for the other timer. This is not true for mode 3. The timers do not operate independently if mode 3 is chosen for timer 0. Placing timer 1 in mode 3 causes it to stop counting; the control bit TR1 and the timer flag TF1 are then used by timer 0.
Timer 0 in mode 3 becomes two completely separate 8-bit counters. TL0 is controlled by the gate arrangement and sets the timer flag TF0 whenever it overflows from FFH to 00H. TH0 receives the timer clock (the oscillator divided by 12) under the control of TR1 only and sets the TF1 flag when it overflows.
Timer 1 may still be used in modes 0, 1 or 2, while timer 0 is in mode 3 with one important exception: No interrupts will be generated by the timer 1 while timer 0 is using the TF1 overflow flag. Switching timer 1 into mode 3 will stop it and hold whatever count is in timer 1. Timer 1 can be used for baud rate generation for the serial port, or any other mode 0, 1 or 2 function that does not depend on an interrupt (or any other use of the TF1 flag) for proper operation.
Counting
The only difference between counting and timing is the source of the clock pulses to the counters. When used as a timer, the clock pulses are sourced from the oscillator through the divide by 12d circuit. When used as a counter, pin T0 supplies pulses to counter 0, and pin T1 to counter 1. A change on the input from high to low between the samples will increment the counter. Each high and low state of the input pulse must thus be held constant for at least one machine cycle to ensure reliable counting.
4.2.4 Interrupts
Interrupts are hardware signals that force the program to call a subroutine. Software techniques use up processor time that could be devoted to other tasks; interrupts take up the processor time only when the action by the program is needed. Interrupts are often the only way in which real-time programming can be done successfully.
Interrupts may be generated by internal chip operations or provided by external circuits. Any interrupt can cause the micro to perform a hardware call to an interrupt handling subroutine that is located at a predetermined absolute address in the program memory. Five interrupts are provided in the 2051. Three of these are generated automatically by internal operations: Timer Flag 0, Timer Flag1, and the serial port interrupt (RI or TI). Two interrupts are triggered by the external circuits provided by the circuitry that is connected to pins INT0 and INT1.
All interrupt functions are under the control of the program. The programmer is able to alter the control bits in the Interrupt Enable register (IE), the Interrupt Priority register (IP), and the Timer Control register(TCON). The program can block all or any of the combination of the interrupts from acting on the program by suitably setting or clearing bits in these registers.
After the interrupt has been handled by the interrupt subroutine which is placed by the programmer at the interrupt location in program memory, the interrupted program must resume operation at the instruction where the interrupt took place. Program resumption is done by storing the interrupted PC address on the stack in RAM before changing the PC to the interrupt address in the
Timer Flag Interrupt
When a timer/counter overflows, the corresponding Timer flag, TF0 or TF1 is set to 1. The flag is cleared to 0 when the resulting interrupt generates a program call to the appropriate timer subroutine in memory.
External Interrupts
Pins INTO and INTl are used by external circuitry. Inputs on these pins can set the interrupt flags IEO and IE1 in the TCON register to 1 by two different method. The IEX flag may be set when the INTX pin reaches a low level, or the flags may be set when a high to low transition takes place on the 1NTX pin. Bits ITO and IT1 in TCON program the INTX pins for low-level interrupt when set to 0 and program the INTX pins for transition interrupt when set to 1. Flags IEX will be reset when a transition generated interrupt is accepted by the processor and the interrupt subroutine are accessed. The external circuit must remove the low level before an RETI is executed.
Reset
This can be considered as the ultimate interrupt as the program cannot block the action of the voltage at the RST pin. This type of interrupt is often called non-maskable interrupt. Unlike other interrupts, the PC is not stored for later program resumption.
Interrupt Control
The IE register holds the programmable bits that can enable or disable all the interrupts in the group, or if the group is enabled, each individual interrupt source can be enabled or disabled. The IP register bits may be set by the program to assign priorities among the various interrupt sources so that more important interrupts can be serviced first.
5. BLOCK DIAGRAM AND DESCRIPTION
The block diagram of the Echo Simulator is as shown in the figure on the previous page. The equipment is basically used for testing the Echo Sounder. The BCD switches are used for setting the input to the device. These switches are used for setting the depth, which determines the delay; the pulse rate, which determines the number of times the echo occurs; and also for setting the duration of the pulse. These switches are connected to the microcontroller via a Buffer. The buffer enables the input to be compatible with the microcontroller i.e. it has a tri-state output. The unit of depth i.e. either meter or centimeter is set using a toggle switch. This toggle switch is directly connected one of the microcontroller pins.
The trigger input from the Echo Sounder is connected to a re-triggerable mono shot via a buffer. The mono shot produces an interrupt signal of a particular duration. The pulse duration is determined by the external capacitance and resistance value of the mono shot. This interrupt signal is then applied to the interrupt pin of the microcontroller. As soon as the microcontroller receives the interrupt signal, it executes its particular interrupt routine. Based on the input setting, the microcontroller calculates the delay required for the depth set. After this delay, the output goes high. The duration of this high pulse depends on the input setting. This echo signal is repeated depending on the pulse rate.
The output from the microcontroller is applied to a mono shot. This mono shot controls the output duration depending on its component values. The output from the mono shot is applied to a buffer and we take the final output from the buffer. This output is then applied back to the Echo Sounder under test. The Echo Sounder gives the reading based on the echo produced. If this reading is same as our input setting, then the device is good, else the device will have to be corrected.
6. CIRCUIT Details AND DESCRIPTION
6.1 Introduction
The basic aim of an echo simulator is to produce or simulate signal corresponding to an echo; and this signal is known as digital echo. This signal is mainly used to test the fidelity of equipments like Echo Sounder, Radar etc. the Echo Simulator achieves this by generating a pulse after a particular time delay, in response to an interrupt signal. This time delay‘d’, corresponds to the depth being set as the input to this device. The trigger input pulse from the echo sounder acts as the external interrupt signal. The output signal can also be subjected to certain variations or modifications so as to study certain specifications and characteristics of the echo sounder.
The delay is calculated by taking the velocity of sound in water as 1500 m/s. Based on this value, the system calculates the time delay’d’ using the formula
D = (2 x h)/V
where ‘h’ is the depth and ‘V’ is the velocity of sound in water.
The system is usually configured for use with a minimum depth of 30cm and a maximum depth of around 2000m. If the depth is in cm, then the delay would be small and can easily be generated; but for larger depths the delay would be more and it creates certain difficulties due to certain device constraints. For e.g., if the depth is said to be 750m, the to and fro distance would be 1500m and it would take 1 sec for the signal to reach back (Echo). As far as the microcontroller is concerned this delay is comparatively large and it cannot easily generate such a large delay. Therefore, for ease of operation, a smaller depth whose delay, can be easily generated by the microcontroller, is taken and this depth is set as the standard. Knowing the actual depth and the standard value, the delay for the actual depth can be generated.
6.2 Working
The diagram for the equipment is as shown in figure. The central part of the circuit is the microcontroller 2051 which along with its external circuitry generates the delay corresponding to the depth set. The working of the system can be divided into three:
6.2.1
The input to the system is set using the Thumb wheel switches provided in the front panel of the device. The Thumb wheel switches are connected to port 1 of the microcontroller through the octal buffers 54240. Instructions are fetched and executed by the microcontroller automatically, beginning with the instruction located at ROM memory address 0000H at the time when the microcontroller is first reset. At the beginning of the program, all the interrupts are disabled and all the control words are configured as per the requirement. The readings at the thumbwheel switches which are connected external to the circuit are now accessed. For this, the buffers are enabled one at a time and the readings at port 1 are stored in different memory locations. The depth is set using the thumb wheel switches TW4, TW3, TW2 and TW1; the repetition rate of the pulse r, is set using the thumb wheel switch TW5, and the duration of the pulse (in milliseconds) is set using the switch TW6.
The thumb wheel switches have at the other end BCD converters which convert the setting on these switches, which range from 0-9 to there corresponding BCD codes. These are then applied to the octal buffers. The outputs of the BCD converters are pulled down to the ground and their common point is connected to the Vcc. Hence when the BCD output is high, the output pin is connected to the common point and the output will be Vcc i.e. high; and when the BCD output is low, the pin is pulled down to the ground and the output will be low. When the buffers are in the disabled state, their output is tristate i.e. in a high impedance state.
After the readings from the thumbwheel switches have been read and stored, the microcontroller reads the unit in which depth is set. This is set using the toggle switch which is connected external to the circuit. This is connected to pin P3.0 of the microcontroller. If the pin is set high, then the unit is in meters, and if the pin is set low, the unit of depth is in centimeters.
6.2.2 Processing the data
As mentioned earlier, the microcontroller has to calculate the delay for an arbitrary depth which is kept as the standard. This depth controls the operation of the timer 0. For convenience; this depth is taken to be 10 cms. This would mean a total of 20cms to be traveled, with a speed of 1500m/s; and the delay for the standard depth is approximately 133 μs. This delay would be easily generated using any of the two timers of the microcontroller. For a single loop of operation of the timer, the timer will take one machine cycle; and for a 12MHz clock, this is 1μs. Hence 8-bit timers could generate a maximum delay of 255 μs in a single loop of operation. Hence using the timer in an iterative loop, we can generate the require delay. For generating the delay we use the timer 0. This timer is configured in mode 2 so that it acts as an auto-re-loadable 8 bit counter. The TH0 register is loaded with the hexadecimal equivalent of the difference of 255 and 133, which comes to 7AH.
Now based on the unit of depth, the program calculates the number of tens of cms in the depth. Hence the depth is manipulated by ‘10’ if the unit is set in meter and it is divided by ‘10’ if the unit is set in cms. This calculated value ‘n’ is then stored in a memory location. This is used as the count for timer 0 operation. This completes the initialization procedure
6.2.3 Generation of Delay
After the initialization procedure, the interrupts are enabled and the microcontroller enters into a wait state. The external interrupt INTO is now enabled and the calculation of the delay is written as an interrupt service subroutine.
6.2.4 Interrupt Signal
The interrupt signal is the input trigger from the echo sounder. This is a low pulse of very short duration, tp and this is applied to 1A3 of the inverting octal buffer, 74HC240. The output from this buffer at IY3 is a high pulse and this is applied to one half of the mono shot 54123. The mono shot is configured in such a way that it will be triggered by the CLR input. For this the input to A is kept low and B s kept high. Under this configuration, a positive edge at the CLR input triggers the monostable multivibrator. The device may be triggered by the CLR input (positive edge) because of the Schmitt trigger input; after triggering, the output maintains the monostable state for the time period determined by the external resistor Rx and capacitor Cx. When Cx >l0nF and Rx>10 K? The output pulse width value is approximately given by the formula:
tW (OUT) = K * Cx * Rx,
where K=0.45
Taking CLR low breaks this MONOSTABLE state. If the next trigger pulse occurs during the MONOSTABLE period it makes the MONOSTBLE period longer, i.e. this is a retriggerable mono shot. Hence the pulse at CLR of the mono shot enables the output i.e. Q goes high for a period tW and the inverted Q goes low for the same duration. This inverted output i.e. a low pulse of duration ‘tW1’ is applied to pin P3.2 which is the INTO input of the microcontroller. This is a low active pin and as soon as the voltage at this pin goes low, the microcontroller acknowledges this interrupt and executes the IEO interrupt subroutine.
6.2.5 Timer 0 Operation
In the IEO interrupt subroutine, the timer 0 is set; the timer 0 interrupt is enabled while the INTO interrupt is disabled and the timer0 interrupt is given a higher priority. As and when the timer overflow flag TF0 is set, the program goes to the corresponding interrupt routine which checks whether the count value is reached. If the count is reached, it implies that the required delay is achieved and then the output pin P3.1 is made high; else the count is increased and the timer starts again. Though the timer acts if it was a clock pulse of duration 133 μs operating for n clock cycles, where n is the count, so as to achieve the delay d as shown in figure below.

6.2.6 Timer 1 Operation
The output has to remain high for a short duration td .This ranges from 1 to 9 milliseconds and is set by the user using the thumb wheel switches. But has mentioned earlier this delay cannot be directly implemented using the timer. Instead the timer is used in an iterative loop which executes the loop for a particular count value. This count value is determined by reading from the thumb wheel switch TW6. The reading from TW6 is first multiplied by ten and this value is set as the count for this timer. Therefore, if we have a 100 μs delay generated using the timer in a single iterative loop then the desired duration of pulse can be achieved. For this the program makes use of timer 1. This timer is also programmed to be used in mode 2 as an auto re-loadable 8 bit counter. The TH1 of this timer is loaded with a hexadecimal equivalent of the difference of 255 and 100 i.e. 9BH so that we can achieve a delay of 100μs.
As and when the output goes high the program returns from the timer 0 interrupt and the program sets the timer 1. The timer 1 interrupt is called enabled and it is given a higher priority. When the timer overflow flag TF1 is set, it executes its corresponding interrupt routine. This routine checks whether the particular count is reached or not. If the desired count is reached, then the desired duration of pulse td is achieved and then the output is made low and the program returns from its interrupt routine; else the output remains high and the count for this particular routine is incremented until it achieves the desired value.
6.2.7 Generation of Repetition rate
When the program returns from the TF interrupt routine, the program checks whether the repetition rate is achieved or not. If this value is achieved, then the program returns from interrupt routine for INTO and this completes the output procedure. If this rate is not achieved, the program returns to the point where enabled timer 0 interrupt is, so that the entire cycle repeats itself until the repetition rate is achieved.
6.2.8 Output
This output from the microcontroller is connected to two parts. In one part the output is directly fed to the inverting octal buffer 74HC240. Here it is first applied 1Al whose output is obtained at 1Yl but inverted. This inverted output is applied to 1A2 and we get the original output from 1Y2. Infact the output from the microcontroller is inverted twice to obtain the output. We call this output the static echo, whose duration td is controlled by the thumb wheel switch alone.
References
1. Introduction to Electronics and communication : Prof. Gopakumar K
2. Electronic communication Systems : Kennedy
3. Introduction to Radar Systems : Merrill L Skolnik